New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dflex/utils

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dflex/utils - npm Package Compare versions

Comparing version 3.10.3 to 3.10.4

40

dist/dev.js

@@ -532,2 +532,4 @@ 'use strict';

/* eslint-disable no-dupe-class-members */
/* eslint-disable no-unused-vars */
class BoxRect extends BoxNum {

@@ -581,2 +583,40 @@ /**

}
getInstance() {
const {
top,
left,
bottom,
right,
width,
height
} = this;
return {
top,
left,
bottom,
right,
width,
height
};
}
/**
* Converts absolute element position to viewport position based on scroll position.
* @param viewportTop - The top position of the viewport.
* @param viewportLeft - The left position of the viewport.
* @returns The position of the element within the viewport.
*/
getViewportPos(viewportTop, viewportLeft, asBoxNum) {
const top = viewportTop;
const right = viewportLeft + this.width;
const bottom = viewportTop + this.height;
const left = viewportLeft;
return asBoxNum ? new BoxNum(top, right, bottom, left) : {
top,
right,
bottom,
left,
height: this.height,
width: this.width
};
}

@@ -583,0 +623,0 @@ /**

2

dist/dflex-utils.js

@@ -1,1 +0,1 @@

class t{constructor(t,s){this.x=t,this.y=s}}class s extends t{setAxes(t,s){this.x=t,this.y=s}clone(t){this.setAxes(t.x,t.y)}getInstance(){return{x:this.x,y:this.y}}isInstanceEqual(t){return this.x===t.x&&this.y===t.y}isEqual(t,s){return this.x===t&&this.y===s}isNotEqual(t,s){return this.x!==t||this.y!==s}}class i{constructor(t,s,i,e){this.top=t,this.right=s,this.bottom=i,this.left=e}}class e extends i{clone(t){this.top=t.top,this.right=t.right,this.bottom=t.bottom,this.left=t.left}setBox(t,s,i,e){return this.top=t,this.right=s,this.bottom=i,this.left=e,this}getBox(){return{top:this.top,right:this.right,bottom:this.bottom,left:this.left}}setByAxis(t,s,i){"x"===t?(this.left=s,this.right=i):(this.top=s,this.bottom=i)}setOne(t,s,i){"x"===t?-1===s?this.left=i:this.right=i:-1===s?this.top=i:this.bottom=i}getOne(t,s){return"x"===t?-1===s?this.left:this.right:-1===s?this.top:this.bottom}setPositionInstance(t){this.top=t.y,this.left=t.x}setPosition(t,s){this.top=s,this.left=t}hasEqualPosition(t,s){return this.top===s||this.left===t}getPosition(){return{x:this.left,y:this.top}}}class n extends e{constructor(t,s,i,e){super(t,s,i,e)}setFalsy(){return this.setBox(!1,!1,!1,!1),this}isTruthyByAxis(t){return"x"===t?this.left||this.right:this.top||this.bottom}isTruthyOnSide(t,s){return"x"===t?1===s?this.right:this.left:1===s?this.bottom:this.top}isTruthy(){return this.left||this.right||this.top||this.bottom}}class r extends e{t(t){return this.top>=t.bottom}i(t){return this.bottom<=t.top}h(t){return this.right<=t.left}o(t){return this.left>=t.right}u(t){return this.top<t.top}l(t){return this.right>t.right}p(t){return this.bottom>t.bottom}m(t){return this.left<t.left}_(t){return this.top>=t.top}T(t){return this.right<=t.right}M(t){return this.bottom<=t.bottom}O(t){return this.left>=t.left}isBoxIntersect(t){return!(this.i(t)||this.o(t)||this.t(t)||this.h(t))}isOutThreshold(t,s,i){if(s.setBox(!1,!1,!1,!1),i){if("y"===i){const i=this.u(t),e=this.p(t);return i&&(s.top=!0),e&&(s.bottom=!0),i||e}const e=this.m(t),n=this.l(t);return e&&(s.left=!0),n&&(s.right=!0),e||n}return this.u(t)?(s.top=!0,!0):this.l(t)?(s.right=!0,!0):this.p(t)?(s.bottom=!0,!0):!!this.m(t)&&(s.left=!0,!0)}isInsideThreshold(t){return this._(t)&&this.T(t)&&this.M(t)&&this.O(t)}getSurroundingBox(t){return{left:Math.min(t.left,this.left),top:Math.min(t.top,this.top),right:Math.max(t.right,this.right),bottom:Math.max(t.bottom,this.bottom)}}isPositionedY(t){return this.t(t)||this.i(t)}assignBiggestBox(t){const{top:s,left:i,right:e,bottom:n}=t;i<this.left&&(this.left=i),s<this.top&&(this.top=s),e>this.right&&(this.right=e),n>this.bottom&&(this.bottom=n)}}function h(t,s){return`${t}_${s}`}const o={};let u=!1;function c(){}const l=new Set,a="height",p="width",x="min-height",f="position",d="opacity";function g(t){return"x"===t?p:a}function m(t){return"x"===t?"left":"top"}class y extends r{constructor(t,s,i,e){super(t,s,i,e),this.width=s-e,this.height=i-t}setByPointAndDimensions(t,s,i,e){this.top=t,this.left=s,this.width=e,this.height=i,this.right=s+e,this.bottom=t+i}setAxes(t,s){this.left=t,this.right=this.width+t,this.top=s,this.bottom=this.height+s}getDimensionDiff(t,s){const i=g(t);return this[i]-s[i]}getPositionDiff(t,s){return this[m(t)]-s[t]}}class w extends s{increase(t){return this.x+=t.x,this.y+=t.y,this}composeBox(t,s){const{top:i,left:e,bottom:n,right:h}=t;return s?new r(i+this.y,h-this.x,n-this.y,e+this.x):new r(i-this.y,h+this.x,n+this.y,e-this.x)}onSameAxis(t,s){return"y"===t?s.x===this.x:s.y===this.y}}class b{static containerKey(t,s){return h(t,s)}static depthKey(t){return h(t,"dp")}constructor(t){this.B=t,this.thresholds={},this.isOut={}}S({width:t,height:s}){const i=Math.round(this.B.horizontal*t/100),e=Math.round(this.B.vertical*s/100);this.A=new w(i,e)}v(t,s,i){this.thresholds[t]=this.A.composeBox(s,i),this.isOut[t]=new n(!1,!1,!1,!1)}setMainThreshold(t,s,i){this.S(s),this.v(t,s,i)}updateMainThreshold(t,s,i){this.thresholds[t]=this.A.composeBox(s,i),this.isOut[t].setFalsy()}getElmMainThreshold(t){return this.A.composeBox(t,!1)}setContainerThreshold(t,s,i,e){this.v(t,i,!1);const{top:n,left:r}=i,{height:h,width:o}=e,u=b.containerKey(s,t),c=b.depthKey(s);this.v(u,{left:r,top:n,right:r+o,bottom:n+h},!1),this.thresholds[c]?this.thresholds[c].assignBiggestBox(this.thresholds[u]):this.v(c,this.thresholds[u],!1)}isOutThreshold(t,s,i){return s.isOutThreshold(this.thresholds[t],this.isOut[t],i)}destroy(){Object.keys(this.thresholds).forEach((t=>{delete this.thresholds[t]})),Object.keys(this.isOut).forEach((t=>{delete this.isOut[t]}))}}const _={x:null,y:null};var T=new class{constructor(){this.D={}}newTravel(t){return void 0===this.D[t]?this.D[t]=0:this.D[t]+=1,`${t}${this.D[t]}`}};function M(t,s,i,e=!0,n="true"){const r=e?`data-${s}`:s;i?t.removeAttribute(r):t.setAttribute(r,n)}const O=[];function B(t){cancelAnimationFrame(t)}function S(){let t,s=!0;function i(){s=!0}function e(){B(t),O.splice(O.indexOf(t),1)}return[function(n,r){r&&e();try{s=!1;const e=function(t,s){return i=>{t(i),s()}}(n,i);t=requestAnimationFrame(e),O.push(t)}catch(t){}},e,function(){return s}]}const A=[];function v(t){let s=null,i=!1;function e(){s&&(clearTimeout(s),s=null)}return A.push(e),[function(n,r){const h=n||c;i=!0,r&&e(),s=setTimeout((()=>{i=!1,h()}),t)},e,function(){return i}]}const[E,D]=v(0);class q{constructor(t,s,i,e,n){this.index=t,this.SK=i,this.id=s,this.cycleID=e,this.hasScroll=n,this.reconciledIDs=new Set,this.numberOfTransformedELm=0,this.marginBottom=null,this.marginTop=null}}const $=Object.freeze(["x","y"]);let F=new WeakMap;function P(t,s,i){t.style.setProperty(s,i)}function R(t,s,i){const e=function(t){if(F.has(t))return F.get(t);const s={computedStyle:getComputedStyle(t),parsedProperties:new Map};return F.set(t,s),s}(t),{parsedProperties:n,computedStyle:r}=e,h=n.get(s);if(void 0===h){const t=r.getPropertyValue(s),e=i?function(t){const s=parseFloat(t);return Number.isNaN(s)?0:s}(t):t;return n.set(s,e),e}return h}function I(t){return{width:R(t,p,!0),height:R(t,a,!0)}}const K=/absolute|fixed/;function k(t){return R(t,f,!1)}exports.AbstractBox=i,exports.AxesPoint=t,exports.BOTH_AXIS=$,exports.Box=e,exports.BoxBool=n,exports.BoxNum=r,exports.BoxRect=y,exports.DFlexCreateRAF=S,exports.DFlexCreateTimeout=v,exports.DFlexCycle=class{constructor(t,s,i,e,n){const r=new q(t,s,i,e,n);this.q=[r],this.SKs=[i],this.complete()}latest(){return this.q[this.q.length-1]}prev(){return this.q[this.q.length-2]}getAll(){return this.q}filter(t,s){return this.q.filter(s?s=>t.find((t=>t===s.cycleID)):s=>t.find((t=>t===s.id)))}$(t){this.SKs=this.SKs.filter((s=>!t.has(s)))}flush(t){const s=new Set;this.q=this.q.filter((i=>void 0===t.find((t=>t===i.SK&&(s.add(i.SK),!0)))||(s.has(i.SK)&&s.delete(i.SK),!1))),this.$(s)}pruneSKFromMigration(t){this.q=this.q.filter((s=>s.SK!==t)),this.$(new Set([t]))}setIndex(t){this.latest().index=t,this.latest().numberOfTransformedELm+=1}preserveVerticalMargin(t,s){this.latest()["bottom"===t?"marginBottom":"marginTop"]=s}clearMargin(){this.latest().marginBottom=null,this.latest().marginTop=null}add(t,s,i,e,n,r){this.q.push(new q(t,s,i,n,r)),e?this.SKs.unshift(i):this.SKs.push(i)}updateReconciledIDs(t,s){const i=this.q.find((s=>s.SK===t));i&&(i.reconciledIDs.clear(),s.forEach((t=>i.reconciledIDs.add(t))))}getMigrationBySK(t){return this.q.find((s=>s.SK===t))}getReconciledIDsBySK(t){const s=this.q.find((s=>s.SK===t));return s?s.reconciledIDs:l}start(){this.isTransitioning=!0}complete(){this.isTransitioning=!1,this.preserveVerticalMargin("top",null),this.preserveVerticalMargin("bottom",null)}clear(){this.q=[],this.SKs=[]}},exports.PREFIX_TRACKER_CYCLE="dflex_cycle_",exports.PREFIX_TRACKER_ID="dflex_id_",exports.PREFIX_TRACKER_KY="dflex_ky_",exports.Point=s,exports.PointBool=class extends s{isOneTruthy(){return this.x||this.y}isAllFalsy(){return!(this.x||this.y)}setFalsy(){this.x=!1,this.y=!1}},exports.PointNum=w,exports.TaskQueue=class{constructor(){this.F={},this.P=new Set}R(t){Array.isArray(this.F[t])||(this.F[t]=[])}I(t,s,i){this.F[s].push(t),i&&this.P.add(i)}K(t){return!Array.isArray(this.F[t])||0===this.F[t].length}hasElm(t){return this.P.has(t)}enqueueBeforeLast(t,s,i,e){this.R(i);const{length:n}=this.F[i];0===n?this.F[i].push(s):this.F[i][n-1]=s,this.I(t,i,e)}enqueue(t,s,i){this.R(s),this.I(t,s,i)}executeQueue(t){const s=[];if(this.K(t))return s;try{this.F[t].forEach((t=>{const i=t();s.push(i)}))}catch(t){}finally{D(),delete this.F[t]}return s}k(t){E((()=>{const[s,i]=t;this.executeQueue(s),i&&queueMicrotask((()=>this.executeQueue(i))),this.P.clear()}),!0)}scheduleNextTask(t){this.k(t)}cancelQueuedTask(){D()}clear(){D(),this.F={},this.P.clear()}},exports.Threshold=b,exports.ThresholdDeadZone=class{constructor(){this.L=new r(0,0,0,0),this.j={..._}}setZone(t,s,i,e){const n=i.getSurroundingBox(e);this.L.clone(n),this.j[t]=s}isInside(t,s,i){return!!i.isInsideThreshold(this.L)&&s===this.j[t]}clear(){this.L.setBox(0,0,0,0),this.j={..._}}},exports.assertElmPos=function(t,s){if(u)return;const i=t.getBoundingClientRect();Object.keys(s).forEach((t=>{if(Object.prototype.hasOwnProperty.call(i,t)&&i[t]!==s[t])throw u=!0,new Error(`Element position assertion failed. Expected: ${i[t]} found: ${s[t]}`)}))},exports.autoCleanupAllRAFs=function(){O.forEach(B),O.length=0},exports.autoCleanupAllTimeouts=function(){A.forEach((t=>{t()})),A.length=0},exports.canUseDOM=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},exports.clearComputedStyleCache=function(){F=new WeakMap},exports.combineKeys=h,exports.eventDebounce=function(t,s=!1,i=200){const[e,n]=v(i),[r,h]=S();let o=performance.now(),u=!1;const c=()=>{if(u)return;const n=performance.now();s||n-o>=i?(r(t,!0),o=n):e(c,!0)};return c.isPaused=()=>u,c.pause=()=>{u||(u=!0,h(),n())},c.resume=()=>{u&&(u=!1,c())},c},exports.featureFlags={__proto__:null,enableCommit:!1,enableMechanismDebugger:!1,enableMutationDebugger:!1,enablePositionAssertion:!1,enableReconcileDebugger:!1,enableRegisterDebugger:!1,enableScrollDebugger:!1,enableUndoSiblingsDebugger:!1,enableVisibilityDebugger:!1},exports.getAnimationOptions=function(t){const s={easing:"ease-in",duration:"dynamic"};return void 0===t?s:null===t?null:{...s,...t}},exports.getCachedComputedStyleProperty=R,exports.getDimensionTypeByAxis=g,exports.getElmBoxRect=function(t,s,i){const{left:e,top:n,right:r,bottom:h,height:o,width:u}=t.getBoundingClientRect(),c=new y(n,r,h,e);return 0===s&&0===i||c.setByPointAndDimensions(n+i,e+s,o,u),c},exports.getElmDimensions=I,exports.getElmOverflow=function(t,s){return R(t,s,!1)},exports.getElmPos=k,exports.getEndingPointByAxis=function(t){return"x"===t?"right":"bottom"},exports.getOppositeAxis=function(t){return"x"===t?"y":"x"},exports.getParentElm=function(t,s){let i=0,e=t;try{do{if(i+=1,i>1&&s(e))return i=0,e;e=e.parentElement}while(null!==e&&!e.isSameNode(document.body))}catch(t){}finally{i=0}return null},exports.getParsedElmTransform=function(t){return function(t){if(!/matrix\([^)]+\)/.test(t))return null;const s=t.match(/matrix\(\s*([^,]+),\s*([^,]+),\s*([^,]+),\s*([^,]+),\s*([^,]+),\s*([^)]+)\)/);return s?[parseFloat(s[5]),parseFloat(s[6])]:null}(R(t,"transform",!1))},exports.getSelection=function(){return window.getSelection()},exports.getStartingPointByAxis=m,exports.hasCSSTransition=function(t){const s=R(t,"transition",!1);return"none"!==s&&""!==s.trim()},exports.noop=c,exports.noopSet=l,exports.removeOpacity=function(t){1!==R(t,d,!0)&&P(t,d,"1")},exports.removeStyleProperty=function(t,s){t.style.removeProperty(s)},exports.rmEmptyAttr=function(t,s){if(!t.hasAttribute(s))return;const i=t.getAttribute(s);i&&""===i.trim()&&t.removeAttribute(s)},exports.setFixedDimensions=function(t){const{height:s,width:i}=I(t);P(t,a,`${s}px`),P(t,p,`${i}px`)},exports.setParentDimensions=function(t){const s=s=>R(t,s,!1),i=s(a),e=s(p),n=s(x),r="auto"!==s(x);"auto"!==n||P(t,x,i),r||P(t,"min-width",e)},exports.setRelativePosition=function(t){const s=k(t);K.test(s)&&P(t,f,"relative")},exports.setStyleProperty=P,exports.tracker=T,exports.updateDOMAttr=M,exports.updateElmDatasetGrid=function(t,s){t.dataset.devX=`${s.x}`,t.dataset.devY=`${s.y}`},exports.updateIndexAttr=function(t,s){M(t,"index",!1,!0,`${s}`)},exports.warnOnce=function(t,...s){o[t]||(o[t]=!0,console.warn(...s))};
class t{constructor(t,s){this.x=t,this.y=s}}class s extends t{setAxes(t,s){this.x=t,this.y=s}clone(t){this.setAxes(t.x,t.y)}getInstance(){return{x:this.x,y:this.y}}isInstanceEqual(t){return this.x===t.x&&this.y===t.y}isEqual(t,s){return this.x===t&&this.y===s}isNotEqual(t,s){return this.x!==t||this.y!==s}}class i{constructor(t,s,i,e){this.top=t,this.right=s,this.bottom=i,this.left=e}}class e extends i{clone(t){this.top=t.top,this.right=t.right,this.bottom=t.bottom,this.left=t.left}setBox(t,s,i,e){return this.top=t,this.right=s,this.bottom=i,this.left=e,this}getBox(){return{top:this.top,right:this.right,bottom:this.bottom,left:this.left}}setByAxis(t,s,i){"x"===t?(this.left=s,this.right=i):(this.top=s,this.bottom=i)}setOne(t,s,i){"x"===t?-1===s?this.left=i:this.right=i:-1===s?this.top=i:this.bottom=i}getOne(t,s){return"x"===t?-1===s?this.left:this.right:-1===s?this.top:this.bottom}setPositionInstance(t){this.top=t.y,this.left=t.x}setPosition(t,s){this.top=s,this.left=t}hasEqualPosition(t,s){return this.top===s||this.left===t}getPosition(){return{x:this.left,y:this.top}}}class n extends e{constructor(t,s,i,e){super(t,s,i,e)}setFalsy(){return this.setBox(!1,!1,!1,!1),this}isTruthyByAxis(t){return"x"===t?this.left||this.right:this.top||this.bottom}isTruthyOnSide(t,s){return"x"===t?1===s?this.right:this.left:1===s?this.bottom:this.top}isTruthy(){return this.left||this.right||this.top||this.bottom}}class r extends e{t(t){return this.top>=t.bottom}i(t){return this.bottom<=t.top}h(t){return this.right<=t.left}o(t){return this.left>=t.right}u(t){return this.top<t.top}l(t){return this.right>t.right}p(t){return this.bottom>t.bottom}m(t){return this.left<t.left}_(t){return this.top>=t.top}T(t){return this.right<=t.right}M(t){return this.bottom<=t.bottom}O(t){return this.left>=t.left}isBoxIntersect(t){return!(this.i(t)||this.o(t)||this.t(t)||this.h(t))}isOutThreshold(t,s,i){if(s.setBox(!1,!1,!1,!1),i){if("y"===i){const i=this.u(t),e=this.p(t);return i&&(s.top=!0),e&&(s.bottom=!0),i||e}const e=this.m(t),n=this.l(t);return e&&(s.left=!0),n&&(s.right=!0),e||n}return this.u(t)?(s.top=!0,!0):this.l(t)?(s.right=!0,!0):this.p(t)?(s.bottom=!0,!0):!!this.m(t)&&(s.left=!0,!0)}isInsideThreshold(t){return this._(t)&&this.T(t)&&this.M(t)&&this.O(t)}getSurroundingBox(t){return{left:Math.min(t.left,this.left),top:Math.min(t.top,this.top),right:Math.max(t.right,this.right),bottom:Math.max(t.bottom,this.bottom)}}isPositionedY(t){return this.t(t)||this.i(t)}assignBiggestBox(t){const{top:s,left:i,right:e,bottom:n}=t;i<this.left&&(this.left=i),s<this.top&&(this.top=s),e>this.right&&(this.right=e),n>this.bottom&&(this.bottom=n)}}function h(t,s){return`${t}_${s}`}const o={};let u=!1;function c(){}const l=new Set,a="height",p="width",x="min-height",f="position",d="opacity";function g(t){return"x"===t?p:a}function m(t){return"x"===t?"left":"top"}class w extends r{constructor(t,s,i,e){super(t,s,i,e),this.width=s-e,this.height=i-t}setByPointAndDimensions(t,s,i,e){this.top=t,this.left=s,this.width=e,this.height=i,this.right=s+e,this.bottom=t+i}setAxes(t,s){this.left=t,this.right=this.width+t,this.top=s,this.bottom=this.height+s}getInstance(){const{top:t,left:s,bottom:i,right:e,width:n,height:r}=this;return{top:t,left:s,bottom:i,right:e,width:n,height:r}}getViewportPos(t,s,i){const e=t,n=s+this.width,h=t+this.height,o=s;return i?new r(e,n,h,o):{top:e,right:n,bottom:h,left:o,height:this.height,width:this.width}}getDimensionDiff(t,s){const i=g(t);return this[i]-s[i]}getPositionDiff(t,s){return this[m(t)]-s[t]}}class b extends s{increase(t){return this.x+=t.x,this.y+=t.y,this}composeBox(t,s){const{top:i,left:e,bottom:n,right:h}=t;return s?new r(i+this.y,h-this.x,n-this.y,e+this.x):new r(i-this.y,h+this.x,n+this.y,e-this.x)}onSameAxis(t,s){return"y"===t?s.x===this.x:s.y===this.y}}class y{static containerKey(t,s){return h(t,s)}static depthKey(t){return h(t,"dp")}constructor(t){this.B=t,this.thresholds={},this.isOut={}}S({width:t,height:s}){const i=Math.round(this.B.horizontal*t/100),e=Math.round(this.B.vertical*s/100);this.A=new b(i,e)}v(t,s,i){this.thresholds[t]=this.A.composeBox(s,i),this.isOut[t]=new n(!1,!1,!1,!1)}setMainThreshold(t,s,i){this.S(s),this.v(t,s,i)}updateMainThreshold(t,s,i){this.thresholds[t]=this.A.composeBox(s,i),this.isOut[t].setFalsy()}getElmMainThreshold(t){return this.A.composeBox(t,!1)}setContainerThreshold(t,s,i,e){this.v(t,i,!1);const{top:n,left:r}=i,{height:h,width:o}=e,u=y.containerKey(s,t),c=y.depthKey(s);this.v(u,{left:r,top:n,right:r+o,bottom:n+h},!1),this.thresholds[c]?this.thresholds[c].assignBiggestBox(this.thresholds[u]):this.v(c,this.thresholds[u],!1)}isOutThreshold(t,s,i){return s.isOutThreshold(this.thresholds[t],this.isOut[t],i)}destroy(){Object.keys(this.thresholds).forEach((t=>{delete this.thresholds[t]})),Object.keys(this.isOut).forEach((t=>{delete this.isOut[t]}))}}const _={x:null,y:null};var T=new class{constructor(){this.D={}}newTravel(t){return void 0===this.D[t]?this.D[t]=0:this.D[t]+=1,`${t}${this.D[t]}`}};function M(t,s,i,e=!0,n="true"){const r=e?`data-${s}`:s;i?t.removeAttribute(r):t.setAttribute(r,n)}const O=[];function B(t){cancelAnimationFrame(t)}function S(){let t,s=!0;function i(){s=!0}function e(){B(t),O.splice(O.indexOf(t),1)}return[function(n,r){r&&e();try{s=!1;const e=function(t,s){return i=>{t(i),s()}}(n,i);t=requestAnimationFrame(e),O.push(t)}catch(t){}},e,function(){return s}]}const A=[];function v(t){let s=null,i=!1;function e(){s&&(clearTimeout(s),s=null)}return A.push(e),[function(n,r){const h=n||c;i=!0,r&&e(),s=setTimeout((()=>{i=!1,h()}),t)},e,function(){return i}]}const[E,D]=v(0);class q{constructor(t,s,i,e,n){this.index=t,this.SK=i,this.id=s,this.cycleID=e,this.hasScroll=n,this.reconciledIDs=new Set,this.numberOfTransformedELm=0,this.marginBottom=null,this.marginTop=null}}const P=Object.freeze(["x","y"]);let $=new WeakMap;function F(t,s,i){t.style.setProperty(s,i)}function R(t,s,i){const e=function(t){if($.has(t))return $.get(t);const s={computedStyle:getComputedStyle(t),parsedProperties:new Map};return $.set(t,s),s}(t),{parsedProperties:n,computedStyle:r}=e,h=n.get(s);if(void 0===h){const t=r.getPropertyValue(s),e=i?function(t){const s=parseFloat(t);return Number.isNaN(s)?0:s}(t):t;return n.set(s,e),e}return h}function I(t){return{width:R(t,p,!0),height:R(t,a,!0)}}const K=/absolute|fixed/;function k(t){return R(t,f,!1)}exports.AbstractBox=i,exports.AxesPoint=t,exports.BOTH_AXIS=P,exports.Box=e,exports.BoxBool=n,exports.BoxNum=r,exports.BoxRect=w,exports.DFlexCreateRAF=S,exports.DFlexCreateTimeout=v,exports.DFlexCycle=class{constructor(t,s,i,e,n){const r=new q(t,s,i,e,n);this.q=[r],this.SKs=[i],this.complete()}latest(){return this.q[this.q.length-1]}prev(){return this.q[this.q.length-2]}getAll(){return this.q}filter(t,s){return this.q.filter(s?s=>t.find((t=>t===s.cycleID)):s=>t.find((t=>t===s.id)))}P(t){this.SKs=this.SKs.filter((s=>!t.has(s)))}flush(t){const s=new Set;this.q=this.q.filter((i=>void 0===t.find((t=>t===i.SK&&(s.add(i.SK),!0)))||(s.has(i.SK)&&s.delete(i.SK),!1))),this.P(s)}pruneSKFromMigration(t){this.q=this.q.filter((s=>s.SK!==t)),this.P(new Set([t]))}setIndex(t){this.latest().index=t,this.latest().numberOfTransformedELm+=1}preserveVerticalMargin(t,s){this.latest()["bottom"===t?"marginBottom":"marginTop"]=s}clearMargin(){this.latest().marginBottom=null,this.latest().marginTop=null}add(t,s,i,e,n,r){this.q.push(new q(t,s,i,n,r)),e?this.SKs.unshift(i):this.SKs.push(i)}updateReconciledIDs(t,s){const i=this.q.find((s=>s.SK===t));i&&(i.reconciledIDs.clear(),s.forEach((t=>i.reconciledIDs.add(t))))}getMigrationBySK(t){return this.q.find((s=>s.SK===t))}getReconciledIDsBySK(t){const s=this.q.find((s=>s.SK===t));return s?s.reconciledIDs:l}start(){this.isTransitioning=!0}complete(){this.isTransitioning=!1,this.preserveVerticalMargin("top",null),this.preserveVerticalMargin("bottom",null)}clear(){this.q=[],this.SKs=[]}},exports.PREFIX_TRACKER_CYCLE="dflex_cycle_",exports.PREFIX_TRACKER_ID="dflex_id_",exports.PREFIX_TRACKER_KY="dflex_ky_",exports.Point=s,exports.PointBool=class extends s{isOneTruthy(){return this.x||this.y}isAllFalsy(){return!(this.x||this.y)}setFalsy(){this.x=!1,this.y=!1}},exports.PointNum=b,exports.TaskQueue=class{constructor(){this.$={},this.F=new Set}R(t){Array.isArray(this.$[t])||(this.$[t]=[])}I(t,s,i){this.$[s].push(t),i&&this.F.add(i)}K(t){return!Array.isArray(this.$[t])||0===this.$[t].length}hasElm(t){return this.F.has(t)}enqueueBeforeLast(t,s,i,e){this.R(i);const{length:n}=this.$[i];0===n?this.$[i].push(s):this.$[i][n-1]=s,this.I(t,i,e)}enqueue(t,s,i){this.R(s),this.I(t,s,i)}executeQueue(t){const s=[];if(this.K(t))return s;try{this.$[t].forEach((t=>{const i=t();s.push(i)}))}catch(t){}finally{D(),delete this.$[t]}return s}k(t){E((()=>{const[s,i]=t;this.executeQueue(s),i&&queueMicrotask((()=>this.executeQueue(i))),this.F.clear()}),!0)}scheduleNextTask(t){this.k(t)}cancelQueuedTask(){D()}clear(){D(),this.$={},this.F.clear()}},exports.Threshold=y,exports.ThresholdDeadZone=class{constructor(){this.L=new r(0,0,0,0),this.j={..._}}setZone(t,s,i,e){const n=i.getSurroundingBox(e);this.L.clone(n),this.j[t]=s}isInside(t,s,i){return!!i.isInsideThreshold(this.L)&&s===this.j[t]}clear(){this.L.setBox(0,0,0,0),this.j={..._}}},exports.assertElmPos=function(t,s){if(u)return;const i=t.getBoundingClientRect();Object.keys(s).forEach((t=>{if(Object.prototype.hasOwnProperty.call(i,t)&&i[t]!==s[t])throw u=!0,new Error(`Element position assertion failed. Expected: ${i[t]} found: ${s[t]}`)}))},exports.autoCleanupAllRAFs=function(){O.forEach(B),O.length=0},exports.autoCleanupAllTimeouts=function(){A.forEach((t=>{t()})),A.length=0},exports.canUseDOM=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},exports.clearComputedStyleCache=function(){$=new WeakMap},exports.combineKeys=h,exports.eventDebounce=function(t,s=!1,i=200){const[e,n]=v(i),[r,h]=S();let o=performance.now(),u=!1;const c=()=>{if(u)return;const n=performance.now();s||n-o>=i?(r(t,!0),o=n):e(c,!0)};return c.isPaused=()=>u,c.pause=()=>{u||(u=!0,h(),n())},c.resume=()=>{u&&(u=!1,c())},c},exports.featureFlags={__proto__:null,enableCommit:!1,enableMechanismDebugger:!1,enableMutationDebugger:!1,enablePositionAssertion:!1,enableReconcileDebugger:!1,enableRegisterDebugger:!1,enableScrollDebugger:!1,enableUndoSiblingsDebugger:!1,enableVisibilityDebugger:!1},exports.getAnimationOptions=function(t){const s={easing:"ease-in",duration:"dynamic"};return void 0===t?s:null===t?null:{...s,...t}},exports.getCachedComputedStyleProperty=R,exports.getDimensionTypeByAxis=g,exports.getElmBoxRect=function(t,s,i){const{left:e,top:n,right:r,bottom:h,height:o,width:u}=t.getBoundingClientRect(),c=new w(n,r,h,e);return 0===s&&0===i||c.setByPointAndDimensions(n+i,e+s,o,u),c},exports.getElmDimensions=I,exports.getElmOverflow=function(t,s){return R(t,s,!1)},exports.getElmPos=k,exports.getEndingPointByAxis=function(t){return"x"===t?"right":"bottom"},exports.getOppositeAxis=function(t){return"x"===t?"y":"x"},exports.getParentElm=function(t,s){let i=0,e=t;try{do{if(i+=1,i>1&&s(e))return i=0,e;e=e.parentElement}while(null!==e&&!e.isSameNode(document.body))}catch(t){}finally{i=0}return null},exports.getParsedElmTransform=function(t){return function(t){if(!/matrix\([^)]+\)/.test(t))return null;const s=t.match(/matrix\(\s*([^,]+),\s*([^,]+),\s*([^,]+),\s*([^,]+),\s*([^,]+),\s*([^)]+)\)/);return s?[parseFloat(s[5]),parseFloat(s[6])]:null}(R(t,"transform",!1))},exports.getSelection=function(){return window.getSelection()},exports.getStartingPointByAxis=m,exports.hasCSSTransition=function(t){const s=R(t,"transition",!1);return"none"!==s&&""!==s.trim()},exports.noop=c,exports.noopSet=l,exports.removeOpacity=function(t){1!==R(t,d,!0)&&F(t,d,"1")},exports.removeStyleProperty=function(t,s){t.style.removeProperty(s)},exports.rmEmptyAttr=function(t,s){if(!t.hasAttribute(s))return;const i=t.getAttribute(s);i&&""===i.trim()&&t.removeAttribute(s)},exports.setFixedDimensions=function(t){const{height:s,width:i}=I(t);F(t,a,`${s}px`),F(t,p,`${i}px`)},exports.setParentDimensions=function(t){const s=s=>R(t,s,!1),i=s(a),e=s(p),n=s(x),r="auto"!==s(x);"auto"!==n||F(t,x,i),r||F(t,"min-width",e)},exports.setRelativePosition=function(t){const s=k(t);K.test(s)&&F(t,f,"relative")},exports.setStyleProperty=F,exports.tracker=T,exports.updateDOMAttr=M,exports.updateElmDatasetGrid=function(t,s){t.dataset.devX=`${s.x}`,t.dataset.devY=`${s.y}`},exports.updateIndexAttr=function(t,s){M(t,"index",!1,!0,`${s}`)},exports.warnOnce=function(t,...s){o[t]||(o[t]=!0,console.warn(...s))};
{
"name": "@dflex/utils",
"version": "3.10.3",
"version": "3.10.4",
"description": "Utility package for DFlex",

@@ -5,0 +5,0 @@ "author": "Jalal Maskoun",

@@ -230,2 +230,5 @@ declare class AxesPoint<T = number> {

setAxes(x: number, y: number): void;
getInstance(): AbstractBoxRect;
getViewportPos(viewportTop: number, viewportLeft: number, asBoxNum: true): BoxNum;
getViewportPos(viewportTop: number, viewportLeft: number, asBoxNum: false): AbstractBox & Dimensions;
/**

@@ -232,0 +235,0 @@ * Gets the width/height difference between two boxes based on axis.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc