@dflex/utils
Advanced tools
Comparing version 3.10.0 to 3.10.1
@@ -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",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))}; | ||
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"){i||t.setAttribute(e?`data-${s}`:s,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))}; |
@@ -936,2 +936,20 @@ 'use strict'; | ||
function updateDOMAttr(DOM, name, isRemove, addPrefix = true, value = "true") { | ||
// Keep dragged attribute as is. | ||
const attrName = addPrefix ? `data-${name}` : name; | ||
if (isRemove) { | ||
{ | ||
if (!DOM.hasAttribute(attrName)) { | ||
throw new Error(`Attribute ${attrName} does not exist on the element.`); | ||
} | ||
DOM.removeAttribute(attrName); | ||
} | ||
return; | ||
} | ||
DOM.setAttribute(attrName, value); | ||
} | ||
function updateIndexAttr(DOM, value) { | ||
updateDOMAttr(DOM, "index", false, true, `${value}`); | ||
} | ||
function getElmBoxRect(DOM, scrollLeft, scrollTop) { | ||
@@ -963,9 +981,29 @@ const { | ||
// Maintain array of active RAF ids | ||
const activeRAFIds = []; | ||
// Utility to cancel RAF | ||
function cancelRAF(rafId) { | ||
cancelAnimationFrame(rafId); | ||
} | ||
// Inject completion logic into callback | ||
function injectRAFCompleteCheck(callback, rafDone) { | ||
return timestamp => { | ||
callback(timestamp); | ||
rafDone(); | ||
}; | ||
} | ||
function DFlexCreateRAF() { | ||
let id = null; | ||
let rafId; | ||
let isCompleted = true; | ||
function rafDone() { | ||
isCompleted = true; | ||
} | ||
function isRafDone() { | ||
return isCompleted; | ||
} | ||
function cleanup() { | ||
if (id) { | ||
cancelAnimationFrame(id); | ||
id = null; | ||
} | ||
cancelRAF(rafId); | ||
activeRAFIds.splice(activeRAFIds.indexOf(rafId), 1); | ||
} | ||
@@ -977,3 +1015,6 @@ function RAF(callback, cancelPrevFrame) { | ||
try { | ||
id = requestAnimationFrame(callback); | ||
isCompleted = false; | ||
const wrappedCallback = injectRAFCompleteCheck(callback, rafDone); | ||
rafId = requestAnimationFrame(wrappedCallback); | ||
activeRAFIds.push(rafId); | ||
} catch (error) { | ||
@@ -986,4 +1027,8 @@ { | ||
} | ||
return [RAF, cleanup]; | ||
return [RAF, cleanup, isRafDone]; | ||
} | ||
function autoCleanupAllRAFs() { | ||
activeRAFIds.forEach(cancelRAF); | ||
activeRAFIds.length = 0; | ||
} | ||
@@ -1621,2 +1666,3 @@ const timeoutInstances = []; | ||
exports.assertElmPos = assertElementPosition; | ||
exports.autoCleanupAllRAFs = autoCleanupAllRAFs; | ||
exports.autoCleanupAllTimeouts = autoCleanupAllTimeouts; | ||
@@ -1652,3 +1698,5 @@ exports.canUseDOM = canUseDOM; | ||
exports.tracker = DFlexTrackerSingleton; | ||
exports.updateDOMAttr = updateDOMAttr; | ||
exports.updateElmDatasetGrid = updateElmDatasetGrid; | ||
exports.updateIndexAttr = updateIndexAttr; | ||
exports.warnOnce = warnOnce; |
@@ -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",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))}; | ||
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"){i||t.setAttribute(e?`data-${s}`:s,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))}; |
{ | ||
"name": "@dflex/utils", | ||
"version": "3.10.0", | ||
"version": "3.10.1", | ||
"description": "Utility package for DFlex", | ||
@@ -5,0 +5,0 @@ "author": "Jalal Maskoun", |
@@ -550,8 +550,13 @@ declare class AxesPoint<T = number> { | ||
declare function updateDOMAttr<T extends string>(DOM: HTMLElement, name: T, isRemove: boolean, addPrefix?: boolean, value?: string | undefined): void; | ||
declare function updateIndexAttr(DOM: HTMLElement, value: number): void; | ||
declare function getElmBoxRect(DOM: HTMLElement, scrollLeft: number, scrollTop: number): BoxRect; | ||
type AnimationFrameCallback = (timestamp: number) => void; | ||
type IsRafDone = () => boolean; | ||
type RAFCleanup = () => void; | ||
type RAFFunction = (callback: AnimationFrameCallback, cancelPrevFrame: boolean) => void; | ||
declare function DFlexCreateRAF(): [RAFFunction, RAFCleanup]; | ||
declare function DFlexCreateRAF(): [RAFFunction, RAFCleanup, IsRafDone]; | ||
declare function autoCleanupAllRAFs(): void; | ||
@@ -596,2 +601,2 @@ type TimeoutCallback = () => void; | ||
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 }; | ||
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, autoCleanupAllRAFs, 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, updateDOMAttr, updateElmDatasetGrid, updateIndexAttr, warnOnce }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
147825
3794