@ishibashi0112/spreadsheet-grid-core 0.47.0 → 0.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.d.ts +2 -1
- package/dist/controllers/columnHeaderDragController.js +147 -133
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/geometry.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/slotDom.cjs");function i(e,n,r,i){let a=e.find(e=>e.key===n);if(!a)return null;let o=t.getColumnPane(a),s={left:[],center:[],right:[]},c=new Map;for(let n of e)s[t.getColumnPane(n)].push(n.key),c.set(n.key,n.visible!==!1);let l=s[r].filter(e=>c.get(e)).indexOf(n),u=s[o].indexOf(n);if(u<0)return null;s[o].splice(u,1);let d=i;o===r&&l>=0&&d>l&&--d;let f=s[r].filter(e=>c.get(e));if(d=Math.max(0,Math.min(d,f.length)),o===r&&l>=0&&d===l)return null;let p;return p=d>=f.length?s[r].length:s[r].indexOf(f[d]),s[r].splice(p,0,n),[...s.left,...s.center,...s.right]}var a=32,o=2,s=14,c=12,l=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" y1="12" x2="22" y2="12"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,u=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/></svg>`,d=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,f=`0.5`,p=200,m=`cubic-bezier(0.2, 0.7, 0.3, 1)`,h=e=>e?.closest(`.ssg-motion-off`)!=null,g=`transform 160ms ${m}`,_=`data-ssg-col-dragging`,v=`4`,y=t=>{let n=[];return t.querySelectorAll(`[data-ssg-col-key]`).forEach(r=>{e.isInsideDetailCardOf(t,r)||n.push(r)}),n},b=t=>{if(!t)return null;let n=new Map;return t.querySelectorAll(`[data-ssg-col-key]`).forEach(r=>{if(e.isInsideDetailCardOf(t,r))return;let i=r.dataset.ssgColKey;i&&!n.has(i)&&n.set(i,r.getBoundingClientRect().left)}),n},x=()=>{let x=null,S=null,C=null,w=null,T={x:0,y:0},E=null,D=!1,O=null,k=null,A=null,j=null,M=null,N=null,P=0,F=null,I=null,L=``,R=()=>x?.motion===`live`,z=()=>({left:x?.leftIndicatorRef.current??null,center:x?.centerIndicatorRef.current??null,right:x?.rightIndicatorRef.current??null}),B=()=>{for(let e of Object.values(z()))e&&(e.style.display=`none`)},V=e=>{if(A)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),x?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),x?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),r.applySlotToElement(t,x?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let i=document.createElement(`span`);i.textContent=e,t.appendChild(n),t.appendChild(i),document.body.appendChild(t),A=t,j=n,M=null},H=e=>{let t=A;if(!t)return;t.style.transform=`translate(`+(T.x+s)+`px,`+(T.y+c)+`px)`;let n=e??`out`;if(M===n)return;M=n;let r=j;n===`out`?(t.style.opacity=f,r&&(r.innerHTML=d)):(t.style.opacity=`1`,r&&(r.innerHTML=n===`center`?l:u))},U=()=>{A&&A.parentNode&&A.parentNode.removeChild(A),A=null,j=null,M=null},W=(e,n)=>{if(x===null)return null;let{paneLayout:r,leftPaneScrollRef:i,rightPaneScrollRef:s,bodyScrollRef:c,scrollContainerRef:l,leftLeadingWidth:u,centerLeadingWidth:d,rightLeadingWidth:f}=x,p=l.current;if(p){let t=p.getBoundingClientRect();if(e<t.left||e>t.right||n<t.top||n>t.bottom)return null}let m=i.current,h=s.current;if(m&&r.left.entries.length===0&&e<=m.getBoundingClientRect().left+a)return{pane:`left`,slot:0,leftPx:o};if(m&&r.left.entries.length>0){let n=m.getBoundingClientRect();if(e<n.right){let i=e-n.left-u,a=t.findPaneDropSlot(r.left,i);return{pane:`left`,slot:a,leftPx:u+t.paneDropSlotBoundaryX(r.left,a)}}}if(h&&r.right.entries.length===0&&e>=h.getBoundingClientRect().left-a)return{pane:`right`,slot:0,leftPx:-2};if(h&&r.right.entries.length>0){let n=h.getBoundingClientRect();if(e>=n.left){let i=e-n.left-f,a=t.findPaneDropSlot(r.right,i);return{pane:`right`,slot:a,leftPx:f+t.paneDropSlotBoundaryX(r.right,a)}}}let g=c.current;if(g&&r.center.entries.length>0){let n=g.getBoundingClientRect(),i=g.scrollLeft+e-n.left-d,a=t.findPaneDropSlot(r.center,Math.max(i,0));return{pane:`center`,slot:a,leftPx:d+t.paneDropSlotBoundaryX(r.center,a)}}return null},G=e=>{let t=z();for(let n of[`left`,`center`,`right`]){let r=t[n];r&&(n===e.pane?(r.style.left=`${e.leftPx}px`,r.style.display=`block`):r.style.display=`none`)}},K=(e,t)=>{let n=I?.get(t);n!==void 0&&I?.delete(t),e.set(t,n??t.style.zIndex)},q=(e,t)=>{let n=F,r=S,i=N;if(!n||r===null||i===null||x===null)return;let a=x.scrollContainerRef.current;if(!a)return;let o=x.paneLayout[i].entries,s=o.findIndex(e=>e.column.key===r);if(s<0)return;let c=o[s].paneLocalSize,l=!t||e===null?s:e>s?e-1:e,u=new Map;for(let e=Math.min(s,l);e<=Math.max(s,l);e+=1)e!==s&&u.set(o[e].column.key,e>s?-c:c);let d=i===`center`?a.scrollLeft-P:0,f=(E?T.x-E.x:0)+d;for(let e of y(a)){let i=e.dataset.ssgColKey;if(i===void 0)continue;if(i===r){n.has(e)||(K(n,e),e.style.zIndex=v,e.style.willChange=`transform`),t?(e.setAttribute(_,`live`),e.style.transition=`none`,e.style.transform=`translateX(${f}px)`):(e.removeAttribute(_),e.style.transition=g,e.style.transform=`translateX(0px)`);continue}let a=u.get(i)??0;if(a===0&&!n.has(e))continue;n.has(e)||K(n,e);let o=`translateX(${a}px)`;e.style.transform!==o&&(e.style.transition=g,e.style.transform=o)}},J=e=>{e.forEach((e,t)=>{t.style.transition=``,t.style.transform=``,t.style.willChange=``,t.style.zIndex=e,t.removeAttribute(_)})},Y=()=>{let e=W(T.x,T.y);if(R()){e&&(C={pane:e.pane,slot:e.slot});let t=C;if(t!==null&&t.pane!==N){V(L),H(t.pane),e&&G(e),q(null,!1);return}U(),B(),q(t===null?null:t.slot,!0);return}if(H(e?e.pane:null),!e){C=null,B();return}C={pane:e.pane,slot:e.slot},G(e)},X=()=>{if(S===null){k=null;return}let e=x?.scrollContainerRef.current??null;if(e&&(D||(!E||n.hasPointerLeftActivationRadius(E,T,6))&&(D=!0),D)){let t=e.getBoundingClientRect(),r=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight}),i=n.resolveAutoScrollAxisDirection(T.x,r.left,r.right,24),a=n.computeNextScrollPosition(e.scrollLeft,i,18,e.scrollWidth-e.clientWidth);a!==e.scrollLeft&&e.scrollTo({left:a,behavior:`auto`})}Y(),k=requestAnimationFrame(X)},Z=e=>{k!==null&&(cancelAnimationFrame(k),k=null),document.body.style.cursor=``,B(),U();let n=S,r=C;S=null,C=null,E=null;let a=F;F=null,N=null;let o=e&&n&&r&&x!==null?i(x.columns,n,r.pane,r.slot):null;if(a&&!o&&(a.forEach((e,t)=>{t.isConnected&&(t.style.transition=g,t.style.transform=`translateX(0px)`)}),I=a,window.setTimeout(()=>{J(a),I===a&&(I=null)},200)),!o||!n||!r||x===null)return;let{columns:s,applyColumnOrderAndPin:c,scrollContainerRef:l}=x,u=s.find(e=>e.key===n),d=u?t.getColumnPane(u):null;w=d!==null&&d===r.pane&&!h(l.current)?b(l.current):null,a&&J(a),c(o,new Map([[n,r.pane===`center`?void 0:r.pane]]))};return{update:e=>{x=e},onColumnDragHandlePointerDown:(e,n)=>{if(x===null||!x.enabled||n.button!==0)return;n.stopPropagation(),n.preventDefault(),S=e.key,C=null,T={x:n.clientX,y:n.clientY},E={x:n.clientX,y:n.clientY},D=!1,document.body.style.cursor=`grabbing`,L=e.title||e.key,R()?(N=t.getColumnPane(e),P=x.scrollContainerRef.current?.scrollLeft??0,F=new Map):V(L);let r=n.currentTarget,i=n.pointerId;try{r.setPointerCapture(i)}catch{}let a=e=>{e.pointerId===i&&(T={x:e.clientX,y:e.clientY},Y())},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),window.removeEventListener(`keydown`,l),O=null;try{r.releasePointerCapture(i)}catch{}};function s(e){e.pointerId===i&&(o(),Z(!0))}function c(e){e.pointerId===i&&(o(),Z(!1))}function l(e){e.key===`Escape`&&(o(),Z(!1))}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),window.addEventListener(`keydown`,l),O=o,Y(),k=requestAnimationFrame(X)},applyReorderSettle:()=>{let t=w;if(w=null,!t)return;let n=x?.scrollContainerRef.current??null;if(!n)return;let r=new Map,i=new Map;n.querySelectorAll(`[data-ssg-col-key]`).forEach(a=>{if(e.isInsideDetailCardOf(n,a))return;let o=a.dataset.ssgColKey;if(!o||!t.has(o))return;let s=r.get(o);s?s.push(a):(r.set(o,[a]),i.set(o,a.getBoundingClientRect().left))});let a=[];if(r.forEach((e,n)=>{let r=t.get(n),o=i.get(n);if(r===void 0||o===void 0)return;let s=r-o;if(!(Math.abs(s)<.5))for(let t of e)t.style.transition=`none`,t.style.transform=`translateX(${s}px)`,t.style.willChange=`transform`,a.push(t)}),a.length!==0){n.getBoundingClientRect();for(let e of a)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateX(0)`;window.setTimeout(()=>{for(let e of a)e.style.transition=``,e.style.transform=``,e.style.willChange=``},280)}},dispose:()=>{O?.(),O=null,k!==null&&(cancelAnimationFrame(k),k=null),S=null,C=null,document.body.style.cursor=``,U(),F&&J(F),F=null,N=null}}};exports.computeHeaderReorderedKeys=i,exports.createColumnHeaderDragController=x;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/geometry.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/slotDom.cjs");function i(e,n,r,i){let a=e.find(e=>e.key===n);if(!a)return null;let o=t.getColumnPane(a),s={left:[],center:[],right:[]},c=new Map;for(let n of e)s[t.getColumnPane(n)].push(n.key),c.set(n.key,n.visible!==!1);let l=s[r].filter(e=>c.get(e)).indexOf(n),u=s[o].indexOf(n);if(u<0)return null;s[o].splice(u,1);let d=i;o===r&&l>=0&&d>l&&--d;let f=s[r].filter(e=>c.get(e));if(d=Math.max(0,Math.min(d,f.length)),o===r&&l>=0&&d===l)return null;let p;return p=d>=f.length?s[r].length:s[r].indexOf(f[d]),s[r].splice(p,0,n),[...s.left,...s.center,...s.right]}function a(n,r,i,a){let o=n.filter(e=>t.getColumnPane(e)===i&&e.visible!==!1).map(e=>e.key),{entries:s}=r;for(let t=Math.max(a,0);t<s.length;t+=1){let n=s[t].column.key;if(e.isSyntheticColumnKey(n))continue;let r=o.indexOf(n);return r<0?o.length:r}return o.length}var o=t=>{let n=0;for(;n<t.entries.length&&e.isSyntheticColumnKey(t.entries[n].column.key);)n+=1;return n},s=32,c=2,l=14,u=12,d=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" y1="12" x2="22" y2="12"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,f=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/></svg>`,p=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,m=`0.5`,h=200,g=`cubic-bezier(0.2, 0.7, 0.3, 1)`,_=e=>e?.closest(`.ssg-motion-off`)!=null,v=`transform 160ms ${g}`,y=`data-ssg-col-dragging`,b=`4`,x=t=>{let n=[];return t.querySelectorAll(`[data-ssg-col-key]`).forEach(r=>{e.isInsideDetailCardOf(t,r)||n.push(r)}),n},S=t=>{if(!t)return null;let n=new Map;return t.querySelectorAll(`[data-ssg-col-key]`).forEach(r=>{if(e.isInsideDetailCardOf(t,r))return;let i=r.dataset.ssgColKey;i&&!n.has(i)&&n.set(i,r.getBoundingClientRect().left)}),n},C=()=>{let C=null,w=null,T=null,E=null,D={x:0,y:0},O=null,k=!1,A=null,j=null,M=null,N=null,P=null,F=null,I=0,L=null,R=null,z=``,B=()=>C?.motion===`live`,V=()=>({left:C?.leftIndicatorRef.current??null,center:C?.centerIndicatorRef.current??null,right:C?.rightIndicatorRef.current??null}),H=()=>{for(let e of Object.values(V()))e&&(e.style.display=`none`)},U=e=>{if(M)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),C?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),C?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),r.applySlotToElement(t,C?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let i=document.createElement(`span`);i.textContent=e,t.appendChild(n),t.appendChild(i),document.body.appendChild(t),M=t,N=n,P=null},W=e=>{let t=M;if(!t)return;t.style.transform=`translate(`+(D.x+l)+`px,`+(D.y+u)+`px)`;let n=e??`out`;if(P===n)return;P=n;let r=N;n===`out`?(t.style.opacity=m,r&&(r.innerHTML=p)):(t.style.opacity=`1`,r&&(r.innerHTML=n===`center`?d:f))},G=()=>{M&&M.parentNode&&M.parentNode.removeChild(M),M=null,N=null,P=null},K=(e,n)=>{if(C===null)return null;let{paneLayout:r,leftPaneScrollRef:i,rightPaneScrollRef:a,bodyScrollRef:l,scrollContainerRef:u,leftLeadingWidth:d,centerLeadingWidth:f,rightLeadingWidth:p}=C,m=u.current;if(m){let t=m.getBoundingClientRect();if(e<t.left||e>t.right||n<t.top||n>t.bottom)return null}let h=i.current,g=a.current;if(h&&r.left.entries.length===0&&e<=h.getBoundingClientRect().left+s)return{pane:`left`,slot:0,leftPx:c};if(h&&r.left.entries.length>0){let n=h.getBoundingClientRect();if(e<n.right){let i=e-n.left-d,a=Math.max(t.findPaneDropSlot(r.left,i),o(r.left));return{pane:`left`,slot:a,leftPx:d+t.paneDropSlotBoundaryX(r.left,a)}}}if(g&&r.right.entries.length===0&&e>=g.getBoundingClientRect().left-s)return{pane:`right`,slot:0,leftPx:-2};if(g&&r.right.entries.length>0){let n=g.getBoundingClientRect();if(e>=n.left){let i=e-n.left-p,a=Math.max(t.findPaneDropSlot(r.right,i),o(r.right));return{pane:`right`,slot:a,leftPx:p+t.paneDropSlotBoundaryX(r.right,a)}}}let _=l.current;if(_&&r.center.entries.length>0){let n=_.getBoundingClientRect(),i=_.scrollLeft+e-n.left-f,a=Math.max(t.findPaneDropSlot(r.center,Math.max(i,0)),o(r.center));return{pane:`center`,slot:a,leftPx:f+t.paneDropSlotBoundaryX(r.center,a)}}return null},q=e=>{let t=V();for(let n of[`left`,`center`,`right`]){let r=t[n];r&&(n===e.pane?(r.style.left=`${e.leftPx}px`,r.style.display=`block`):r.style.display=`none`)}},J=(e,t)=>{let n=R?.get(t);n!==void 0&&R?.delete(t),e.set(t,n??t.style.zIndex)},Y=(e,t)=>{let n=L,r=w,i=F;if(!n||r===null||i===null||C===null)return;let a=C.scrollContainerRef.current;if(!a)return;let o=C.paneLayout[i].entries,s=o.findIndex(e=>e.column.key===r);if(s<0)return;let c=o[s].paneLocalSize,l=!t||e===null?s:e>s?e-1:e,u=new Map;for(let e=Math.min(s,l);e<=Math.max(s,l);e+=1)e!==s&&u.set(o[e].column.key,e>s?-c:c);let d=i===`center`?a.scrollLeft-I:0,f=(O?D.x-O.x:0)+d;for(let e of x(a)){let i=e.dataset.ssgColKey;if(i===void 0)continue;if(i===r){n.has(e)||(J(n,e),e.style.zIndex=b,e.style.willChange=`transform`),t?(e.setAttribute(y,`live`),e.style.transition=`none`,e.style.transform=`translateX(${f}px)`):(e.removeAttribute(y),e.style.transition=v,e.style.transform=`translateX(0px)`);continue}let a=u.get(i)??0;if(a===0&&!n.has(e))continue;n.has(e)||J(n,e);let o=`translateX(${a}px)`;e.style.transform!==o&&(e.style.transition=v,e.style.transform=o)}},X=e=>{e.forEach((e,t)=>{t.style.transition=``,t.style.transform=``,t.style.willChange=``,t.style.zIndex=e,t.removeAttribute(y)})},Z=()=>{let e=K(D.x,D.y);if(B()){e&&(T={pane:e.pane,slot:e.slot});let t=T;if(t!==null&&t.pane!==F){U(z),W(t.pane),e&&q(e),Y(null,!1);return}G(),H(),Y(t===null?null:t.slot,!0);return}if(W(e?e.pane:null),!e){T=null,H();return}T={pane:e.pane,slot:e.slot},q(e)},Q=()=>{if(w===null){j=null;return}let e=C?.scrollContainerRef.current??null;if(e&&(k||(!O||n.hasPointerLeftActivationRadius(O,D,6))&&(k=!0),k)){let t=e.getBoundingClientRect(),r=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight}),i=n.resolveAutoScrollAxisDirection(D.x,r.left,r.right,24),a=n.computeNextScrollPosition(e.scrollLeft,i,18,e.scrollWidth-e.clientWidth);a!==e.scrollLeft&&e.scrollTo({left:a,behavior:`auto`})}Z(),j=requestAnimationFrame(Q)},$=e=>{j!==null&&(cancelAnimationFrame(j),j=null),document.body.style.cursor=``,H(),G();let n=w,r=T;w=null,T=null,O=null;let o=L;L=null,F=null;let s=n!==null&&r!==null&&C!==null?C.paneLayout[r.pane].entries.findIndex(e=>e.column.key===n):-1,c=r!==null&&s>=0&&(r.slot===s||r.slot===s+1),l=e&&n&&r&&C!==null&&!c?i(C.columns,n,r.pane,a(C.columns,C.paneLayout[r.pane],r.pane,r.slot)):null;if(o&&!l&&(o.forEach((e,t)=>{t.isConnected&&(t.style.transition=v,t.style.transform=`translateX(0px)`)}),R=o,window.setTimeout(()=>{X(o),R===o&&(R=null)},200)),!l||!n||!r||C===null)return;let{columns:u,applyColumnOrderAndPin:d,scrollContainerRef:f}=C,p=u.find(e=>e.key===n),m=p?t.getColumnPane(p):null;E=m!==null&&m===r.pane&&!_(f.current)?S(f.current):null,o&&X(o),d(l,new Map([[n,r.pane===`center`?void 0:r.pane]]))};return{update:e=>{C=e},onColumnDragHandlePointerDown:(e,n)=>{if(C===null||!C.enabled||n.button!==0)return;n.stopPropagation(),n.preventDefault(),w=e.key,T=null,D={x:n.clientX,y:n.clientY},O={x:n.clientX,y:n.clientY},k=!1,document.body.style.cursor=`grabbing`,z=e.title||e.key,B()?(F=t.getColumnPane(e),I=C.scrollContainerRef.current?.scrollLeft??0,L=new Map):U(z);let r=n.currentTarget,i=n.pointerId;try{r.setPointerCapture(i)}catch{}let a=e=>{e.pointerId===i&&(D={x:e.clientX,y:e.clientY},Z())},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),window.removeEventListener(`keydown`,l),A=null;try{r.releasePointerCapture(i)}catch{}};function s(e){e.pointerId===i&&(o(),$(!0))}function c(e){e.pointerId===i&&(o(),$(!1))}function l(e){e.key===`Escape`&&(o(),$(!1))}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),window.addEventListener(`keydown`,l),A=o,Z(),j=requestAnimationFrame(Q)},applyReorderSettle:()=>{let t=E;if(E=null,!t)return;let n=C?.scrollContainerRef.current??null;if(!n)return;let r=new Map,i=new Map;n.querySelectorAll(`[data-ssg-col-key]`).forEach(a=>{if(e.isInsideDetailCardOf(n,a))return;let o=a.dataset.ssgColKey;if(!o||!t.has(o))return;let s=r.get(o);s?s.push(a):(r.set(o,[a]),i.set(o,a.getBoundingClientRect().left))});let a=[];if(r.forEach((e,n)=>{let r=t.get(n),o=i.get(n);if(r===void 0||o===void 0)return;let s=r-o;if(!(Math.abs(s)<.5))for(let t of e)t.style.transition=`none`,t.style.transform=`translateX(${s}px)`,t.style.willChange=`transform`,a.push(t)}),a.length!==0){n.getBoundingClientRect();for(let e of a)e.style.transition=`transform ${h}ms ${g}`,e.style.transform=`translateX(0)`;window.setTimeout(()=>{for(let e of a)e.style.transition=``,e.style.transform=``,e.style.willChange=``},280)}},dispose:()=>{A?.(),A=null,j!==null&&(cancelAnimationFrame(j),j=null),w=null,T=null,document.body.style.cursor=``,G(),L&&X(L),L=null,F=null}}};exports.computeHeaderReorderedKeys=i,exports.createColumnHeaderDragController=C,exports.resolveConsumerDropSlot=a;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { GridColumn, GridColumnPinned, GridResolvedSlot } from '../model/gridTypes.unbound.js';
|
|
2
|
-
import { type ColumnPane, type GridPaneLayout } from '../logic/geometry.js';
|
|
2
|
+
import { type ColumnPane, type GridPaneLayout, type PaneGeometry } from '../logic/geometry.js';
|
|
3
3
|
type ApplyColumnOrderAndPin = (orderedKeys: string[], pinOverride?: Map<string, GridColumnPinned | undefined>) => void;
|
|
4
4
|
export declare function computeHeaderReorderedKeys<T>(columns: GridColumn<T>[], draggedKey: string, targetPane: ColumnPane, slotInTargetVisible: number): string[] | null;
|
|
5
|
+
export declare function resolveConsumerDropSlot<T>(columns: GridColumn<T>[], paneGeometry: PaneGeometry<T>, pane: ColumnPane, slot: number): number;
|
|
5
6
|
type ReadonlyRef<V> = {
|
|
6
7
|
readonly current: V;
|
|
7
8
|
};
|
|
@@ -1,37 +1,51 @@
|
|
|
1
|
-
import { isInsideDetailCardOf as e } from "../logic/detailRow.js";
|
|
2
|
-
import { findPaneDropSlot as
|
|
3
|
-
import { computeNextScrollPosition as
|
|
4
|
-
import { applySlotToElement as
|
|
1
|
+
import { isInsideDetailCardOf as e, isSyntheticColumnKey as t } from "../logic/detailRow.js";
|
|
2
|
+
import { findPaneDropSlot as n, getColumnPane as r, paneDropSlotBoundaryX as i } from "../logic/geometry.js";
|
|
3
|
+
import { computeNextScrollPosition as a, hasPointerLeftActivationRadius as o, resolveAutoScrollAxisDirection as s, resolveScrollContentBox as c } from "../logic/autoScrollGeometry.js";
|
|
4
|
+
import { applySlotToElement as l } from "../logic/slotDom.js";
|
|
5
5
|
//#region src/controllers/columnHeaderDragController.ts
|
|
6
|
-
function
|
|
6
|
+
function u(e, t, n, i) {
|
|
7
7
|
let a = e.find((e) => e.key === t);
|
|
8
8
|
if (!a) return null;
|
|
9
|
-
let o =
|
|
9
|
+
let o = r(a), s = {
|
|
10
10
|
left: [],
|
|
11
11
|
center: [],
|
|
12
12
|
right: []
|
|
13
13
|
}, c = /* @__PURE__ */ new Map();
|
|
14
|
-
for (let t of e) s[
|
|
15
|
-
let l = s[
|
|
14
|
+
for (let t of e) s[r(t)].push(t.key), c.set(t.key, t.visible !== !1);
|
|
15
|
+
let l = s[n].filter((e) => c.get(e)).indexOf(t), u = s[o].indexOf(t);
|
|
16
16
|
if (u < 0) return null;
|
|
17
17
|
s[o].splice(u, 1);
|
|
18
18
|
let d = i;
|
|
19
|
-
o ===
|
|
20
|
-
let f = s[
|
|
21
|
-
if (d = Math.max(0, Math.min(d, f.length)), o ===
|
|
19
|
+
o === n && l >= 0 && d > l && --d;
|
|
20
|
+
let f = s[n].filter((e) => c.get(e));
|
|
21
|
+
if (d = Math.max(0, Math.min(d, f.length)), o === n && l >= 0 && d === l) return null;
|
|
22
22
|
let p;
|
|
23
|
-
return p = d >= f.length ? s[
|
|
23
|
+
return p = d >= f.length ? s[n].length : s[n].indexOf(f[d]), s[n].splice(p, 0, t), [
|
|
24
24
|
...s.left,
|
|
25
25
|
...s.center,
|
|
26
26
|
...s.right
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
function d(e, n, i, a) {
|
|
30
|
+
let o = e.filter((e) => r(e) === i && e.visible !== !1).map((e) => e.key), { entries: s } = n;
|
|
31
|
+
for (let e = Math.max(a, 0); e < s.length; e += 1) {
|
|
32
|
+
let n = s[e].column.key;
|
|
33
|
+
if (t(n)) continue;
|
|
34
|
+
let r = o.indexOf(n);
|
|
35
|
+
return r < 0 ? o.length : r;
|
|
36
|
+
}
|
|
37
|
+
return o.length;
|
|
38
|
+
}
|
|
39
|
+
var f = (e) => {
|
|
40
|
+
let n = 0;
|
|
41
|
+
for (; n < e.entries.length && t(e.entries[n].column.key);) n += 1;
|
|
42
|
+
return n;
|
|
43
|
+
}, p = 32, m = 2, h = 14, g = 12, _ = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"5 9 2 12 5 15\"/><polyline points=\"9 5 12 2 15 5\"/><polyline points=\"15 19 12 22 9 19\"/><polyline points=\"19 9 22 12 19 15\"/><line x1=\"2\" y1=\"12\" x2=\"22\" y2=\"12\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"22\"/></svg>", v = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"12\" y1=\"17\" x2=\"12\" y2=\"22\"/><path d=\"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z\"/></svg>", y = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"4.9\" y1=\"4.9\" x2=\"19.1\" y2=\"19.1\"/></svg>", ee = "0.5", te = 200, b = "cubic-bezier(0.2, 0.7, 0.3, 1)", x = (e) => e?.closest(".ssg-motion-off") != null, S = `transform 160ms ${b}`, C = "data-ssg-col-dragging", ne = "4", re = (t) => {
|
|
30
44
|
let n = [];
|
|
31
45
|
return t.querySelectorAll("[data-ssg-col-key]").forEach((r) => {
|
|
32
46
|
e(t, r) || n.push(r);
|
|
33
47
|
}), n;
|
|
34
|
-
},
|
|
48
|
+
}, w = (t) => {
|
|
35
49
|
if (!t) return null;
|
|
36
50
|
let n = /* @__PURE__ */ new Map();
|
|
37
51
|
return t.querySelectorAll("[data-ssg-col-key]").forEach((r) => {
|
|
@@ -39,20 +53,20 @@ var u = 32, d = 2, f = 14, p = 12, m = "<svg viewBox=\"0 0 24 24\" width=\"14\"
|
|
|
39
53
|
let i = r.dataset.ssgColKey;
|
|
40
54
|
i && !n.has(i) && n.set(i, r.getBoundingClientRect().left);
|
|
41
55
|
}), n;
|
|
42
|
-
},
|
|
43
|
-
let
|
|
56
|
+
}, T = () => {
|
|
57
|
+
let t = null, T = null, E = null, D = null, O = {
|
|
44
58
|
x: 0,
|
|
45
59
|
y: 0
|
|
46
|
-
}, k = null, A = !1, j = null, M = null, N = null, P = null, F = null, I = null, L = 0, R = null, z = null, B = "", V = () =>
|
|
47
|
-
left:
|
|
48
|
-
center:
|
|
49
|
-
right:
|
|
60
|
+
}, k = null, A = !1, j = null, M = null, N = null, P = null, F = null, I = null, L = 0, R = null, z = null, B = "", V = () => t?.motion === "live", H = () => ({
|
|
61
|
+
left: t?.leftIndicatorRef.current ?? null,
|
|
62
|
+
center: t?.centerIndicatorRef.current ?? null,
|
|
63
|
+
right: t?.rightIndicatorRef.current ?? null
|
|
50
64
|
}), U = () => {
|
|
51
65
|
for (let e of Object.values(H())) e && (e.style.display = "none");
|
|
52
66
|
}, W = (e) => {
|
|
53
67
|
if (N) return;
|
|
54
|
-
let
|
|
55
|
-
|
|
68
|
+
let n = document.createElement("div");
|
|
69
|
+
n.setAttribute("data-grid-drag-ghost", ""), t?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && n.classList.add("ssg-theme-dark"), t?.scrollContainerRef.current?.closest(".ssg-motion-off") != null && n.classList.add("ssg-motion-off"), n.style.cssText = [
|
|
56
70
|
"position:fixed",
|
|
57
71
|
"top:0",
|
|
58
72
|
"left:0",
|
|
@@ -74,69 +88,69 @@ var u = 32, d = 2, f = 14, p = 12, m = "<svg viewBox=\"0 0 24 24\" width=\"14\"
|
|
|
74
88
|
"z-index:9999",
|
|
75
89
|
"will-change:transform",
|
|
76
90
|
"transform:translate(-9999px,-9999px)"
|
|
77
|
-
].join(";"),
|
|
78
|
-
let n = document.createElement("span");
|
|
79
|
-
n.style.cssText = "display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none";
|
|
91
|
+
].join(";"), l(n, t?.ghostSlot);
|
|
80
92
|
let r = document.createElement("span");
|
|
81
|
-
r.
|
|
93
|
+
r.style.cssText = "display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none";
|
|
94
|
+
let i = document.createElement("span");
|
|
95
|
+
i.textContent = e, n.appendChild(r), n.appendChild(i), document.body.appendChild(n), N = n, P = r, F = null;
|
|
82
96
|
}, G = (e) => {
|
|
83
97
|
let t = N;
|
|
84
98
|
if (!t) return;
|
|
85
|
-
t.style.transform = "translate(" + (O.x +
|
|
99
|
+
t.style.transform = "translate(" + (O.x + h) + "px," + (O.y + g) + "px)";
|
|
86
100
|
let n = e ?? "out";
|
|
87
101
|
if (F === n) return;
|
|
88
102
|
F = n;
|
|
89
103
|
let r = P;
|
|
90
|
-
n === "out" ? (t.style.opacity =
|
|
104
|
+
n === "out" ? (t.style.opacity = ee, r && (r.innerHTML = y)) : (t.style.opacity = "1", r && (r.innerHTML = n === "center" ? _ : v));
|
|
91
105
|
}, K = () => {
|
|
92
106
|
N && N.parentNode && N.parentNode.removeChild(N), N = null, P = null, F = null;
|
|
93
|
-
},
|
|
94
|
-
if (
|
|
95
|
-
let { paneLayout:
|
|
96
|
-
if (
|
|
97
|
-
let t =
|
|
98
|
-
if (e < t.left || e > t.right ||
|
|
107
|
+
}, ie = (e, r) => {
|
|
108
|
+
if (t === null) return null;
|
|
109
|
+
let { paneLayout: a, leftPaneScrollRef: o, rightPaneScrollRef: s, bodyScrollRef: c, scrollContainerRef: l, leftLeadingWidth: u, centerLeadingWidth: d, rightLeadingWidth: h } = t, g = l.current;
|
|
110
|
+
if (g) {
|
|
111
|
+
let t = g.getBoundingClientRect();
|
|
112
|
+
if (e < t.left || e > t.right || r < t.top || r > t.bottom) return null;
|
|
99
113
|
}
|
|
100
|
-
let
|
|
101
|
-
if (
|
|
114
|
+
let _ = o.current, v = s.current;
|
|
115
|
+
if (_ && a.left.entries.length === 0 && e <= _.getBoundingClientRect().left + p) return {
|
|
102
116
|
pane: "left",
|
|
103
117
|
slot: 0,
|
|
104
|
-
leftPx:
|
|
118
|
+
leftPx: m
|
|
105
119
|
};
|
|
106
|
-
if (
|
|
107
|
-
let
|
|
108
|
-
if (e <
|
|
109
|
-
let
|
|
120
|
+
if (_ && a.left.entries.length > 0) {
|
|
121
|
+
let t = _.getBoundingClientRect();
|
|
122
|
+
if (e < t.right) {
|
|
123
|
+
let r = e - t.left - u, o = Math.max(n(a.left, r), f(a.left));
|
|
110
124
|
return {
|
|
111
125
|
pane: "left",
|
|
112
126
|
slot: o,
|
|
113
|
-
leftPx:
|
|
127
|
+
leftPx: u + i(a.left, o)
|
|
114
128
|
};
|
|
115
129
|
}
|
|
116
130
|
}
|
|
117
|
-
if (
|
|
131
|
+
if (v && a.right.entries.length === 0 && e >= v.getBoundingClientRect().left - p) return {
|
|
118
132
|
pane: "right",
|
|
119
133
|
slot: 0,
|
|
120
134
|
leftPx: -2
|
|
121
135
|
};
|
|
122
|
-
if (
|
|
123
|
-
let
|
|
124
|
-
if (e >=
|
|
125
|
-
let
|
|
136
|
+
if (v && a.right.entries.length > 0) {
|
|
137
|
+
let t = v.getBoundingClientRect();
|
|
138
|
+
if (e >= t.left) {
|
|
139
|
+
let r = e - t.left - h, o = Math.max(n(a.right, r), f(a.right));
|
|
126
140
|
return {
|
|
127
141
|
pane: "right",
|
|
128
142
|
slot: o,
|
|
129
|
-
leftPx:
|
|
143
|
+
leftPx: h + i(a.right, o)
|
|
130
144
|
};
|
|
131
145
|
}
|
|
132
146
|
}
|
|
133
|
-
let
|
|
134
|
-
if (
|
|
135
|
-
let
|
|
147
|
+
let y = c.current;
|
|
148
|
+
if (y && a.center.entries.length > 0) {
|
|
149
|
+
let t = y.getBoundingClientRect(), r = y.scrollLeft + e - t.left - d, o = Math.max(n(a.center, Math.max(r, 0)), f(a.center));
|
|
136
150
|
return {
|
|
137
151
|
pane: "center",
|
|
138
152
|
slot: o,
|
|
139
|
-
leftPx:
|
|
153
|
+
leftPx: d + i(a.center, o)
|
|
140
154
|
};
|
|
141
155
|
}
|
|
142
156
|
return null;
|
|
@@ -153,35 +167,35 @@ var u = 32, d = 2, f = 14, p = 12, m = "<svg viewBox=\"0 0 24 24\" width=\"14\"
|
|
|
153
167
|
}, J = (e, t) => {
|
|
154
168
|
let n = z?.get(t);
|
|
155
169
|
n !== void 0 && z?.delete(t), e.set(t, n ?? t.style.zIndex);
|
|
156
|
-
}, Y = (e,
|
|
157
|
-
let
|
|
158
|
-
if (!
|
|
159
|
-
let
|
|
160
|
-
if (!
|
|
161
|
-
let
|
|
162
|
-
if (
|
|
163
|
-
let
|
|
164
|
-
for (let e = Math.min(
|
|
165
|
-
let
|
|
166
|
-
for (let e of
|
|
167
|
-
let
|
|
168
|
-
if (
|
|
169
|
-
if (
|
|
170
|
-
|
|
170
|
+
}, Y = (e, n) => {
|
|
171
|
+
let r = R, i = T, a = I;
|
|
172
|
+
if (!r || i === null || a === null || t === null) return;
|
|
173
|
+
let o = t.scrollContainerRef.current;
|
|
174
|
+
if (!o) return;
|
|
175
|
+
let s = t.paneLayout[a].entries, c = s.findIndex((e) => e.column.key === i);
|
|
176
|
+
if (c < 0) return;
|
|
177
|
+
let l = s[c].paneLocalSize, u = !n || e === null ? c : e > c ? e - 1 : e, d = /* @__PURE__ */ new Map();
|
|
178
|
+
for (let e = Math.min(c, u); e <= Math.max(c, u); e += 1) e !== c && d.set(s[e].column.key, e > c ? -l : l);
|
|
179
|
+
let f = a === "center" ? o.scrollLeft - L : 0, p = (k ? O.x - k.x : 0) + f;
|
|
180
|
+
for (let e of re(o)) {
|
|
181
|
+
let t = e.dataset.ssgColKey;
|
|
182
|
+
if (t === void 0) continue;
|
|
183
|
+
if (t === i) {
|
|
184
|
+
r.has(e) || (J(r, e), e.style.zIndex = ne, e.style.willChange = "transform"), n ? (e.setAttribute(C, "live"), e.style.transition = "none", e.style.transform = `translateX(${p}px)`) : (e.removeAttribute(C), e.style.transition = S, e.style.transform = "translateX(0px)");
|
|
171
185
|
continue;
|
|
172
186
|
}
|
|
173
|
-
let a =
|
|
174
|
-
if (a === 0 && !
|
|
175
|
-
|
|
187
|
+
let a = d.get(t) ?? 0;
|
|
188
|
+
if (a === 0 && !r.has(e)) continue;
|
|
189
|
+
r.has(e) || J(r, e);
|
|
176
190
|
let o = `translateX(${a}px)`;
|
|
177
|
-
e.style.transform !== o && (e.style.transition =
|
|
191
|
+
e.style.transform !== o && (e.style.transition = S, e.style.transform = o);
|
|
178
192
|
}
|
|
179
193
|
}, X = (e) => {
|
|
180
194
|
e.forEach((e, t) => {
|
|
181
|
-
t.style.transition = "", t.style.transform = "", t.style.willChange = "", t.style.zIndex = e, t.removeAttribute(
|
|
195
|
+
t.style.transition = "", t.style.transform = "", t.style.willChange = "", t.style.zIndex = e, t.removeAttribute(C);
|
|
182
196
|
});
|
|
183
197
|
}, Z = () => {
|
|
184
|
-
let e =
|
|
198
|
+
let e = ie(O.x, O.y);
|
|
185
199
|
if (V()) {
|
|
186
200
|
e && (E = {
|
|
187
201
|
pane: e.pane,
|
|
@@ -208,100 +222,100 @@ var u = 32, d = 2, f = 14, p = 12, m = "<svg viewBox=\"0 0 24 24\" width=\"14\"
|
|
|
208
222
|
M = null;
|
|
209
223
|
return;
|
|
210
224
|
}
|
|
211
|
-
let e =
|
|
212
|
-
if (e && (A || (!k ||
|
|
213
|
-
let t = e.getBoundingClientRect(), n =
|
|
225
|
+
let e = t?.scrollContainerRef.current ?? null;
|
|
226
|
+
if (e && (A || (!k || o(k, O, 6)) && (A = !0), A)) {
|
|
227
|
+
let t = e.getBoundingClientRect(), n = c({
|
|
214
228
|
rectLeft: t.left,
|
|
215
229
|
rectTop: t.top,
|
|
216
230
|
clientLeft: e.clientLeft,
|
|
217
231
|
clientTop: e.clientTop,
|
|
218
232
|
clientWidth: e.clientWidth,
|
|
219
233
|
clientHeight: e.clientHeight
|
|
220
|
-
}), r =
|
|
221
|
-
|
|
222
|
-
left:
|
|
234
|
+
}), r = s(O.x, n.left, n.right, 24), i = a(e.scrollLeft, r, 18, e.scrollWidth - e.clientWidth);
|
|
235
|
+
i !== e.scrollLeft && e.scrollTo({
|
|
236
|
+
left: i,
|
|
223
237
|
behavior: "auto"
|
|
224
238
|
});
|
|
225
239
|
}
|
|
226
240
|
Z(), M = requestAnimationFrame(Q);
|
|
227
241
|
}, $ = (e) => {
|
|
228
242
|
M !== null && (cancelAnimationFrame(M), M = null), document.body.style.cursor = "", U(), K();
|
|
229
|
-
let
|
|
243
|
+
let n = T, i = E;
|
|
230
244
|
T = null, E = null, k = null;
|
|
231
|
-
let
|
|
245
|
+
let a = R;
|
|
232
246
|
R = null, I = null;
|
|
233
|
-
let
|
|
234
|
-
if (
|
|
235
|
-
t.isConnected && (t.style.transition =
|
|
236
|
-
}), z =
|
|
237
|
-
X(
|
|
238
|
-
}, 200)), !
|
|
239
|
-
let { columns:
|
|
240
|
-
D =
|
|
247
|
+
let o = n !== null && i !== null && t !== null ? t.paneLayout[i.pane].entries.findIndex((e) => e.column.key === n) : -1, s = i !== null && o >= 0 && (i.slot === o || i.slot === o + 1), c = e && n && i && t !== null && !s ? u(t.columns, n, i.pane, d(t.columns, t.paneLayout[i.pane], i.pane, i.slot)) : null;
|
|
248
|
+
if (a && !c && (a.forEach((e, t) => {
|
|
249
|
+
t.isConnected && (t.style.transition = S, t.style.transform = "translateX(0px)");
|
|
250
|
+
}), z = a, window.setTimeout(() => {
|
|
251
|
+
X(a), z === a && (z = null);
|
|
252
|
+
}, 200)), !c || !n || !i || t === null) return;
|
|
253
|
+
let { columns: l, applyColumnOrderAndPin: f, scrollContainerRef: p } = t, m = l.find((e) => e.key === n), h = m ? r(m) : null;
|
|
254
|
+
D = h !== null && h === i.pane && !x(p.current) ? w(p.current) : null, a && X(a), f(c, /* @__PURE__ */ new Map([[n, i.pane === "center" ? void 0 : i.pane]]));
|
|
241
255
|
};
|
|
242
256
|
return {
|
|
243
257
|
update: (e) => {
|
|
244
|
-
|
|
258
|
+
t = e;
|
|
245
259
|
},
|
|
246
|
-
onColumnDragHandlePointerDown: (e,
|
|
247
|
-
if (
|
|
248
|
-
|
|
249
|
-
x:
|
|
250
|
-
y:
|
|
260
|
+
onColumnDragHandlePointerDown: (e, n) => {
|
|
261
|
+
if (t === null || !t.enabled || n.button !== 0) return;
|
|
262
|
+
n.stopPropagation(), n.preventDefault(), T = e.key, E = null, O = {
|
|
263
|
+
x: n.clientX,
|
|
264
|
+
y: n.clientY
|
|
251
265
|
}, k = {
|
|
252
|
-
x:
|
|
253
|
-
y:
|
|
254
|
-
}, A = !1, document.body.style.cursor = "grabbing", B = e.title || e.key, V() ? (I =
|
|
255
|
-
let
|
|
266
|
+
x: n.clientX,
|
|
267
|
+
y: n.clientY
|
|
268
|
+
}, A = !1, document.body.style.cursor = "grabbing", B = e.title || e.key, V() ? (I = r(e), L = t.scrollContainerRef.current?.scrollLeft ?? 0, R = /* @__PURE__ */ new Map()) : W(B);
|
|
269
|
+
let i = n.currentTarget, a = n.pointerId;
|
|
256
270
|
try {
|
|
257
|
-
|
|
271
|
+
i.setPointerCapture(a);
|
|
258
272
|
} catch {}
|
|
259
|
-
let
|
|
260
|
-
e.pointerId ===
|
|
273
|
+
let o = (e) => {
|
|
274
|
+
e.pointerId === a && (O = {
|
|
261
275
|
x: e.clientX,
|
|
262
276
|
y: e.clientY
|
|
263
277
|
}, Z());
|
|
264
|
-
},
|
|
265
|
-
window.removeEventListener("pointermove",
|
|
278
|
+
}, s = () => {
|
|
279
|
+
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", c), window.removeEventListener("pointercancel", l), window.removeEventListener("keydown", u), j = null;
|
|
266
280
|
try {
|
|
267
|
-
|
|
281
|
+
i.releasePointerCapture(a);
|
|
268
282
|
} catch {}
|
|
269
283
|
};
|
|
270
|
-
function s(e) {
|
|
271
|
-
e.pointerId === i && (o(), $(!0));
|
|
272
|
-
}
|
|
273
284
|
function c(e) {
|
|
274
|
-
e.pointerId ===
|
|
285
|
+
e.pointerId === a && (s(), $(!0));
|
|
275
286
|
}
|
|
276
287
|
function l(e) {
|
|
277
|
-
e.
|
|
288
|
+
e.pointerId === a && (s(), $(!1));
|
|
289
|
+
}
|
|
290
|
+
function u(e) {
|
|
291
|
+
e.key === "Escape" && (s(), $(!1));
|
|
278
292
|
}
|
|
279
|
-
window.addEventListener("pointermove",
|
|
293
|
+
window.addEventListener("pointermove", o), window.addEventListener("pointerup", c), window.addEventListener("pointercancel", l), window.addEventListener("keydown", u), j = s, Z(), M = requestAnimationFrame(Q);
|
|
280
294
|
},
|
|
281
295
|
applyReorderSettle: () => {
|
|
282
|
-
let
|
|
283
|
-
if (D = null, !
|
|
284
|
-
let
|
|
285
|
-
if (!
|
|
286
|
-
let
|
|
287
|
-
|
|
288
|
-
if (e(
|
|
289
|
-
let o =
|
|
290
|
-
if (!o || !
|
|
291
|
-
let s =
|
|
292
|
-
s ? s.push(
|
|
296
|
+
let n = D;
|
|
297
|
+
if (D = null, !n) return;
|
|
298
|
+
let r = t?.scrollContainerRef.current ?? null;
|
|
299
|
+
if (!r) return;
|
|
300
|
+
let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
301
|
+
r.querySelectorAll("[data-ssg-col-key]").forEach((t) => {
|
|
302
|
+
if (e(r, t)) return;
|
|
303
|
+
let o = t.dataset.ssgColKey;
|
|
304
|
+
if (!o || !n.has(o)) return;
|
|
305
|
+
let s = i.get(o);
|
|
306
|
+
s ? s.push(t) : (i.set(o, [t]), a.set(o, t.getBoundingClientRect().left));
|
|
293
307
|
});
|
|
294
|
-
let
|
|
295
|
-
if (
|
|
296
|
-
let r =
|
|
297
|
-
if (r === void 0 ||
|
|
298
|
-
let s = r -
|
|
299
|
-
if (!(Math.abs(s) < .5)) for (let t of e) t.style.transition = "none", t.style.transform = `translateX(${s}px)`, t.style.willChange = "transform",
|
|
300
|
-
}),
|
|
301
|
-
|
|
302
|
-
for (let e of
|
|
308
|
+
let o = [];
|
|
309
|
+
if (i.forEach((e, t) => {
|
|
310
|
+
let r = n.get(t), i = a.get(t);
|
|
311
|
+
if (r === void 0 || i === void 0) return;
|
|
312
|
+
let s = r - i;
|
|
313
|
+
if (!(Math.abs(s) < .5)) for (let t of e) t.style.transition = "none", t.style.transform = `translateX(${s}px)`, t.style.willChange = "transform", o.push(t);
|
|
314
|
+
}), o.length !== 0) {
|
|
315
|
+
r.getBoundingClientRect();
|
|
316
|
+
for (let e of o) e.style.transition = `transform ${te}ms ${b}`, e.style.transform = "translateX(0)";
|
|
303
317
|
window.setTimeout(() => {
|
|
304
|
-
for (let e of
|
|
318
|
+
for (let e of o) e.style.transition = "", e.style.transform = "", e.style.willChange = "";
|
|
305
319
|
}, 280);
|
|
306
320
|
}
|
|
307
321
|
},
|
|
@@ -311,4 +325,4 @@ var u = 32, d = 2, f = 14, p = 12, m = "<svg viewBox=\"0 0 24 24\" width=\"14\"
|
|
|
311
325
|
};
|
|
312
326
|
};
|
|
313
327
|
//#endregion
|
|
314
|
-
export {
|
|
328
|
+
export { u as computeHeaderReorderedKeys, T as createColumnHeaderDragController, d as resolveConsumerDropSlot };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/slotDom.cjs"),t=require("../logic/tooltipGeometry.cjs");var n=`data-ssg-tooltip`,r=`[${n}], [data-ssg-tooltip-overflow]`,i=350,a=800,o=0,s=null,c=null,l=0,u=null,d,f;function p(t){f=e.applySlotToElement(t,d,f)}function m(){if(s!==null)return s;let e=document.createElement(`div`);return e.className=`ssg-tooltip`,e.setAttribute(`aria-hidden`,`true`),f=void 0,p(e),document.body.appendChild(e),s=e,e}function h(){c!==null&&(window.clearTimeout(c),c=null)}function g(){h(),u!==null&&(l=Date.now()+a),u=null,s!==null&&s.classList.remove(`ssg-tooltip--visible`)}function _(e){let r=e.getAttribute(n),i=r!==null&&r!==``?r:(e.textContent??``).trim();if(i===``)return;let a=m();a.classList.toggle(`ssg-theme-dark`,e.closest(`.ssg-theme-dark`)!==null),a.classList.toggle(`ssg-motion-off`,e.closest(`.ssg-motion-off`)!==null),a.textContent=i,a.style.left=`0px`,a.style.top=`0px`;let o=t.computeTooltipPlacement({targetRect:e.getBoundingClientRect(),tipWidth:a.offsetWidth,tipHeight:a.offsetHeight,viewportWidth:window.innerWidth});a.style.left=`${o.left}px`,a.style.top=`${o.top}px`,a.classList.add(`ssg-tooltip--visible`),u=e}function v(e){let t=e.target;if(!(t instanceof Element))return;let a=t.closest(r);if(a===null||a===u||!a.hasAttribute(n)&&a.scrollWidth<=a.clientWidth+1)return;let o=u!==null;g(),o||Date.now()<l?_(a):c=window.setTimeout(()=>{c=null,_(a)},i)}function y(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(r);if(n===null)return;let i=e.relatedTarget;i instanceof Node&&n.contains(i)||g()}function b(){g()}function x(e){e.key===`Escape`&&g()}function S(){window.addEventListener(`pointerover`,v,!0),window.addEventListener(`pointerout`,y,!0),window.addEventListener(`focusin`,v,!0),window.addEventListener(`focusout`,y,!0),window.addEventListener(`pointerdown`,b,!0),window.addEventListener(`scroll`,b,!0),window.addEventListener(`keydown`,x,!0)}function C(){window.removeEventListener(`pointerover`,v,!0),window.removeEventListener(`pointerout`,y,!0),window.removeEventListener(`focusin`,v,!0),window.removeEventListener(`focusout`,y,!0),window.removeEventListener(`pointerdown`,b,!0),window.removeEventListener(`scroll`,b,!0),window.removeEventListener(`keydown`,x,!0)}function w(e){o+=1,o===1&&S();let t=!1,n=e=>{d=e,s!==null&&p(s)};return n(e),{setSlot:n,dispose:()=>{t||(t=!0,--o,o===0&&(C(),h(),u=null,s!==null&&(s.remove(),s=null)))}}}exports.acquireTooltipController=w;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/slotDom.cjs"),t=require("../logic/tooltipGeometry.cjs");var n=`data-ssg-tooltip`,r=`[${n}], [data-ssg-tooltip-overflow]`,i=350,a=800,o=0,s=null,c=null,l=0,u=null,d,f;function p(t){f=e.applySlotToElement(t,d,f)}function m(){if(s!==null)return s;let e=document.createElement(`div`);return e.className=`ssg-tooltip`,e.setAttribute(`aria-hidden`,`true`),f=void 0,p(e),document.body.appendChild(e),s=e,e}function h(){c!==null&&(window.clearTimeout(c),c=null)}function g(){h(),u!==null&&(l=Date.now()+a),u=null,s!==null&&s.classList.remove(`ssg-tooltip--visible`)}function _(e){let r=e.getAttribute(n),i=r!==null&&r!==``?r:(e.textContent??``).trim();if(i===``)return;let a=m();a.classList.toggle(`ssg-theme-dark`,e.closest(`.ssg-theme-dark`)!==null),a.classList.toggle(`ssg-motion-off`,e.closest(`.ssg-motion-off`)!==null),a.textContent=i,a.style.left=`0px`,a.style.top=`0px`;let o=t.computeTooltipPlacement({targetRect:e.getBoundingClientRect(),tipWidth:a.offsetWidth,tipHeight:a.offsetHeight,viewportWidth:window.innerWidth});a.style.left=`${o.left}px`,a.style.top=`${o.top}px`,a.classList.add(`ssg-tooltip--visible`),u=e}function v(e){let t=e.target;if(!(t instanceof Element)||typeof PointerEvent<`u`&&e instanceof PointerEvent&&e.buttons!==0)return;let a=t.closest(r);if(a===null||a===u||!a.hasAttribute(n)&&a.scrollWidth<=a.clientWidth+1)return;let o=u!==null;g(),o||Date.now()<l?_(a):c=window.setTimeout(()=>{c=null,_(a)},i)}function y(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(r);if(n===null)return;let i=e.relatedTarget;i instanceof Node&&n.contains(i)||g()}function b(){g()}function x(e){e.key===`Escape`&&g()}function S(){window.addEventListener(`pointerover`,v,!0),window.addEventListener(`pointerout`,y,!0),window.addEventListener(`focusin`,v,!0),window.addEventListener(`focusout`,y,!0),window.addEventListener(`pointerdown`,b,!0),window.addEventListener(`scroll`,b,!0),window.addEventListener(`keydown`,x,!0)}function C(){window.removeEventListener(`pointerover`,v,!0),window.removeEventListener(`pointerout`,y,!0),window.removeEventListener(`focusin`,v,!0),window.removeEventListener(`focusout`,y,!0),window.removeEventListener(`pointerdown`,b,!0),window.removeEventListener(`scroll`,b,!0),window.removeEventListener(`keydown`,x,!0)}function w(e){o+=1,o===1&&S();let t=!1,n=e=>{d=e,s!==null&&p(s)};return n(e),{setSlot:n,dispose:()=>{t||(t=!0,--o,o===0&&(C(),h(),u=null,s!==null&&(s.remove(),s=null)))}}}exports.acquireTooltipController=w;
|
|
@@ -31,7 +31,7 @@ function _(e) {
|
|
|
31
31
|
}
|
|
32
32
|
function v(e) {
|
|
33
33
|
let t = e.target;
|
|
34
|
-
if (!(t instanceof Element)) return;
|
|
34
|
+
if (!(t instanceof Element) || typeof PointerEvent < "u" && e instanceof PointerEvent && e.buttons !== 0) return;
|
|
35
35
|
let a = t.closest(r);
|
|
36
36
|
if (a === null || a === u || !a.hasAttribute(n) && a.scrollWidth <= a.clientWidth + 1) return;
|
|
37
37
|
let o = u !== null;
|
package/package.json
CHANGED