@dynamix-layout/core 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.cjs.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class k{buffer;head=0;tail=0;count=0;capacity;constructor(t=16,e=[]){this.capacity=Math.max(t,e.length),this.buffer=new Array(this.capacity),e.forEach(n=>{this.enqueue(n)})}enqueue(t){this.count===this.capacity&&this.resize(),this.buffer[this.tail]=t,this.tail=(this.tail+1)%this.capacity,this.count++}enqueueFront(t){this.count===this.capacity&&this.resize(),this.head=(this.head-1+this.capacity)%this.capacity,this.buffer[this.head]=t,this.count++}insert(t,e){if(t<0||t>this.count)return!1;if(t===0)return this.enqueueFront(e),!0;if(t===this.count)return this.enqueue(e),!0;this.count===this.capacity&&this.resize();const n=t,i=this.count-t;return n<=i?this.shiftLeft(t,e):this.shiftRight(t,e),this.count++,!0}insertArray(t,e){if(t<0||t>this.count)return!1;if(e.length===0)return!0;if(t===0){for(let r=e.length-1;r>=0;r--)this.enqueueFront(e[r]);return!0}if(t===this.count)return e.forEach(r=>this.enqueue(r)),!0;for(;this.count+e.length>this.capacity;)this.resize();const n=t,i=this.count-t,s=e.length;return n<=i?this.shiftLeftArray(t,e):this.shiftRightArray(t,e),this.count+=s,!0}insertQueue(t,e){if(t<0||t>this.count)return!1;if(e.isEmpty())return!0;const n=e.size();if(t===0){const c=e.toArray();for(let d=c.length-1;d>=0;d--)this.enqueueFront(c[d]);return!0}if(t===this.count){for(const c of e)this.enqueue(c);return!0}for(;this.count+n>this.capacity;)this.resize();const i=e.toArray(),s=t,r=this.count-t;return s<=r?this.shiftLeftArray(t,i):this.shiftRightArray(t,i),this.count+=n,!0}push(t){this.enqueue(t)}unshift(t){this.enqueueFront(t)}dequeue(){if(this.count===0)return;const t=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,t}dequeueBack(){if(this.count===0)return;this.tail=(this.tail-1+this.capacity)%this.capacity;const t=this.buffer[this.tail];return this.count--,t}indexOf(t){for(let e=0;e<this.count;e++){const n=(this.head+e)%this.capacity;if(this.buffer[n]===t)return e}return-1}remove(t){const e=this.indexOf(t);return e===-1?!1:(this.removeAt(e),!0)}removeAt(t){if(t<0||t>=this.count)return;if(t===0)return this.dequeue();if(t===this.count-1)return this.dequeueBack();const e=(this.head+t)%this.capacity,n=this.buffer[e],i=t,s=this.count-t-1;return i<=s?this.shiftRightForRemoval(t):this.shiftLeftForRemoval(t),this.count--,n}shift(){return this.dequeue()}pop(){return this.dequeueBack()}fifoAdd(t){this.enqueue(t)}fifoRemove(){return this.dequeue()}filoAdd(t){this.enqueue(t)}filoRemove(){return this.dequeueBack()}lifoAdd(t){this.enqueueFront(t)}lifoRemove(){return this.dequeue()}liloAdd(t){this.enqueueFront(t)}liloRemove(){return this.dequeueBack()}get(t){if(t<0||t>=this.count)return;const e=(this.head+t)%this.capacity;return this.buffer[e]}set(t,e){if(t<0||t>=this.count)return!1;const n=(this.head+t)%this.capacity;return this.buffer[n]=e,!0}peek(){return this.count>0?this.buffer[this.head]:void 0}peekBack(){if(this.count===0)return;const t=(this.tail-1+this.capacity)%this.capacity;return this.buffer[t]}front(){return this.peek()}back(){return this.peekBack()}size(){return this.count}getCapacity(){return this.capacity}isEmpty(){return this.count===0}isFull(){return this.count===this.capacity}clear(){this.head=0,this.tail=0,this.count=0}toArray(){const t=[];for(let e=0;e<this.count;e++){const n=(this.head+e)%this.capacity;t.push(this.buffer[n])}return t}*[Symbol.iterator](){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*forward(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*reverse(){for(let t=this.count-1;t>=0;t--){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*entries(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield[t,this.buffer[e]]}}*keys(){for(let t=0;t<this.count;t++)yield t}*values(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}toString(){return`Queue(${this.toArray().join(", ")})`}resize(){const t=this.capacity*2,e=new Array(t);for(let n=0;n<this.count;n++){const i=(this.head+n)%this.capacity;e[n]=this.buffer[i]}this.buffer=e,this.capacity=t,this.head=0,this.tail=this.count}shiftLeft(t,e){this.head=(this.head-1+this.capacity)%this.capacity;for(let i=0;i<t;i++){const s=(this.head+1+i)%this.capacity,r=(this.head+i)%this.capacity;this.buffer[r]=this.buffer[s]}const n=(this.head+t)%this.capacity;this.buffer[n]=e}shiftRight(t,e){for(let i=this.count-1;i>=t;i--){const s=(this.head+i)%this.capacity,r=(this.head+i+1)%this.capacity;this.buffer[r]=this.buffer[s]}const n=(this.head+t)%this.capacity;this.buffer[n]=e,this.tail=(this.tail+1)%this.capacity}shiftRightForRemoval(t){for(let e=t;e>0;e--){const n=(this.head+e-1)%this.capacity,i=(this.head+e)%this.capacity;this.buffer[i]=this.buffer[n]}this.head=(this.head+1)%this.capacity}shiftLeftForRemoval(t){for(let e=t;e<this.count-1;e++){const n=(this.head+e+1)%this.capacity,i=(this.head+e)%this.capacity;this.buffer[i]=this.buffer[n]}this.tail=(this.tail-1+this.capacity)%this.capacity}shiftLeftArray(t,e){const n=e.length;this.head=(this.head-n+this.capacity)%this.capacity;for(let i=0;i<t;i++){const s=(this.head+n+i)%this.capacity,r=(this.head+i)%this.capacity;this.buffer[r]=this.buffer[s]}for(let i=0;i<n;i++){const s=(this.head+t+i)%this.capacity;this.buffer[s]=e[i]}}shiftRightArray(t,e){const n=e.length;for(let i=this.count-1;i>=t;i--){const s=(this.head+i)%this.capacity,r=(this.head+i+n)%this.capacity;this.buffer[r]=this.buffer[s]}for(let i=0;i<n;i++){const s=(this.head+t+i)%this.capacity;this.buffer[s]=e[i]}this.tail=(this.tail+n)%this.capacity}}function v(o,t=(e,n)=>e===n){let e=o;const n=new Set;let i=[];const s=()=>e,r=(f,m=!1)=>{if(m){e=f;return}t(e,f)||(e=f,n.forEach(p=>p(e)),i.forEach(p=>p(e)),i=[])},c=()=>{n.forEach(f=>f(e)),i.forEach(f=>f(e)),i=[]},d=f=>(n.add(f),()=>n.delete(f)),l=()=>new Promise(f=>{i.push(f)});return{get:s,set:r,onChange:d,nextChange:l,triggerChange:c,onChangePromise:f=>{let m=!0;return(async()=>{for(;m;){const I=await l();if(!m)break;f(I)}})(),()=>{m=!1}}}}function E(o,t){if(o.size!==t.size)return!1;for(const[e,n]of o.entries()){const i=t.get(e);if(!i||!T(n,i))return!1}return!0}function T(o,t){if(o.typNode!==t.typNode||o.nodName!==t.nodName||o.uidNode!==t.uidNode||o.nodPart!==t.nodPart)return!1;const e=o.nodDims,n=t.nodDims;return e.x===n.x&&e.y===n.y&&e.w===n.w&&e.h===n.h}const O=()=>crypto.randomUUID(),D={set:(o,t)=>setTimeout(o,t),clear:o=>clearTimeout(o)},u={createId:O,timer:D,root:void 0,tree:null,minW:40,minH:40,bond:10,inst:null};class a{static cache={dimMins:new Map,mapDirs:new Map,tabCnts:new Map,mapElem:new Map,tabOpts:v(new Map,E),nodOpts:v(new Map,E),bndOpts:v(new Map,E)};kids=new k;dims={w:0,h:0,x:0,y:0};unId;next=null;prev=null;type="row";name="";part=0;host=null;open="";constructor(t={}){const e={type:"row",host:null,name:"",part:100,dims:{w:0,h:0,x:0,y:0},unId:u.createId(),open:""};this.type=t.type??e.type,this.host=t.host??e.host,this.name=t.name??e.name,this.part=t.part??e.part,this.dims=t.dims??e.dims,this.open=t.open??e.open,this.unId=t.unId||e.unId}addBond(t,e=null){if(!e)return;const n=new x(t,this,e);a.cache.mapElem.set(n.unId,n)}getReqDimension(){const t=a.cache.dimMins.get(this.unId),e=a.cache.tabCnts.get(this.unId),n=Math.max(t.minWidth,e.horizontal*u.minW+Math.max(0,e.horizontal-1)*u.bond),i=Math.max(t.minHeight,e.vertical*u.minH+Math.max(0,e.vertical-1)*u.bond);return{width:n,height:i}}calcDimensions(){const t=a.cache.mapDirs.get(this.unId);if(!this.kids)return;let e=0;const n=a.cache.dimMins.get(this.unId)||{minWidth:0,minHeight:0};let i=0;for(const h of this.kids)e+=h.part;if(e===0)return;let s;t?s=this.dims.w-n.minWidth:s=this.dims.h-n.minHeight;const r=s<0,c=this.kids.peekBack();let d=0,l=0;for(const h of this.kids){const f=a.cache.dimMins.get(h.unId)||{minWidth:0,minHeight:0};let m=0;if(!r){d+=h.part;const p=h===c?s:Math.round(s*d/e);m=p-l,l=p}t?(h.dims.w=f.minWidth+m,h.dims.h=this.dims.h,h.dims.x=this.dims.x+i,h.dims.y=this.dims.y,i+=h.dims.w+u.bond):(h.dims.h=f.minHeight+m,h.dims.w=this.dims.w,h.dims.y=this.dims.y+i,h.dims.x=this.dims.x,i+=h.dims.h+u.bond),h.next&&(t?h.next.dims={w:u.bond,h:h.dims.h,x:h.dims.x+h.dims.w,y:h.dims.y}:h.next.dims={w:h.dims.w,h:u.bond,x:h.dims.x,y:h.dims.y+h.dims.h})}}toJSON(){const t=[];for(const n of this.kids)t.push(n.toJSON());const e={typNode:this.type,nodPart:this.part,nodName:this.name,uidNode:this.unId};return this.open&&(e.nodOpen=this.open),t.length>0&&(e.nodKids=t),e}}class x{dims={w:0,h:0,x:0,y:0};unId=u.createId();next=null;prev=null;host=null;constructor(t=null,e=null,n=null){this.host=t,this.next=e,this.prev=n,this.next&&(this.next.prev=this),this.prev&&(this.prev.next=this)}toJSON(){return{nodName:this.host?.name||"",typNode:"bond",uidNode:this.unId,nodPart:0,nodOpen:"",nodKids:[]}}}function*S(o){const t=new k;for(t.enqueue(o);!t.isEmpty();){const e=t.dequeue();if(e&&(yield e,e.nodKids&&e.nodKids.length>0))for(const n of e.nodKids)t.enqueue(n)}}function*R(o){const t=new k;for(t.enqueue(o);!t.isEmpty();){const e=t.dequeue();if(e&&(a.cache.mapElem.set(e.unId,e),yield e,e.kids.size()>0))for(const n of e.kids)t.enqueue(n)}}function*q(o,t){for(const e of t.kids)yield*o.NodeLayoutRecursiveIterator(e);yield t}function H(o,t){const e=a.cache.mapDirs.get(t.unId);if(e===void 0){console.warn(`Cannot update child directions for node ${t.unId}; its own direction is not set.`);return}for(const n of t.kids)a.cache.mapDirs.set(n.unId,!e),n.kids.size()>0&&(n.host=t,o.updateChildDirections(n),n.next&&a.cache.mapDirs.set(n.next.unId,!e))}function B(o,t=u.tree){if(!t)return;const e=o.JSONLayoutIterator(t),n=o.NodeLayoutIterator(u.root);for(a.cache.mapDirs.set(u.root.unId,!0);;){const i=e.next(),s=n.next();if(i.done||s.done)break;const r=i.value,c=s.value;!r||!c||o.createNodeTreeFromJSONTree(r,c)}o.calcTabsetCountAndMinDim()}function M(o,t,e){const n=a.cache.mapDirs.get(e.unId);for(const i of t.nodKids||[]){const s=o.createNodeFromJSON(i),r=e.kids.peekBack();s.host=e,s.addBond(s.host,r),e.kids.enqueue(s),a.cache.mapDirs.set(s.unId,!n)}e.type==="tabset"&&a.cache.mapElem.set(e.unId,e),e.type==="tab"&&a.cache.mapElem.set(e.unId,e)}function C(o,t,e=u.root){const n=new k;for(n.enqueue(e),a.cache.mapDirs.set(u.root.unId,!0);!t.isEmpty();){const i=n.dequeue();if(!i)break;const s=a.cache.mapDirs.get(i.unId);if(t.size()==2){const h=t.dequeue(),f=t.dequeue(),m=new a({type:"tabset",host:i}),p=new a({type:"tabset",host:i}),I=new a({type:"tab",host:m,name:h,unId:o.tabsIds.get(h??"")??u.createId()}),y=new a({type:"tab",host:p,name:f,unId:o.tabsIds.get(f??"")??u.createId()});m.open=I.name,p.open=y.name,m.kids.enqueue(I),p.kids.enqueue(y),i.kids.enqueue(m),i.kids.enqueue(p),p.addBond(i,m),a.cache.mapDirs.set(m.unId,!s),a.cache.mapDirs.set(p.unId,!s),a.cache.mapElem.set(m.unId,m),a.cache.mapElem.set(p.unId,p),a.cache.mapDirs.set(I.unId,s),a.cache.mapDirs.set(y.unId,s),a.cache.mapElem.set(I.unId,I),a.cache.mapElem.set(y.unId,y);break}const r=t.dequeue(),c=new a({type:"tabset",host:i}),d=new a({type:"row",host:i}),l=new a({type:"tab",host:c,name:r,unId:o.tabsIds.get(r??"")??u.createId()});c.open=l.name,c.kids.enqueue(l),i.kids.enqueue(c),i.kids.enqueue(d),d.addBond(i,c),a.cache.mapDirs.set(c.unId,!s),a.cache.mapDirs.set(d.unId,!s),a.cache.mapElem.set(c.unId,c),a.cache.mapDirs.set(l.unId,s),a.cache.mapElem.set(l.unId,l),n.enqueue(d)}o.calcTabsetCountAndMinDim()}function F(o,t){const e=new a({type:t.typNode,name:t.nodName,unId:t.uidNode,part:t.nodPart,dims:{w:0,h:0,x:0,y:0},open:typeof t.nodOpen=="string"?t.nodOpen:""});return t.typNode==="tab"&&(e.unId=o.tabsIds.get(t.nodName)||t.uidNode),e}function W(o,t=u.root,e=!0){t===u.root&&e&&(a.cache.tabCnts.clear(),a.cache.dimMins.clear(),a.cache.mapElem.clear(),a.cache.nodOpts.get().clear(),a.cache.bndOpts.get().clear());for(const n of o.NodeLayoutRecursiveIterator(t)){const i=a.cache.tabCnts,s=a.cache.dimMins;a.cache.mapElem.set(n.unId,n);const r=i.set(n.unId,{horizontal:0,vertical:0}).get(n.unId),c=s.set(n.unId,{minWidth:0,minHeight:0}).get(n.unId),d=a.cache.mapDirs.get(n.unId);if(n.type==="tab"&&(a.cache.mapElem.set(n.unId,n),s.set(n.unId,{minWidth:0,minHeight:0})),n.next&&a.cache.mapElem.set(n.next.unId,n.next),n.type==="tabset"&&(a.cache.mapElem.set(n.unId,n),s.set(n.unId,{minWidth:u.minW,minHeight:u.minH}),d?i.set(n.unId,{horizontal:0,vertical:1}):i.set(n.unId,{horizontal:1,vertical:0})),n.type==="row"){for(const l of n.kids){const h=i.get(l.unId),f=s.get(l.unId);h&&(r.horizontal+=h.horizontal,r.vertical+=h.vertical,d?(c.minHeight=Math.max(c.minHeight,f.minHeight),c.minWidth+=f.minWidth):(c.minHeight+=f.minHeight,c.minWidth=Math.max(c.minWidth,f.minWidth)))}d?c.minWidth+=(n.kids.size()-1)*u.bond:c.minHeight+=(n.kids.size()-1)*u.bond}}t===u.root&&e&&o.pruneStaleDirections()}function L(){for(const o of a.cache.mapDirs.keys())a.cache.mapElem.has(o)||a.cache.mapDirs.delete(o)}function P(){const o=u.root.getReqDimension();let t=!1,e=u.root.dims.w,n=u.root.dims.h;return u.root.dims.w<o.width&&(e=o.width,t=!0),u.root.dims.h<o.height&&(n=o.height,t=!0),t&&(u.root.dims.w=e,u.root.dims.h=n),{adjustedW:e,adjustedH:n,wasAdjusted:t}}function z(o,t=u.root,e=!1){const n=t===u.root,i=d=>n?new Map:new Map(d.get()),s=i(a.cache.nodOpts),r=i(a.cache.bndOpts),c=i(a.cache.tabOpts);n&&o.calculateRootAdjustment();for(const d of o.NodeLayoutIterator(t)){d.calcDimensions();const l=a.cache.mapDirs.get(d.unId);if(d.type==="tabset"){const h={typNode:d.type,nodName:d.name,uidNode:d.unId,nodPart:d.part,nodOpen:d.open,nodeDir:l,nodKids:Array.from(d.kids).map(f=>{const m={typNode:f.type,nodName:f.name,uidNode:f.unId,nodPart:f.part,nodOpen:d.open===f.name,nodeDir:!l,nodDims:{...d.dims}};return c.set(f.unId,m),m}),nodDims:{...d.dims}};s.set(d.unId,h)}if(d.next&&d.type!=="tab"){const h={typNode:"bond",nodName:d.name,uidNode:d.next.unId,nodeDir:l,nodPart:0,nodDims:{...d.next.dims}};r.set(d.next.unId,h)}}a.cache.nodOpts.set(s,e),a.cache.bndOpts.set(r,e),a.cache.tabOpts.set(c,e)}function K(o,t,e=!1,n=2){if(u.root.dims=t,e){o.calcDimensions(u.root);return}o.cntdown&&(u.timer.clear(o.cntdown),o.cntdown=null),o.cntdown=u.timer.set(()=>{o.cntdown=null,o.calcDimensions()},n)}function U(o,t,e,n=!1,i=2){if(n){o.updateSliderDimension(t,e);return}o.cntdown&&(u.timer.clear(o.cntdown),o.cntdown=null),o.cntdown=u.timer.set(()=>{o.cntdown=null,o.updateSliderDimension(t,e)},i)}function $(o,t,e){const n=a.cache.mapElem.get(t);if(!n||!(n instanceof x)){console.warn(`Bond with id ${t} not found or is not a Bond instance`);return}const i=a.cache.mapDirs.get(n.host.unId),s=n.prev,r=n.next,c=n.host;if(!s||!r||!c){console.warn("Missing prev, next, or host node",s,r,c);return}const d=a.cache.dimMins.get(s.unId)||{minWidth:0,minHeight:0},l=a.cache.dimMins.get(r.unId)||{minWidth:0,minHeight:0},h=u.bond/2;if(i){const f=r.dims.x+r.dims.w,m=s.dims.x+d.minWidth+h,p=f-l.minWidth-h,I=Math.max(m,Math.min(p,e.x));n.dims.x=I-h,s.dims.w=n.dims.x-s.dims.x,r.dims.x=I+h,r.dims.w=f-r.dims.x;const y=Math.max(0,s.dims.w-d.minWidth),g=Math.max(0,r.dims.w-l.minWidth),b=y+g,N=s.part+r.part;b>0?(s.part=y/b*N,r.part=g/b*N):(s.part=N/2,r.part=N/2)}else{const f=r.dims.y+r.dims.h,m=s.dims.y+d.minHeight+h,p=f-l.minHeight-h,I=Math.max(m,Math.min(p,e.y));n.dims.y=I-h,s.dims.h=n.dims.y-s.dims.y,r.dims.y=I+h,r.dims.h=f-r.dims.y;const y=Math.max(0,s.dims.h-d.minHeight),g=Math.max(0,r.dims.h-l.minHeight),b=y+g,N=s.part+r.part;b>0?(s.part=y/b*N,r.part=g/b*N):(s.part=N/2,r.part=N/2)}o.calcDimensions(c)}function _(o,t,e,n){const i=a.cache.mapElem.get(t);let s=a.cache.mapElem.get(e);return!i||!(i instanceof a)||!s||!(s instanceof a)?(console.warn(`Source node ${t} not found or is not a Node instance`),!1):i?.type=="tab"&&i.host===s&&s.kids.size()<2?(console.warn("Cannot move to self as it has only one tab"),!1):i?.type=="tabset"&&s?.host===i?(console.warn("Cannot move tabset to self as it is already a child"),!1):!i||!s?(console.warn(`Source or destination node not found: ${t}, ${e}`),!1):i===s?(console.warn("Source and destination nodes are the same, no action taken."),!1):!i.host||!s.host&&s.type!=="row"?(console.warn(`Source node or destination node's host is null: ${i.unId}, ${s.unId}`),!1):s.type==="row"&&s!==u.root?(console.warn(`Cannot move relative to a nested row: ${s.unId}`),!1):s.type==="row"&&n==="contain"?(console.warn(`Cannot move to a row with 'contain' layout: ${s.unId}`),!1):i.type==="row"||(s.type==="tabset"&&n==="contain"&&(s=s.kids.peekBack()||s),i===s)?!1:o.isOnlyContent(i)?(console.warn("Cannot move the only tabset or tab in the layout"),!1):(s.type==="tab"&&(n==="contain"||n==="left"||n==="right")?o.moveNodeAsTab(i,s,n):s.type==="row"&&n!=="contain"?o.moveRelativeToRoot(i,s,n):s.type==="tabset"&&n!=="contain"&&o.moveRelativeToTabset(i,s,n),o.calcTabsetCountAndMinDim(),o.calcDimensions(u.root,!0),!0)}function Y(o,t){let e=0;for(const n of o.NodeLayoutRecursiveIterator(u.root))n.type==="tabset"&&e++;return e!==1?!1:t.type==="tabset"||t.type==="tab"&&t.host?.kids.size()===1}function G(o,t,e,n){if(!e||!e.host){console.warn(`Destination node ${e.unId} has no host, cannot move.`);return}o.removeNode(t);const i=e.host,s=i.kids.indexOf(e);if(s===void 0||s===-1)return;const r=n==="contain"||n==="left",c=r?s:s+1,d=i.kids.get(c+1),l=i.kids.get(c-1),h=e.next,f=e.prev;if(!r&&h?a.cache.mapElem.delete(h.unId):r&&f&&a.cache.mapElem.delete(f.unId),t.type=="tab")r?(l&&t.addBond(i,l),e.addBond(i,t)):(t.addBond(i,e),d&&d.addBond(i,t)),i.kids.insert(c,t),t.host=i,i.open=t.name;else if(t.type=="tabset"){const m=t.kids.peek(),p=t.kids.peekBack();r?(m&&l&&m.addBond(i,l),p&&e&&e.addBond(i,p)):(m&&e&&m.addBond(i,e),p&&d&&d.addBond(i,p)),i.kids.insertQueue(c,t.kids);for(const I of t.kids)I.host=i,I.next&&(I.next.host=i);i.open=p?p.name:""}o.updateChildDirections(i)}const J={root:(o,t)=>o===t,tabset:(o,t)=>o!==t};function A(o,t,e,n,i){if(o.removeNode(t),t.type!=="tab"&&t.type!=="tabset")return;const s=a.cache.mapDirs.get(e.unId)===!1,r=n==="left"||n==="right",c=n==="top"||n==="left";let d=t;t.type==="tab"&&(d=new a({type:"tabset",host:e.host}),d.kids.enqueue(t),d.open=t.name,t.host=d),J[i](s,r)?o.insertNodeWithNewParent(d,e,c):o.insertNode(e,d,c)}function Q(o,t,e,n){A(o,t,e,n,"root")}function j(o,t,e,n){A(o,t,e,n,"tabset")}function X(o,t,e,n){const i=t.host;if(t==u.root){const f=u.root.kids.peek(),m=u.root.kids.peekBack();n?(u.root.kids.enqueueFront(e),f&&f.addBond(u.root,e)):(u.root.kids.enqueue(e),m&&e.addBond(u.root,m)),e.host=u.root,o.updateChildDirections(u.root);return}if(!i){console.warn(`Destination node ${t.unId} has no host, cannot insert.`);return}const s=i.kids.indexOf(t);if(s===-1){console.warn(`Destination node ${t.unId} not found in its host's kids.`);return}const r=a.cache.mapDirs.get(i.unId);r&&a.cache.mapDirs.set(e.unId,!r);const c=i.kids.get(s+1),d=i.kids.get(s-1),l=t.next,h=t.prev;e.host=i,n?(i.kids.insert(s,e),t.addBond(i,e),d&&e.addBond(i,d),h&&a.cache.mapElem.delete(h.unId)):(i.kids.insert(s+1,e),e.addBond(i,t),c&&c.addBond(i,e),l&&a.cache.mapElem.delete(l.unId)),o.updateChildDirections(i)}function V(o,t,e,n){const i=new k,s=new a({type:"tabset",host:e.host});if(!e||!t){console.warn(`Destination node ${e.unId} has no host, cannot insert.`);return}if(e===u.root){const c=new a({type:"row",host:e});if(e.kids.size()===0)e.kids.enqueue(t),t.host=e;else if(e.kids.size()==1&&e.kids.peek()?.type==="tabset"){const d=e.kids.dequeue();if(!d){console.warn(`No kid found in destination node ${e.unId}, cannot insert.`);return}n?(c.kids.enqueue(t),c.kids.enqueue(d),e.kids.enqueue(c),d.addBond(c,t)):(c.kids.enqueue(d),c.kids.enqueue(t),t.addBond(c,d),e.kids.enqueue(c)),t.host=c,d.host=c}else if(e.kids.size()==1&&e.kids.peek()?.type==="row"){const d=e.kids.peek(),l=d?.kids.peek(),h=d?.kids.peekBack();n&&d?(d.kids.enqueueFront(t),l&&l.addBond(d,t)):d&&(d.kids.enqueue(t),h&&t.addBond(d,h)),t.host=d}else if(e.kids.size()>1){const d=new a({type:"row",host:e}),l=new a({type:"row",host:d});for(const h of e.kids)l.kids.enqueue(h),h.host=l,h.next&&(h.next.host=l);t.host=d,e.kids.clear(),n?(d.kids.enqueueFront(t),d.kids.enqueue(l),l.addBond(d,t)):(d.kids.enqueue(l),d.kids.enqueue(t),t.addBond(d,l)),e.kids.enqueue(d)}o.updateChildDirections(e);return}t.host=e,s.host=e,s.kids=e.kids,s.open=e.open;const r=a.cache.mapDirs.get(e.unId);for(const c of s.kids)c.host=s,c.next&&(c.next.host=s),a.cache.mapDirs.set(c.unId,r);for(const c of t.kids)c.host=t,c.next&&(c.next.host=t),a.cache.mapDirs.set(c.unId,r);a.cache.mapDirs.set(s.unId,!r),a.cache.mapDirs.set(t.unId,!r),n?(i.enqueue(t),i.enqueue(s),e.kids=i,e.type="row",s.addBond(e,t)):(i.enqueue(s),i.enqueue(t),e.kids=i,e.type="row",t.addBond(e,s))}function Z(o,t){if(!t.host||!t.host.host){console.warn(`Source node ${t.unId} has no host, cannot move.`);return}const e=t.host,n=t.host.host,i=n.kids.indexOf(e),s=n.kids.get(i-1),r=n.kids.get(i+1),c=t.kids.peek(),d=t.kids.peekBack();o.removeKid(e);let l=i;if(t.type=="row"&&e){s&&c&&c.addBond(n,s),r&&d&&r.addBond(n,d);for(const h of t.kids)h.host=n,h.next&&(h.next.host=n),n.kids.insert(l,h),a.cache.mapDirs.set(h.unId,!a.cache.mapDirs.get(n.unId)),a.cache.dimMins.delete(h.unId),l++}else if(t.type=="tabset"){s&&t.addBond(n,s),r&&r.addBond(n,t),n.kids.insert(l,t),t.host=n,a.cache.mapDirs.set(t.unId,!a.cache.mapDirs.get(n.unId));for(const h of t.kids)a.cache.mapDirs.set(h.unId,a.cache.mapDirs.get(n.unId)),a.cache.dimMins.delete(h.unId)}}function tt(o,t=!0){const e=o.host,n=o.prev,i=o.next;if(o.host=null,o.next=null,o.prev=null,n&&(n.next=null),i&&(i.prev=null),!t)return o;n&&i&&n.prev&&i.next?n.prev.addBond(e,i.next):n&&n.prev?n.prev.next=null:i&&i.next&&(i.next.prev=null)}function et(o,t){if(!t.host){console.warn("Kid node has no host, cannot remove.");return}const e=t?.host,n=e?.host;if(o.removeKid(t),t.type==="tabset"&&e.kids.size()===1){const i=e.kids.peek();i&&o.moveAdjacentNodeToGrandParent(i)}else if(t.type==="tab"&&e.kids.size()===0&&n.kids.size()===2){o.removeKid(e);const i=n?.kids.peek();i&&o.moveAdjacentNodeToGrandParent(i)}else if(t.type==="tab"&&e.kids.size()===0&&n.kids.size()>2)o.removeKid(e);else if(t.type==="tab"&&e.open===t.name&&e.kids.size()>0){const i=e.kids.peek();i&&(e.open=i.name)}}function nt(o){if(!o.host){console.warn("Kid node has no host, cannot remove.");return}const t=o.host,e=t.kids.indexOf(o),n=t.kids.get(e+1),i=t.kids.get(e-1),s=o.next,r=o.prev;if(e===-1){console.warn("Kid node not found in its host's kids.");return}s&&a.cache.mapElem.delete(s.unId),r&&a.cache.mapElem.delete(r.unId),n&&i?n.addBond(t,i):n?n.prev=null:i&&(i.next=null),t.kids.removeAt(e),a.cache.mapElem.delete(o.unId),a.cache.dimMins.delete(o.unId),a.cache.mapDirs.delete(o.unId),a.cache.tabCnts.delete(o.unId),o.type==="tabset"&&a.cache.mapElem.delete(o.unId),o.type==="tab"&&a.cache.mapElem.delete(o.unId),o.host=null,o.next=null,o.prev=null}function it(){a.cache.dimMins.clear(),a.cache.mapDirs.clear(),a.cache.tabCnts.clear(),a.cache.mapElem.clear(),a.cache.nodOpts.get().clear(),a.cache.bndOpts.get().clear()}class w{static get _root(){return u.root}static set _root(t){u.root=t}static get _tree(){return u.tree}static set _tree(t){u.tree=t}static get _minW(){return u.minW}static set _minW(t){u.minW=t}static get _minH(){return u.minH}static set _minH(t){u.minH=t}static get _bond(){return u.bond}static set _bond(t){u.bond=t}static get _inst(){return u.inst}static set _inst(t){u.inst=t}nodeOps;cntdown=null;tabsIds=new Map;constructor(t={}){const e={tabs:[],tree:null,minW:40,minH:40,bond:10,uqid:"dynamix-layout-root",tabsIds:new Map,...t};this.tabsIds=e.tabsIds,u.createId=e.createId??O,u.timer=e.timer??D,w._tree=e.tree??null,w._root=new a({unId:e.uqid,name:e.uqid,type:"row"}),this.nodeOps=v(new Map,E),w._minW=e.minW,w._minH=e.minH,w._bond=e.bond;const n=new k(e.tabs.length,e.tabs);w._tree?this.createNodeLayout():this.createBinaryNodeTreeFromQueue(n),w._inst=this}*JSONLayoutIterator(t){yield*S(t)}*NodeLayoutIterator(t){yield*R(t)}*NodeLayoutRecursiveIterator(t){yield*q(this,t)}updateChildDirections(t){return H(this,t)}createNodeLayout(t=w._tree){return B(this,t)}createNodeTreeFromJSONTree(t,e){return M(this,t,e)}createBinaryNodeTreeFromQueue(t,e=w._root){return C(this,t,e)}createNodeFromJSON(t){return F(this,t)}calcTabsetCountAndMinDim(t=w._root,e=!0){return W(this,t,e)}pruneStaleDirections(){return L()}calculateRootAdjustment(){return P()}calcDimensions(t=w._root,e=!1){return z(this,t,e)}updateDimension(t,e=!1,n=2){return K(this,t,e,n)}updateSlider(t,e,n=!1,i=2){return U(this,t,e,n,i)}updateSliderDimension(t,e){return $(this,t,e)}updateTree(t,e,n){return _(this,t,e,n)}isOnlyContent(t){return Y(this,t)}moveNodeAsTab(t,e,n){return G(this,t,e,n)}moveRelativeToRoot(t,e,n){return Q(this,t,e,n)}moveRelativeToTabset(t,e,n){return j(this,t,e,n)}insertNode(t,e,n){return X(this,t,e,n)}insertNodeWithNewParent(t,e,n){return V(this,t,e,n)}moveAdjacentNodeToGrandParent(t){return Z(this,t)}removeRelation(t,e=!0){return tt(t,e)}removeNode(t){return et(this,t)}removeKid(t){return nt(t)}clearAllCache(){return it()}}const ot=6;function st(o,t,e){const{left:n,top:i,width:s,height:r}=o,c=t-n,d=e-i;return c<s/3?{area:"left",left:n,top:i,width:s/2,height:r}:c>2*s/3?{area:"right",left:n+s/2,top:i,width:s/2,height:r}:d<r/3?{area:"top",left:n,top:i,width:s,height:r/2}:d>2*r/3?{area:"bottom",left:n,top:i+r/2,width:s,height:r/2}:{area:"contain",left:n+s*.1,top:i+r*.1,width:s*.8,height:r*.8}}function at(o,t){const{x:e,y:n,w:i,h:s}=o;switch(t){case"left":return{area:t,left:e,top:n,width:i/2,height:s};case"right":return{area:t,left:e+i/2,top:n,width:i/2,height:s};case"top":return{area:t,left:e,top:n,width:i,height:s/2};case"bottom":return{area:t,left:e,top:n+s/2,width:i,height:s/2}}}function rt(o,t,e,n){if(t.length===0||n<o.top||n>o.bottom)return null;const i=t[0],s=t[t.length-1];let r=ot;if(e>s.right)return{index:t.length-1,area:"right",left:s.right+1,top:s.top,width:r-2,height:s.height};if(e<i.left)return{index:0,area:"left",left:i.left-r+1,top:i.top,width:r-2,height:i.height};let c=0,d=1/0,l=!1;t.forEach((m,p)=>{const I=m.left+m.width/2,y=Math.abs(e-I);y<d&&(d=y,c=p,l=e<I)});const h=l?c>0:c<t.length-1;t.length>1&&h&&(r=t[1].left-i.right);const f=t[c];return{index:c,area:l?"left":"right",left:l?f.left-r+1:f.right+1,top:f.top,width:r-2,height:f.height}}function dt(o,t){return o.area===t.area&&o.left===t.left&&o.top===t.top&&o.width===t.width&&o.height===t.height}function ct(o,{x:t,y:e,w:n,h:i}){o.style.left=`${t}px`,o.style.top=`${e}px`,o.style.width=`${n}px`,o.style.height=`${i}px`}function ht(o,t){return{x:o.x,y:o.y+t,w:o.w,h:Math.max(0,o.h-t)}}function ut(o){let t=null,e=null;const n=()=>{e=null;const i=t;t=null,i&&o(i.value)};return{schedule(i){t={value:i},e===null&&(e=requestAnimationFrame(n))},flush(){e!==null&&(cancelAnimationFrame(e),n())},cancel(){e!==null&&cancelAnimationFrame(e),e=null,t=null}}}(()=>{if(typeof window>"u")return;const o="color: #03A9F4; font-weight: bold; line-height: 1.2;",t="color: #E0E0E0; font-size: 12px;",e="color: #42a5f5; font-size: 12px;",n="color: #9E9E9E; font-size: 10px;",i=`
2
- ██████╗ ██╗ ██╗ ███╗ ██╗ █████╗ ███╗ ███╗ ██████╗ ██╗ ██╗
3
- ██╔══██╗╚██╗ ██╔╝ ████╗ ██║ ██╔══██╗ ████╗ ████║ ╚═██╔═╝ ╚██╗██╔╝
4
- ██║ ██║ ╚████╔╝ ██╔██╗ ██║ ███████║ ██╔████╔██║ ██║ ╚███╔╝
5
- ██║ ██║ ╚██╔╝ ██║╚██╗██║ ██╔══██║ ██║╚██╔╝██║ ██║ ██╔██╗
6
- ██████╔╝ ██║ ██║ ╚████║ ██║ ██║ ██║ ╚═╝ ██║ ██████╗ ██╔╝ ██╗
7
- ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
8
- ██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗
9
- ██║ ██╔══██╗ ╚██╗ ██╔╝ ██╔═══██╗ ██║ ██║╚══██╔══╝
10
- ██║ ███████║ ╚████╔╝ ██║ ██║ ██║ ██║ ██║
11
- ██║ ██╔══██║ ╚██╔╝ ██║ ██║ ██║ ██║ ██║
12
- ███████╗ ██║ ██║ ██║ ╚██████╔╝ ╚█████╔╝ ██║
13
- ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝ ╚═╝
14
- `;console.groupCollapsed("%cDYNAMIX LAYOUT (click to expand)","color: #03A9F4; font-weight: bold; font-size: 14px;"),console.log(`%c${i}`,o),console.log("%c A powerful, dynamic layout system 🚀",t),console.log(`%c ⚡ For docs and more info,
15
- ⚡ visit: https://github.com/akash-aman/dynamix-layout`,e),console.log(`%cMIT License
16
-
17
- Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
18
-
19
- Permission is hereby granted, free of charge, to any person obtaining a copy
20
- of this software and associated documentation files (the "Software"), to deal
21
- in the Software without restriction, including without limitation the rights
22
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
- copies of the Software, and to permit persons to whom the Software is
24
- furnished to do so, subject to the following conditions:
25
-
26
- The above copyright notice and this permission notice shall be included in all
27
- copies or substantial portions of the Software.
28
-
29
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
- SOFTWARE.
36
- `,n),console.groupEnd(),typeof window<"u"&&(window.__DYNAMIX_LAYOUT__={__LICENSE__:`MIT License
37
-
38
- Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
39
-
40
- Permission is hereby granted, free of charge, to any person obtaining a copy
41
- of this software and associated documentation files (the "Software"), to deal
42
- in the Software without restriction, including without limitation the rights
43
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
- copies of the Software, and to permit persons to whom the Software is
45
- furnished to do so, subject to the following conditions:
46
-
47
- The above copyright notice and this permission notice shall be included in all
48
- copies or substantial portions of the Software.
49
-
50
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56
- SOFTWARE.
57
- `,__LAYOUT__:w})})();exports.Bond=x;exports.DynamixLayoutCore=w;exports.Node=a;exports.Queue=k;exports.areNodeOptionsEqual=T;exports.areNodeOptionsMapEqual=E;exports.createFrameScheduler=ut;exports.createReactiveState=v;exports.getNavbarDropPreview=rt;exports.getRootSplitPreview=at;exports.getTabBodyRect=ht;exports.getTabsetDropPreview=st;exports.isSameDropPreview=dt;exports.setElementRect=ct;
@@ -1,3 +0,0 @@
1
- import { NodeOptions } from '../type';
2
- export declare function areNodeOptionsMapEqual(mapA: Map<string, NodeOptions>, mapB: Map<string, NodeOptions>): boolean;
3
- export declare function areNodeOptionsEqual(a: NodeOptions, b: NodeOptions): boolean;
@@ -1,17 +0,0 @@
1
- import { Dimension } from '../type';
2
- export declare function setElementRect(el: HTMLElement, { x, y, w, h }: Dimension): void;
3
- /** Area of a tabset below its tab bar; never negative when squeezed. */
4
- export declare function getTabBodyRect(tabset: Dimension, tabbarHeight: number): Dimension;
5
- export interface FrameScheduler<T> {
6
- /** Remember `value`; `onFlush` runs with the latest value on the next frame. */
7
- schedule: (value: T) => void;
8
- /** Run a pending flush now (e.g. on pointer up). */
9
- flush: () => void;
10
- /** Drop a pending flush (e.g. on unmount). */
11
- cancel: () => void;
12
- }
13
- /**
14
- * Coalesces bursts of updates (pointer events can fire several times per
15
- * frame) into at most one `onFlush` call per animation frame.
16
- */
17
- export declare function createFrameScheduler<T>(onFlush: (value: T) => void): FrameScheduler<T>;
@@ -1,27 +0,0 @@
1
- import { Dimension } from '../type';
2
- export type DropArea = 'top' | 'bottom' | 'left' | 'right' | 'contain';
3
- export type RootSide = Exclude<DropArea, 'contain'>;
4
- /** Where a dragged tab or tabset would land, in viewport coordinates. */
5
- export interface DropPreview {
6
- area: DropArea;
7
- left: number;
8
- top: number;
9
- width: number;
10
- height: number;
11
- }
12
- export type PreviewRect = Pick<DOMRect, 'left' | 'top' | 'right' | 'bottom' | 'width' | 'height'>;
13
- /**
14
- * Splits a tabset into thirds: the outer thirds drop beside it, the middle
15
- * drops into it as a tab.
16
- */
17
- export declare function getTabsetDropPreview(rect: PreviewRect, clientX: number, clientY: number): DropPreview;
18
- /** The half of the whole layout a root-edge drop would take. */
19
- export declare function getRootSplitPreview(container: Dimension, side: RootSide): DropPreview;
20
- /**
21
- * Insertion marker between the tabs of a tab bar. `index` is the tab the
22
- * marker sits next to. Returns null when the pointer is above or below the bar.
23
- */
24
- export declare function getNavbarDropPreview(navbarRect: PreviewRect, tabRects: PreviewRect[], clientX: number, clientY: number): (DropPreview & {
25
- index: number;
26
- }) | null;
27
- export declare function isSameDropPreview(a: Partial<DropPreview>, b: DropPreview): boolean;
@@ -1,69 +0,0 @@
1
- import { Queue } from './queue';
2
- import { Node, Bond } from './node';
3
- import { Timer } from './state';
4
- import { Dimension, LayoutTree, NodeOptions, RootAdjustment, ReactiveValue, TabsIds } from '../type';
5
- declare class Layout {
6
- static get _root(): Node;
7
- static set _root(value: Node);
8
- static get _tree(): LayoutTree | null;
9
- static set _tree(value: LayoutTree | null);
10
- static get _minW(): number;
11
- static set _minW(value: number);
12
- static get _minH(): number;
13
- static set _minH(value: number);
14
- static get _bond(): number;
15
- static set _bond(value: number);
16
- static get _inst(): Layout | null;
17
- static set _inst(value: Layout | null);
18
- nodeOps: ReactiveValue<Map<string, NodeOptions>>;
19
- cntdown: ReturnType<typeof setTimeout> | null;
20
- tabsIds: TabsIds;
21
- constructor(options?: {
22
- tabs?: string[];
23
- tree?: LayoutTree | null;
24
- minW?: number;
25
- minH?: number;
26
- bond?: number;
27
- uqid?: string;
28
- tabsIds?: TabsIds;
29
- /** Generates ids for new nodes and bonds (default `crypto.randomUUID`). */
30
- createId?: () => string;
31
- /** Schedules deferred updates (default `setTimeout`/`clearTimeout`). */
32
- timer?: Timer;
33
- });
34
- JSONLayoutIterator(root: LayoutTree): IterableIterator<LayoutTree>;
35
- NodeLayoutIterator(root: Node): IterableIterator<Node>;
36
- NodeLayoutRecursiveIterator(root: Node): IterableIterator<Node>;
37
- updateChildDirections(parent: Node): void;
38
- createNodeLayout(root?: LayoutTree | null): void;
39
- createNodeTreeFromJSONTree(json: LayoutTree, host: Node): void;
40
- createBinaryNodeTreeFromQueue(queue: Queue<string>, host?: Node): void;
41
- createNodeFromJSON(json: LayoutTree): Node;
42
- calcTabsetCountAndMinDim(root?: Node, clear?: boolean): void;
43
- pruneStaleDirections(): void;
44
- calculateRootAdjustment(): RootAdjustment;
45
- calcDimensions(root?: Node, supress?: boolean): void;
46
- updateDimension(dim: Dimension, disableTimeout?: boolean, timeout?: number): void;
47
- updateSlider(id: string, dim: {
48
- x: number;
49
- y: number;
50
- }, disableTimeout?: boolean, timeout?: number): void;
51
- updateSliderDimension(id: string, dim: {
52
- x: number;
53
- y: number;
54
- }): void;
55
- updateTree(src: string, des: string, layout: 'top' | 'bottom' | 'left' | 'right' | 'contain'): boolean;
56
- isOnlyContent(node: Node): boolean;
57
- moveNodeAsTab(src: Node, des: Node, layout: 'left' | 'right' | 'contain'): void;
58
- moveRelativeToRoot(src: Node, des: Node, layout: 'top' | 'bottom' | 'left' | 'right'): void;
59
- moveRelativeToTabset(src: Node, des: Node, layout: 'top' | 'bottom' | 'left' | 'right'): void;
60
- insertNode(des: Node, src: Node, flag: boolean): void;
61
- insertNodeWithNewParent(src: Node, des: Node, flag: boolean): void;
62
- moveAdjacentNodeToGrandParent(src: Node): void;
63
- removeRelation(src: Node, fix?: boolean): Node | undefined;
64
- removeNode(src: Node): void;
65
- removeKid(kid: Node): void;
66
- clearAllCache(): void;
67
- }
68
- export { Node, Bond };
69
- export { Layout as DynamixLayoutCore };
@@ -1,9 +0,0 @@
1
- import { Node } from './node';
2
- import { Dimension, RootAdjustment } from '../type';
3
- import { DynamixLayoutCore as Layout } from './dynamix';
4
- /** Minimum sizes and the position/size of every tabset, tab and bond. */
5
- export declare function calcTabsetCountAndMinDim(engine: Layout, root?: Node, clear?: boolean): void;
6
- export declare function pruneStaleDirections(): void;
7
- export declare function calculateRootAdjustment(): RootAdjustment;
8
- export declare function calcDimensions(engine: Layout, root?: Node, supress?: boolean): void;
9
- export declare function updateDimension(engine: Layout, dim: Dimension, disableTimeout?: boolean, timeout?: number): void;
@@ -1,6 +0,0 @@
1
- export * from './dynamix';
2
- export * from './comparator';
3
- export * from './queue';
4
- export * from './reactive-state';
5
- export * from './drop-preview';
6
- export * from './dom';
@@ -1,40 +0,0 @@
1
- import { Queue } from './queue';
2
- import { Dimension, LayoutTree, NodeCache } from '../type';
3
- export declare class Node {
4
- static cache: NodeCache;
5
- kids: Queue<Node>;
6
- dims: Dimension;
7
- unId: string;
8
- next: Bond | null;
9
- prev: Bond | null;
10
- type: 'row' | 'tabset' | 'tab' | 'bond';
11
- name: string;
12
- part: number;
13
- host: Node | null;
14
- open: string;
15
- constructor(options?: {
16
- type?: 'row' | 'tabset' | 'tab' | 'bond';
17
- host?: Node | null;
18
- name?: string;
19
- part?: number;
20
- dims?: Dimension;
21
- unId?: string;
22
- open?: string;
23
- });
24
- addBond(parent: Node | null, prev?: Node | null): void;
25
- getReqDimension(): {
26
- width: number;
27
- height: number;
28
- };
29
- calcDimensions(): void;
30
- toJSON(): LayoutTree;
31
- }
32
- export declare class Bond {
33
- dims: Dimension;
34
- unId: string;
35
- next: Node | null;
36
- prev: Node | null;
37
- host: Node | null;
38
- constructor(parent?: Node | null, next?: Node | null, prev?: Node | null);
39
- toJSON(): LayoutTree;
40
- }
@@ -1,217 +0,0 @@
1
- declare class Queue<T> {
2
- private buffer;
3
- private head;
4
- private tail;
5
- private count;
6
- private capacity;
7
- constructor(initialCapacity?: number, array?: T[]);
8
- /**
9
- * Add element to the back of the queue - O(1) amortized
10
- * Used for FIFO and FILO patterns
11
- */
12
- enqueue(item: T): void;
13
- /**
14
- * Add element to the front of the queue - O(1) amortized
15
- * Used for LIFO and LILO patterns
16
- */
17
- enqueueFront(item: T): void;
18
- /**
19
- * Insert element at specific logical index - O(n)
20
- * All elements at and after the index are shifted right
21
- * @param index - Logical index (0 = front of queue)
22
- * @param item - Element to insert
23
- * @returns true if insertion successful, false if index out of bounds
24
- */
25
- insert(index: number, item: T): boolean;
26
- /**
27
- * Insert array of elements at specific logical index - O(n + m) where n is elements to shift, m is array length
28
- * All elements at and after the index are shifted right to make room for the entire array
29
- * @param index - Logical index (0 = front of queue)
30
- * @param items - Array of elements to insert
31
- * @returns true if insertion successful, false if index out of bounds
32
- */
33
- insertArray(index: number, items: T[]): boolean;
34
- /**
35
- * Insert another queue at specific logical index - O(n + m) where n is elements to shift, m is queue size
36
- * All elements at and after the index are shifted right to make room for the entire queue
37
- * @param index - Logical index (0 = front of queue)
38
- * @param queue - Queue to insert
39
- * @returns true if insertion successful, false if index out of bounds
40
- */
41
- insertQueue(index: number, queue: Queue<T>): boolean;
42
- /**
43
- * Alias for enqueue (add to back)
44
- */
45
- push(item: T): void;
46
- /**
47
- * Alias for enqueueFront (add to front)
48
- */
49
- unshift(item: T): void;
50
- /**
51
- * Remove and return element from front of queue - O(1)
52
- * Used for FIFO and LIFO patterns
53
- */
54
- dequeue(): T | undefined;
55
- /**
56
- * Remove and return element from back of queue - O(1)
57
- * Used for FILO and LILO patterns
58
- */
59
- dequeueBack(): T | undefined;
60
- indexOf(item: T): number;
61
- remove(item: T): boolean;
62
- /**
63
- * Remove element at specific logical index - O(n)
64
- * All elements after the index are shifted left
65
- * @param index - Logical index (0 = front of queue)
66
- * @returns The removed element, or undefined if index out of bounds
67
- */
68
- removeAt(index: number): T | undefined;
69
- /**
70
- * Alias for dequeue (remove from front)
71
- */
72
- shift(): T | undefined;
73
- /**
74
- * Alias for dequeueBack (remove from back)
75
- */
76
- pop(): T | undefined;
77
- /**
78
- * FIFO: First In, First Out
79
- * Add to back, remove from front
80
- */
81
- fifoAdd(item: T): void;
82
- fifoRemove(): T | undefined;
83
- /**
84
- * FILO: First In, Last Out
85
- * Add to back, remove from back
86
- */
87
- filoAdd(item: T): void;
88
- filoRemove(): T | undefined;
89
- /**
90
- * LIFO: Last In, First Out
91
- * Add to front, remove from front
92
- */
93
- lifoAdd(item: T): void;
94
- lifoRemove(): T | undefined;
95
- /**
96
- * LILO: Last In, Last Out
97
- * Add to front, remove from back
98
- */
99
- liloAdd(item: T): void;
100
- liloRemove(): T | undefined;
101
- /**
102
- * Get element at logical index (0 = front of queue) - O(1)
103
- */
104
- get(index: number): T | undefined;
105
- /**
106
- * Set element at logical index - O(1)
107
- */
108
- set(index: number, item: T): boolean;
109
- /**
110
- * Get the front element without removing it - O(1)
111
- */
112
- peek(): T | undefined;
113
- /**
114
- * Get the back element without removing it - O(1)
115
- */
116
- peekBack(): T | undefined;
117
- /**
118
- * Alias for peek (front element)
119
- */
120
- front(): T | undefined;
121
- /**
122
- * Alias for peekBack (back element)
123
- */
124
- back(): T | undefined;
125
- /**
126
- * Get current size of queue - O(1)
127
- */
128
- size(): number;
129
- /**
130
- * Get current capacity - O(1)
131
- */
132
- getCapacity(): number;
133
- /**
134
- * Check if queue is empty - O(1)
135
- */
136
- isEmpty(): boolean;
137
- /**
138
- * Check if queue is full - O(1)
139
- */
140
- isFull(): boolean;
141
- /**
142
- * Clear all elements from queue - O(1)
143
- */
144
- clear(): void;
145
- /**
146
- * Convert queue to array (maintains order from front to back) - O(n)
147
- */
148
- toArray(): T[];
149
- /**
150
- * Forward iterator support for for...of loops - O(n) total
151
- * Iterates from front to back
152
- */
153
- [Symbol.iterator](): IterableIterator<T>;
154
- /**
155
- * Forward iterator (same as Symbol.iterator) - O(n) total
156
- * Iterates from front to back
157
- */
158
- forward(): IterableIterator<T>;
159
- /**
160
- * Reverse iterator - O(n) total
161
- * Iterates from back to front
162
- */
163
- reverse(): IterableIterator<T>;
164
- /**
165
- * Iterator with index information - O(n) total
166
- * Returns [index, value] pairs from front to back
167
- */
168
- entries(): IterableIterator<[number, T]>;
169
- /**
170
- * Iterator for keys (indices) - O(n) total
171
- */
172
- keys(): IterableIterator<number>;
173
- /**
174
- * Iterator for values only - O(n) total
175
- * Same as Symbol.iterator but more explicit
176
- */
177
- values(): IterableIterator<T>;
178
- /**
179
- * Get string representation - O(n)
180
- */
181
- toString(): string;
182
- /**
183
- * Private method to resize buffer when capacity is exceeded
184
- */
185
- private resize;
186
- /**
187
- * Shift elements left (towards head) to make room for insertion
188
- * Used when inserting closer to head
189
- */
190
- private shiftLeft;
191
- /**
192
- * Shift elements right (towards tail) to make room for insertion
193
- * Used when inserting closer to tail
194
- */
195
- private shiftRight;
196
- /**
197
- * Shift elements right (towards tail) to fill gap after removal
198
- * Used when removing closer to head
199
- */
200
- private shiftRightForRemoval;
201
- /**
202
- * Shift elements left (towards head) to fill gap after removal
203
- * Used when removing closer to tail
204
- */
205
- private shiftLeftForRemoval;
206
- /**
207
- * Shift elements left (towards head) to make room for array insertion
208
- * Used when inserting array closer to head
209
- */
210
- private shiftLeftArray;
211
- /**
212
- * Shift elements right (towards tail) to make room for array insertion
213
- * Used when inserting array closer to tail
214
- */
215
- private shiftRightArray;
216
- }
217
- export { Queue };
@@ -1,3 +0,0 @@
1
- import { ReactiveValue } from '../type';
2
- declare function createReactiveState<T>(initialValue: T, comparator?: (a: T, b: T) => boolean): ReactiveValue<T>;
3
- export { createReactiveState };
@@ -1,10 +0,0 @@
1
- import { DynamixLayoutCore as Layout } from './dynamix';
2
- /** Moving a bond (slider) between two siblings. */
3
- export declare function updateSlider(engine: Layout, id: string, dim: {
4
- x: number;
5
- y: number;
6
- }, disableTimeout?: boolean, timeout?: number): void;
7
- export declare function updateSliderDimension(engine: Layout, id: string, dim: {
8
- x: number;
9
- y: number;
10
- }): void;
@@ -1,20 +0,0 @@
1
- import { Node } from './node';
2
- import { DynamixLayoutCore } from './dynamix';
3
- import { LayoutTree } from '../type';
4
- export type Timer = {
5
- set: (callback: () => void, ms: number) => ReturnType<typeof setTimeout>;
6
- clear: (handle: ReturnType<typeof setTimeout>) => void;
7
- };
8
- export declare const defaultCreateId: () => string;
9
- export declare const defaultTimer: Timer;
10
- /** Shared layout settings and the current root, used by every layout module. */
11
- export declare const layoutState: {
12
- createId: () => string;
13
- timer: Timer;
14
- root: Node;
15
- tree: LayoutTree | null;
16
- minW: number;
17
- minH: number;
18
- bond: number;
19
- inst: DynamixLayoutCore | null;
20
- };
@@ -1,13 +0,0 @@
1
- import { Queue } from './queue';
2
- import { Node } from './node';
3
- import { LayoutTree } from '../type';
4
- import { DynamixLayoutCore as Layout } from './dynamix';
5
- /** Building the node tree from a saved layout or a list of tabs, and walking it. */
6
- export declare function JSONLayoutIterator(root: LayoutTree): IterableIterator<LayoutTree>;
7
- export declare function NodeLayoutIterator(root: Node): IterableIterator<Node>;
8
- export declare function NodeLayoutRecursiveIterator(engine: Layout, root: Node): IterableIterator<Node>;
9
- export declare function updateChildDirections(engine: Layout, parent: Node): void;
10
- export declare function createNodeLayout(engine: Layout, root?: LayoutTree | null): void;
11
- export declare function createNodeTreeFromJSONTree(engine: Layout, json: LayoutTree, host: Node): void;
12
- export declare function createBinaryNodeTreeFromQueue(engine: Layout, queue: Queue<string>, host?: Node): void;
13
- export declare function createNodeFromJSON(engine: Layout, json: LayoutTree): Node;
@@ -1,17 +0,0 @@
1
- import { Node } from './node';
2
- import { DynamixLayoutCore as Layout } from './dynamix';
3
- /** Drag and drop: moving tabs/tabsets and keeping bonds and caches consistent. */
4
- export declare function updateTree(engine: Layout, src: string, des: string, layout: 'top' | 'bottom' | 'left' | 'right' | 'contain'): boolean;
5
- export declare function isOnlyContent(engine: Layout, node: Node): boolean;
6
- export declare function moveNodeAsTab(engine: Layout, src: Node, des: Node, layout: 'left' | 'right' | 'contain'): void;
7
- type Side = 'top' | 'bottom' | 'left' | 'right';
8
- export declare function moveRelativeToRoot(engine: Layout, src: Node, des: Node, layout: Side): void;
9
- export declare function moveRelativeToTabset(engine: Layout, src: Node, des: Node, layout: Side): void;
10
- export declare function insertNode(engine: Layout, des: Node, src: Node, flag: boolean): void;
11
- export declare function insertNodeWithNewParent(engine: Layout, src: Node, des: Node, flag: boolean): void;
12
- export declare function moveAdjacentNodeToGrandParent(engine: Layout, src: Node): void;
13
- export declare function removeRelation(src: Node, fix?: boolean): Node | undefined;
14
- export declare function removeNode(engine: Layout, src: Node): void;
15
- export declare function removeKid(kid: Node): void;
16
- export declare function clearAllCache(): void;
17
- export {};
@@ -1,54 +0,0 @@
1
- import { Node, Bond } from '../app/dynamix';
2
- export type Dimension = {
3
- w: number;
4
- h: number;
5
- x: number;
6
- y: number;
7
- };
8
- export interface NodeCache {
9
- dimMins: Map<string, {
10
- minWidth: number;
11
- minHeight: number;
12
- }>;
13
- mapDirs: Map<string, boolean>;
14
- tabCnts: Map<string, {
15
- horizontal: number;
16
- vertical: number;
17
- }>;
18
- mapElem: Map<string, Node | Bond>;
19
- nodOpts: ReactiveValue<Map<string, NodeOptions>>;
20
- bndOpts: ReactiveValue<Map<string, NodeOptions>>;
21
- tabOpts: ReactiveValue<Map<string, NodeOptions>>;
22
- }
23
- export type NodeType = 'row' | 'tabset' | 'tab';
24
- export type NodeTypeWithBond = NodeType | 'bond';
25
- export type TabsIds = Map<string, string>;
26
- export interface BaseNode {
27
- typNode: NodeTypeWithBond;
28
- nodName: string;
29
- uidNode: string;
30
- nodPart: number;
31
- nodeDir: boolean;
32
- nodDims: Dimension;
33
- nodOpen?: string | boolean;
34
- }
35
- export type LayoutTree = Omit<BaseNode, 'nodeDir' | 'nodDims'> & {
36
- nodKids?: LayoutTree[];
37
- };
38
- export interface NodeOptions extends BaseNode {
39
- nodKids?: BaseNode[];
40
- }
41
- export interface RootAdjustment {
42
- adjustedW: number;
43
- adjustedH: number;
44
- wasAdjusted: boolean;
45
- }
46
- export type ChangeListener<T> = (newValue: T) => void;
47
- export interface ReactiveValue<T> {
48
- get: () => T;
49
- set: (newValue: T, flag?: boolean) => void;
50
- onChange: (listener: ChangeListener<T>) => () => void;
51
- nextChange: () => Promise<T>;
52
- onChangePromise: (listener: ChangeListener<T>) => () => void;
53
- triggerChange: () => void;
54
- }