@dflex/utils
Advanced tools
Comparing version 3.9.10 to 3.10.0
@@ -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="position";function d(t){return"x"===t?p:a}function f(t){return"x"===t?"left":"top"}class g 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=d(t);return this[i]-s[i]}getPositionDiff(t,s){return this[f(t)]-s[t]}}class m 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 m(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]}))}}var b=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 w(){let t=null;function s(){t&&(cancelAnimationFrame(t),t=null)}return[function(i,e){e&&s();try{t=requestAnimationFrame(i)}catch(t){}},s]}function _(t){let s=null,i=!1;function e(){s&&(clearTimeout(s),s=null)}return[function(n,r){const h=n||c;i=!0,r&&e(),s=setTimeout((()=>{i=!1,h()}),t)},e,function(){return i}]}const[T,M]=_(0);class O{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 B=Object.freeze(["x","y"]);let S=new WeakMap;function A(t,s,i){t.style.setProperty(s,i)}function v(t,s,i){const e=function(t){if(S.has(t))return S.get(t);const s={computedStyle:getComputedStyle(t),parsedProperties:new Map};return S.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 E(t){return{width:v(t,p,!0),height:v(t,a,!0)}}const D=/absolute|fixed/;function q(t){return v(t,x,!1)}exports.AbstractBox=i,exports.AxesPoint=t,exports.BOTH_AXIS=B,exports.Box=e,exports.BoxBool=n,exports.BoxNum=r,exports.BoxRect=g,exports.DFlexCreateRAF=w,exports.DFlexCreateTimeout=_,exports.DFlexCycle=class{constructor(t,s,i,e,n){const r=new O(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)))}F(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.F(s)}pruneSKFromMigration(t){this.q=this.q.filter((s=>s.SK!==t)),this.F(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 O(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=m,exports.TaskQueue=class{constructor(){this.P={},this.R=new Set}$(t){Array.isArray(this.P[t])||(this.P[t]=[])}I(t,s,i){this.P[s].push(t),i&&this.R.add(i)}K(t){return!Array.isArray(this.P[t])||0===this.P[t].length}hasElm(t){return this.R.has(t)}enqueueBeforeLast(t,s,i,e){this.$(i);const{length:n}=this.P[i];0===n?this.P[i].push(s):this.P[i][n-1]=s,this.I(t,i,e)}enqueue(t,s,i){this.$(s),this.I(t,s,i)}executeQueue(t){const s=[];if(this.K(t))return s;try{this.P[t].forEach((t=>{const i=t();s.push(i)}))}catch(t){}finally{M(),delete this.P[t]}return s}k(t){T((()=>{const[s,i]=t;this.executeQueue(s),i&&queueMicrotask((()=>this.executeQueue(i))),this.R.clear()}),!0)}scheduleNextTask(t){this.k(t)}cancelQueuedTask(){M()}clear(){M(),this.P={},this.R.clear()}},exports.Threshold=y,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.canUseDOM=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},exports.clearComputedStyleCache=function(){S=new WeakMap},exports.combineKeys=h,exports.eventDebounce=function(t,s=!1,i=200){const[e,n]=_(i),[r,h]=w();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=v,exports.getDimensionTypeByAxis=d,exports.getElmBoxRect=function(t,s,i){const{left:e,top:n,right:r,bottom:h,height:o,width:u}=t.getBoundingClientRect(),c=new g(n,r,h,e);return 0===s&&0===i||c.setByPointAndDimensions(n+i,e+s,o,u),c},exports.getElmDimensions=E,exports.getElmOverflow=function(t,s){return v(t,s,!1)},exports.getElmPos=q,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}(v(t,"transform",!1))},exports.getSelection=function(){return window.getSelection()},exports.getStartingPointByAxis=f,exports.hasCSSTransition=function(t){const s=v(t,"transition",!1);return"none"!==s&&""!==s.trim()},exports.noop=c,exports.noopSet=l,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}=E(t);A(t,a,`${s}px`),A(t,p,`${i}px`)},exports.setRelativePosition=function(t){const s=q(t);D.test(s)&&A(t,x,"relative")},exports.setStyleProperty=A,exports.tracker=b,exports.updateElmDatasetGrid=function(t,s){t.dataset.devX=`${s.x}`,t.dataset.devY=`${s.y}`},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",d="position",f="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(){let t=null;function s(){t&&(cancelAnimationFrame(t),t=null)}return[function(i,e){e&&s();try{t=requestAnimationFrame(i)}catch(t){}},s]}const O=[];function B(t){let s=null,i=!1;function e(){s&&(clearTimeout(s),s=null)}return O.push(e),[function(n,r){const h=n||c;i=!0,r&&e(),s=setTimeout((()=>{i=!1,h()}),t)},e,function(){return i}]}const[S,A]=B(0);class v{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 E=Object.freeze(["x","y"]);let D=new WeakMap;function q(t,s,i){t.style.setProperty(s,i)}function F(t,s,i){const e=function(t){if(D.has(t))return D.get(t);const s={computedStyle:getComputedStyle(t),parsedProperties:new Map};return D.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 P(t){return{width:F(t,p,!0),height:F(t,a,!0)}}const R=/absolute|fixed/;function $(t){return F(t,d,!1)}exports.AbstractBox=i,exports.AxesPoint=t,exports.BOTH_AXIS=E,exports.Box=e,exports.BoxBool=n,exports.BoxNum=r,exports.BoxRect=y,exports.DFlexCreateRAF=M,exports.DFlexCreateTimeout=B,exports.DFlexCycle=class{constructor(t,s,i,e,n){const r=new v(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)))}F(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.F(s)}pruneSKFromMigration(t){this.q=this.q.filter((s=>s.SK!==t)),this.F(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 v(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.P={},this.R=new Set}$(t){Array.isArray(this.P[t])||(this.P[t]=[])}I(t,s,i){this.P[s].push(t),i&&this.R.add(i)}K(t){return!Array.isArray(this.P[t])||0===this.P[t].length}hasElm(t){return this.R.has(t)}enqueueBeforeLast(t,s,i,e){this.$(i);const{length:n}=this.P[i];0===n?this.P[i].push(s):this.P[i][n-1]=s,this.I(t,i,e)}enqueue(t,s,i){this.$(s),this.I(t,s,i)}executeQueue(t){const s=[];if(this.K(t))return s;try{this.P[t].forEach((t=>{const i=t();s.push(i)}))}catch(t){}finally{A(),delete this.P[t]}return s}k(t){S((()=>{const[s,i]=t;this.executeQueue(s),i&&queueMicrotask((()=>this.executeQueue(i))),this.R.clear()}),!0)}scheduleNextTask(t){this.k(t)}cancelQueuedTask(){A()}clear(){A(),this.P={},this.R.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.autoCleanupAllTimeouts=function(){O.forEach((t=>{t()})),O.length=0},exports.canUseDOM=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},exports.clearComputedStyleCache=function(){D=new WeakMap},exports.combineKeys=h,exports.eventDebounce=function(t,s=!1,i=200){const[e,n]=B(i),[r,h]=M();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=F,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=P,exports.getElmOverflow=function(t,s){return F(t,s,!1)},exports.getElmPos=$,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}(F(t,"transform",!1))},exports.getSelection=function(){return window.getSelection()},exports.getStartingPointByAxis=m,exports.hasCSSTransition=function(t){const s=F(t,"transition",!1);return"none"!==s&&""!==s.trim()},exports.noop=c,exports.noopSet=l,exports.removeOpacity=function(t){1!==F(t,f,!0)&&q(t,f,"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}=P(t);q(t,a,`${s}px`),q(t,p,`${i}px`)},exports.setParentDimensions=function(t){const s=s=>F(t,s,!1),i=s(a),e=s(p),n=s(x),r="auto"!==s(x);"auto"!==n||q(t,x,i),r||q(t,"min-width",e)},exports.setRelativePosition=function(t){const s=$(t);R.test(s)&&q(t,d,"relative")},exports.setStyleProperty=q,exports.tracker=T,exports.updateElmDatasetGrid=function(t,s){t.dataset.devX=`${s.x}`,t.dataset.devY=`${s.y}`},exports.warnOnce=function(t,...s){o[t]||(o[t]=!0,console.warn(...s))}; |
121
dist/dev.js
@@ -509,2 +509,4 @@ 'use strict'; | ||
const WIDTH = "width"; | ||
const MIN_HEIGHT = "min-height"; | ||
const MIN_WIDTH = "min-width"; | ||
const LEFT = "left"; | ||
@@ -516,2 +518,3 @@ const TOP = "top"; | ||
const TRANSFORM = "transform"; | ||
const OPACITY = "opacity"; | ||
@@ -779,2 +782,79 @@ function getDimensionTypeByAxis(axis) { | ||
const INITIAL_MOVEMENT = { | ||
x: null, | ||
y: null | ||
}; | ||
/** | ||
* Represents a threshold dead zone used to manage the stabilizing zone that prevents | ||
* the dragged element from getting stuck between two intersected thresholds. | ||
*/ | ||
class ThresholdDeadZone { | ||
/** | ||
* A bounding box representing the threshold dead zone. | ||
*/ | ||
/** | ||
* Indicates movement directions for each axis (x and y). | ||
*/ | ||
constructor() { | ||
this._area = new BoxNum(0, 0, 0, 0); | ||
this._movement = { | ||
...INITIAL_MOVEMENT | ||
}; | ||
{ | ||
Object.seal(this); | ||
} | ||
} | ||
/** | ||
* Sets up the stabilizing zone to prevent the dragged element from getting stuck | ||
* between two intersected thresholds. | ||
* | ||
* @param axis - The axis (x or y) along which the stabilizing zone is applied. | ||
* @param movementDirection - The direction of movement on the specified axis. | ||
* @param firstThreshold - The bounding box representing the first threshold. | ||
* @param secondThreshold - The bounding box representing the second threshold. | ||
*/ | ||
setZone(axis, movementDirection, firstThreshold, secondThreshold) { | ||
// Calculate the surrounding bounding box for the stabilizing zone. | ||
const surroundingBox = firstThreshold.getSurroundingBox(secondThreshold); | ||
// Store the calculated area as the dead zone stabilizer. | ||
this._area.clone(surroundingBox); | ||
// Record the direction of movement on the specified axis. | ||
this._movement[axis] = movementDirection; | ||
} | ||
/** | ||
* Checks if the dragged element is inside the threshold dead zone. | ||
* | ||
* @param axis - The axis along which the movement is occurring ('x' or 'y'). | ||
* @param movementDirection - The direction of movement on the specified axis. | ||
* @param draggedPos - The position of the dragged element. | ||
* @returns True if the dragged element is inside the dead zone with matching | ||
* movement direction, otherwise false. | ||
*/ | ||
isInside(axis, movementDirection, draggedPos) { | ||
const isInsideDeadZone = draggedPos.isInsideThreshold(this._area); | ||
if (isInsideDeadZone) { | ||
const hasMatchingDir = movementDirection === this._movement[axis]; | ||
return hasMatchingDir; | ||
} | ||
return false; | ||
} | ||
/** | ||
* Clears the area and movement values, resetting them to their initial state. | ||
*/ | ||
clear() { | ||
this._area.setBox(0, 0, 0, 0); | ||
this._movement = { | ||
...INITIAL_MOVEMENT | ||
}; | ||
} | ||
} | ||
class DFlexTracker { | ||
@@ -909,3 +989,4 @@ /** | ||
function DFlexCreateTimeout(delay) { | ||
const timeoutInstances = []; | ||
function DFlexCreateTimeout(msDelay) { | ||
let id = null; | ||
@@ -928,3 +1009,3 @@ let isThrottled = false; | ||
cb(); | ||
}, delay); | ||
}, msDelay); | ||
} | ||
@@ -934,4 +1015,11 @@ function getIsThrottled() { | ||
} | ||
timeoutInstances.push(cleanup); | ||
return [timeout, cleanup, getIsThrottled]; | ||
} | ||
function autoCleanupAllTimeouts() { | ||
timeoutInstances.forEach(cleanup => { | ||
cleanup(); | ||
}); | ||
timeoutInstances.length = 0; | ||
} | ||
@@ -1444,2 +1532,27 @@ const [timeout, cancelTimeout] = DFlexCreateTimeout(0); | ||
} | ||
function removeOpacity(DOM) { | ||
const opacityValue = getCachedComputedStyleProperty(DOM, OPACITY, true); | ||
if (opacityValue !== 1) { | ||
{ | ||
// eslint-disable-next-line no-console | ||
console.error(`The application of opacity to the element with id '${DOM.id}' ` + `may interfere with its z-index, which is crucial for establishing the visual hierarchy. ` + `To ensure proper positioning of the drag element above others, DFlex will remove it.`); | ||
} | ||
setStyleProperty(DOM, OPACITY, "1"); | ||
} | ||
} | ||
function setParentDimensions(DOM) { | ||
const getStyle = property => getCachedComputedStyleProperty(DOM, property, false); | ||
const height = getStyle(HEIGHT); | ||
const width = getStyle(WIDTH); | ||
const minHeight = getStyle(MIN_HEIGHT); | ||
const minWidth = getStyle(MIN_HEIGHT); | ||
const hasMinHeight = minHeight !== "auto"; | ||
const hasMinWidth = minWidth !== "auto"; | ||
if (!hasMinHeight) { | ||
setStyleProperty(DOM, MIN_HEIGHT, height); | ||
} | ||
if (!hasMinWidth) { | ||
setStyleProperty(DOM, MIN_WIDTH, width); | ||
} | ||
} | ||
function hasCSSTransition(DOM) { | ||
@@ -1509,3 +1622,5 @@ const transitionValue = getCachedComputedStyleProperty(DOM, "transition", false); | ||
exports.Threshold = DFlexThreshold; | ||
exports.ThresholdDeadZone = ThresholdDeadZone; | ||
exports.assertElmPos = assertElementPosition; | ||
exports.autoCleanupAllTimeouts = autoCleanupAllTimeouts; | ||
exports.canUseDOM = canUseDOM; | ||
@@ -1532,5 +1647,7 @@ exports.clearComputedStyleCache = clearComputedStyleCache; | ||
exports.noopSet = noopSet; | ||
exports.removeOpacity = removeOpacity; | ||
exports.removeStyleProperty = removeStyleProperty; | ||
exports.rmEmptyAttr = rmEmptyAttr; | ||
exports.setFixedDimensions = setFixedDimensions; | ||
exports.setParentDimensions = setParentDimensions; | ||
exports.setRelativePosition = setRelativePosition; | ||
@@ -1537,0 +1654,0 @@ exports.setStyleProperty = setStyleProperty; |
@@ -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="position";function d(t){return"x"===t?p:a}function f(t){return"x"===t?"left":"top"}class g 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=d(t);return this[i]-s[i]}getPositionDiff(t,s){return this[f(t)]-s[t]}}class m 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 m(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]}))}}var b=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 w(){let t=null;function s(){t&&(cancelAnimationFrame(t),t=null)}return[function(i,e){e&&s();try{t=requestAnimationFrame(i)}catch(t){}},s]}function _(t){let s=null,i=!1;function e(){s&&(clearTimeout(s),s=null)}return[function(n,r){const h=n||c;i=!0,r&&e(),s=setTimeout((()=>{i=!1,h()}),t)},e,function(){return i}]}const[T,M]=_(0);class O{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 B=Object.freeze(["x","y"]);let S=new WeakMap;function A(t,s,i){t.style.setProperty(s,i)}function v(t,s,i){const e=function(t){if(S.has(t))return S.get(t);const s={computedStyle:getComputedStyle(t),parsedProperties:new Map};return S.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 E(t){return{width:v(t,p,!0),height:v(t,a,!0)}}const D=/absolute|fixed/;function q(t){return v(t,x,!1)}exports.AbstractBox=i,exports.AxesPoint=t,exports.BOTH_AXIS=B,exports.Box=e,exports.BoxBool=n,exports.BoxNum=r,exports.BoxRect=g,exports.DFlexCreateRAF=w,exports.DFlexCreateTimeout=_,exports.DFlexCycle=class{constructor(t,s,i,e,n){const r=new O(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)))}F(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.F(s)}pruneSKFromMigration(t){this.q=this.q.filter((s=>s.SK!==t)),this.F(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 O(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=m,exports.TaskQueue=class{constructor(){this.P={},this.R=new Set}$(t){Array.isArray(this.P[t])||(this.P[t]=[])}I(t,s,i){this.P[s].push(t),i&&this.R.add(i)}K(t){return!Array.isArray(this.P[t])||0===this.P[t].length}hasElm(t){return this.R.has(t)}enqueueBeforeLast(t,s,i,e){this.$(i);const{length:n}=this.P[i];0===n?this.P[i].push(s):this.P[i][n-1]=s,this.I(t,i,e)}enqueue(t,s,i){this.$(s),this.I(t,s,i)}executeQueue(t){const s=[];if(this.K(t))return s;try{this.P[t].forEach((t=>{const i=t();s.push(i)}))}catch(t){}finally{M(),delete this.P[t]}return s}k(t){T((()=>{const[s,i]=t;this.executeQueue(s),i&&queueMicrotask((()=>this.executeQueue(i))),this.R.clear()}),!0)}scheduleNextTask(t){this.k(t)}cancelQueuedTask(){M()}clear(){M(),this.P={},this.R.clear()}},exports.Threshold=y,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.canUseDOM=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},exports.clearComputedStyleCache=function(){S=new WeakMap},exports.combineKeys=h,exports.eventDebounce=function(t,s=!1,i=200){const[e,n]=_(i),[r,h]=w();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=v,exports.getDimensionTypeByAxis=d,exports.getElmBoxRect=function(t,s,i){const{left:e,top:n,right:r,bottom:h,height:o,width:u}=t.getBoundingClientRect(),c=new g(n,r,h,e);return 0===s&&0===i||c.setByPointAndDimensions(n+i,e+s,o,u),c},exports.getElmDimensions=E,exports.getElmOverflow=function(t,s){return v(t,s,!1)},exports.getElmPos=q,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}(v(t,"transform",!1))},exports.getSelection=function(){return window.getSelection()},exports.getStartingPointByAxis=f,exports.hasCSSTransition=function(t){const s=v(t,"transition",!1);return"none"!==s&&""!==s.trim()},exports.noop=c,exports.noopSet=l,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}=E(t);A(t,a,`${s}px`),A(t,p,`${i}px`)},exports.setRelativePosition=function(t){const s=q(t);D.test(s)&&A(t,x,"relative")},exports.setStyleProperty=A,exports.tracker=b,exports.updateElmDatasetGrid=function(t,s){t.dataset.devX=`${s.x}`,t.dataset.devY=`${s.y}`},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",d="position",f="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(){let t=null;function s(){t&&(cancelAnimationFrame(t),t=null)}return[function(i,e){e&&s();try{t=requestAnimationFrame(i)}catch(t){}},s]}const O=[];function B(t){let s=null,i=!1;function e(){s&&(clearTimeout(s),s=null)}return O.push(e),[function(n,r){const h=n||c;i=!0,r&&e(),s=setTimeout((()=>{i=!1,h()}),t)},e,function(){return i}]}const[S,A]=B(0);class v{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 E=Object.freeze(["x","y"]);let D=new WeakMap;function q(t,s,i){t.style.setProperty(s,i)}function F(t,s,i){const e=function(t){if(D.has(t))return D.get(t);const s={computedStyle:getComputedStyle(t),parsedProperties:new Map};return D.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 P(t){return{width:F(t,p,!0),height:F(t,a,!0)}}const R=/absolute|fixed/;function $(t){return F(t,d,!1)}exports.AbstractBox=i,exports.AxesPoint=t,exports.BOTH_AXIS=E,exports.Box=e,exports.BoxBool=n,exports.BoxNum=r,exports.BoxRect=y,exports.DFlexCreateRAF=M,exports.DFlexCreateTimeout=B,exports.DFlexCycle=class{constructor(t,s,i,e,n){const r=new v(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)))}F(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.F(s)}pruneSKFromMigration(t){this.q=this.q.filter((s=>s.SK!==t)),this.F(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 v(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.P={},this.R=new Set}$(t){Array.isArray(this.P[t])||(this.P[t]=[])}I(t,s,i){this.P[s].push(t),i&&this.R.add(i)}K(t){return!Array.isArray(this.P[t])||0===this.P[t].length}hasElm(t){return this.R.has(t)}enqueueBeforeLast(t,s,i,e){this.$(i);const{length:n}=this.P[i];0===n?this.P[i].push(s):this.P[i][n-1]=s,this.I(t,i,e)}enqueue(t,s,i){this.$(s),this.I(t,s,i)}executeQueue(t){const s=[];if(this.K(t))return s;try{this.P[t].forEach((t=>{const i=t();s.push(i)}))}catch(t){}finally{A(),delete this.P[t]}return s}k(t){S((()=>{const[s,i]=t;this.executeQueue(s),i&&queueMicrotask((()=>this.executeQueue(i))),this.R.clear()}),!0)}scheduleNextTask(t){this.k(t)}cancelQueuedTask(){A()}clear(){A(),this.P={},this.R.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.autoCleanupAllTimeouts=function(){O.forEach((t=>{t()})),O.length=0},exports.canUseDOM=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},exports.clearComputedStyleCache=function(){D=new WeakMap},exports.combineKeys=h,exports.eventDebounce=function(t,s=!1,i=200){const[e,n]=B(i),[r,h]=M();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=F,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=P,exports.getElmOverflow=function(t,s){return F(t,s,!1)},exports.getElmPos=$,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}(F(t,"transform",!1))},exports.getSelection=function(){return window.getSelection()},exports.getStartingPointByAxis=m,exports.hasCSSTransition=function(t){const s=F(t,"transition",!1);return"none"!==s&&""!==s.trim()},exports.noop=c,exports.noopSet=l,exports.removeOpacity=function(t){1!==F(t,f,!0)&&q(t,f,"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}=P(t);q(t,a,`${s}px`),q(t,p,`${i}px`)},exports.setParentDimensions=function(t){const s=s=>F(t,s,!1),i=s(a),e=s(p),n=s(x),r="auto"!==s(x);"auto"!==n||q(t,x,i),r||q(t,"min-width",e)},exports.setRelativePosition=function(t){const s=$(t);R.test(s)&&q(t,d,"relative")},exports.setStyleProperty=q,exports.tracker=T,exports.updateElmDatasetGrid=function(t,s){t.dataset.devX=`${s.x}`,t.dataset.devY=`${s.y}`},exports.warnOnce=function(t,...s){o[t]||(o[t]=!0,console.warn(...s))}; |
{ | ||
"name": "@dflex/utils", | ||
"version": "3.9.10", | ||
"version": "3.10.0", | ||
"description": "Utility package for DFlex", | ||
@@ -5,0 +5,0 @@ "author": "Jalal Maskoun", |
@@ -330,2 +330,43 @@ declare class AxesPoint<T = number> { | ||
type MovementDirection = "r" | "l" | "d" | "u"; | ||
/** | ||
* Represents a threshold dead zone used to manage the stabilizing zone that prevents | ||
* the dragged element from getting stuck between two intersected thresholds. | ||
*/ | ||
declare class ThresholdDeadZone { | ||
/** | ||
* A bounding box representing the threshold dead zone. | ||
*/ | ||
private _area; | ||
/** | ||
* Indicates movement directions for each axis (x and y). | ||
*/ | ||
private _movement; | ||
constructor(); | ||
/** | ||
* Sets up the stabilizing zone to prevent the dragged element from getting stuck | ||
* between two intersected thresholds. | ||
* | ||
* @param axis - The axis (x or y) along which the stabilizing zone is applied. | ||
* @param movementDirection - The direction of movement on the specified axis. | ||
* @param firstThreshold - The bounding box representing the first threshold. | ||
* @param secondThreshold - The bounding box representing the second threshold. | ||
*/ | ||
setZone(axis: Axis, movementDirection: MovementDirection, firstThreshold: BoxNum, secondThreshold: BoxNum): void; | ||
/** | ||
* Checks if the dragged element is inside the threshold dead zone. | ||
* | ||
* @param axis - The axis along which the movement is occurring ('x' or 'y'). | ||
* @param movementDirection - The direction of movement on the specified axis. | ||
* @param draggedPos - The position of the dragged element. | ||
* @returns True if the dragged element is inside the dead zone with matching | ||
* movement direction, otherwise false. | ||
*/ | ||
isInside(axis: Axis, movementDirection: MovementDirection, draggedPos: BoxNum): boolean; | ||
/** | ||
* Clears the area and movement values, resetting them to their initial state. | ||
*/ | ||
clear(): void; | ||
} | ||
declare class DFlexTracker { | ||
@@ -497,2 +538,4 @@ private _travelID; | ||
declare function setRelativePosition(DOM: HTMLElement): void; | ||
declare function removeOpacity(DOM: HTMLElement): void; | ||
declare function setParentDimensions(DOM: HTMLElement): void; | ||
declare function hasCSSTransition(DOM: HTMLElement): boolean; | ||
@@ -520,3 +563,4 @@ declare function rmEmptyAttr(DOM: HTMLElement, attribute: string): void; | ||
type IsThrottledFunction = () => boolean; | ||
declare function DFlexCreateTimeout(delay: number): [TimeoutFunction, TimeoutCleanup, IsThrottledFunction]; | ||
declare function DFlexCreateTimeout(msDelay: number): [TimeoutFunction, TimeoutCleanup, IsThrottledFunction]; | ||
declare function autoCleanupAllTimeouts(): void; | ||
@@ -554,2 +598,2 @@ /** | ||
export { AbstractBox, type AbstractBoxRect, AbstractDFlexCycle, type AnimationOpts, type Axes, AxesPoint, type Axis, BOTH_AXIS, Box, BoxBool, BoxNum, BoxRect, type CSS, type CSSClass, type CSSStyle, type CubicBezier, DFlexCreateRAF, DFlexCreateTimeout, DFlexCycle, type Dimensions, type Direction, type IsThrottledFunction, PREFIX_TRACKER_CYCLE, PREFIX_TRACKER_ID, PREFIX_TRACKER_KY, Point, PointBool, PointNum, type RAFCleanup, type RAFFunction, TaskQueue, DFlexThreshold as Threshold, type ThresholdPercentages, type TimeoutCleanup, type TimeoutFunction, assertElementPosition as assertElmPos, canUseDOM, clearComputedStyleCache, combineKeys, DFlexEventDebounce as eventDebounce, FeatureFlags as featureFlags, getAnimationOptions, getCachedComputedStyleProperty, getDimensionTypeByAxis, getElmBoxRect, getElmDimensions, getElmOverflow, getElmPos, getEndingPointByAxis, getOppositeAxis, getParentElm, getParsedElmTransform, getSelection, getStartingPointByAxis, hasCSSTransition, noop, noopSet, removeStyleProperty, rmEmptyAttr, setFixedDimensions, setRelativePosition, setStyleProperty, _default as tracker, updateElmDatasetGrid, warnOnce }; | ||
export { AbstractBox, type AbstractBoxRect, AbstractDFlexCycle, type AnimationOpts, type Axes, AxesPoint, type Axis, BOTH_AXIS, Box, BoxBool, BoxNum, BoxRect, type CSS, type CSSClass, type CSSStyle, type CubicBezier, DFlexCreateRAF, DFlexCreateTimeout, DFlexCycle, type Dimensions, type Direction, type IsThrottledFunction, PREFIX_TRACKER_CYCLE, PREFIX_TRACKER_ID, PREFIX_TRACKER_KY, Point, PointBool, PointNum, type RAFCleanup, type RAFFunction, TaskQueue, DFlexThreshold as Threshold, ThresholdDeadZone, type ThresholdPercentages, type TimeoutCleanup, type TimeoutFunction, assertElementPosition as assertElmPos, autoCleanupAllTimeouts, canUseDOM, clearComputedStyleCache, combineKeys, DFlexEventDebounce as eventDebounce, FeatureFlags as featureFlags, getAnimationOptions, getCachedComputedStyleProperty, getDimensionTypeByAxis, getElmBoxRect, getElmDimensions, getElmOverflow, getElmPos, getEndingPointByAxis, getOppositeAxis, getParentElm, getParsedElmTransform, getSelection, getStartingPointByAxis, hasCSSTransition, noop, noopSet, removeOpacity, removeStyleProperty, rmEmptyAttr, setFixedDimensions, setParentDimensions, setRelativePosition, setStyleProperty, _default as tracker, updateElmDatasetGrid, warnOnce }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143722
3697