fone-design-system_v2 1.0.301 → 1.0.302
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.
|
@@ -68176,10 +68176,10 @@ const TDe = ({
|
|
|
68176
68176
|
if (!ge && d || !ge && ((he = T.current) == null ? void 0 : he.rowIndex) === F && ((me = T.current) == null ? void 0 : me.tick) === ie)
|
|
68177
68177
|
return;
|
|
68178
68178
|
const Ce = ((ye = oe.current) == null ? void 0 : ye[F]) ?? ((De = j.current) == null ? void 0 : De[F]);
|
|
68179
|
-
|
|
68179
|
+
X(Ce, F), T.current = {
|
|
68180
68180
|
rowIndex: F,
|
|
68181
68181
|
tick: ie
|
|
68182
|
-
}
|
|
68182
|
+
};
|
|
68183
68183
|
}, [ie, d, F, X]);
|
|
68184
68184
|
const pe = ui(() => {
|
|
68185
68185
|
H(h ?? -1);
|
|
@@ -818,7 +818,7 @@ ${X.current.stack}
|
|
|
818
818
|
outline: 2px solid var(--ds-color-primary);
|
|
819
819
|
outline-offset: -2px;
|
|
820
820
|
}
|
|
821
|
-
`,z0e=(e,t,n)=>{const r=[...e],[o]=r.splice(t,1);return r.splice(n,0,o),r},W0e=(e,t,n)=>Object.entries(e).filter(([,i])=>!!i).map(([i])=>Number(i)).map(i=>i===t?n:t<n&&i>t&&i<=n?i-1:t>n&&i>=n&&i<t?i+1:i).reduce((i,a)=>(i[a.toString()]=!0,i),{}),U0e=(e,t)=>{const n=e.original,r=(n==null?void 0:n.id)??(n==null?void 0:n.key)??e.id;return`table-row-${String(r)}-${t}`},Y0e=e=>e&&{...e,transform:e.transform},G0e={width:"100%",tableLayout:"fixed",borderCollapse:"separate",borderSpacing:0},GS=(e,t)=>({...G0e,...t!=null&&t.hasFooter?{minHeight:"100%"}:void 0,...t!=null&&t.empty?{height:"100%"}:void 0,...e}),q0e=e=>{R.useEffect(()=>{let t=null;const n=()=>{window.removeEventListener("touchmove",o,s),window.removeEventListener("touchend",i,s),window.removeEventListener("touchcancel",a,s)},r=()=>{n(),t=null};function o(u){const d=u.touches[0];!d||!(t!=null&&t.isActive())||(u.preventDefault(),t.move({x:d.clientX,y:d.clientY}))}function i(){if(!t)return;const u=t;r(),u.isActive()&&u.drop({shouldBlockNextClick:!0})}function a(){if(!t)return;const u=t;r(),u.isActive()&&u.cancel({shouldBlockNextClick:!0})}const s={capture:!0,passive:!1},l=u=>{if(t||u.touches.length!==1)return;const d=e.findClosestDraggableId(u);if(!d)return;const f=e.tryGetLock(d,void 0,{sourceEvent:u});if(!f)return;const A=u.touches[0];if(!A){f.abort();return}t=f.fluidLift({x:A.clientX,y:A.clientY}),window.addEventListener("touchmove",o,s),window.addEventListener("touchend",i,s),window.addEventListener("touchcancel",a,s)};return window.addEventListener("touchstart",l,s),()=>{window.removeEventListener("touchstart",l,s),r()}},[e])},c8=R.forwardRef(({table:e,clickedRowIndex:t,onChange:n,onCellClick:r,selectedCellInfo:o,showSelectedCellBorder:i=!1,showFocusedCellBorder:a=!1,onReorder:s,setTableData:l,setRowSelection:u,isLoading:d,onRowClick:f,onRowDoubleClick:A,scrollTo:g,rowSelection:m,rowActiveIdx:h,radio:v,reorderMode:C=!1,getRowProps:w,tableSx:x,rowHeight:S,headerRowHeight:E,rowCountChangeScrollPosition:O="top",focusedCellInfo:I,setFocusedCellInfo:M},N)=>{const P=R.useRef(null),k=R.useRef(null),F=R.useRef(null),L=R.useRef(null),[B,$]=R.useState(null);R.useImperativeHandle(N,()=>P.current);const V=R.useRef([]),_=R.useRef(null),W=e.getRowModel().rows,Y=W.length,j=e==null?void 0:e.getVisibleLeafColumns(),U=j.some(z=>z.columnDef.footer!=null),q=R.useMemo(()=>[L6,F6,q0e],[]);R.useEffect(()=>{const z=_.current;if(_.current=Y,z!==null&&z!==Y&&z!==0&&P.current){const ie=P.current.querySelector("[data-radix-scroll-area-viewport]");if(!ie)return;let ue;switch(O){case"top":ue=0;break;case"bottom":ue=ie.scrollHeight;break;case"preserve":ue=null;break;default:ue=Number(O)||0;break}ue!==null&&ie.scrollTo({top:ue,behavior:"auto"})}},[O,Y]),R.useEffect(()=>{if(g){if(!(g>0))return;let z=0;const oe=8,ie=()=>{if(z+=1,P.current){const ue=g-1;if(V.current[ue]){const ge=P.current.querySelector(`[data-index="${ue}"]`);if(ge){ge.scrollIntoView({block:"nearest",behavior:"smooth"});return}}}z<oe&&requestAnimationFrame(ie)};requestAnimationFrame(ie)}},[g,Y]),R.useEffect(()=>{const z=P.current;if(!z)return;const oe=z.querySelector("[data-radix-scroll-area-viewport]");if(!oe)return;const ie=()=>{const ue=oe.scrollLeft;k.current&&(k.current.scrollLeft=ue),F.current&&(F.current.scrollLeft=ue)};return ie(),oe.addEventListener("scroll",ie,{passive:!0}),()=>{oe.removeEventListener("scroll",ie)}},[U,j.length]);const K=R.useCallback(z=>{const{source:oe,destination:ie}=z;!C||!ie||oe.index!==ie.index&&(l(ue=>{const pe=z0e(ue,oe.index,ie.index);return n==null||n(pe),s==null||s(pe),pe}),u(ue=>W0e(ue,oe.index,ie.index)))},[n,s,C,u,l]),Q=(z,oe,ie)=>{const{setInnerRef:ue,dragHandleProps:pe,draggableProps:we,isDragging:ge=!1,draggableStyle:Ce}=ie??{};return T.jsx(l8,{ref:me=>{V.current[oe]=me,ue==null||ue(me)},row:z,onCellClick:r,onHoverChange:$,selectedCellInfo:o,showSelectedCellBorder:i,showFocusedCellBorder:a,onChange:n,setTableData:l,setRowSelection:u,onRowClick:f,onRowDoubleClick:A,radio:v,reorderMode:C,getRowProps:w,dragHandleProps:pe,isDragging:ge,rowProps:we,rowStyle:Y0e(Ce),isScrollHighlighted:Number(g)>0&&oe===Number(g)-1,isRowActive:h===oe,isRowHovered:oe===B,clickedRowIndex:t,hoveredRowIndex:B,rowSelection:m,isRowClicked:oe===t,rowHeight:S,draggingColumnWidths:G(),focusedCellInfo:I,setFocusedCellInfo:M},z.id??oe)},G=R.useCallback(()=>{var oe;const z=(oe=L.current)==null?void 0:oe.querySelectorAll("thead tr:last-child > th");return z!=null&&z.length?Array.from(z).map(ie=>`${ie.getBoundingClientRect().width}px`):j.map(ie=>ie.columnDef.width)},[j]),X=z=>T.jsx("colgroup",{children:j.map((oe,ie)=>{const ue=(z==null?void 0:z[ie])??oe.columnDef.width;return T.jsx("col",{style:ue?{width:ue}:void 0},oe.id)})}),ne=()=>T.jsxs("table",{ref:L,className:"table2",style:GS(x),children:[X(),T.jsx(o8,{table:e,clickedRowIndex:t,headerRowHeight:E})]}),ee=({children:z,empty:oe=!1,columnWidths:ie})=>T.jsxs("table",{className:oe?"table2 table2--empty":"table2",style:GS(x,{empty:oe,hasFooter:U}),children:[X(ie),z]}),te=()=>U?T.jsxs("table",{className:"table2",style:GS(x),children:[X(),T.jsx(y0e,{table:e,footerRowHeight:E})]}):null,re=()=>T.jsx("tbody",{children:T.jsx("tr",{children:T.jsx("td",{colSpan:Math.max(j.length,1),style:{padding:0},children:T.jsx(b0e,{})})})}),Z=(z,oe,ie)=>{var we;const ue=(we=V.current[oe])==null?void 0:we.getBoundingClientRect().width,pe=G();return T.jsx("div",{style:{width:ue?`${ue}px`:"100%",pointerEvents:"none",zIndex:1e3,border:"1px solid red !important"},children:ee({columnWidths:pe,children:T.jsx("tbody",{style:{border:"1px solid red !important"},children:Q(z,oe,ie)})})})};return d?T.jsx("div",{style:{display:"flex",height:"100%",width:"100%",alignItems:"center",justifyContent:"center",backgroundColor:"white",paddingBottom:"2rem"},children:T.jsx(bA,{color:"inherit",style:{opacity:.4},disableShrink:!0})}):T.jsxs("div",{style:{display:"flex",height:"100%",width:"100%",flexDirection:"column",backgroundColor:"white"},children:[T.jsx("div",{ref:k,style:{overflow:"hidden",flexShrink:0},children:ne()}),T.jsxs(yA,{ref:P,style:{flex:1,width:"100%",backgroundColor:"white"},children:[Y===0?ee({children:re(),empty:!0}):C?T.jsx(j6,{onDragEnd:K,enableDefaultSensors:!1,sensors:q,children:T.jsx(US,{droppableId:"table-rows",children:z=>ee({children:T.jsxs("tbody",{ref:z.innerRef,...z.droppableProps,children:[W.map((oe,ie)=>{if(!oe)return null;const ue=U0e(oe,ie);return T.jsx(Q6,{draggableId:ue,index:ie,disableInteractiveElementBlocking:!0,children:(pe,we)=>{const ge={setInnerRef:pe.innerRef,dragHandleProps:pe.dragHandleProps,draggableProps:pe.draggableProps,isDragging:we.isDragging,draggableStyle:pe.draggableProps.style},Ce=Q(oe,ie,ge);return we.isDragging&&typeof document<"u"?_r.createPortal(Z(oe,ie,ge),document.body):Ce}},ue)}),z.placeholder]})})})}):ee({children:T.jsx("tbody",{children:W.map((z,oe)=>z?Q(z,oe):null)})}),T.jsx(dl,{orientation:"vertical"}),T.jsx(dl,{orientation:"horizontal"})]}),U?T.jsx("div",{ref:F,style:{overflow:"hidden",flexShrink:0},children:te()}):null]})});c8.displayName="Rows";const Q0e=({data:e,columns:t=[],onChange:n,checkbox:r=!1,no:o=!1,radio:i=!1,selectedCell:a=!1,focusedCell:s=!1,onRowClick:l,onRowDoubleClick:u,isLoading:d=!1,rowCountChangeScrollPosition:f="top",scrollTo:A,isEditMode:g=!0,rowClickTriggerIdx:m,resetTriggerOnDataChange:h=!1,noTriggerOnDataChange:v=!1,reorderMode:C=!1,onReorder:w,onCellClick:x,getRowProps:S,rowHeight:E=30,headerRowHeight:O=30,sx:I})=>{const M=R.useRef(null),N=R.useRef(null);zAe(()=>{$(-1),Y(void 0),B!==-1&&_(B)});const[P,k]=R.useState([]),[F,L]=R.useState({}),[B,$]=R.useState(-1),[V,_]=R.useState(m??-1),[W,Y]=R.useState(void 0),[j,U]=R.useState(null),q=R.useCallback(ge=>{const Ce=ge.target.checked;if(Ce){const me={};for(let he=0;he<P.length;he+=1)me[he.toString()]=!0;L(me)}else L({});k(me=>{const he=me.map(ye=>({...ye,checked:Ce}));return n==null||n(he),he})},[n,P.length]),K=R.useCallback((ge,Ce)=>{$(Ce),Y(void 0),l==null||l(ge,Ce)},[l,$,Y]),Q=R.useCallback((ge,Ce)=>{ge!=null&&(u==null||u(ge,Ce))},[u]),G=R.useCallback((ge,Ce,me,he)=>{ge!=null&&(Y({rowIndex:Ce,colIndex:he}),x==null||x(ge,Ce,me,he))},[x]),X=R.useMemo(()=>({id:"selection",header:({table:ge})=>i?null:T.jsx(Ba,{checked:ge==null?void 0:ge.getIsAllRowsSelected(),onChange:q}),cell:({row:ge})=>T.jsx(Ba,{checked:ge==null?void 0:ge.getIsSelected(),disabled:!(ge!=null&&ge.getCanSelect()),onChange:ge==null?void 0:ge.getToggleSelectedHandler()}),width:"3.2rem",align:"center"}),[q,i]),ne=R.useMemo(()=>({id:"no",header:"No",cell:({row:ge})=>ge,width:"4.8rem",align:"center"}),[]),ee=R.useMemo(()=>({id:"edit",header:()=>{},cell:({row:ge})=>ge,width:"3rem",align:"center",showEditIcon:g}),[g]),te=R.useMemo(()=>({id:"reorder",header:()=>{},cell:({row:ge})=>ge,width:"3.2rem",align:"center"}),[]),re=R.useMemo(()=>{const ge=t.filter(me=>me.visible!==!1),Ce=[];return o&&Ce.push(ne),g&&Ce.push(ee),(r||i)&&Ce.push(X),Ce.push(...ge),C&&Ce.push(te),Ce},[r,X,t,ee,g,o,ne,i,te,C]),Z=jAe({data:P,columns:re,getCoreRowModel:FAe(),enableRowSelection:!0,enableMultiRowSelection:!i,onRowSelectionChange:L,state:{rowSelection:F}}),z=R.useRef(e);z.current=e;const oe=R.useRef(P);oe.current=P,R.useEffect(()=>{e!==void 0&&k(e)},[e]),R.useEffect(()=>{const ge={};if(i){const Ce=P.findIndex(me=>(me==null?void 0:me.checked)===!0);Ce>=0&&(ge[Ce.toString()]=!0)}else P.forEach((Ce,me)=>{(Ce==null?void 0:Ce.checked)===!0&&(ge[me.toString()]=!0)});L(ge)},[i,P]);const[ie,ue]=R.useState(0);R.useEffect(()=>{v||j||ue(ge=>ge+1)},[e,P,v]),R.useEffect(()=>{var me,he,ye,Te;if(V<0||ie===0)return;const ge=JSON.stringify(oe.current)!==JSON.stringify(z.current);if(!ge&&d||!ge&&((me=N.current)==null?void 0:me.rowIndex)===V&&((he=N.current)==null?void 0:he.tick)===ie)return;const Ce=((ye=oe.current)==null?void 0:ye[V])??((Te=z.current)==null?void 0:Te[V]);Ce!=null&&(K(Ce,V),N.current={rowIndex:V,tick:ie})},[ie,d,V,K]);const pe=R.useCallback(()=>{_(m??-1)},[m]);R.useEffect(()=>{h&&(d||pe())},[d,h,pe]),R.useEffect(()=>{h&&e&&pe()},[e,pe,h]),R.useEffect(()=>{h&&JSON.stringify(P)!==JSON.stringify(e)&&pe()},[e,h,pe,P]);const we=()=>V<0?-1:B!==-1?B:A!==void 0?-1:V;return T.jsx("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",borderTop:"1px solid var(--ds-table-header-border-top-color)",color:"var(--ds-table-text-color)"},children:T.jsx("div",{style:{display:"flex",flex:1,minHeight:0},children:T.jsx(c8,{table:Z,clickedRowIndex:B,onChange:n,onReorder:w,tableSx:I,setTableData:k,setRowSelection:L,isLoading:d,onCellClick:G,selectedCellInfo:W,showSelectedCellBorder:a,showFocusedCellBorder:s,onRowClick:K,onRowDoubleClick:Q,scrollTo:A,radio:i,reorderMode:C,getRowProps:S,rowActiveIdx:we(),rowSelection:F,ref:M,rowHeight:E,headerRowHeight:O,rowCountChangeScrollPosition:f,focusedCellInfo:j,setFocusedCellInfo:U})})})};var WA={exports:{}};/**
|
|
821
|
+
`,z0e=(e,t,n)=>{const r=[...e],[o]=r.splice(t,1);return r.splice(n,0,o),r},W0e=(e,t,n)=>Object.entries(e).filter(([,i])=>!!i).map(([i])=>Number(i)).map(i=>i===t?n:t<n&&i>t&&i<=n?i-1:t>n&&i>=n&&i<t?i+1:i).reduce((i,a)=>(i[a.toString()]=!0,i),{}),U0e=(e,t)=>{const n=e.original,r=(n==null?void 0:n.id)??(n==null?void 0:n.key)??e.id;return`table-row-${String(r)}-${t}`},Y0e=e=>e&&{...e,transform:e.transform},G0e={width:"100%",tableLayout:"fixed",borderCollapse:"separate",borderSpacing:0},GS=(e,t)=>({...G0e,...t!=null&&t.hasFooter?{minHeight:"100%"}:void 0,...t!=null&&t.empty?{height:"100%"}:void 0,...e}),q0e=e=>{R.useEffect(()=>{let t=null;const n=()=>{window.removeEventListener("touchmove",o,s),window.removeEventListener("touchend",i,s),window.removeEventListener("touchcancel",a,s)},r=()=>{n(),t=null};function o(u){const d=u.touches[0];!d||!(t!=null&&t.isActive())||(u.preventDefault(),t.move({x:d.clientX,y:d.clientY}))}function i(){if(!t)return;const u=t;r(),u.isActive()&&u.drop({shouldBlockNextClick:!0})}function a(){if(!t)return;const u=t;r(),u.isActive()&&u.cancel({shouldBlockNextClick:!0})}const s={capture:!0,passive:!1},l=u=>{if(t||u.touches.length!==1)return;const d=e.findClosestDraggableId(u);if(!d)return;const f=e.tryGetLock(d,void 0,{sourceEvent:u});if(!f)return;const A=u.touches[0];if(!A){f.abort();return}t=f.fluidLift({x:A.clientX,y:A.clientY}),window.addEventListener("touchmove",o,s),window.addEventListener("touchend",i,s),window.addEventListener("touchcancel",a,s)};return window.addEventListener("touchstart",l,s),()=>{window.removeEventListener("touchstart",l,s),r()}},[e])},c8=R.forwardRef(({table:e,clickedRowIndex:t,onChange:n,onCellClick:r,selectedCellInfo:o,showSelectedCellBorder:i=!1,showFocusedCellBorder:a=!1,onReorder:s,setTableData:l,setRowSelection:u,isLoading:d,onRowClick:f,onRowDoubleClick:A,scrollTo:g,rowSelection:m,rowActiveIdx:h,radio:v,reorderMode:C=!1,getRowProps:w,tableSx:x,rowHeight:S,headerRowHeight:E,rowCountChangeScrollPosition:O="top",focusedCellInfo:I,setFocusedCellInfo:M},N)=>{const P=R.useRef(null),k=R.useRef(null),F=R.useRef(null),L=R.useRef(null),[B,$]=R.useState(null);R.useImperativeHandle(N,()=>P.current);const V=R.useRef([]),_=R.useRef(null),W=e.getRowModel().rows,Y=W.length,j=e==null?void 0:e.getVisibleLeafColumns(),U=j.some(z=>z.columnDef.footer!=null),q=R.useMemo(()=>[L6,F6,q0e],[]);R.useEffect(()=>{const z=_.current;if(_.current=Y,z!==null&&z!==Y&&z!==0&&P.current){const ie=P.current.querySelector("[data-radix-scroll-area-viewport]");if(!ie)return;let ue;switch(O){case"top":ue=0;break;case"bottom":ue=ie.scrollHeight;break;case"preserve":ue=null;break;default:ue=Number(O)||0;break}ue!==null&&ie.scrollTo({top:ue,behavior:"auto"})}},[O,Y]),R.useEffect(()=>{if(g){if(!(g>0))return;let z=0;const oe=8,ie=()=>{if(z+=1,P.current){const ue=g-1;if(V.current[ue]){const ge=P.current.querySelector(`[data-index="${ue}"]`);if(ge){ge.scrollIntoView({block:"nearest",behavior:"smooth"});return}}}z<oe&&requestAnimationFrame(ie)};requestAnimationFrame(ie)}},[g,Y]),R.useEffect(()=>{const z=P.current;if(!z)return;const oe=z.querySelector("[data-radix-scroll-area-viewport]");if(!oe)return;const ie=()=>{const ue=oe.scrollLeft;k.current&&(k.current.scrollLeft=ue),F.current&&(F.current.scrollLeft=ue)};return ie(),oe.addEventListener("scroll",ie,{passive:!0}),()=>{oe.removeEventListener("scroll",ie)}},[U,j.length]);const K=R.useCallback(z=>{const{source:oe,destination:ie}=z;!C||!ie||oe.index!==ie.index&&(l(ue=>{const pe=z0e(ue,oe.index,ie.index);return n==null||n(pe),s==null||s(pe),pe}),u(ue=>W0e(ue,oe.index,ie.index)))},[n,s,C,u,l]),Q=(z,oe,ie)=>{const{setInnerRef:ue,dragHandleProps:pe,draggableProps:we,isDragging:ge=!1,draggableStyle:Ce}=ie??{};return T.jsx(l8,{ref:me=>{V.current[oe]=me,ue==null||ue(me)},row:z,onCellClick:r,onHoverChange:$,selectedCellInfo:o,showSelectedCellBorder:i,showFocusedCellBorder:a,onChange:n,setTableData:l,setRowSelection:u,onRowClick:f,onRowDoubleClick:A,radio:v,reorderMode:C,getRowProps:w,dragHandleProps:pe,isDragging:ge,rowProps:we,rowStyle:Y0e(Ce),isScrollHighlighted:Number(g)>0&&oe===Number(g)-1,isRowActive:h===oe,isRowHovered:oe===B,clickedRowIndex:t,hoveredRowIndex:B,rowSelection:m,isRowClicked:oe===t,rowHeight:S,draggingColumnWidths:G(),focusedCellInfo:I,setFocusedCellInfo:M},z.id??oe)},G=R.useCallback(()=>{var oe;const z=(oe=L.current)==null?void 0:oe.querySelectorAll("thead tr:last-child > th");return z!=null&&z.length?Array.from(z).map(ie=>`${ie.getBoundingClientRect().width}px`):j.map(ie=>ie.columnDef.width)},[j]),X=z=>T.jsx("colgroup",{children:j.map((oe,ie)=>{const ue=(z==null?void 0:z[ie])??oe.columnDef.width;return T.jsx("col",{style:ue?{width:ue}:void 0},oe.id)})}),ne=()=>T.jsxs("table",{ref:L,className:"table2",style:GS(x),children:[X(),T.jsx(o8,{table:e,clickedRowIndex:t,headerRowHeight:E})]}),ee=({children:z,empty:oe=!1,columnWidths:ie})=>T.jsxs("table",{className:oe?"table2 table2--empty":"table2",style:GS(x,{empty:oe,hasFooter:U}),children:[X(ie),z]}),te=()=>U?T.jsxs("table",{className:"table2",style:GS(x),children:[X(),T.jsx(y0e,{table:e,footerRowHeight:E})]}):null,re=()=>T.jsx("tbody",{children:T.jsx("tr",{children:T.jsx("td",{colSpan:Math.max(j.length,1),style:{padding:0},children:T.jsx(b0e,{})})})}),Z=(z,oe,ie)=>{var we;const ue=(we=V.current[oe])==null?void 0:we.getBoundingClientRect().width,pe=G();return T.jsx("div",{style:{width:ue?`${ue}px`:"100%",pointerEvents:"none",zIndex:1e3,border:"1px solid red !important"},children:ee({columnWidths:pe,children:T.jsx("tbody",{style:{border:"1px solid red !important"},children:Q(z,oe,ie)})})})};return d?T.jsx("div",{style:{display:"flex",height:"100%",width:"100%",alignItems:"center",justifyContent:"center",backgroundColor:"white",paddingBottom:"2rem"},children:T.jsx(bA,{color:"inherit",style:{opacity:.4},disableShrink:!0})}):T.jsxs("div",{style:{display:"flex",height:"100%",width:"100%",flexDirection:"column",backgroundColor:"white"},children:[T.jsx("div",{ref:k,style:{overflow:"hidden",flexShrink:0},children:ne()}),T.jsxs(yA,{ref:P,style:{flex:1,width:"100%",backgroundColor:"white"},children:[Y===0?ee({children:re(),empty:!0}):C?T.jsx(j6,{onDragEnd:K,enableDefaultSensors:!1,sensors:q,children:T.jsx(US,{droppableId:"table-rows",children:z=>ee({children:T.jsxs("tbody",{ref:z.innerRef,...z.droppableProps,children:[W.map((oe,ie)=>{if(!oe)return null;const ue=U0e(oe,ie);return T.jsx(Q6,{draggableId:ue,index:ie,disableInteractiveElementBlocking:!0,children:(pe,we)=>{const ge={setInnerRef:pe.innerRef,dragHandleProps:pe.dragHandleProps,draggableProps:pe.draggableProps,isDragging:we.isDragging,draggableStyle:pe.draggableProps.style},Ce=Q(oe,ie,ge);return we.isDragging&&typeof document<"u"?_r.createPortal(Z(oe,ie,ge),document.body):Ce}},ue)}),z.placeholder]})})})}):ee({children:T.jsx("tbody",{children:W.map((z,oe)=>z?Q(z,oe):null)})}),T.jsx(dl,{orientation:"vertical"}),T.jsx(dl,{orientation:"horizontal"})]}),U?T.jsx("div",{ref:F,style:{overflow:"hidden",flexShrink:0},children:te()}):null]})});c8.displayName="Rows";const Q0e=({data:e,columns:t=[],onChange:n,checkbox:r=!1,no:o=!1,radio:i=!1,selectedCell:a=!1,focusedCell:s=!1,onRowClick:l,onRowDoubleClick:u,isLoading:d=!1,rowCountChangeScrollPosition:f="top",scrollTo:A,isEditMode:g=!0,rowClickTriggerIdx:m,resetTriggerOnDataChange:h=!1,noTriggerOnDataChange:v=!1,reorderMode:C=!1,onReorder:w,onCellClick:x,getRowProps:S,rowHeight:E=30,headerRowHeight:O=30,sx:I})=>{const M=R.useRef(null),N=R.useRef(null);zAe(()=>{$(-1),Y(void 0),B!==-1&&_(B)});const[P,k]=R.useState([]),[F,L]=R.useState({}),[B,$]=R.useState(-1),[V,_]=R.useState(m??-1),[W,Y]=R.useState(void 0),[j,U]=R.useState(null),q=R.useCallback(ge=>{const Ce=ge.target.checked;if(Ce){const me={};for(let he=0;he<P.length;he+=1)me[he.toString()]=!0;L(me)}else L({});k(me=>{const he=me.map(ye=>({...ye,checked:Ce}));return n==null||n(he),he})},[n,P.length]),K=R.useCallback((ge,Ce)=>{$(Ce),Y(void 0),l==null||l(ge,Ce)},[l,$,Y]),Q=R.useCallback((ge,Ce)=>{ge!=null&&(u==null||u(ge,Ce))},[u]),G=R.useCallback((ge,Ce,me,he)=>{ge!=null&&(Y({rowIndex:Ce,colIndex:he}),x==null||x(ge,Ce,me,he))},[x]),X=R.useMemo(()=>({id:"selection",header:({table:ge})=>i?null:T.jsx(Ba,{checked:ge==null?void 0:ge.getIsAllRowsSelected(),onChange:q}),cell:({row:ge})=>T.jsx(Ba,{checked:ge==null?void 0:ge.getIsSelected(),disabled:!(ge!=null&&ge.getCanSelect()),onChange:ge==null?void 0:ge.getToggleSelectedHandler()}),width:"3.2rem",align:"center"}),[q,i]),ne=R.useMemo(()=>({id:"no",header:"No",cell:({row:ge})=>ge,width:"4.8rem",align:"center"}),[]),ee=R.useMemo(()=>({id:"edit",header:()=>{},cell:({row:ge})=>ge,width:"3rem",align:"center",showEditIcon:g}),[g]),te=R.useMemo(()=>({id:"reorder",header:()=>{},cell:({row:ge})=>ge,width:"3.2rem",align:"center"}),[]),re=R.useMemo(()=>{const ge=t.filter(me=>me.visible!==!1),Ce=[];return o&&Ce.push(ne),g&&Ce.push(ee),(r||i)&&Ce.push(X),Ce.push(...ge),C&&Ce.push(te),Ce},[r,X,t,ee,g,o,ne,i,te,C]),Z=jAe({data:P,columns:re,getCoreRowModel:FAe(),enableRowSelection:!0,enableMultiRowSelection:!i,onRowSelectionChange:L,state:{rowSelection:F}}),z=R.useRef(e);z.current=e;const oe=R.useRef(P);oe.current=P,R.useEffect(()=>{e!==void 0&&k(e)},[e]),R.useEffect(()=>{const ge={};if(i){const Ce=P.findIndex(me=>(me==null?void 0:me.checked)===!0);Ce>=0&&(ge[Ce.toString()]=!0)}else P.forEach((Ce,me)=>{(Ce==null?void 0:Ce.checked)===!0&&(ge[me.toString()]=!0)});L(ge)},[i,P]);const[ie,ue]=R.useState(0);R.useEffect(()=>{v||j||ue(ge=>ge+1)},[e,P,v]),R.useEffect(()=>{var me,he,ye,Te;if(V<0||ie===0)return;const ge=JSON.stringify(oe.current)!==JSON.stringify(z.current);if(!ge&&d||!ge&&((me=N.current)==null?void 0:me.rowIndex)===V&&((he=N.current)==null?void 0:he.tick)===ie)return;const Ce=((ye=oe.current)==null?void 0:ye[V])??((Te=z.current)==null?void 0:Te[V]);K(Ce,V),N.current={rowIndex:V,tick:ie}},[ie,d,V,K]);const pe=R.useCallback(()=>{_(m??-1)},[m]);R.useEffect(()=>{h&&(d||pe())},[d,h,pe]),R.useEffect(()=>{h&&e&&pe()},[e,pe,h]),R.useEffect(()=>{h&&JSON.stringify(P)!==JSON.stringify(e)&&pe()},[e,h,pe,P]);const we=()=>V<0?-1:B!==-1?B:A!==void 0?-1:V;return T.jsx("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",borderTop:"1px solid var(--ds-table-header-border-top-color)",color:"var(--ds-table-text-color)"},children:T.jsx("div",{style:{display:"flex",flex:1,minHeight:0},children:T.jsx(c8,{table:Z,clickedRowIndex:B,onChange:n,onReorder:w,tableSx:I,setTableData:k,setRowSelection:L,isLoading:d,onCellClick:G,selectedCellInfo:W,showSelectedCellBorder:a,showFocusedCellBorder:s,onRowClick:K,onRowDoubleClick:Q,scrollTo:A,radio:i,reorderMode:C,getRowProps:S,rowActiveIdx:we(),rowSelection:F,ref:M,rowHeight:E,headerRowHeight:O,rowCountChangeScrollPosition:f,focusedCellInfo:j,setFocusedCellInfo:U})})})};var WA={exports:{}};/**
|
|
822
822
|
* @license
|
|
823
823
|
* Lodash <https://lodash.com/>
|
|
824
824
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
package/package.json
CHANGED