simple-table-core 0.7.23 → 0.7.25

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/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as n,Fragment as r}from"react/jsx-runtime";import{useState as t,useRef as o,useCallback as i,useEffect as a,useMemo as l,forwardRef as d,useLayoutEffect as c,createElement as s,Fragment as u,createRef as f,memo as h,useReducer as v}from"react";var g=function(){return g=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},g.apply(this,arguments)};function w(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]])}return r}function m(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var p,R=function(e){var n=e.rowIndex,r=e.colIndex,t=e.rowId;return"".concat(n,"-").concat(r,"-").concat(t)},I=function(r){var t=r.currentPage,o=r.hideFooter,i=r.nextIcon,a=r.onPageChange,l=r.onNextPage,d=r.onPreviousPage,c=r.prevIcon,s=r.shouldPaginate,u=r.totalPages;if(o||!s)return null;var f=!(t>1)&&!d,h=!(t<u)&&!l;return e("div",g({className:"st-footer"},{children:[n("button",g({className:"st-next-prev-btn ".concat(f?"disabled":""),onClick:function(){var e=t-1;e>=1&&a(e),d&&d(e-1)},disabled:f},{children:c})),n("button",g({className:"st-next-prev-btn ".concat(h?"disabled":""),onClick:function(){var e=t+1;(e<=u||l)&&a(e),l&&l(t)},disabled:h},{children:i})),Array.from({length:u},(function(e,r){return n("button",g({onClick:function(){var e;(e=r+1)>=1&&e<=u&&(a(e),e>t&&l?l(e-1):e<t&&d&&d(e-1))},className:"st-page-btn ".concat(t===r+1?"active":"")},{children:r+1}),r)}))]}))},C=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})}))},x=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})}))},b=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M5.41 11.41L10 6.83l4.59 4.58L16 10l-6-6-6 6z"})}))},y=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M5.41 7.59L10 12.17l4.59-4.58L16 9l-6 6-6-6z"})}))},H=function(e){return e.position*(e.rowHeight+1)-1},M=function(e){return e.position*(e.rowHeight+1)},D=function(e){var n=e.accessor,r=e.rowIndex;return"cell-".concat(n,"-").concat(r)},S=function(e){var n=e.hiddenColumns,r=e.header,t=e.pinned;return n[r.accessor]?null:!t&&!r.pinned||r.pinned===t||null},E=function(r){var t=r.value,o=r.onBlur,i=r.onChange;return e("select",g({value:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;i("true"===n)}},{children:[n("option",g({value:"true"},{children:"True"})),n("option",g({value:"false"},{children:"False"}))]}))},k=function(e){var r=e.defaultValue,t=e.onBlur,i=e.onChange,a=o(null);return n("input",{className:"editable-cell-input",ref:a,autoFocus:!0,type:"text",defaultValue:null!=r?r:"",onBlur:t,onChange:function(e){var n=e.target.value;i(n)}})},N=function(e){var r=e.defaultValue,t=e.onBlur,i=e.onChange,a=o(null);return n("input",{className:"editable-cell-input",ref:a,autoFocus:!0,defaultValue:r.toString(),onBlur:t,onChange:function(e){var n=e.target.value;/^\d*\.?\d*$/.test(n)&&i(n)}})},T=function(e){var t=e.onChange,o=e.setIsEditing,i=e.value,a=function(e){null==t||t(e)},l=function(){o(!1)};return n(r,{children:"string"==typeof i||null==i?n(k,{defaultValue:i,onBlur:l,onChange:a}):"boolean"==typeof i?n(E,{onBlur:l,onChange:a,value:i}):"number"==typeof i?n(N,{defaultValue:i,onBlur:l,onChange:a}):null})},L=0,O=function(){return function(e){var n=e.callback,r=e.callbackProps,t=e.limit,o=Date.now();(0===L||o-L>=t)&&(L=o,n(r))}},B=Date.now(),W={screenX:0,screenY:0},A=function(e){var n,r,t=e.draggedHeaderRef,i=e.headersRef,l=e.hoveredHeaderRef,d=e.onColumnOrderChange,c=e.onTableHeaderDragEnd,s=(n=i.current,r=o(n),a((function(){r.current=n}),[n]),r.current);return{handleDragStart:function(e){t.current=e,B=Date.now()},handleDragOver:function(e){var n,r=e.event,o=e.hoveredHeader;if(r.preventDefault(),i.current){var a=r.currentTarget.getAnimations().some((function(e){return"running"===e.playState})),d=r.screenX,u=r.screenY,f=Math.sqrt(Math.pow(d-W.screenX,2)+Math.pow(u-W.screenY,2));l.current=o;var h=m([],i.current,!0),v=h.findIndex((function(e){var n;return e.accessor===(null===(n=t.current)||void 0===n?void 0:n.accessor)})),g=h.findIndex((function(e){return e.accessor===o.accessor})),w=h.splice(v,1)[0];if(h.splice(g,0,w),!(a||o.accessor===(null===(n=t.current)||void 0===n?void 0:n.accessor)||null===t.current||f<10||void 0===v||void 0===g||JSON.stringify(h)===JSON.stringify(i.current))){var p=Date.now();JSON.stringify(h)===JSON.stringify(s)&&p-B<800&&f<50||(B=p,W={screenX:d,screenY:u},c(h))}}},handleDragEnd:function(){t.current=null,l.current=null,null==d||d(i.current)}}},P=d((function(r,o){var i,l,d=r.borderClass,c=r.colIndex,s=r.draggedHeaderRef,u=r.header,f=r.headersRef,h=r.hoveredHeaderRef,v=r.isSelected,w=r.isInitialFocusedCell,m=r.onCellEdit,p=r.onExpandRowClick,R=r.onMouseDown,I=r.onMouseOver,C=r.onTableHeaderDragEnd,b=r.rowIndex,H=r.visibleRow,M=H.depth,S=H.row,E=t(S.rowData[u.accessor]),k=E[0],N=E[1],L=t(!1),B=L[0],W=L[1],P=A({draggedHeaderRef:s,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:C}).handleDragOver,F=O(),z="cell-".concat(b,"-").concat(c),U=Boolean(null===(l=null===(i=S.rowMeta)||void 0===i?void 0:i.children)||void 0===l?void 0:l.length),j=Boolean(null==u?void 0:u.isEditable),K=b%2==0,V="st-cell ".concat(M>0&&u.expandable?"st-cell-depth-".concat(M):""," ").concat(v?w?"st-cell-selected-first ".concat(d):"st-cell-selected ".concat(d):""," ").concat(K?"st-cell-odd-row":"st-cell-even-row"," ").concat(j?"clickable":"");a((function(){N(S.rowData[u.accessor])}),[u.accessor,S]);return B?n("div",g({className:"st-cell-editing ".concat(K?"st-cell-odd-row":"st-cell-even-row"),id:D({accessor:u.accessor,rowIndex:b+1})},{children:n(T,{onChange:function(e){N(e),null==m||m({accessor:u.accessor,newValue:e,row:S})},setIsEditing:W,value:k})})):e("div",g({className:V,id:z,onDoubleClick:function(){return u.isEditable&&W(!0)},onMouseDown:function(){return R({rowIndex:b,colIndex:c,rowId:S.rowMeta.rowId})},onMouseOver:function(){return I({rowIndex:b,colIndex:c,rowId:S.rowMeta.rowId})},onDragOver:function(e){return F({callback:P,callbackProps:{event:e,hoveredHeader:u},limit:50})},onKeyDown:function(e){"F2"!==e.key&&"Enter"!==e.key||!u.isEditable||B||(e.preventDefault(),W(!0))},ref:o,"data-row-index":b,"data-col-index":c,"aria-selected":v},{children:[u.expandable&&U?S.rowMeta.isExpanded?n("div",g({className:"st-sort-icon-container",onClick:function(){return p(S.rowMeta.rowId)}},{children:n(y,{className:"st-sort-icon"})})):n("div",g({className:"st-sort-icon-container",onClick:function(){return p(S.rowMeta.rowId)}},{children:n(x,{className:"st-sort-icon"})})):null,n("span",g({className:"st-cell-content ".concat("right"===u.align?"right-aligned":"center"===u.align?"center-aligned":"")},{children:u.cellRenderer?u.cellRenderer({accessor:u.accessor,colIndex:c,row:S}):k}))]}))})),F=function(e){var t=e.allowAnimations,o=e.children,i=w(e,["allowAnimations","children"]);return t?n(z,g({},i,{children:o})):n(r,{children:o})},z=function(e){var i=e.allowHorizontalAnimate,l=void 0===i||i,d=e.children,s=e.draggedHeaderRef,u=e.headersRef,f=e.isBody,h=e.mainBodyRef,v=e.pauseAnimation,g=e.rowIndex,w=o(!1),m=t({}),p=m[0],R=m[1],I=o({}),C=u.current;return c((function(){if(C){var e=function(e){var n=e.currentHeaders,r=e.draggedHeaderRef,t=e.rowIndex,o={};return n.forEach((function(e){var n;if(e){var i=document.getElementById(D({accessor:e.accessor,rowIndex:t}));if(i){var a=i.getAnimations().some((function(e){return"running"===e.playState})),l=i.getBoundingClientRect();a&&(null===(n=null==r?void 0:r.current)||void 0===n?void 0:n.accessor)!==e.accessor?o[e.accessor]=!1:o[e.accessor]=l}}})),o}({currentHeaders:C,draggedHeaderRef:s,rowIndex:g});JSON.stringify(e)!==JSON.stringify(p)&&(I.current=p,R(e))}}),[p,C,s,f,g]),c((function(){var e=h.current,n=function(){w.current=!0},r=function(){w.current=!1};return null==e||e.addEventListener("scroll",n),null==e||e.addEventListener("scrollend",r),function(){null==e||e.removeEventListener("scroll",n),null==e||e.removeEventListener("scrollend",r)}}),[s,h]),a((function(){v||w.current||Object.keys(I.current).length&&C&&C.forEach((function(e){var n=document.getElementById(D({accessor:e.accessor,rowIndex:g}));if(n){var r=I.current[e.accessor],t=p[e.accessor];if(r&&t){var o=r.left-t.left,i=l?0:r.top-t.top,a=Math.abs(o),d=Math.abs(i);(a>10||d>10)&&requestAnimationFrame((function(){n.style.transform="translate(".concat(o,"px, ").concat(i,"px)"),n.style.transition="transform 0s",requestAnimationFrame((function(){n.style.transform="",n.style.transition="transform ".concat(400,"ms ease-out")}))}))}}}))}),[l,p,C,f,v,I,g]),n(r,{children:d})},U=function(e){var r=e.getBorderClass,t=e.handleMouseDown,o=e.handleMouseOver,i=e.headers,a=e.hiddenColumns,l=e.isSelected,d=e.isInitialFocusedCell,c=e.onExpandRowClick,u=e.pinned,f=e.rowIndex,h=e.visibleRow,v=w(e,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isInitialFocusedCell","onExpandRowClick","pinned","rowIndex","visibleRow"]);return n(F,g({allowAnimations:v.allowAnimations,allowHorizontalAnimate:v.shouldPaginate,draggedHeaderRef:v.draggedHeaderRef,headersRef:v.headersRef,isBody:!0,mainBodyRef:v.mainBodyRef,pauseAnimation:v.isWidthDragging,rowIndex:f+1},{children:i.map((function(e,n){return S({hiddenColumns:a,header:e,pinned:u})?s(P,g({},v,{borderClass:r({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId}),colIndex:n,header:e,isSelected:l({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId}),isInitialFocusedCell:d({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId}),key:D({accessor:e.accessor,rowIndex:f+1}),onExpandRowClick:c,onMouseDown:function(){return t({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId})},onMouseOver:function(){return o({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId})},rowIndex:f,visibleRow:h})):null}))}))},j=function(e){var r=e.getNextRowIndex,t=e.gridTemplateColumns,o=e.index,i=e.pinned,a=e.props,l=e.rowHeight,d=e.visibleRow,c=d.position,s=r();return n("div",g({className:"st-table-row",style:{gridTemplateColumns:t,top:M({position:c,rowHeight:l}),height:"".concat(l,"px")}},{children:n(U,g({pinned:i,rowIndex:s,visibleRow:d},a),o)}))},K=function(e){var r=e.lastGroupRow,t=e.position,o=e.rowHeight,i=e.templateColumns;return n("div",g({className:"st-row-separator ".concat(r?"st-last-group-row":""),style:{display:"grid",gridTemplateColumns:i,position:"absolute",top:H({position:t,rowHeight:o}),minWidth:"100%"}},{children:n("div",{style:{gridColumn:"1 / -1"}})}))},V=function(r){r.headerContainerRef;var t=r.onExpandRowClick,i=r.pinned,l=r.rowHeight,d=r.sectionRef,c=r.templateColumns,s=r.totalHeight,f=r.visibleRows,h=r.width,v=w(r,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),m=i?"st-table-body-pinned-".concat(i):"st-table-body-main",p=o(0);a((function(){p.current=0}));var R=function(){return p.current++};return n("div",g({className:m,ref:d,style:{position:"relative",height:"".concat(s,"px"),width:h}},{children:f.map((function(r,o){var a,d,s=Boolean(null===(d=null===(a=r.row.rowMeta)||void 0===a?void 0:a.children)||void 0===d?void 0:d.length);return e(u,{children:[n(j,{getNextRowIndex:R,gridTemplateColumns:c,index:o,pinned:i,props:g(g({},v),{onExpandRowClick:t,rowHeight:l,visibleRows:f}),rowHeight:l,visibleRow:r}),0!==o&&n(K,{lastGroupRow:s,position:r.position,rowHeight:l,templateColumns:c})]},o)}))}))},J=function(r){var i,l,d,c,s,u=r.centerHeaderRef,f=r.flattenedRows,h=r.headerContainerRef,v=r.mainBodyRef,w=r.mainTemplateColumns,m=r.pinnedLeftColumns,p=r.pinnedLeftHeaderRef,R=r.pinnedLeftRef,I=r.pinnedLeftTemplateColumns,C=r.pinnedRightColumns,x=r.pinnedRightHeaderRef,b=r.pinnedRightRef,y=r.pinnedRightTemplateColumns,H=r.rowHeight,M=r.scrollbarWidth,D=r.setFlattenedRows,S=r.setScrollTop,E=r.tableBodyContainerRef,k=r.visibleRows;!function(e){var n=e.headerContainerRef,r=e.mainSectionRef,o=e.scrollbarWidth,i=t(!1),l=i[0],d=i[1];a((function(){var e=null==n?void 0:n.current;if(l&&e)return e.classList.add("st-header-scroll-padding"),e.style.setProperty("--st-after-width","".concat(o,"px")),function(){e.classList.remove("st-header-scroll-padding")}}),[n,l,o]),a((function(){var e=null==n?void 0:n.current,t=null==r?void 0:r.current;if(t&&e){var o=function(){if(t){var e=t.scrollHeight>t.clientHeight;d(e)}};o();var i=new ResizeObserver((function(){o()}));return i.observe(t),function(){t&&i.unobserve(t)}}}),[n,r])}({headerContainerRef:h,mainSectionRef:E,scrollbarWidth:M});var N,T,L=o(null),O=(N=0,(T=function(e){e.forEach((function(e){N+=1,e.rowMeta.isExpanded&&e.rowMeta.children&&T(e.rowMeta.children)}))})(f),N)*(H+1)-1,B=function(e){var n=function(r){return r.rowMeta.rowId===e&&r.rowMeta.children?g(g({},r),{rowMeta:g(g({},r.rowMeta),{isExpanded:!r.rowMeta.isExpanded})}):r.rowMeta.children?g(g({},r),{rowMeta:g(g({},r.rowMeta),{children:r.rowMeta.children.map(n)})}):r};D((function(e){return e.map(n)}))},W=(null===(i=p.current)||void 0===i?void 0:i.clientWidth)?(null===(l=p.current)||void 0===l?void 0:l.clientWidth)+1:0,A=null===(d=u.current)||void 0===d?void 0:d.clientWidth,P=(null===(c=x.current)||void 0===c?void 0:c.clientWidth)?(null===(s=x.current)||void 0===s?void 0:s.clientWidth)+1:0;return e("div",g({className:"st-table-body-container",ref:E,onScroll:function(e){var n=e.currentTarget.scrollTop;L.current&&cancelAnimationFrame(L.current),L.current=requestAnimationFrame((function(){S(n)}))}},{children:[m.length>0&&n(V,g({},r,{onExpandRowClick:B,pinned:"left",rowHeight:H,sectionRef:R,templateColumns:I,totalHeight:O,visibleRows:k,width:W})),n(V,g({},r,{onExpandRowClick:B,rowHeight:H,sectionRef:v,templateColumns:w,totalHeight:O,visibleRows:k,width:A})),C.length>0&&n(V,g({},r,{onExpandRowClick:B,pinned:"right",rowHeight:H,sectionRef:b,templateColumns:y,totalHeight:O,visibleRows:k,width:P}))]}))},X={string:function(e,n,r){if(e===n)return 0;var t=e.localeCompare(n);return"ascending"===r?t:-t},number:function(e,n,r){if(e===n)return 0;var t=e-n;return"ascending"===r?t:-t},boolean:function(e,n,r){if(e===n)return 0;var t=e===n?0:e?-1:1;return"ascending"===r?t:-t},date:function(e,n,r){var t=new Date(e),o=new Date(n);if(t.getTime()===o.getTime())return 0;var i=t.getTime()-o.getTime();return"ascending"===r?i:-i},enum:function(e,n,r){return X.string(e,n,r)},default:function(e,n,r){return e===n?0:null==e?"ascending"===r?-1:1:null==n?"ascending"===r?1:-1:"string"==typeof e&&"string"==typeof n?X.string(e,n,r):"number"==typeof e&&"number"==typeof n?X.number(e,n,r):"boolean"==typeof e&&"boolean"==typeof n?X.boolean(e,n,r):X.string(String(e),String(n),r)}},q=function(e,n,r,t){if(void 0===r&&(r="string"),null==e||""===e)return"ascending"===t?-1:1;if(null==n||""===n)return"ascending"===t?1:-1;if("number"===r){var o=function(e){var n;if("number"==typeof e)return e;var r=String(e);if("string"==typeof r){var t=r.replace(/[$,]/g,"").match(/^([-+]?\d*\.?\d+)([TBMKtbmk])?/);if(t){var o=parseFloat(t[1]),i=null===(n=t[2])||void 0===n?void 0:n.toUpperCase();return"T"===i?o*=1e12:"B"===i?o*=1e9:"M"===i?o*=1e6:"K"===i&&(o*=1e3),o}}return parseFloat(r)||0},i=o(e),a=o(n);return X.number(i,a,t)}return"date"===r?X.date(String(e),String(n),t):"boolean"===r?X.boolean(Boolean(e),Boolean(n),t):"enum"===r?X.enum(String(e),String(n),t):X.string(String(e),String(n),t)},Y=function(e,n,r){var t=r.find((function(e){return e.accessor===n.key.accessor})),o=(null==t?void 0:t.type)||"string",i=n.direction,a=new Map,l=new Map,d="";e.forEach((function(e){var r;if(e.rowData&&!e.rowData[n.key.accessor]&&void 0!==e.rowMeta.isExpanded){var t=(e.rowData.sector||"group_".concat(a.size)).toString();d=t,l.set(d,e),a.has(d)||a.set(d,[])}else if(d){var o=a.get(d)||[];o.push(e),a.set(d,o)}else{var i="default";a.has(i)||a.set(i,[]),null===(r=a.get(i))||void 0===r||r.push(e)}}));var c=[];return a.forEach((function(e,t){if(l.has(t)){var a=l.get(t);a.rowMeta.children&&a.rowMeta.children.length>0&&(a.rowMeta.children=G(a.rowMeta.children,n,r)),c.push(a)}var d=m([],e,!0).sort((function(e,r){if(!(null==e?void 0:e.rowData)||!(null==r?void 0:r.rowData))return 0;var t=n.key.accessor,a=e.rowData[t],l=r.rowData[t];return q(a,l,o,i)}));c.push.apply(c,d.map((function(e){var t=g({},e);if(t.rowMeta.children&&t.rowMeta.children.length>0){var o=G(t.rowMeta.children,n,r);t.rowMeta=g(g({},t.rowMeta),{children:o})}return t})))})),c},G=function(e,n,r){var t=r.find((function(e){return e.accessor===n.key.accessor})),o=(null==t?void 0:t.type)||"string",i=n.direction;return m([],e,!0).sort((function(e,r){if(!(null==e?void 0:e.rowData)||!(null==r?void 0:r.rowData))return 0;var t=n.key.accessor,a=e.rowData[t],l=r.rowData[t];return q(a,l,o,i)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?g(g({},e),{rowMeta:g(g({},e.rowMeta),{children:G(e.rowMeta.children,n,r)})}):e}))},$=function(e){var n=e.event,r=e.forceUpdate,t=e.header,o=e.headersRef,i=e.index;e.reverse;var a=e.setIsWidthDragging,l=e.startWidth;a(!0),n.preventDefault();var d=n.clientX;if(t){var c=function(e){var n=Math.max(l+(e.clientX-d),40);t&&o.current&&(o.current[i].width=n,r())},s=function(){document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",s),a(!1)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",s)}},_=d((function(r,o){var i,l=r.columnResizing,d=r.currentRows,c=r.columnReordering,s=r.draggedHeaderRef,u=r.forceUpdate,f=r.headersRef,h=r.hoveredHeaderRef,v=r.index,w=r.onColumnOrderChange,m=r.onSort,p=r.onTableHeaderDragEnd,I=r.reverse,C=r.rowHeight,x=r.selectableColumns,b=r.setIsWidthDragging,y=r.setSelectedCells,H=r.sort,M=r.sortDownIcon,S=r.sortUpIcon,E=t(!1),k=E[0],N=E[1],T=null===(i=f.current)||void 0===i?void 0:i[v],L=Boolean(null==T?void 0:T.isSortable),B="st-header-cell ".concat(T===h.current?"st-hovered":""," ").concat(k?"st-dragging":""," ").concat(L?"clickable":""," ").concat(c&&!L?"columnReordering":""," ").concat("right"===(null==T?void 0:T.align)?"right-aligned":"center"===(null==T?void 0:T.align)?"center-aligned":""),W=A({draggedHeaderRef:s,headersRef:f,hoveredHeaderRef:h,onColumnOrderChange:w,onTableHeaderDragEnd:p}),P=W.handleDragStart,F=W.handleDragEnd,z=W.handleDragOver,U=O(),j=function(e){var n=e.event,r=e.header;if(x){var t=d.length,o=Array.from({length:t},(function(e,n){return R({rowIndex:n,colIndex:v,rowId:d[n].rowMeta.rowId})})),i=function(e,n){var r=new Set,o=Math.min(e,n),i=Math.max(e,n);return Array.from({length:t}).forEach((function(e,n){Array.from({length:i-o+1}).forEach((function(e,t){r.add(R({rowIndex:n,colIndex:o+t,rowId:d[n].rowMeta.rowId}))}))})),r};n.shiftKey?y((function(e){var n,r=Number(null===(n=Array.from(e)[0])||void 0===n?void 0:n.split("-")[1]),t=Number(o[0].split("-")[1]);return r===t?new Set(o):r>t?i(t,r):i(r,t)})):y(new Set(o))}else r.isSortable&&m(v,r.accessor)};if(a((function(){var e=function(e){e.preventDefault(),e.dataTransfer.dropEffect="move"};return document.addEventListener("dragover",e),function(){document.removeEventListener("dragover",e)}}),[]),!T)return null;var K=l&&n("div",{className:"st-header-resize-handle",onMouseDown:function(e){var n;U({callback:$,callbackProps:{event:e,forceUpdate:u,header:T,headersRef:f,index:v,setIsWidthDragging:b,startWidth:"object"==typeof o&&null!==o&&"current"in o?null===(n=o.current)||void 0===n?void 0:n.offsetWidth:void 0},limit:10})}}),V=H&&H.key.accessor===T.accessor&&e("div",g({className:"st-sort-icon-container",onClick:function(e){return j({event:e,header:T})}},{children:["ascending"===H.direction&&S&&S,"descending"===H.direction&&M&&M]}));return e("div",g({className:B,id:D({accessor:T.accessor,rowIndex:0}),onDragOver:function(e){U({callback:z,callbackProps:{event:e,hoveredHeader:T},limit:50})},ref:o,style:{width:T.width,height:C}},{children:[I&&K,e("div",g({className:"st-header-label ".concat("right"===T.align?"right-aligned":"center"===T.align?"center-aligned":""),draggable:c,onClick:function(e){return j({event:e,header:T})},onDragEnd:function(e){e.preventDefault(),N(!1),F()},onDragStart:function(e){c&&T&&function(e){N(!0),P(e)}(T)}},{children:["right"===T.align&&V,null==T?void 0:T.label,"right"!==T.align&&V]})),!I&&K]}))})),Q=function(e,n){a((function(){if(e.current){var r=e.current,t=function(){var e,t=null==r?void 0:r.scrollLeft;void 0!==t&&(null===(e=n.current)||void 0===e||e.scrollTo(t,0))};return r.addEventListener("scroll",t),function(){null==r||r.removeEventListener("scroll",t)}}}),[e,n])},Z=function(r){var t,o,i,a=r.allowAnimations,l=r.centerHeaderRef,d=r.columnResizing,c=r.currentRows,s=r.columnReordering,u=r.draggedHeaderRef,h=r.forceUpdate,v=r.headerContainerRef,w=r.headersRef,m=r.hiddenColumns,p=r.hoveredHeaderRef,R=r.isWidthDragging,I=r.mainBodyRef,C=r.mainTemplateColumns,x=r.onColumnOrderChange,b=r.onSort,y=r.onTableHeaderDragEnd,H=r.pinnedLeftColumns,M=r.pinnedLeftHeaderRef,D=r.pinnedLeftTemplateColumns,E=r.pinnedRightColumns,k=r.pinnedRightHeaderRef,N=r.pinnedRightTemplateColumns,T=r.rowHeight,L=r.selectableColumns,O=r.setIsWidthDragging,B=r.setSelectedCells,W=r.sort,A=r.sortDownIcon,P=r.sortUpIcon;Q(I,l);return e("div",g({className:"st-header-container",ref:v},{children:[H.length>0&&n("div",g({className:"st-header-pinned-left",ref:M,style:{gridTemplateColumns:D}},{children:n(F,g({allowAnimations:a,draggedHeaderRef:u,headersRef:w,mainBodyRef:I,pauseAnimation:R,rowIndex:0},{children:null===(t=w.current)||void 0===t?void 0:t.map((function(e,r){return S({hiddenColumns:m,header:e,pinned:"left"})?n(_,{columnResizing:d,currentRows:c,columnReordering:s,draggedHeaderRef:u,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:r,onColumnOrderChange:x,onSort:b,onTableHeaderDragEnd:y,ref:f(),rowHeight:T,selectableColumns:L,setIsWidthDragging:O,setSelectedCells:B,sort:W,sortDownIcon:A,sortUpIcon:P},e.accessor):null}))}))})),n("div",g({className:"st-header-main",onScroll:function(e){var n,r,t=null===(n=l.current)||void 0===n?void 0:n.scrollLeft;void 0!==t&&(null===(r=I.current)||void 0===r||r.scrollTo(t,0))},ref:l,style:{gridTemplateColumns:C}},{children:n(F,g({allowAnimations:a,draggedHeaderRef:u,headersRef:w,mainBodyRef:I,pauseAnimation:R,rowIndex:0},{children:null===(o=w.current)||void 0===o?void 0:o.map((function(e,r){return S({hiddenColumns:m,header:e})?n(_,{columnResizing:d,currentRows:c,columnReordering:s,draggedHeaderRef:u,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:r,onColumnOrderChange:x,onSort:b,onTableHeaderDragEnd:y,ref:f(),rowHeight:T,selectableColumns:L,setIsWidthDragging:O,setSelectedCells:B,sort:W,sortDownIcon:A,sortUpIcon:P},e.accessor):null}))}))})),E.length>0&&n("div",g({className:"st-header-pinned-right",ref:k,style:{gridTemplateColumns:N}},{children:n(F,g({allowAnimations:a,draggedHeaderRef:u,headersRef:w,mainBodyRef:I,pauseAnimation:R,rowIndex:0},{children:null===(i=w.current)||void 0===i?void 0:i.map((function(e,r){return S({hiddenColumns:m,header:e,pinned:"right"})?n(_,{columnResizing:d,currentRows:c,columnReordering:s,draggedHeaderRef:u,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:r,onColumnOrderChange:x,onSort:b,onTableHeaderDragEnd:y,reverse:!0,ref:f(),rowHeight:T,selectableColumns:L,setIsWidthDragging:O,setSelectedCells:B,sort:W,sortDownIcon:A,sortUpIcon:P},e.accessor):null}))}))}))]}))},ee=function(e){var n=e.minWidth,r=e.width;return"number"==typeof r&&(r="".concat(r,"px")),n&&"number"==typeof n&&(n="".concat(n,"px")),void 0!==n?"minmax(".concat(n,", ").concat(r,")"):r},ne=function(r){var t=r.allowAnimations,i=r.columnReordering,a=r.columnResizing,d=r.currentRows,c=r.draggedHeaderRef,s=r.editColumns,u=r.flattenedRows,f=r.forceUpdate,h=r.getBorderClass,v=r.handleMouseDown,w=r.handleMouseOver,m=r.headersRef,p=r.hiddenColumns,R=r.hoveredHeaderRef,I=r.isSelected,C=r.isInitialFocusedCell,x=r.isWidthDragging,b=r.mainBodyRef,y=r.onCellEdit,H=r.onColumnOrderChange,M=r.onSort,D=r.onTableHeaderDragEnd,S=r.pinnedLeftRef,E=r.pinnedRightRef,k=r.rowHeight,N=r.scrollbarWidth,T=r.selectableColumns,L=r.setIsWidthDragging,O=r.setFlattenedRows,B=r.setScrollTop,W=r.setSelectedCells,A=r.shouldPaginate,P=r.sort,F=r.sortDownIcon,z=r.sortUpIcon,U=r.tableBodyContainerRef,j=r.visibleRows,K=o(null),V=o(null),X=o(null),q=o(null),Y=m.current.filter((function(e){return!e.hide&&!e.pinned})),G=m.current.filter((function(e){return"left"===e.pinned&&!0!==e.hide})),$=m.current.filter((function(e){return"right"===e.pinned&&!0!==e.hide})),_=l((function(){return"".concat(G.map((function(e){return ee(e)})).join(" "))}),[G]),Q=l((function(){return"".concat(Y.filter((function(e){return!0!==p[e.accessor]})).map((function(e){return ee(e)})).join(" "))}),[Y,p]),ne=l((function(){return"".concat($.map((function(e){return ee(e)})).join(" "))}),[$]),re={allowAnimations:t,centerHeaderRef:X,columnResizing:a,currentRows:d,columnReordering:i,draggedHeaderRef:c,forceUpdate:f,headerContainerRef:K,headersRef:m,hiddenColumns:p,hoveredHeaderRef:R,isWidthDragging:x,mainBodyRef:b,mainTemplateColumns:Q,onColumnOrderChange:H,onSort:M,onTableHeaderDragEnd:D,pinnedLeftColumns:G,pinnedLeftHeaderRef:V,pinnedLeftTemplateColumns:_,pinnedRightColumns:$,pinnedRightHeaderRef:q,pinnedRightTemplateColumns:ne,rowHeight:k,selectableColumns:T,setIsWidthDragging:L,setSelectedCells:W,sort:P,sortDownIcon:F,sortUpIcon:z,tableBodyContainerRef:U},te={allowAnimations:t,centerHeaderRef:X,draggedHeaderRef:c,flattenedRows:u,getBorderClass:h,handleMouseDown:v,handleMouseOver:w,headerContainerRef:K,headers:m.current,headersRef:m,hiddenColumns:p,hoveredHeaderRef:R,isSelected:I,isInitialFocusedCell:C,isWidthDragging:x,mainBodyRef:b,mainTemplateColumns:Q,onCellEdit:y,onTableHeaderDragEnd:D,pinnedLeftColumns:G,pinnedLeftHeaderRef:V,pinnedLeftRef:S,pinnedLeftTemplateColumns:_,pinnedRightColumns:$,pinnedRightHeaderRef:q,pinnedRightRef:E,pinnedRightTemplateColumns:ne,rowHeight:k,scrollbarWidth:N,setFlattenedRows:O,shouldPaginate:A,setScrollTop:B,tableBodyContainerRef:U,visibleRows:j};return e("div",g({className:"st-table-content",style:{width:s?"calc(100% - 27.5px)":"100%"}},{children:[n(Z,g({},re)),n(J,g({},te))]}))},re=function(e){var n=e.callback,r=e.ref,t=e.widthAttribute;a((function(){var e=r.current;if(e){var o=function(){n(e[t]||0)};o();var i=new ResizeObserver((function(){o()}));return i.observe(e),function(){return i.disconnect()}}}),[n,r,t])},te=function(r){var i=r.mainBodyRef,a=r.pinnedLeftRef,l=r.pinnedRightRef,d=r.tableContentWidth,c=t(0),s=c[0],u=c[1],f=t(0),h=f[0],v=f[1],w=t(0),m=w[0],p=w[1],R=o(null);return re({widthAttribute:"offsetWidth",callback:u,ref:a}),re({widthAttribute:"scrollWidth",callback:p,ref:i}),re({widthAttribute:"offsetWidth",callback:v,ref:l}),Q(i,R),!i.current||i.current.scrollWidth<=i.current.clientWidth?null:e("div",g({className:"st-horizontal-scrollbar-container",style:{width:d}},{children:[s>0&&n("div",{className:"st-horizontal-scrollbar-left",style:{flexShrink:0,width:s}}),m>0&&n("div",g({className:"st-horizontal-scrollbar-middle",onScroll:function(e){var n=e.target.scrollLeft;void 0!==n&&i.current&&i.current.scrollTo({left:n,behavior:"auto"})},ref:R},{children:n("div",{style:{width:m}})})),h>0&&n("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:h}})]}))},oe=function(e){var n=e.headers,r=e.tableRows,o=t(null),i=o[0],a=o[1],d=l((function(){var e={};return n.forEach((function(n){!0===n.hide&&(e[n.accessor]=!0)})),e}),[n]),c=t(d),s=c[0],u=c[1],f=l((function(){if(!i)return r;var e=function(e,n,r){return{sortedData:Y(n,r,e),newSortConfig:r}}(n,r,i).sortedData;return e}),[r,i,n]);return{sort:i,setSort:a,updateSort:function(e,r){var t=n.find((function(e){return e.accessor===r}));t&&a((function(e){return e&&e.key.accessor===r?"ascending"===e.direction?{key:t,direction:"descending"}:null:{key:t,direction:"ascending"}}))},sortedRows:f,hiddenColumns:s,setHiddenColumns:u}},ie=function(r){var o=r.checked,i=void 0!==o&&o,a=r.children,l=r.onChange,d=t(i),c=d[0],s=d[1];return e("label",g({className:"st-checkbox-label"},{children:[n("input",{checked:c,className:"st-checkbox-input",onChange:function(){var e=!c;s(e),l&&l(e)},type:"checkbox"}),n("span",g({className:"st-checkbox-custom ".concat(c?"st-checked":"")},{children:c&&n("span",{className:"st-checkbox-checkmark"})})),a]}))},ae=function(e){var r=e.headers,t=e.open,o=e.position;e.setOpen;var i=e.setHiddenColumns,a=e.hiddenColumns,l="left"===o?"left":"";return n("div",g({className:"st-column-editor-popout ".concat(t?"open":""," ").concat(l),onClick:function(e){return e.stopPropagation()}},{children:n("div",g({className:"st-column-editor-popout-content"},{children:r.map((function(e,r){return n(ie,g({checked:a[e.accessor],onChange:function(n){var r;return i(g(g({},a),((r={})[e.accessor]=n,r)))}},{children:e.label}),r)}))}))}))},le=function(r){var o=r.columnEditorText,i=r.editColumns,a=r.editColumnsInitOpen,l=r.headers,d=r.position,c=void 0===d?"right":d,s=r.setHiddenColumns,u=r.hiddenColumns,f=t(a),h=f[0],v=f[1];return i?e("div",g({className:"st-column-editor ".concat(h?"open":""," ").concat(c),onClick:function(){return function(e){v(e)}(!h)}},{children:[n("div",g({className:"st-column-editor-text"},{children:o})),n(ae,{headers:l,open:h,position:c,setOpen:v,setHiddenColumns:s,hiddenColumns:u})]})):null};!function(e){e.Left="left",e.Right="right"}(p||(p={}));var de=h((function(r){var d=r.allowAnimations,s=void 0!==d&&d,u=r.columnEditorPosition,f=void 0===u?p.Right:u,h=r.columnEditorText,w=void 0===h?"Columns":h,m=r.columnResizing,H=void 0!==m&&m,M=r.defaultHeaders,D=r.editColumns,S=void 0!==D&&D,E=r.editColumnsInitOpen,k=void 0!==E&&E,N=r.columnReordering,T=void 0!==N&&N,L=r.height,O=r.hideFooter,B=void 0!==O&&O,W=r.nextIcon,A=void 0===W?n(x,{className:"st-next-prev-icon"}):W,P=r.onCellEdit,F=r.onColumnOrderChange,z=r.onNextPage,U=r.onPreviousPage,j=r.prevIcon,K=void 0===j?n(C,{className:"st-next-prev-icon"}):j,V=r.rowHeight,J=void 0===V?40:V,X=r.rows,q=r.rowsPerPage,Y=void 0===q?10:q,G=r.selectableCells,$=void 0!==G&&G,_=r.selectableColumns,Q=void 0!==_&&_,Z=r.shouldPaginate,ee=void 0!==Z&&Z,re=r.sortDownIcon,ie=void 0===re?n(y,{className:"st-sort-icon"}):re,ae=r.sortUpIcon,de=void 0===ae?n(b,{className:"st-sort-icon"}):ae,ce=r.theme,se=void 0===ce?"light":ce,ue=r.totalPages,fe=o(null),he=o(M),ve=o(null),ge=o(null),we=o(null),me=o(null),pe=o(null),Re=t(!1),Ie=Re[0],Ce=Re[1],xe=t(1),be=xe[0],ye=xe[1],He=t(0),Me=He[0],De=He[1],Se=t(0),Ee=Se[0],ke=Se[1],Ne=t(0),Te=Ne[0],Le=Ne[1],Oe=oe({headers:he.current,tableRows:X}),Be=Oe.sort,We=Oe.sortedRows,Ae=Oe.hiddenColumns,Pe=Oe.setHiddenColumns,Fe=Oe.updateSort,ze=l((function(){if(!ee)return We;var e=(be-1)*Y,n=e+Y;return We.slice(e,n)}),[be,Y,ee,We]),Ue=t(ze),je=Ue[0],Ke=Ue[1];a((function(){Ke(ze)}),[ze]);var Ve=l((function(){var e;if(!L)return window.innerHeight-J;var n=document.querySelector(".simple-table-root"),r=0;if(L.endsWith("px"))r=parseInt(L,10);else if(L.endsWith("vh")){var t=parseInt(L,10);r=window.innerHeight*t/100}else if(L.endsWith("%")){var o=parseInt(L,10);r=((null===(e=null==n?void 0:n.parentElement)||void 0===e?void 0:e.clientHeight)||window.innerHeight)*o/100}else r=window.innerHeight;return Math.max(0,r-J)}),[L,J]),Je=l((function(){return function(e){var n=e.bufferRowCount,r=e.contentHeight,t=e.flattenedRows,o=e.rowHeight,i=e.scrollTop,a=[],l=0,d=Math.max(0,i-o*n),c=i+r+o*n,s=function(e,n){for(var r,t=0,i=e;t<i.length;t++){var u=i[t],f=l*o;if(f>=c)break;f+o>d&&a.push({row:u,depth:n,position:l,isLastGroupRow:Boolean(null===(r=u.rowMeta.children)||void 0===r?void 0:r.length)&&n>1}),l+=1,u.rowMeta.isExpanded&&u.rowMeta.children&&s(u.rowMeta.children,n+1)}};return s(t,0),a}({bufferRowCount:5,contentHeight:Ve,flattenedRows:je,rowHeight:J,scrollTop:Te})}),[Ve,J,je,Te]),Xe=v((function(e){return e+1}),0)[1],qe=function(e){var n=e.selectableCells,r=e.headers,d=e.visibleRows,c=t(new Set),s=c[0],u=c[1],f=t(null),h=f[0],v=f[1],g=o(!1),w=o(null),m=i((function(){var e=Array.from(s).reduce((function(e,n){var t=n.split("-").map(Number),o=t[0],i=t[1];return e[o]||(e[o]=[]),e[o][i]=d[o].row.rowData[r[i].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");s.size>0&&navigator.clipboard.writeText(n)}),[r,s,d]),p=i((function(e,n){for(var r=new Set,t=Math.min(e.rowIndex,n.rowIndex),o=Math.max(e.rowIndex,n.rowIndex),i=Math.min(e.colIndex,n.colIndex),a=Math.max(e.colIndex,n.colIndex),l=t;l<=o;l++)for(var c=i;c<=a;c++)if(l>=0&&l<d.length){var s=d[l].row.rowMeta.rowId;r.add(R({colIndex:c,rowIndex:l,rowId:s}))}u(r)}),[d]),I=i((function(e){if(e.rowIndex>=0&&e.rowIndex<d.length&&e.colIndex>=0&&e.colIndex<r.length){var n=R(e);u(new Set([n])),v(e)}}),[r.length,d.length]);a((function(){var e=function(e){if(n&&h){var t=h.rowIndex,o=h.colIndex,i=h.rowId;if(!e.ctrlKey&&!e.metaKey||"c"!==e.key){if(d[t].row.rowMeta.rowId!==i){var a=d.findIndex((function(e){return e.row.rowMeta.rowId===i}));if(-1===a)return;t=a}if("ArrowUp"===e.key){if(e.preventDefault(),t>0){var l={rowIndex:t-1,colIndex:o,rowId:d[t-1].row.rowMeta.rowId};I(l)}}else"ArrowDown"===e.key?(e.preventDefault(),t<d.length-1&&(l={rowIndex:t+1,colIndex:o,rowId:d[t+1].row.rowMeta.rowId},I(l))):"ArrowLeft"===e.key||"Tab"===e.key&&e.shiftKey?(e.preventDefault(),o>0&&(l={rowIndex:t,colIndex:o-1,rowId:d[t].row.rowMeta.rowId},I(l))):"ArrowRight"===e.key||"Tab"===e.key?(e.preventDefault(),o<r.length-1&&(l={rowIndex:t,colIndex:o+1,rowId:d[t].row.rowMeta.rowId},I(l))):"Escape"===e.key&&(u(new Set),w.current=null,v(null))}else m()}};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[m,r.length,h,p,I,n,d]);var C=i((function(e){var n=e.colIndex,r=e.rowIndex,t=e.rowId,o=R({colIndex:n,rowIndex:r,rowId:t});return s.has(o)}),[s]),x=i((function(e){var n,r,t,o,i,a,l=e.colIndex,c=e.rowIndex,s=e.rowId,u=[],f=null===(t=null===(r=null===(n=d[c-1])||void 0===n?void 0:n.row)||void 0===r?void 0:r.rowMeta)||void 0===t?void 0:t.rowId,h={colIndex:l,rowIndex:c+1,rowId:null===(a=null===(i=null===(o=d[c+1])||void 0===o?void 0:o.row)||void 0===i?void 0:i.rowMeta)||void 0===a?void 0:a.rowId},v={colIndex:l-1,rowIndex:c,rowId:s},g={colIndex:l+1,rowIndex:c,rowId:s};return C({colIndex:l,rowIndex:c-1,rowId:f})||u.push("st-selected-top-border"),C(h)||u.push("st-selected-bottom-border"),C(v)||u.push("st-selected-left-border"),C(g)||u.push("st-selected-right-border"),u.join(" ")}),[C,d]),b=l((function(){return h?function(e){var n=e.rowIndex,r=e.colIndex,t=e.rowId;return n===h.rowIndex&&r===h.colIndex&&t===h.rowId}:function(){return!1}}),[h]);return{getBorderClass:x,handleMouseDown:function(e){var r=e.colIndex,t=e.rowIndex,o=e.rowId;if(n){g.current=!0,w.current={rowIndex:t,colIndex:r,rowId:o};var i=R({colIndex:r,rowIndex:t,rowId:o});u(new Set([i])),v({rowIndex:t,colIndex:r,rowId:o})}},handleMouseOver:function(e){var r=e.colIndex,t=e.rowIndex;if(e.rowId,n&&g.current&&w.current){for(var o=new Set,i=Math.min(w.current.rowIndex,t),a=Math.max(w.current.rowIndex,t),l=Math.min(w.current.colIndex,r),c=Math.max(w.current.colIndex,r),s=i;s<=a;s++)for(var f=l;f<=c;f++)if(s>=0&&s<d.length){var h=d[s].row.rowMeta.rowId;o.add(R({colIndex:f,rowIndex:s,rowId:h}))}u(o)}},handleMouseUp:function(){g.current=!1},isInitialFocusedCell:b,isSelected:C,selectedCells:s,setSelectedCells:u}}({selectableCells:$,headers:he.current,visibleRows:Je}),Ye=qe.handleMouseDown,Ge=qe.handleMouseOver,$e=qe.handleMouseUp,_e=qe.isSelected,Qe=qe.getBorderClass,Ze=qe.isInitialFocusedCell,en=qe.setSelectedCells,nn=i((function(e,n){Fe(e,n)}),[Fe]),rn=i((function(e){he.current=e,Xe()}),[]);return a((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||Q&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||en(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[Q,en]),c((function(){if(pe.current){var e=pe.current.offsetWidth-pe.current.clientWidth,n=pe.current.clientWidth;De(e),ke(n)}}),[]),c((function(){var e=function(){if(Xe(),pe.current){var e=pe.current.offsetWidth-pe.current.clientWidth,n=pe.current.clientWidth;De(e),ke(n)}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),e("div",g({className:"simple-table-root st-wrapper theme-".concat(se),style:L?{height:L}:{}},{children:[e("div",g({className:"st-table-wrapper-container"},{children:[e("div",g({className:"st-table-wrapper",onMouseUp:$e,onMouseLeave:$e},{children:[n(ne,{allowAnimations:s,columnReordering:T,columnResizing:H,currentRows:ze,draggedHeaderRef:fe,editColumns:S,flattenedRows:je,forceUpdate:Xe,getBorderClass:Qe,handleMouseDown:Ye,handleMouseOver:Ge,headers:he.current,headersRef:he,hiddenColumns:Ae,hoveredHeaderRef:ve,isInitialFocusedCell:Ze,isSelected:_e,isWidthDragging:Ie,mainBodyRef:ge,onCellEdit:P,onColumnOrderChange:F,onSort:nn,onTableHeaderDragEnd:rn,pinnedLeftRef:we,pinnedRightRef:me,rowHeight:J,scrollbarWidth:Me,selectableColumns:Q,setIsWidthDragging:Ce,setFlattenedRows:Ke,setScrollTop:Le,setSelectedCells:en,shouldPaginate:ee,sort:Be,sortDownIcon:ie,sortUpIcon:de,tableBodyContainerRef:pe,visibleRows:Je}),n(le,{columnEditorText:w,editColumns:S,editColumnsInitOpen:k,headers:he.current,hiddenColumns:Ae,position:f,setHiddenColumns:Pe})]})),n(te,{mainBodyRef:ge,pinnedLeftRef:we,pinnedRightRef:me,tableContentWidth:Ee})]})),n(I,{currentPage:be,hideFooter:B,nextIcon:A,onPageChange:ye,onNextPage:z,onPreviousPage:U,prevIcon:K,shouldPaginate:ee,totalPages:ue||Math.ceil(We.length/Y)})]}))}));export{de as SimpleTable};
1
+ import{jsxs as e,jsx as n,Fragment as r}from"react/jsx-runtime";import{useState as t,useRef as o,useCallback as i,useEffect as a,useMemo as l,forwardRef as d,useLayoutEffect as c,createElement as s,Fragment as u,createRef as f,memo as h,useReducer as v}from"react";var g=function(){return g=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},g.apply(this,arguments)};function w(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]])}return r}function m(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var p,R=function(e){var n=e.rowIndex,r=e.colIndex,t=e.rowId;return"".concat(n,"-").concat(r,"-").concat(t)},I=function(r){var t=r.currentPage,o=r.hideFooter,i=r.nextIcon,a=r.onPageChange,l=r.onNextPage,d=r.onPreviousPage,c=r.prevIcon,s=r.shouldPaginate,u=r.totalPages;if(o||!s)return null;var f=!(t>1)&&!d,h=!(t<u)&&!l;return e("div",g({className:"st-footer"},{children:[n("button",g({className:"st-next-prev-btn ".concat(f?"disabled":""),onClick:function(){var e=t-1;e>=1&&a(e),d&&d(e-1)},disabled:f},{children:c})),n("button",g({className:"st-next-prev-btn ".concat(h?"disabled":""),onClick:function(){var e=t+1;(e<=u||l)&&a(e),l&&l(t)},disabled:h},{children:i})),Array.from({length:u},(function(e,r){return n("button",g({onClick:function(){var e;(e=r+1)>=1&&e<=u&&(a(e),e>t&&l?l(e-1):e<t&&d&&d(e-1))},className:"st-page-btn ".concat(t===r+1?"active":"")},{children:r+1}),r)}))]}))},C=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})}))},x=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})}))},b=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M5.41 11.41L10 6.83l4.59 4.58L16 10l-6-6-6 6z"})}))},y=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M5.41 7.59L10 12.17l4.59-4.58L16 9l-6 6-6-6z"})}))},H=function(e){return e.position*(e.rowHeight+1)-1},M=function(e){return e.position*(e.rowHeight+1)},D=function(e){var n=e.accessor,r=e.rowIndex;return"cell-".concat(n,"-").concat(r)},S=function(e){var n=e.hiddenColumns,r=e.header,t=e.pinned;return n[r.accessor]?null:!t&&!r.pinned||r.pinned===t||null},E=function(r){var t=r.value,o=r.onBlur,i=r.onChange;return e("select",g({value:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;i("true"===n)}},{children:[n("option",g({value:"true"},{children:"True"})),n("option",g({value:"false"},{children:"False"}))]}))},k=function(e){var r=e.defaultValue,t=e.onBlur,i=e.onChange,a=o(null);return n("input",{className:"editable-cell-input",ref:a,autoFocus:!0,type:"text",defaultValue:null!=r?r:"",onBlur:t,onChange:function(e){var n=e.target.value;i(n)}})},N=function(e){var r=e.defaultValue,t=e.onBlur,i=e.onChange,a=o(null);return n("input",{className:"editable-cell-input",ref:a,autoFocus:!0,defaultValue:r.toString(),onBlur:t,onChange:function(e){var n=e.target.value;/^\d*\.?\d*$/.test(n)&&i(n)}})},T=function(e){var t=e.onChange,o=e.setIsEditing,i=e.value,a=function(e){null==t||t(e)},l=function(){o(!1)};return n(r,{children:"string"==typeof i||null==i?n(k,{defaultValue:i,onBlur:l,onChange:a}):"boolean"==typeof i?n(E,{onBlur:l,onChange:a,value:i}):"number"==typeof i?n(N,{defaultValue:i,onBlur:l,onChange:a}):null})},L=0,O=function(){return function(e){var n=e.callback,r=e.callbackProps,t=e.limit,o=Date.now();(0===L||o-L>=t)&&(L=o,n(r))}},B=Date.now(),W={screenX:0,screenY:0},A=function(e){var n,r,t=e.draggedHeaderRef,i=e.headersRef,l=e.hoveredHeaderRef,d=e.onColumnOrderChange,c=e.onTableHeaderDragEnd,s=(n=i.current,r=o(n),a((function(){r.current=n}),[n]),r.current);return{handleDragStart:function(e){t.current=e,B=Date.now()},handleDragOver:function(e){var n,r=e.event,o=e.hoveredHeader;if(r.preventDefault(),i.current){var a=r.currentTarget.getAnimations().some((function(e){return"running"===e.playState})),d=r.screenX,u=r.screenY,f=Math.sqrt(Math.pow(d-W.screenX,2)+Math.pow(u-W.screenY,2));l.current=o;var h=m([],i.current,!0),v=h.findIndex((function(e){var n;return e.accessor===(null===(n=t.current)||void 0===n?void 0:n.accessor)})),g=h.findIndex((function(e){return e.accessor===o.accessor})),w=h.splice(v,1)[0];if(h.splice(g,0,w),!(a||o.accessor===(null===(n=t.current)||void 0===n?void 0:n.accessor)||null===t.current||f<10||void 0===v||void 0===g||JSON.stringify(h)===JSON.stringify(i.current))){var p=Date.now();JSON.stringify(h)===JSON.stringify(s)&&p-B<800&&f<50||(B=p,W={screenX:d,screenY:u},c(h))}}},handleDragEnd:function(){t.current=null,l.current=null,null==d||d(i.current)}}},P=d((function(r,o){var i,l,d=r.borderClass,c=r.colIndex,s=r.draggedHeaderRef,u=r.header,f=r.headersRef,h=r.hoveredHeaderRef,v=r.isSelected,w=r.isInitialFocusedCell,m=r.onCellEdit,p=r.onExpandRowClick,R=r.onMouseDown,I=r.onMouseOver,C=r.onTableHeaderDragEnd,b=r.rowIndex,H=r.visibleRow,M=H.depth,S=H.row,E=t(S.rowData[u.accessor]),k=E[0],N=E[1],L=t(!1),B=L[0],W=L[1],P=A({draggedHeaderRef:s,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:C}).handleDragOver,F=O(),z="cell-".concat(b,"-").concat(c),U=Boolean(null===(l=null===(i=S.rowMeta)||void 0===i?void 0:i.children)||void 0===l?void 0:l.length),j=Boolean(null==u?void 0:u.isEditable),K=b%2==0,V="st-cell ".concat(M>0&&u.expandable?"st-cell-depth-".concat(M):""," ").concat(v?w?"st-cell-selected-first ".concat(d):"st-cell-selected ".concat(d):""," ").concat(K?"st-cell-odd-row":"st-cell-even-row"," ").concat(j?"clickable":"");a((function(){N(S.rowData[u.accessor])}),[u.accessor,S]);return B?n("div",g({className:"st-cell-editing ".concat(K?"st-cell-odd-row":"st-cell-even-row"),id:D({accessor:u.accessor,rowIndex:b+1})},{children:n(T,{onChange:function(e){N(e),null==m||m({accessor:u.accessor,newValue:e,row:S})},setIsEditing:W,value:k})})):e("div",g({className:V,id:z,onDoubleClick:function(){return u.isEditable&&W(!0)},onMouseDown:function(){return R({rowIndex:b,colIndex:c,rowId:S.rowMeta.rowId})},onMouseOver:function(){return I({rowIndex:b,colIndex:c,rowId:S.rowMeta.rowId})},onDragOver:function(e){return F({callback:P,callbackProps:{event:e,hoveredHeader:u},limit:50})},onKeyDown:function(e){"F2"!==e.key&&"Enter"!==e.key||!u.isEditable||B||(e.preventDefault(),W(!0))},ref:o,"data-row-index":b,"data-col-index":c,"aria-selected":v},{children:[u.expandable&&U?S.rowMeta.isExpanded?n("div",g({className:"st-sort-icon-container",onClick:function(){return p(S.rowMeta.rowId)}},{children:n(y,{className:"st-sort-icon"})})):n("div",g({className:"st-sort-icon-container",onClick:function(){return p(S.rowMeta.rowId)}},{children:n(x,{className:"st-sort-icon"})})):null,n("span",g({className:"st-cell-content ".concat("right"===u.align?"right-aligned":"center"===u.align?"center-aligned":"")},{children:u.cellRenderer?u.cellRenderer({accessor:u.accessor,colIndex:c,row:S}):k}))]}))})),F=function(e){var t=e.allowAnimations,o=e.children,i=w(e,["allowAnimations","children"]);return t?n(z,g({},i,{children:o})):n(r,{children:o})},z=function(e){var i=e.allowHorizontalAnimate,l=void 0===i||i,d=e.children,s=e.draggedHeaderRef,u=e.headersRef,f=e.isBody,h=e.mainBodyRef,v=e.pauseAnimation,g=e.rowIndex,w=o(!1),m=t({}),p=m[0],R=m[1],I=o({}),C=u.current;return c((function(){if(C){var e=function(e){var n=e.currentHeaders,r=e.draggedHeaderRef,t=e.rowIndex,o={};return n.forEach((function(e){var n;if(e){var i=document.getElementById(D({accessor:e.accessor,rowIndex:t}));if(i){var a=i.getAnimations().some((function(e){return"running"===e.playState})),l=i.getBoundingClientRect();a&&(null===(n=null==r?void 0:r.current)||void 0===n?void 0:n.accessor)!==e.accessor?o[e.accessor]=!1:o[e.accessor]=l}}})),o}({currentHeaders:C,draggedHeaderRef:s,rowIndex:g});JSON.stringify(e)!==JSON.stringify(p)&&(I.current=p,R(e))}}),[p,C,s,f,g]),c((function(){var e=h.current,n=function(){w.current=!0},r=function(){w.current=!1};return null==e||e.addEventListener("scroll",n),null==e||e.addEventListener("scrollend",r),function(){null==e||e.removeEventListener("scroll",n),null==e||e.removeEventListener("scrollend",r)}}),[s,h]),a((function(){v||w.current||Object.keys(I.current).length&&C&&C.forEach((function(e){var n=document.getElementById(D({accessor:e.accessor,rowIndex:g}));if(n){var r=I.current[e.accessor],t=p[e.accessor];if(r&&t){var o=r.left-t.left,i=l?0:r.top-t.top,a=Math.abs(o),d=Math.abs(i);(a>10||d>10)&&requestAnimationFrame((function(){n.style.transform="translate(".concat(o,"px, ").concat(i,"px)"),n.style.transition="transform 0s",requestAnimationFrame((function(){n.style.transform="",n.style.transition="transform ".concat(400,"ms ease-out")}))}))}}}))}),[l,p,C,f,v,I,g]),n(r,{children:d})},U=function(e){var r=e.getBorderClass,t=e.handleMouseDown,o=e.handleMouseOver,i=e.headers,a=e.hiddenColumns,l=e.isSelected,d=e.isInitialFocusedCell,c=e.onExpandRowClick,u=e.pinned,f=e.rowIndex,h=e.visibleRow,v=w(e,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isInitialFocusedCell","onExpandRowClick","pinned","rowIndex","visibleRow"]);return n(F,g({allowAnimations:v.allowAnimations,allowHorizontalAnimate:v.shouldPaginate,draggedHeaderRef:v.draggedHeaderRef,headersRef:v.headersRef,isBody:!0,mainBodyRef:v.mainBodyRef,pauseAnimation:v.isWidthDragging,rowIndex:f+1},{children:i.map((function(e,n){return S({hiddenColumns:a,header:e,pinned:u})?s(P,g({},v,{borderClass:r({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId}),colIndex:n,header:e,isSelected:l({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId}),isInitialFocusedCell:d({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId}),key:D({accessor:e.accessor,rowIndex:f+1}),onExpandRowClick:c,onMouseDown:function(){return t({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId})},onMouseOver:function(){return o({rowIndex:f,colIndex:n,rowId:h.row.rowMeta.rowId})},rowIndex:f,visibleRow:h})):null}))}))},j=function(e){var r=e.getNextRowIndex,t=e.gridTemplateColumns,o=e.index,i=e.pinned,a=e.props,l=e.rowHeight,d=e.visibleRow,c=d.position,s=r();return n("div",g({className:"st-table-row",style:{gridTemplateColumns:t,top:M({position:c,rowHeight:l}),height:"".concat(l,"px")}},{children:n(U,g({pinned:i,rowIndex:s,visibleRow:d},a),o)}))},K=function(e){var r=e.lastGroupRow,t=e.position,o=e.rowHeight,i=e.templateColumns;return n("div",g({className:"st-row-separator ".concat(r?"st-last-group-row":""),style:{display:"grid",gridTemplateColumns:i,position:"absolute",top:H({position:t,rowHeight:o}),minWidth:"100%"}},{children:n("div",{style:{gridColumn:"1 / -1"}})}))},V=function(r){r.headerContainerRef;var t=r.onExpandRowClick,i=r.pinned,l=r.rowHeight,d=r.sectionRef,c=r.templateColumns,s=r.totalHeight,f=r.visibleRows,h=r.width,v=w(r,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),m=i?"st-table-body-pinned-".concat(i):"st-table-body-main",p=o(0);a((function(){p.current=0}));var R=function(){return p.current++};return n("div",g({className:m,ref:d,style:{position:"relative",height:"".concat(s,"px"),width:h}},{children:f.map((function(r,o){var a,d,s=Boolean(null===(d=null===(a=r.row.rowMeta)||void 0===a?void 0:a.children)||void 0===d?void 0:d.length);return e(u,{children:[n(j,{getNextRowIndex:R,gridTemplateColumns:c,index:o,pinned:i,props:g(g({},v),{onExpandRowClick:t,rowHeight:l,visibleRows:f}),rowHeight:l,visibleRow:r}),0!==o&&n(K,{lastGroupRow:s,position:r.position,rowHeight:l,templateColumns:c})]},o)}))}))},J=function(r){var i,l,d,c,s,u=r.centerHeaderRef,f=r.flattenedRows,h=r.headerContainerRef,v=r.mainBodyRef,w=r.mainTemplateColumns,m=r.pinnedLeftColumns,p=r.pinnedLeftHeaderRef,R=r.pinnedLeftRef,I=r.pinnedLeftTemplateColumns,C=r.pinnedRightColumns,x=r.pinnedRightHeaderRef,b=r.pinnedRightRef,y=r.pinnedRightTemplateColumns,H=r.rowHeight,M=r.scrollbarWidth,D=r.setFlattenedRows,S=r.setScrollTop,E=r.tableBodyContainerRef,k=r.visibleRows;!function(e){var n=e.headerContainerRef,r=e.mainSectionRef,o=e.scrollbarWidth,i=t(!1),l=i[0],d=i[1];a((function(){var e=null==n?void 0:n.current;if(l&&e)return e.classList.add("st-header-scroll-padding"),e.style.setProperty("--st-after-width","".concat(o,"px")),function(){e.classList.remove("st-header-scroll-padding")}}),[n,l,o]),a((function(){var e=null==n?void 0:n.current,t=null==r?void 0:r.current;if(t&&e){var o=function(){if(t){var e=t.scrollHeight>t.clientHeight;d(e)}};o();var i=new ResizeObserver((function(){o()}));return i.observe(t),function(){t&&i.unobserve(t)}}}),[n,r])}({headerContainerRef:h,mainSectionRef:E,scrollbarWidth:M});var N,T,L=o(null),O=(N=0,(T=function(e){e.forEach((function(e){N+=1,e.rowMeta.isExpanded&&e.rowMeta.children&&T(e.rowMeta.children)}))})(f),N)*(H+1)-1,B=function(e){var n=function(r){return r.rowMeta.rowId===e&&r.rowMeta.children?g(g({},r),{rowMeta:g(g({},r.rowMeta),{isExpanded:!r.rowMeta.isExpanded})}):r.rowMeta.children?g(g({},r),{rowMeta:g(g({},r.rowMeta),{children:r.rowMeta.children.map(n)})}):r};D((function(e){return e.map(n)}))},W=(null===(i=p.current)||void 0===i?void 0:i.clientWidth)?(null===(l=p.current)||void 0===l?void 0:l.clientWidth)+1:0,A=null===(d=u.current)||void 0===d?void 0:d.clientWidth,P=(null===(c=x.current)||void 0===c?void 0:c.clientWidth)?(null===(s=x.current)||void 0===s?void 0:s.clientWidth)+1:0;return e("div",g({className:"st-table-body-container",ref:E,onScroll:function(e){var n=e.currentTarget.scrollTop;L.current&&cancelAnimationFrame(L.current),L.current=requestAnimationFrame((function(){S(n)}))}},{children:[m.length>0&&n(V,g({},r,{onExpandRowClick:B,pinned:"left",rowHeight:H,sectionRef:R,templateColumns:I,totalHeight:O,visibleRows:k,width:W})),n(V,g({},r,{onExpandRowClick:B,rowHeight:H,sectionRef:v,templateColumns:w,totalHeight:O,visibleRows:k,width:A})),C.length>0&&n(V,g({},r,{onExpandRowClick:B,pinned:"right",rowHeight:H,sectionRef:b,templateColumns:y,totalHeight:O,visibleRows:k,width:P}))]}))},X={string:function(e,n,r){if(e===n)return 0;var t=e.localeCompare(n);return"ascending"===r?t:-t},number:function(e,n,r){if(e===n)return 0;var t=e-n;return"ascending"===r?t:-t},boolean:function(e,n,r){if(e===n)return 0;var t=e===n?0:e?-1:1;return"ascending"===r?t:-t},date:function(e,n,r){var t=new Date(e),o=new Date(n);if(t.getTime()===o.getTime())return 0;var i=t.getTime()-o.getTime();return"ascending"===r?i:-i},enum:function(e,n,r){return X.string(e,n,r)},default:function(e,n,r){return e===n?0:null==e?"ascending"===r?-1:1:null==n?"ascending"===r?1:-1:"string"==typeof e&&"string"==typeof n?X.string(e,n,r):"number"==typeof e&&"number"==typeof n?X.number(e,n,r):"boolean"==typeof e&&"boolean"==typeof n?X.boolean(e,n,r):X.string(String(e),String(n),r)}},q=function(e,n,r,t){if(void 0===r&&(r="string"),null==e||""===e)return"ascending"===t?-1:1;if(null==n||""===n)return"ascending"===t?1:-1;if("number"===r){var o=function(e){var n;if("number"==typeof e)return e;var r=String(e);if("string"==typeof r){var t=r.replace(/[$,]/g,"").match(/^([-+]?\d*\.?\d+)([TBMKtbmk])?/);if(t){var o=parseFloat(t[1]),i=null===(n=t[2])||void 0===n?void 0:n.toUpperCase();return"T"===i?o*=1e12:"B"===i?o*=1e9:"M"===i?o*=1e6:"K"===i&&(o*=1e3),o}}return parseFloat(r)||0},i=o(e),a=o(n);return X.number(i,a,t)}return"date"===r?X.date(String(e),String(n),t):"boolean"===r?X.boolean(Boolean(e),Boolean(n),t):"enum"===r?X.enum(String(e),String(n),t):X.string(String(e),String(n),t)},Y=function(e,n,r){var t=r.find((function(e){return e.accessor===n.key.accessor})),o=(null==t?void 0:t.type)||"string",i=n.direction,a=new Map,l=new Map,d="";e.forEach((function(e){var r;if(e.rowData&&!e.rowData[n.key.accessor]&&void 0!==e.rowMeta.isExpanded){var t=(e.rowData.sector||"group_".concat(a.size)).toString();d=t,l.set(d,e),a.has(d)||a.set(d,[])}else if(d){var o=a.get(d)||[];o.push(e),a.set(d,o)}else{var i="default";a.has(i)||a.set(i,[]),null===(r=a.get(i))||void 0===r||r.push(e)}}));var c=[];return a.forEach((function(e,t){if(l.has(t)){var a=l.get(t);a.rowMeta.children&&a.rowMeta.children.length>0&&(a.rowMeta.children=G(a.rowMeta.children,n,r)),c.push(a)}var d=m([],e,!0).sort((function(e,r){if(!(null==e?void 0:e.rowData)||!(null==r?void 0:r.rowData))return 0;var t=n.key.accessor,a=e.rowData[t],l=r.rowData[t];return q(a,l,o,i)}));c.push.apply(c,d.map((function(e){var t=g({},e);if(t.rowMeta.children&&t.rowMeta.children.length>0){var o=G(t.rowMeta.children,n,r);t.rowMeta=g(g({},t.rowMeta),{children:o})}return t})))})),c},G=function(e,n,r){var t=r.find((function(e){return e.accessor===n.key.accessor})),o=(null==t?void 0:t.type)||"string",i=n.direction;return m([],e,!0).sort((function(e,r){if(!(null==e?void 0:e.rowData)||!(null==r?void 0:r.rowData))return 0;var t=n.key.accessor,a=e.rowData[t],l=r.rowData[t];return q(a,l,o,i)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?g(g({},e),{rowMeta:g(g({},e.rowMeta),{children:G(e.rowMeta.children,n,r)})}):e}))},$=function(e){var n=e.event,r=e.forceUpdate,t=e.header,o=e.headersRef,i=e.index;e.reverse;var a=e.setIsWidthDragging,l=e.startWidth;a(!0),n.preventDefault();var d=n.clientX;if(t){var c=function(e){var n=Math.max(l+(e.clientX-d),40);t&&o.current&&(o.current[i].width=n,r())},s=function(){document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",s),a(!1)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",s)}},_=d((function(r,o){var i,l=r.columnResizing,d=r.currentRows,c=r.columnReordering,s=r.draggedHeaderRef,u=r.forceUpdate,f=r.headersRef,h=r.hoveredHeaderRef,v=r.index,w=r.onColumnOrderChange,m=r.onSort,p=r.onTableHeaderDragEnd,I=r.reverse,C=r.rowHeight,x=r.selectableColumns,b=r.setIsWidthDragging,y=r.setSelectedCells,H=r.sort,M=r.sortDownIcon,S=r.sortUpIcon,E=t(!1),k=E[0],N=E[1],T=null===(i=f.current)||void 0===i?void 0:i[v],L=Boolean(null==T?void 0:T.isSortable),B="st-header-cell ".concat(T===h.current?"st-hovered":""," ").concat(k?"st-dragging":""," ").concat(L?"clickable":""," ").concat(c&&!L?"columnReordering":""," ").concat("right"===(null==T?void 0:T.align)?"right-aligned":"center"===(null==T?void 0:T.align)?"center-aligned":""),W=A({draggedHeaderRef:s,headersRef:f,hoveredHeaderRef:h,onColumnOrderChange:w,onTableHeaderDragEnd:p}),P=W.handleDragStart,F=W.handleDragEnd,z=W.handleDragOver,U=O(),j=function(e){var n=e.event,r=e.header;if(x){var t=d.length,o=Array.from({length:t},(function(e,n){return R({rowIndex:n,colIndex:v,rowId:d[n].rowMeta.rowId})})),i=function(e,n){var r=new Set,o=Math.min(e,n),i=Math.max(e,n);return Array.from({length:t}).forEach((function(e,n){Array.from({length:i-o+1}).forEach((function(e,t){r.add(R({rowIndex:n,colIndex:o+t,rowId:d[n].rowMeta.rowId}))}))})),r};n.shiftKey?y((function(e){var n,r=Number(null===(n=Array.from(e)[0])||void 0===n?void 0:n.split("-")[1]),t=Number(o[0].split("-")[1]);return r===t?new Set(o):r>t?i(t,r):i(r,t)})):y(new Set(o))}else r.isSortable&&m(v,r.accessor)};if(a((function(){var e=function(e){e.preventDefault(),e.dataTransfer.dropEffect="move"};return document.addEventListener("dragover",e),function(){document.removeEventListener("dragover",e)}}),[]),!T)return null;var K=l&&n("div",{className:"st-header-resize-handle",onMouseDown:function(e){var n;U({callback:$,callbackProps:{event:e,forceUpdate:u,header:T,headersRef:f,index:v,setIsWidthDragging:b,startWidth:"object"==typeof o&&null!==o&&"current"in o?null===(n=o.current)||void 0===n?void 0:n.offsetWidth:void 0},limit:10})}}),V=H&&H.key.accessor===T.accessor&&e("div",g({className:"st-sort-icon-container",onClick:function(e){return j({event:e,header:T})}},{children:["ascending"===H.direction&&S&&S,"descending"===H.direction&&M&&M]}));return e("div",g({className:B,id:D({accessor:T.accessor,rowIndex:0}),onDragOver:function(e){U({callback:z,callbackProps:{event:e,hoveredHeader:T},limit:50})},ref:o,style:{width:T.width,height:C}},{children:[I&&K,e("div",g({className:"st-header-label ".concat("right"===T.align?"right-aligned":"center"===T.align?"center-aligned":""),draggable:c,onClick:function(e){return j({event:e,header:T})},onDragEnd:function(e){e.preventDefault(),N(!1),F()},onDragStart:function(e){c&&T&&function(e){N(!0),P(e)}(T)}},{children:["right"===T.align&&V,null==T?void 0:T.label,"right"!==T.align&&V]})),!I&&K]}))})),Q=function(e,n){a((function(){if(e.current){var r=e.current,t=function(){var e,t=null==r?void 0:r.scrollLeft;void 0!==t&&(null===(e=n.current)||void 0===e||e.scrollTo(t,0))};return r.addEventListener("scroll",t),function(){null==r||r.removeEventListener("scroll",t)}}}),[e,n])},Z=function(r){var t,o,i,a=r.allowAnimations,l=r.centerHeaderRef,d=r.columnResizing,c=r.currentRows,s=r.columnReordering,u=r.draggedHeaderRef,h=r.forceUpdate,v=r.headerContainerRef,w=r.headersRef,m=r.hiddenColumns,p=r.hoveredHeaderRef,R=r.isWidthDragging,I=r.mainBodyRef,C=r.mainTemplateColumns,x=r.onColumnOrderChange,b=r.onSort,y=r.onTableHeaderDragEnd,H=r.pinnedLeftColumns,M=r.pinnedLeftHeaderRef,D=r.pinnedLeftTemplateColumns,E=r.pinnedRightColumns,k=r.pinnedRightHeaderRef,N=r.pinnedRightTemplateColumns,T=r.rowHeight,L=r.selectableColumns,O=r.setIsWidthDragging,B=r.setSelectedCells,W=r.sort,A=r.sortDownIcon,P=r.sortUpIcon;Q(I,l);return e("div",g({className:"st-header-container",ref:v},{children:[H.length>0&&n("div",g({className:"st-header-pinned-left",ref:M,style:{gridTemplateColumns:D}},{children:n(F,g({allowAnimations:a,draggedHeaderRef:u,headersRef:w,mainBodyRef:I,pauseAnimation:R,rowIndex:0},{children:null===(t=w.current)||void 0===t?void 0:t.map((function(e,r){return S({hiddenColumns:m,header:e,pinned:"left"})?n(_,{columnResizing:d,currentRows:c,columnReordering:s,draggedHeaderRef:u,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:r,onColumnOrderChange:x,onSort:b,onTableHeaderDragEnd:y,ref:f(),rowHeight:T,selectableColumns:L,setIsWidthDragging:O,setSelectedCells:B,sort:W,sortDownIcon:A,sortUpIcon:P},e.accessor):null}))}))})),n("div",g({className:"st-header-main",onScroll:function(e){var n,r,t=null===(n=l.current)||void 0===n?void 0:n.scrollLeft;void 0!==t&&(null===(r=I.current)||void 0===r||r.scrollTo(t,0))},ref:l,style:{gridTemplateColumns:C}},{children:n(F,g({allowAnimations:a,draggedHeaderRef:u,headersRef:w,mainBodyRef:I,pauseAnimation:R,rowIndex:0},{children:null===(o=w.current)||void 0===o?void 0:o.map((function(e,r){return S({hiddenColumns:m,header:e})?n(_,{columnResizing:d,currentRows:c,columnReordering:s,draggedHeaderRef:u,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:r,onColumnOrderChange:x,onSort:b,onTableHeaderDragEnd:y,ref:f(),rowHeight:T,selectableColumns:L,setIsWidthDragging:O,setSelectedCells:B,sort:W,sortDownIcon:A,sortUpIcon:P},e.accessor):null}))}))})),E.length>0&&n("div",g({className:"st-header-pinned-right",ref:k,style:{gridTemplateColumns:N}},{children:n(F,g({allowAnimations:a,draggedHeaderRef:u,headersRef:w,mainBodyRef:I,pauseAnimation:R,rowIndex:0},{children:null===(i=w.current)||void 0===i?void 0:i.map((function(e,r){return S({hiddenColumns:m,header:e,pinned:"right"})?n(_,{columnResizing:d,currentRows:c,columnReordering:s,draggedHeaderRef:u,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:r,onColumnOrderChange:x,onSort:b,onTableHeaderDragEnd:y,reverse:!0,ref:f(),rowHeight:T,selectableColumns:L,setIsWidthDragging:O,setSelectedCells:B,sort:W,sortDownIcon:A,sortUpIcon:P},e.accessor):null}))}))}))]}))},ee=function(e){var n=e.headers,r=e.hiddenColumns;return"".concat(n.filter((function(e){return!0!==r[e.accessor]})).map((function(e){return function(e){var n=e.minWidth,r=e.width;return"number"==typeof r&&(r="".concat(r,"px")),n&&"number"==typeof n&&(n="".concat(n,"px")),void 0!==n?"minmax(".concat(n,", ").concat(r,")"):r}(e)})).join(" "))},ne=function(r){var t=r.allowAnimations,i=r.columnReordering,a=r.columnResizing,d=r.currentRows,c=r.draggedHeaderRef,s=r.editColumns,u=r.flattenedRows,f=r.forceUpdate,h=r.getBorderClass,v=r.handleMouseDown,w=r.handleMouseOver,m=r.headersRef,p=r.hiddenColumns,R=r.hoveredHeaderRef,I=r.isSelected,C=r.isInitialFocusedCell,x=r.isWidthDragging,b=r.mainBodyRef,y=r.onCellEdit,H=r.onColumnOrderChange,M=r.onSort,D=r.onTableHeaderDragEnd,S=r.pinnedLeftRef,E=r.pinnedRightRef,k=r.rowHeight,N=r.scrollbarWidth,T=r.selectableColumns,L=r.setIsWidthDragging,O=r.setFlattenedRows,B=r.setScrollTop,W=r.setSelectedCells,A=r.shouldPaginate,P=r.sort,F=r.sortDownIcon,z=r.sortUpIcon,U=r.tableBodyContainerRef,j=r.visibleRows,K=o(null),V=o(null),X=o(null),q=o(null),Y=m.current.filter((function(e){return!e.pinned})),G=m.current.filter((function(e){return"left"===e.pinned})),$=m.current.filter((function(e){return"right"===e.pinned})),_=l((function(){return ee({headers:G,hiddenColumns:p})}),[G,p]),Q=l((function(){return ee({headers:Y,hiddenColumns:p})}),[Y,p]),ne=l((function(){return ee({headers:$,hiddenColumns:p})}),[$,p]),re={allowAnimations:t,centerHeaderRef:X,columnResizing:a,currentRows:d,columnReordering:i,draggedHeaderRef:c,forceUpdate:f,headerContainerRef:K,headersRef:m,hiddenColumns:p,hoveredHeaderRef:R,isWidthDragging:x,mainBodyRef:b,mainTemplateColumns:Q,onColumnOrderChange:H,onSort:M,onTableHeaderDragEnd:D,pinnedLeftColumns:G,pinnedLeftHeaderRef:V,pinnedLeftTemplateColumns:_,pinnedRightColumns:$,pinnedRightHeaderRef:q,pinnedRightTemplateColumns:ne,rowHeight:k,selectableColumns:T,setIsWidthDragging:L,setSelectedCells:W,sort:P,sortDownIcon:F,sortUpIcon:z,tableBodyContainerRef:U},te={allowAnimations:t,centerHeaderRef:X,draggedHeaderRef:c,flattenedRows:u,getBorderClass:h,handleMouseDown:v,handleMouseOver:w,headerContainerRef:K,headers:m.current,headersRef:m,hiddenColumns:p,hoveredHeaderRef:R,isSelected:I,isInitialFocusedCell:C,isWidthDragging:x,mainBodyRef:b,mainTemplateColumns:Q,onCellEdit:y,onTableHeaderDragEnd:D,pinnedLeftColumns:G,pinnedLeftHeaderRef:V,pinnedLeftRef:S,pinnedLeftTemplateColumns:_,pinnedRightColumns:$,pinnedRightHeaderRef:q,pinnedRightRef:E,pinnedRightTemplateColumns:ne,rowHeight:k,scrollbarWidth:N,setFlattenedRows:O,shouldPaginate:A,setScrollTop:B,tableBodyContainerRef:U,visibleRows:j};return e("div",g({className:"st-table-content",style:{width:s?"calc(100% - 27.5px)":"100%"}},{children:[n(Z,g({},re)),n(J,g({},te))]}))},re=function(e){var n=e.callback,r=e.ref,t=e.widthAttribute;a((function(){var e=r.current;if(e){var o=function(){n(e[t]||0)};o();var i=new ResizeObserver((function(){o()}));return i.observe(e),function(){return i.disconnect()}}}),[n,r,t])},te=function(r){var i=r.mainBodyRef,a=r.pinnedLeftRef,l=r.pinnedRightRef,d=r.tableContentWidth,c=t(0),s=c[0],u=c[1],f=t(0),h=f[0],v=f[1],w=t(0),m=w[0],p=w[1],R=o(null);return re({widthAttribute:"offsetWidth",callback:u,ref:a}),re({widthAttribute:"scrollWidth",callback:p,ref:i}),re({widthAttribute:"offsetWidth",callback:v,ref:l}),Q(i,R),!i.current||i.current.scrollWidth<=i.current.clientWidth?null:e("div",g({className:"st-horizontal-scrollbar-container",style:{width:d}},{children:[s>0&&n("div",{className:"st-horizontal-scrollbar-left",style:{flexShrink:0,width:s}}),m>0&&n("div",g({className:"st-horizontal-scrollbar-middle",onScroll:function(e){var n=e.target.scrollLeft;void 0!==n&&i.current&&i.current.scrollTo({left:n,behavior:"auto"})},ref:R},{children:n("div",{style:{width:m}})})),h>0&&n("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:h}})]}))},oe=function(e){var n=e.headers,r=e.tableRows,o=t(null),i=o[0],a=o[1],d=l((function(){var e={};return n.forEach((function(n){!0===n.hide&&(e[n.accessor]=!0)})),e}),[n]),c=t(d),s=c[0],u=c[1],f=l((function(){if(!i)return r;var e=function(e,n,r){return{sortedData:Y(n,r,e),newSortConfig:r}}(n,r,i).sortedData;return e}),[r,i,n]);return{sort:i,setSort:a,updateSort:function(e,r){var t=n.find((function(e){return e.accessor===r}));t&&a((function(e){return e&&e.key.accessor===r?"ascending"===e.direction?{key:t,direction:"descending"}:null:{key:t,direction:"ascending"}}))},sortedRows:f,hiddenColumns:s,setHiddenColumns:u}},ie=function(r){var o=r.checked,i=void 0!==o&&o,a=r.children,l=r.onChange,d=t(i),c=d[0],s=d[1];return e("label",g({className:"st-checkbox-label"},{children:[n("input",{checked:c,className:"st-checkbox-input",onChange:function(){var e=!c;s(e),l&&l(e)},type:"checkbox"}),n("span",g({className:"st-checkbox-custom ".concat(c?"st-checked":"")},{children:c&&n("span",{className:"st-checkbox-checkmark"})})),a]}))},ae=function(e){var r=e.headers,t=e.open,o=e.position;e.setOpen;var i=e.setHiddenColumns,a=e.hiddenColumns,l="left"===o?"left":"";return n("div",g({className:"st-column-editor-popout ".concat(t?"open":""," ").concat(l),onClick:function(e){return e.stopPropagation()}},{children:n("div",g({className:"st-column-editor-popout-content"},{children:r.map((function(e,r){return n(ie,g({checked:a[e.accessor],onChange:function(n){var r;return i(g(g({},a),((r={})[e.accessor]=n,r)))}},{children:e.label}),r)}))}))}))},le=function(r){var o=r.columnEditorText,i=r.editColumns,a=r.editColumnsInitOpen,l=r.headers,d=r.position,c=void 0===d?"right":d,s=r.setHiddenColumns,u=r.hiddenColumns,f=t(a),h=f[0],v=f[1];return i?e("div",g({className:"st-column-editor ".concat(h?"open":""," ").concat(c),onClick:function(){return function(e){v(e)}(!h)}},{children:[n("div",g({className:"st-column-editor-text"},{children:o})),n(ae,{headers:l,open:h,position:c,setOpen:v,setHiddenColumns:s,hiddenColumns:u})]})):null};!function(e){e.Left="left",e.Right="right"}(p||(p={}));var de=h((function(r){var d=r.allowAnimations,s=void 0!==d&&d,u=r.columnEditorPosition,f=void 0===u?p.Right:u,h=r.columnEditorText,w=void 0===h?"Columns":h,m=r.columnResizing,H=void 0!==m&&m,M=r.defaultHeaders,D=r.editColumns,S=void 0!==D&&D,E=r.editColumnsInitOpen,k=void 0!==E&&E,N=r.columnReordering,T=void 0!==N&&N,L=r.height,O=r.hideFooter,B=void 0!==O&&O,W=r.nextIcon,A=void 0===W?n(x,{className:"st-next-prev-icon"}):W,P=r.onCellEdit,F=r.onColumnOrderChange,z=r.onNextPage,U=r.onPreviousPage,j=r.prevIcon,K=void 0===j?n(C,{className:"st-next-prev-icon"}):j,V=r.rowHeight,J=void 0===V?40:V,X=r.rows,q=r.rowsPerPage,Y=void 0===q?10:q,G=r.selectableCells,$=void 0!==G&&G,_=r.selectableColumns,Q=void 0!==_&&_,Z=r.shouldPaginate,ee=void 0!==Z&&Z,re=r.sortDownIcon,ie=void 0===re?n(y,{className:"st-sort-icon"}):re,ae=r.sortUpIcon,de=void 0===ae?n(b,{className:"st-sort-icon"}):ae,ce=r.theme,se=void 0===ce?"light":ce,ue=r.totalPages,fe=o(null),he=o(M),ve=o(null),ge=o(null),we=o(null),me=o(null),pe=o(null),Re=t(!1),Ie=Re[0],Ce=Re[1],xe=t(1),be=xe[0],ye=xe[1],He=t(0),Me=He[0],De=He[1],Se=t(0),Ee=Se[0],ke=Se[1],Ne=t(0),Te=Ne[0],Le=Ne[1],Oe=oe({headers:he.current,tableRows:X}),Be=Oe.sort,We=Oe.sortedRows,Ae=Oe.hiddenColumns,Pe=Oe.setHiddenColumns,Fe=Oe.updateSort,ze=l((function(){if(!ee)return We;var e=(be-1)*Y,n=e+Y;return We.slice(e,n)}),[be,Y,ee,We]),Ue=t(ze),je=Ue[0],Ke=Ue[1];a((function(){Ke(ze)}),[ze]);var Ve=l((function(){var e;if(!L)return window.innerHeight-J;var n=document.querySelector(".simple-table-root"),r=0;if(L.endsWith("px"))r=parseInt(L,10);else if(L.endsWith("vh")){var t=parseInt(L,10);r=window.innerHeight*t/100}else if(L.endsWith("%")){var o=parseInt(L,10);r=((null===(e=null==n?void 0:n.parentElement)||void 0===e?void 0:e.clientHeight)||window.innerHeight)*o/100}else r=window.innerHeight;return Math.max(0,r-J)}),[L,J]),Je=l((function(){return function(e){var n=e.bufferRowCount,r=e.contentHeight,t=e.flattenedRows,o=e.rowHeight,i=e.scrollTop,a=[],l=0,d=Math.max(0,i-o*n),c=i+r+o*n,s=function(e,n){for(var r,t=0,i=e;t<i.length;t++){var u=i[t],f=l*o;if(f>=c)break;f+o>d&&a.push({row:u,depth:n,position:l,isLastGroupRow:Boolean(null===(r=u.rowMeta.children)||void 0===r?void 0:r.length)&&n>1}),l+=1,u.rowMeta.isExpanded&&u.rowMeta.children&&s(u.rowMeta.children,n+1)}};return s(t,0),a}({bufferRowCount:5,contentHeight:Ve,flattenedRows:je,rowHeight:J,scrollTop:Te})}),[Ve,J,je,Te]),Xe=v((function(e){return e+1}),0)[1],qe=function(e){var n=e.selectableCells,r=e.headers,d=e.visibleRows,c=t(new Set),s=c[0],u=c[1],f=t(null),h=f[0],v=f[1],g=o(!1),w=o(null),m=i((function(){var e=Array.from(s).reduce((function(e,n){var t=n.split("-").map(Number),o=t[0],i=t[1];return e[o]||(e[o]=[]),e[o][i]=d[o].row.rowData[r[i].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");s.size>0&&navigator.clipboard.writeText(n)}),[r,s,d]),p=i((function(e,n){for(var r=new Set,t=Math.min(e.rowIndex,n.rowIndex),o=Math.max(e.rowIndex,n.rowIndex),i=Math.min(e.colIndex,n.colIndex),a=Math.max(e.colIndex,n.colIndex),l=t;l<=o;l++)for(var c=i;c<=a;c++)if(l>=0&&l<d.length){var s=d[l].row.rowMeta.rowId;r.add(R({colIndex:c,rowIndex:l,rowId:s}))}u(r)}),[d]),I=i((function(e){if(e.rowIndex>=0&&e.rowIndex<d.length&&e.colIndex>=0&&e.colIndex<r.length){var n=R(e);u(new Set([n])),v(e)}}),[r.length,d.length]);a((function(){var e=function(e){if(n&&h){var t=h.rowIndex,o=h.colIndex,i=h.rowId;if(!e.ctrlKey&&!e.metaKey||"c"!==e.key){if(d[t].row.rowMeta.rowId!==i){var a=d.findIndex((function(e){return e.row.rowMeta.rowId===i}));if(-1===a)return;t=a}if("ArrowUp"===e.key){if(e.preventDefault(),t>0){var l={rowIndex:t-1,colIndex:o,rowId:d[t-1].row.rowMeta.rowId};I(l)}}else"ArrowDown"===e.key?(e.preventDefault(),t<d.length-1&&(l={rowIndex:t+1,colIndex:o,rowId:d[t+1].row.rowMeta.rowId},I(l))):"ArrowLeft"===e.key||"Tab"===e.key&&e.shiftKey?(e.preventDefault(),o>0&&(l={rowIndex:t,colIndex:o-1,rowId:d[t].row.rowMeta.rowId},I(l))):"ArrowRight"===e.key||"Tab"===e.key?(e.preventDefault(),o<r.length-1&&(l={rowIndex:t,colIndex:o+1,rowId:d[t].row.rowMeta.rowId},I(l))):"Escape"===e.key&&(u(new Set),w.current=null,v(null))}else m()}};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[m,r.length,h,p,I,n,d]);var C=i((function(e){var n=e.colIndex,r=e.rowIndex,t=e.rowId,o=R({colIndex:n,rowIndex:r,rowId:t});return s.has(o)}),[s]),x=i((function(e){var n,r,t,o,i,a,l=e.colIndex,c=e.rowIndex,s=e.rowId,u=[],f=null===(t=null===(r=null===(n=d[c-1])||void 0===n?void 0:n.row)||void 0===r?void 0:r.rowMeta)||void 0===t?void 0:t.rowId,h={colIndex:l,rowIndex:c+1,rowId:null===(a=null===(i=null===(o=d[c+1])||void 0===o?void 0:o.row)||void 0===i?void 0:i.rowMeta)||void 0===a?void 0:a.rowId},v={colIndex:l-1,rowIndex:c,rowId:s},g={colIndex:l+1,rowIndex:c,rowId:s};return C({colIndex:l,rowIndex:c-1,rowId:f})||u.push("st-selected-top-border"),C(h)||u.push("st-selected-bottom-border"),C(v)||u.push("st-selected-left-border"),C(g)||u.push("st-selected-right-border"),u.join(" ")}),[C,d]),b=l((function(){return h?function(e){var n=e.rowIndex,r=e.colIndex,t=e.rowId;return n===h.rowIndex&&r===h.colIndex&&t===h.rowId}:function(){return!1}}),[h]);return{getBorderClass:x,handleMouseDown:function(e){var r=e.colIndex,t=e.rowIndex,o=e.rowId;if(n){g.current=!0,w.current={rowIndex:t,colIndex:r,rowId:o};var i=R({colIndex:r,rowIndex:t,rowId:o});u(new Set([i])),v({rowIndex:t,colIndex:r,rowId:o})}},handleMouseOver:function(e){var r=e.colIndex,t=e.rowIndex;if(e.rowId,n&&g.current&&w.current){for(var o=new Set,i=Math.min(w.current.rowIndex,t),a=Math.max(w.current.rowIndex,t),l=Math.min(w.current.colIndex,r),c=Math.max(w.current.colIndex,r),s=i;s<=a;s++)for(var f=l;f<=c;f++)if(s>=0&&s<d.length){var h=d[s].row.rowMeta.rowId;o.add(R({colIndex:f,rowIndex:s,rowId:h}))}u(o)}},handleMouseUp:function(){g.current=!1},isInitialFocusedCell:b,isSelected:C,selectedCells:s,setSelectedCells:u}}({selectableCells:$,headers:he.current,visibleRows:Je}),Ye=qe.handleMouseDown,Ge=qe.handleMouseOver,$e=qe.handleMouseUp,_e=qe.isSelected,Qe=qe.getBorderClass,Ze=qe.isInitialFocusedCell,en=qe.setSelectedCells,nn=i((function(e,n){Fe(e,n)}),[Fe]),rn=i((function(e){he.current=e,Xe()}),[]);return a((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||Q&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||en(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[Q,en]),c((function(){if(pe.current){var e=pe.current.offsetWidth-pe.current.clientWidth,n=pe.current.clientWidth;De(e),ke(n)}}),[]),c((function(){var e=function(){if(Xe(),pe.current){var e=pe.current.offsetWidth-pe.current.clientWidth,n=pe.current.clientWidth;De(e),ke(n)}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),e("div",g({className:"simple-table-root st-wrapper theme-".concat(se),style:L?{height:L}:{}},{children:[e("div",g({className:"st-table-wrapper-container"},{children:[e("div",g({className:"st-table-wrapper",onMouseUp:$e,onMouseLeave:$e},{children:[n(ne,{allowAnimations:s,columnReordering:T,columnResizing:H,currentRows:ze,draggedHeaderRef:fe,editColumns:S,flattenedRows:je,forceUpdate:Xe,getBorderClass:Qe,handleMouseDown:Ye,handleMouseOver:Ge,headersRef:he,hiddenColumns:Ae,hoveredHeaderRef:ve,isInitialFocusedCell:Ze,isSelected:_e,isWidthDragging:Ie,mainBodyRef:ge,onCellEdit:P,onColumnOrderChange:F,onSort:nn,onTableHeaderDragEnd:rn,pinnedLeftRef:we,pinnedRightRef:me,rowHeight:J,scrollbarWidth:Me,selectableColumns:Q,setIsWidthDragging:Ce,setFlattenedRows:Ke,setScrollTop:Le,setSelectedCells:en,shouldPaginate:ee,sort:Be,sortDownIcon:ie,sortUpIcon:de,tableBodyContainerRef:pe,visibleRows:Je}),n(le,{columnEditorText:w,editColumns:S,editColumnsInitOpen:k,headers:he.current,hiddenColumns:Ae,position:f,setHiddenColumns:Pe})]})),n(te,{mainBodyRef:ge,pinnedLeftRef:we,pinnedRightRef:me,tableContentWidth:Ee})]})),n(I,{currentPage:be,hideFooter:B,nextIcon:A,onPageChange:ye,onNextPage:z,onPreviousPage:U,prevIcon:K,shouldPaginate:ee,totalPages:ue||Math.ceil(We.length/Y)})]}))}));export{de as SimpleTable};
2
2
  //# sourceMappingURL=index.es.js.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=function(){return r=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},r.apply(this,arguments)};function t(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]])}return r}function o(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var i,a=function(e){var n=e.rowIndex,r=e.colIndex,t=e.rowId;return"".concat(n,"-").concat(r,"-").concat(t)},l=function(n){var t=n.currentPage,o=n.hideFooter,i=n.nextIcon,a=n.onPageChange,l=n.onNextPage,s=n.onPreviousPage,d=n.prevIcon,c=n.shouldPaginate,u=n.totalPages;if(o||!c)return null;var f=!(t>1)&&!s,h=!(t<u)&&!l;return e.jsxs("div",r({className:"st-footer"},{children:[e.jsx("button",r({className:"st-next-prev-btn ".concat(f?"disabled":""),onClick:function(){var e=t-1;e>=1&&a(e),s&&s(e-1)},disabled:f},{children:d})),e.jsx("button",r({className:"st-next-prev-btn ".concat(h?"disabled":""),onClick:function(){var e=t+1;(e<=u||l)&&a(e),l&&l(t)},disabled:h},{children:i})),Array.from({length:u},(function(n,o){return e.jsx("button",r({onClick:function(){var e;(e=o+1)>=1&&e<=u&&(a(e),e>t&&l?l(e-1):e<t&&s&&s(e-1))},className:"st-page-btn ".concat(t===o+1?"active":"")},{children:o+1}),o)}))]}))},s=function(n){var t=n.className;return e.jsx("svg",r({className:t,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})}))},d=function(n){var t=n.className;return e.jsx("svg",r({className:t,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})}))},c=function(n){var t=n.className;return e.jsx("svg",r({className:t,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M5.41 11.41L10 6.83l4.59 4.58L16 10l-6-6-6 6z"})}))},u=function(n){var t=n.className;return e.jsx("svg",r({className:t,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M5.41 7.59L10 12.17l4.59-4.58L16 9l-6 6-6-6z"})}))},f=function(e){return e.position*(e.rowHeight+1)-1},h=function(e){return e.position*(e.rowHeight+1)},v=function(e){var n=e.accessor,r=e.rowIndex;return"cell-".concat(n,"-").concat(r)},g=function(e){var n=e.hiddenColumns,r=e.header,t=e.pinned;return n[r.accessor]?null:!t&&!r.pinned||r.pinned===t||null},w=function(n){var t=n.value,o=n.onBlur,i=n.onChange;return e.jsxs("select",r({value:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;i("true"===n)}},{children:[e.jsx("option",r({value:"true"},{children:"True"})),e.jsx("option",r({value:"false"},{children:"False"}))]}))},m=function(r){var t=r.defaultValue,o=r.onBlur,i=r.onChange,a=n.useRef(null);return e.jsx("input",{className:"editable-cell-input",ref:a,autoFocus:!0,type:"text",defaultValue:null!=t?t:"",onBlur:o,onChange:function(e){var n=e.target.value;i(n)}})},p=function(r){var t=r.defaultValue,o=r.onBlur,i=r.onChange,a=n.useRef(null);return e.jsx("input",{className:"editable-cell-input",ref:a,autoFocus:!0,defaultValue:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;/^\d*\.?\d*$/.test(n)&&i(n)}})},x=function(n){var r=n.onChange,t=n.setIsEditing,o=n.value,i=function(e){null==r||r(e)},a=function(){t(!1)};return e.jsx(e.Fragment,{children:"string"==typeof o||null==o?e.jsx(m,{defaultValue:o,onBlur:a,onChange:i}):"boolean"==typeof o?e.jsx(w,{onBlur:a,onChange:i,value:o}):"number"==typeof o?e.jsx(p,{defaultValue:o,onBlur:a,onChange:i}):null})},R=0,I=function(){return function(e){var n=e.callback,r=e.callbackProps,t=e.limit,o=Date.now();(0===R||o-R>=t)&&(R=o,n(r))}},C=Date.now(),b={screenX:0,screenY:0},y=function(e){var r,t,i=e.draggedHeaderRef,a=e.headersRef,l=e.hoveredHeaderRef,s=e.onColumnOrderChange,d=e.onTableHeaderDragEnd,c=(r=a.current,t=n.useRef(r),n.useEffect((function(){t.current=r}),[r]),t.current);return{handleDragStart:function(e){i.current=e,C=Date.now()},handleDragOver:function(e){var n,r=e.event,t=e.hoveredHeader;if(r.preventDefault(),a.current){var s=r.currentTarget.getAnimations().some((function(e){return"running"===e.playState})),u=r.screenX,f=r.screenY,h=Math.sqrt(Math.pow(u-b.screenX,2)+Math.pow(f-b.screenY,2));l.current=t;var v=o([],a.current,!0),g=v.findIndex((function(e){var n;return e.accessor===(null===(n=i.current)||void 0===n?void 0:n.accessor)})),w=v.findIndex((function(e){return e.accessor===t.accessor})),m=v.splice(g,1)[0];if(v.splice(w,0,m),!(s||t.accessor===(null===(n=i.current)||void 0===n?void 0:n.accessor)||null===i.current||h<10||void 0===g||void 0===w||JSON.stringify(v)===JSON.stringify(a.current))){var p=Date.now();JSON.stringify(v)===JSON.stringify(c)&&p-C<800&&h<50||(C=p,b={screenX:u,screenY:f},d(v))}}},handleDragEnd:function(){i.current=null,l.current=null,null==s||s(a.current)}}},M=n.forwardRef((function(t,o){var i,a,l=t.borderClass,s=t.colIndex,c=t.draggedHeaderRef,f=t.header,h=t.headersRef,g=t.hoveredHeaderRef,w=t.isSelected,m=t.isInitialFocusedCell,p=t.onCellEdit,R=t.onExpandRowClick,C=t.onMouseDown,b=t.onMouseOver,M=t.onTableHeaderDragEnd,H=t.rowIndex,j=t.visibleRow,S=j.depth,E=j.row,D=n.useState(E.rowData[f.accessor]),k=D[0],N=D[1],L=n.useState(!1),T=L[0],O=L[1],B=y({draggedHeaderRef:c,headersRef:h,hoveredHeaderRef:g,onTableHeaderDragEnd:M}).handleDragOver,W=I(),A="cell-".concat(H,"-").concat(s),P=Boolean(null===(a=null===(i=E.rowMeta)||void 0===i?void 0:i.children)||void 0===a?void 0:a.length),F=Boolean(null==f?void 0:f.isEditable),z=H%2==0,U="st-cell ".concat(S>0&&f.expandable?"st-cell-depth-".concat(S):""," ").concat(w?m?"st-cell-selected-first ".concat(l):"st-cell-selected ".concat(l):""," ").concat(z?"st-cell-odd-row":"st-cell-even-row"," ").concat(F?"clickable":"");n.useEffect((function(){N(E.rowData[f.accessor])}),[f.accessor,E]);return T?e.jsx("div",r({className:"st-cell-editing ".concat(z?"st-cell-odd-row":"st-cell-even-row"),id:v({accessor:f.accessor,rowIndex:H+1})},{children:e.jsx(x,{onChange:function(e){N(e),null==p||p({accessor:f.accessor,newValue:e,row:E})},setIsEditing:O,value:k})})):e.jsxs("div",r({className:U,id:A,onDoubleClick:function(){return f.isEditable&&O(!0)},onMouseDown:function(){return C({rowIndex:H,colIndex:s,rowId:E.rowMeta.rowId})},onMouseOver:function(){return b({rowIndex:H,colIndex:s,rowId:E.rowMeta.rowId})},onDragOver:function(e){return W({callback:B,callbackProps:{event:e,hoveredHeader:f},limit:50})},onKeyDown:function(e){"F2"!==e.key&&"Enter"!==e.key||!f.isEditable||T||(e.preventDefault(),O(!0))},ref:o,"data-row-index":H,"data-col-index":s,"aria-selected":w},{children:[f.expandable&&P?E.rowMeta.isExpanded?e.jsx("div",r({className:"st-sort-icon-container",onClick:function(){return R(E.rowMeta.rowId)}},{children:e.jsx(u,{className:"st-sort-icon"})})):e.jsx("div",r({className:"st-sort-icon-container",onClick:function(){return R(E.rowMeta.rowId)}},{children:e.jsx(d,{className:"st-sort-icon"})})):null,e.jsx("span",r({className:"st-cell-content ".concat("right"===f.align?"right-aligned":"center"===f.align?"center-aligned":"")},{children:f.cellRenderer?f.cellRenderer({accessor:f.accessor,colIndex:s,row:E}):k}))]}))})),H=function(n){var o=n.allowAnimations,i=n.children,a=t(n,["allowAnimations","children"]);return o?e.jsx(j,r({},a,{children:i})):e.jsx(e.Fragment,{children:i})},j=function(r){var t=r.allowHorizontalAnimate,o=void 0===t||t,i=r.children,a=r.draggedHeaderRef,l=r.headersRef,s=r.isBody,d=r.mainBodyRef,c=r.pauseAnimation,u=r.rowIndex,f=n.useRef(!1),h=n.useState({}),g=h[0],w=h[1],m=n.useRef({}),p=l.current;return n.useLayoutEffect((function(){if(p){var e=function(e){var n=e.currentHeaders,r=e.draggedHeaderRef,t=e.rowIndex,o={};return n.forEach((function(e){var n;if(e){var i=document.getElementById(v({accessor:e.accessor,rowIndex:t}));if(i){var a=i.getAnimations().some((function(e){return"running"===e.playState})),l=i.getBoundingClientRect();a&&(null===(n=null==r?void 0:r.current)||void 0===n?void 0:n.accessor)!==e.accessor?o[e.accessor]=!1:o[e.accessor]=l}}})),o}({currentHeaders:p,draggedHeaderRef:a,rowIndex:u});JSON.stringify(e)!==JSON.stringify(g)&&(m.current=g,w(e))}}),[g,p,a,s,u]),n.useLayoutEffect((function(){var e=d.current,n=function(){f.current=!0},r=function(){f.current=!1};return null==e||e.addEventListener("scroll",n),null==e||e.addEventListener("scrollend",r),function(){null==e||e.removeEventListener("scroll",n),null==e||e.removeEventListener("scrollend",r)}}),[a,d]),n.useEffect((function(){c||f.current||Object.keys(m.current).length&&p&&p.forEach((function(e){var n=document.getElementById(v({accessor:e.accessor,rowIndex:u}));if(n){var r=m.current[e.accessor],t=g[e.accessor];if(r&&t){var i=r.left-t.left,a=o?0:r.top-t.top,l=Math.abs(i),s=Math.abs(a);(l>10||s>10)&&requestAnimationFrame((function(){n.style.transform="translate(".concat(i,"px, ").concat(a,"px)"),n.style.transition="transform 0s",requestAnimationFrame((function(){n.style.transform="",n.style.transition="transform ".concat(400,"ms ease-out")}))}))}}}))}),[o,g,p,s,c,m,u]),e.jsx(e.Fragment,{children:i})},S=function(o){var i=o.getBorderClass,a=o.handleMouseDown,l=o.handleMouseOver,s=o.headers,d=o.hiddenColumns,c=o.isSelected,u=o.isInitialFocusedCell,f=o.onExpandRowClick,h=o.pinned,w=o.rowIndex,m=o.visibleRow,p=t(o,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isInitialFocusedCell","onExpandRowClick","pinned","rowIndex","visibleRow"]);return e.jsx(H,r({allowAnimations:p.allowAnimations,allowHorizontalAnimate:p.shouldPaginate,draggedHeaderRef:p.draggedHeaderRef,headersRef:p.headersRef,isBody:!0,mainBodyRef:p.mainBodyRef,pauseAnimation:p.isWidthDragging,rowIndex:w+1},{children:s.map((function(e,t){return g({hiddenColumns:d,header:e,pinned:h})?n.createElement(M,r({},p,{borderClass:i({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId}),colIndex:t,header:e,isSelected:c({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId}),isInitialFocusedCell:u({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId}),key:v({accessor:e.accessor,rowIndex:w+1}),onExpandRowClick:f,onMouseDown:function(){return a({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId})},onMouseOver:function(){return l({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId})},rowIndex:w,visibleRow:m})):null}))}))},E=function(n){var t=n.getNextRowIndex,o=n.gridTemplateColumns,i=n.index,a=n.pinned,l=n.props,s=n.rowHeight,d=n.visibleRow,c=d.position,u=t();return e.jsx("div",r({className:"st-table-row",style:{gridTemplateColumns:o,top:h({position:c,rowHeight:s}),height:"".concat(s,"px")}},{children:e.jsx(S,r({pinned:a,rowIndex:u,visibleRow:d},l),i)}))},D=function(n){var t=n.lastGroupRow,o=n.position,i=n.rowHeight,a=n.templateColumns;return e.jsx("div",r({className:"st-row-separator ".concat(t?"st-last-group-row":""),style:{display:"grid",gridTemplateColumns:a,position:"absolute",top:f({position:o,rowHeight:i}),minWidth:"100%"}},{children:e.jsx("div",{style:{gridColumn:"1 / -1"}})}))},k=function(o){o.headerContainerRef;var i=o.onExpandRowClick,a=o.pinned,l=o.rowHeight,s=o.sectionRef,d=o.templateColumns,c=o.totalHeight,u=o.visibleRows,f=o.width,h=t(o,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),v=a?"st-table-body-pinned-".concat(a):"st-table-body-main",g=n.useRef(0);n.useEffect((function(){g.current=0}));var w=function(){return g.current++};return e.jsx("div",r({className:v,ref:s,style:{position:"relative",height:"".concat(c,"px"),width:f}},{children:u.map((function(t,o){var s,c,f=Boolean(null===(c=null===(s=t.row.rowMeta)||void 0===s?void 0:s.children)||void 0===c?void 0:c.length);return e.jsxs(n.Fragment,{children:[e.jsx(E,{getNextRowIndex:w,gridTemplateColumns:d,index:o,pinned:a,props:r(r({},h),{onExpandRowClick:i,rowHeight:l,visibleRows:u}),rowHeight:l,visibleRow:t}),0!==o&&e.jsx(D,{lastGroupRow:f,position:t.position,rowHeight:l,templateColumns:d})]},o)}))}))},N=function(t){var o,i,a,l,s,d=t.centerHeaderRef,c=t.flattenedRows,u=t.headerContainerRef,f=t.mainBodyRef,h=t.mainTemplateColumns,v=t.pinnedLeftColumns,g=t.pinnedLeftHeaderRef,w=t.pinnedLeftRef,m=t.pinnedLeftTemplateColumns,p=t.pinnedRightColumns,x=t.pinnedRightHeaderRef,R=t.pinnedRightRef,I=t.pinnedRightTemplateColumns,C=t.rowHeight,b=t.scrollbarWidth,y=t.setFlattenedRows,M=t.setScrollTop,H=t.tableBodyContainerRef,j=t.visibleRows;!function(e){var r=e.headerContainerRef,t=e.mainSectionRef,o=e.scrollbarWidth,i=n.useState(!1),a=i[0],l=i[1];n.useEffect((function(){var e=null==r?void 0:r.current;if(a&&e)return e.classList.add("st-header-scroll-padding"),e.style.setProperty("--st-after-width","".concat(o,"px")),function(){e.classList.remove("st-header-scroll-padding")}}),[r,a,o]),n.useEffect((function(){var e=null==r?void 0:r.current,n=null==t?void 0:t.current;if(n&&e){var o=function(){if(n){var e=n.scrollHeight>n.clientHeight;l(e)}};o();var i=new ResizeObserver((function(){o()}));return i.observe(n),function(){n&&i.unobserve(n)}}}),[r,t])}({headerContainerRef:u,mainSectionRef:H,scrollbarWidth:b});var S,E,D=n.useRef(null),N=(S=0,(E=function(e){e.forEach((function(e){S+=1,e.rowMeta.isExpanded&&e.rowMeta.children&&E(e.rowMeta.children)}))})(c),S)*(C+1)-1,L=function(e){var n=function(t){return t.rowMeta.rowId===e&&t.rowMeta.children?r(r({},t),{rowMeta:r(r({},t.rowMeta),{isExpanded:!t.rowMeta.isExpanded})}):t.rowMeta.children?r(r({},t),{rowMeta:r(r({},t.rowMeta),{children:t.rowMeta.children.map(n)})}):t};y((function(e){return e.map(n)}))},T=(null===(o=g.current)||void 0===o?void 0:o.clientWidth)?(null===(i=g.current)||void 0===i?void 0:i.clientWidth)+1:0,O=null===(a=d.current)||void 0===a?void 0:a.clientWidth,B=(null===(l=x.current)||void 0===l?void 0:l.clientWidth)?(null===(s=x.current)||void 0===s?void 0:s.clientWidth)+1:0;return e.jsxs("div",r({className:"st-table-body-container",ref:H,onScroll:function(e){var n=e.currentTarget.scrollTop;D.current&&cancelAnimationFrame(D.current),D.current=requestAnimationFrame((function(){M(n)}))}},{children:[v.length>0&&e.jsx(k,r({},t,{onExpandRowClick:L,pinned:"left",rowHeight:C,sectionRef:w,templateColumns:m,totalHeight:N,visibleRows:j,width:T})),e.jsx(k,r({},t,{onExpandRowClick:L,rowHeight:C,sectionRef:f,templateColumns:h,totalHeight:N,visibleRows:j,width:O})),p.length>0&&e.jsx(k,r({},t,{onExpandRowClick:L,pinned:"right",rowHeight:C,sectionRef:R,templateColumns:I,totalHeight:N,visibleRows:j,width:B}))]}))},L={string:function(e,n,r){if(e===n)return 0;var t=e.localeCompare(n);return"ascending"===r?t:-t},number:function(e,n,r){if(e===n)return 0;var t=e-n;return"ascending"===r?t:-t},boolean:function(e,n,r){if(e===n)return 0;var t=e===n?0:e?-1:1;return"ascending"===r?t:-t},date:function(e,n,r){var t=new Date(e),o=new Date(n);if(t.getTime()===o.getTime())return 0;var i=t.getTime()-o.getTime();return"ascending"===r?i:-i},enum:function(e,n,r){return L.string(e,n,r)},default:function(e,n,r){return e===n?0:null==e?"ascending"===r?-1:1:null==n?"ascending"===r?1:-1:"string"==typeof e&&"string"==typeof n?L.string(e,n,r):"number"==typeof e&&"number"==typeof n?L.number(e,n,r):"boolean"==typeof e&&"boolean"==typeof n?L.boolean(e,n,r):L.string(String(e),String(n),r)}},T=function(e,n,r,t){if(void 0===r&&(r="string"),null==e||""===e)return"ascending"===t?-1:1;if(null==n||""===n)return"ascending"===t?1:-1;if("number"===r){var o=function(e){var n;if("number"==typeof e)return e;var r=String(e);if("string"==typeof r){var t=r.replace(/[$,]/g,"").match(/^([-+]?\d*\.?\d+)([TBMKtbmk])?/);if(t){var o=parseFloat(t[1]),i=null===(n=t[2])||void 0===n?void 0:n.toUpperCase();return"T"===i?o*=1e12:"B"===i?o*=1e9:"M"===i?o*=1e6:"K"===i&&(o*=1e3),o}}return parseFloat(r)||0},i=o(e),a=o(n);return L.number(i,a,t)}return"date"===r?L.date(String(e),String(n),t):"boolean"===r?L.boolean(Boolean(e),Boolean(n),t):"enum"===r?L.enum(String(e),String(n),t):L.string(String(e),String(n),t)},O=function(e,n,t){var i=t.find((function(e){return e.accessor===n.key.accessor})),a=(null==i?void 0:i.type)||"string",l=n.direction,s=new Map,d=new Map,c="";e.forEach((function(e){var r;if(e.rowData&&!e.rowData[n.key.accessor]&&void 0!==e.rowMeta.isExpanded){var t=(e.rowData.sector||"group_".concat(s.size)).toString();c=t,d.set(c,e),s.has(c)||s.set(c,[])}else if(c){var o=s.get(c)||[];o.push(e),s.set(c,o)}else{var i="default";s.has(i)||s.set(i,[]),null===(r=s.get(i))||void 0===r||r.push(e)}}));var u=[];return s.forEach((function(e,i){if(d.has(i)){var s=d.get(i);s.rowMeta.children&&s.rowMeta.children.length>0&&(s.rowMeta.children=B(s.rowMeta.children,n,t)),u.push(s)}var c=o([],e,!0).sort((function(e,r){if(!(null==e?void 0:e.rowData)||!(null==r?void 0:r.rowData))return 0;var t=n.key.accessor,o=e.rowData[t],i=r.rowData[t];return T(o,i,a,l)}));u.push.apply(u,c.map((function(e){var o=r({},e);if(o.rowMeta.children&&o.rowMeta.children.length>0){var i=B(o.rowMeta.children,n,t);o.rowMeta=r(r({},o.rowMeta),{children:i})}return o})))})),u},B=function(e,n,t){var i=t.find((function(e){return e.accessor===n.key.accessor})),a=(null==i?void 0:i.type)||"string",l=n.direction;return o([],e,!0).sort((function(e,r){if(!(null==e?void 0:e.rowData)||!(null==r?void 0:r.rowData))return 0;var t=n.key.accessor,o=e.rowData[t],i=r.rowData[t];return T(o,i,a,l)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?r(r({},e),{rowMeta:r(r({},e.rowMeta),{children:B(e.rowMeta.children,n,t)})}):e}))},W=function(e){var n=e.event,r=e.forceUpdate,t=e.header,o=e.headersRef,i=e.index;e.reverse;var a=e.setIsWidthDragging,l=e.startWidth;a(!0),n.preventDefault();var s=n.clientX;if(t){var d=function(e){var n=Math.max(l+(e.clientX-s),40);t&&o.current&&(o.current[i].width=n,r())},c=function(){document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",c),a(!1)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",c)}},A=n.forwardRef((function(t,o){var i,l=t.columnResizing,s=t.currentRows,d=t.columnReordering,c=t.draggedHeaderRef,u=t.forceUpdate,f=t.headersRef,h=t.hoveredHeaderRef,g=t.index,w=t.onColumnOrderChange,m=t.onSort,p=t.onTableHeaderDragEnd,x=t.reverse,R=t.rowHeight,C=t.selectableColumns,b=t.setIsWidthDragging,M=t.setSelectedCells,H=t.sort,j=t.sortDownIcon,S=t.sortUpIcon,E=n.useState(!1),D=E[0],k=E[1],N=null===(i=f.current)||void 0===i?void 0:i[g],L=Boolean(null==N?void 0:N.isSortable),T="st-header-cell ".concat(N===h.current?"st-hovered":""," ").concat(D?"st-dragging":""," ").concat(L?"clickable":""," ").concat(d&&!L?"columnReordering":""," ").concat("right"===(null==N?void 0:N.align)?"right-aligned":"center"===(null==N?void 0:N.align)?"center-aligned":""),O=y({draggedHeaderRef:c,headersRef:f,hoveredHeaderRef:h,onColumnOrderChange:w,onTableHeaderDragEnd:p}),B=O.handleDragStart,A=O.handleDragEnd,P=O.handleDragOver,F=I(),z=function(e){var n=e.event,r=e.header;if(C){var t=s.length,o=Array.from({length:t},(function(e,n){return a({rowIndex:n,colIndex:g,rowId:s[n].rowMeta.rowId})})),i=function(e,n){var r=new Set,o=Math.min(e,n),i=Math.max(e,n);return Array.from({length:t}).forEach((function(e,n){Array.from({length:i-o+1}).forEach((function(e,t){r.add(a({rowIndex:n,colIndex:o+t,rowId:s[n].rowMeta.rowId}))}))})),r};n.shiftKey?M((function(e){var n,r=Number(null===(n=Array.from(e)[0])||void 0===n?void 0:n.split("-")[1]),t=Number(o[0].split("-")[1]);return r===t?new Set(o):r>t?i(t,r):i(r,t)})):M(new Set(o))}else r.isSortable&&m(g,r.accessor)};if(n.useEffect((function(){var e=function(e){e.preventDefault(),e.dataTransfer.dropEffect="move"};return document.addEventListener("dragover",e),function(){document.removeEventListener("dragover",e)}}),[]),!N)return null;var U=l&&e.jsx("div",{className:"st-header-resize-handle",onMouseDown:function(e){var n;F({callback:W,callbackProps:{event:e,forceUpdate:u,header:N,headersRef:f,index:g,setIsWidthDragging:b,startWidth:"object"==typeof o&&null!==o&&"current"in o?null===(n=o.current)||void 0===n?void 0:n.offsetWidth:void 0},limit:10})}}),q=H&&H.key.accessor===N.accessor&&e.jsxs("div",r({className:"st-sort-icon-container",onClick:function(e){return z({event:e,header:N})}},{children:["ascending"===H.direction&&S&&S,"descending"===H.direction&&j&&j]}));return e.jsxs("div",r({className:T,id:v({accessor:N.accessor,rowIndex:0}),onDragOver:function(e){F({callback:P,callbackProps:{event:e,hoveredHeader:N},limit:50})},ref:o,style:{width:N.width,height:R}},{children:[x&&U,e.jsxs("div",r({className:"st-header-label ".concat("right"===N.align?"right-aligned":"center"===N.align?"center-aligned":""),draggable:d,onClick:function(e){return z({event:e,header:N})},onDragEnd:function(e){e.preventDefault(),k(!1),A()},onDragStart:function(e){d&&N&&function(e){k(!0),B(e)}(N)}},{children:["right"===N.align&&q,null==N?void 0:N.label,"right"!==N.align&&q]})),!x&&U]}))})),P=function(e,r){n.useEffect((function(){if(e.current){var n=e.current,t=function(){var e,t=null==n?void 0:n.scrollLeft;void 0!==t&&(null===(e=r.current)||void 0===e||e.scrollTo(t,0))};return n.addEventListener("scroll",t),function(){null==n||n.removeEventListener("scroll",t)}}}),[e,r])},F=function(t){var o,i,a,l=t.allowAnimations,s=t.centerHeaderRef,d=t.columnResizing,c=t.currentRows,u=t.columnReordering,f=t.draggedHeaderRef,h=t.forceUpdate,v=t.headerContainerRef,w=t.headersRef,m=t.hiddenColumns,p=t.hoveredHeaderRef,x=t.isWidthDragging,R=t.mainBodyRef,I=t.mainTemplateColumns,C=t.onColumnOrderChange,b=t.onSort,y=t.onTableHeaderDragEnd,M=t.pinnedLeftColumns,j=t.pinnedLeftHeaderRef,S=t.pinnedLeftTemplateColumns,E=t.pinnedRightColumns,D=t.pinnedRightHeaderRef,k=t.pinnedRightTemplateColumns,N=t.rowHeight,L=t.selectableColumns,T=t.setIsWidthDragging,O=t.setSelectedCells,B=t.sort,W=t.sortDownIcon,F=t.sortUpIcon;P(R,s);return e.jsxs("div",r({className:"st-header-container",ref:v},{children:[M.length>0&&e.jsx("div",r({className:"st-header-pinned-left",ref:j,style:{gridTemplateColumns:S}},{children:e.jsx(H,r({allowAnimations:l,draggedHeaderRef:f,headersRef:w,mainBodyRef:R,pauseAnimation:x,rowIndex:0},{children:null===(o=w.current)||void 0===o?void 0:o.map((function(r,t){return g({hiddenColumns:m,header:r,pinned:"left"})?e.jsx(A,{columnResizing:d,currentRows:c,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:t,onColumnOrderChange:C,onSort:b,onTableHeaderDragEnd:y,ref:n.createRef(),rowHeight:N,selectableColumns:L,setIsWidthDragging:T,setSelectedCells:O,sort:B,sortDownIcon:W,sortUpIcon:F},r.accessor):null}))}))})),e.jsx("div",r({className:"st-header-main",onScroll:function(e){var n,r,t=null===(n=s.current)||void 0===n?void 0:n.scrollLeft;void 0!==t&&(null===(r=R.current)||void 0===r||r.scrollTo(t,0))},ref:s,style:{gridTemplateColumns:I}},{children:e.jsx(H,r({allowAnimations:l,draggedHeaderRef:f,headersRef:w,mainBodyRef:R,pauseAnimation:x,rowIndex:0},{children:null===(i=w.current)||void 0===i?void 0:i.map((function(r,t){return g({hiddenColumns:m,header:r})?e.jsx(A,{columnResizing:d,currentRows:c,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:t,onColumnOrderChange:C,onSort:b,onTableHeaderDragEnd:y,ref:n.createRef(),rowHeight:N,selectableColumns:L,setIsWidthDragging:T,setSelectedCells:O,sort:B,sortDownIcon:W,sortUpIcon:F},r.accessor):null}))}))})),E.length>0&&e.jsx("div",r({className:"st-header-pinned-right",ref:D,style:{gridTemplateColumns:k}},{children:e.jsx(H,r({allowAnimations:l,draggedHeaderRef:f,headersRef:w,mainBodyRef:R,pauseAnimation:x,rowIndex:0},{children:null===(a=w.current)||void 0===a?void 0:a.map((function(r,t){return g({hiddenColumns:m,header:r,pinned:"right"})?e.jsx(A,{columnResizing:d,currentRows:c,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:t,onColumnOrderChange:C,onSort:b,onTableHeaderDragEnd:y,reverse:!0,ref:n.createRef(),rowHeight:N,selectableColumns:L,setIsWidthDragging:T,setSelectedCells:O,sort:B,sortDownIcon:W,sortUpIcon:F},r.accessor):null}))}))}))]}))},z=function(e){var n=e.minWidth,r=e.width;return"number"==typeof r&&(r="".concat(r,"px")),n&&"number"==typeof n&&(n="".concat(n,"px")),void 0!==n?"minmax(".concat(n,", ").concat(r,")"):r},U=function(t){var o=t.allowAnimations,i=t.columnReordering,a=t.columnResizing,l=t.currentRows,s=t.draggedHeaderRef,d=t.editColumns,c=t.flattenedRows,u=t.forceUpdate,f=t.getBorderClass,h=t.handleMouseDown,v=t.handleMouseOver,g=t.headersRef,w=t.hiddenColumns,m=t.hoveredHeaderRef,p=t.isSelected,x=t.isInitialFocusedCell,R=t.isWidthDragging,I=t.mainBodyRef,C=t.onCellEdit,b=t.onColumnOrderChange,y=t.onSort,M=t.onTableHeaderDragEnd,H=t.pinnedLeftRef,j=t.pinnedRightRef,S=t.rowHeight,E=t.scrollbarWidth,D=t.selectableColumns,k=t.setIsWidthDragging,L=t.setFlattenedRows,T=t.setScrollTop,O=t.setSelectedCells,B=t.shouldPaginate,W=t.sort,A=t.sortDownIcon,P=t.sortUpIcon,U=t.tableBodyContainerRef,q=t.visibleRows,K=n.useRef(null),V=n.useRef(null),J=n.useRef(null),X=n.useRef(null),Y=g.current.filter((function(e){return!e.hide&&!e.pinned})),G=g.current.filter((function(e){return"left"===e.pinned&&!0!==e.hide})),_=g.current.filter((function(e){return"right"===e.pinned&&!0!==e.hide})),$=n.useMemo((function(){return"".concat(G.map((function(e){return z(e)})).join(" "))}),[G]),Q=n.useMemo((function(){return"".concat(Y.filter((function(e){return!0!==w[e.accessor]})).map((function(e){return z(e)})).join(" "))}),[Y,w]),Z=n.useMemo((function(){return"".concat(_.map((function(e){return z(e)})).join(" "))}),[_]),ee={allowAnimations:o,centerHeaderRef:J,columnResizing:a,currentRows:l,columnReordering:i,draggedHeaderRef:s,forceUpdate:u,headerContainerRef:K,headersRef:g,hiddenColumns:w,hoveredHeaderRef:m,isWidthDragging:R,mainBodyRef:I,mainTemplateColumns:Q,onColumnOrderChange:b,onSort:y,onTableHeaderDragEnd:M,pinnedLeftColumns:G,pinnedLeftHeaderRef:V,pinnedLeftTemplateColumns:$,pinnedRightColumns:_,pinnedRightHeaderRef:X,pinnedRightTemplateColumns:Z,rowHeight:S,selectableColumns:D,setIsWidthDragging:k,setSelectedCells:O,sort:W,sortDownIcon:A,sortUpIcon:P,tableBodyContainerRef:U},ne={allowAnimations:o,centerHeaderRef:J,draggedHeaderRef:s,flattenedRows:c,getBorderClass:f,handleMouseDown:h,handleMouseOver:v,headerContainerRef:K,headers:g.current,headersRef:g,hiddenColumns:w,hoveredHeaderRef:m,isSelected:p,isInitialFocusedCell:x,isWidthDragging:R,mainBodyRef:I,mainTemplateColumns:Q,onCellEdit:C,onTableHeaderDragEnd:M,pinnedLeftColumns:G,pinnedLeftHeaderRef:V,pinnedLeftRef:H,pinnedLeftTemplateColumns:$,pinnedRightColumns:_,pinnedRightHeaderRef:X,pinnedRightRef:j,pinnedRightTemplateColumns:Z,rowHeight:S,scrollbarWidth:E,setFlattenedRows:L,shouldPaginate:B,setScrollTop:T,tableBodyContainerRef:U,visibleRows:q};return e.jsxs("div",r({className:"st-table-content",style:{width:d?"calc(100% - 27.5px)":"100%"}},{children:[e.jsx(F,r({},ee)),e.jsx(N,r({},ne))]}))},q=function(e){var r=e.callback,t=e.ref,o=e.widthAttribute;n.useEffect((function(){var e=t.current;if(e){var n=function(){r(e[o]||0)};n();var i=new ResizeObserver((function(){n()}));return i.observe(e),function(){return i.disconnect()}}}),[r,t,o])},K=function(t){var o=t.mainBodyRef,i=t.pinnedLeftRef,a=t.pinnedRightRef,l=t.tableContentWidth,s=n.useState(0),d=s[0],c=s[1],u=n.useState(0),f=u[0],h=u[1],v=n.useState(0),g=v[0],w=v[1],m=n.useRef(null);return q({widthAttribute:"offsetWidth",callback:c,ref:i}),q({widthAttribute:"scrollWidth",callback:w,ref:o}),q({widthAttribute:"offsetWidth",callback:h,ref:a}),P(o,m),!o.current||o.current.scrollWidth<=o.current.clientWidth?null:e.jsxs("div",r({className:"st-horizontal-scrollbar-container",style:{width:l}},{children:[d>0&&e.jsx("div",{className:"st-horizontal-scrollbar-left",style:{flexShrink:0,width:d}}),g>0&&e.jsx("div",r({className:"st-horizontal-scrollbar-middle",onScroll:function(e){var n=e.target.scrollLeft;void 0!==n&&o.current&&o.current.scrollTo({left:n,behavior:"auto"})},ref:m},{children:e.jsx("div",{style:{width:g}})})),f>0&&e.jsx("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:f}})]}))},V=function(e){var r=e.headers,t=e.tableRows,o=n.useState(null),i=o[0],a=o[1],l=n.useMemo((function(){var e={};return r.forEach((function(n){!0===n.hide&&(e[n.accessor]=!0)})),e}),[r]),s=n.useState(l),d=s[0],c=s[1],u=n.useMemo((function(){if(!i)return t;var e=function(e,n,r){return{sortedData:O(n,r,e),newSortConfig:r}}(r,t,i).sortedData;return e}),[t,i,r]);return{sort:i,setSort:a,updateSort:function(e,n){var t=r.find((function(e){return e.accessor===n}));t&&a((function(e){return e&&e.key.accessor===n?"ascending"===e.direction?{key:t,direction:"descending"}:null:{key:t,direction:"ascending"}}))},sortedRows:u,hiddenColumns:d,setHiddenColumns:c}},J=function(t){var o=t.checked,i=void 0!==o&&o,a=t.children,l=t.onChange,s=n.useState(i),d=s[0],c=s[1];return e.jsxs("label",r({className:"st-checkbox-label"},{children:[e.jsx("input",{checked:d,className:"st-checkbox-input",onChange:function(){var e=!d;c(e),l&&l(e)},type:"checkbox"}),e.jsx("span",r({className:"st-checkbox-custom ".concat(d?"st-checked":"")},{children:d&&e.jsx("span",{className:"st-checkbox-checkmark"})})),a]}))},X=function(n){var t=n.headers,o=n.open,i=n.position;n.setOpen;var a=n.setHiddenColumns,l=n.hiddenColumns,s="left"===i?"left":"";return e.jsx("div",r({className:"st-column-editor-popout ".concat(o?"open":""," ").concat(s),onClick:function(e){return e.stopPropagation()}},{children:e.jsx("div",r({className:"st-column-editor-popout-content"},{children:t.map((function(n,t){return e.jsx(J,r({checked:l[n.accessor],onChange:function(e){var t;return a(r(r({},l),((t={})[n.accessor]=e,t)))}},{children:n.label}),t)}))}))}))},Y=function(t){var o=t.columnEditorText,i=t.editColumns,a=t.editColumnsInitOpen,l=t.headers,s=t.position,d=void 0===s?"right":s,c=t.setHiddenColumns,u=t.hiddenColumns,f=n.useState(a),h=f[0],v=f[1];return i?e.jsxs("div",r({className:"st-column-editor ".concat(h?"open":""," ").concat(d),onClick:function(){return function(e){v(e)}(!h)}},{children:[e.jsx("div",r({className:"st-column-editor-text"},{children:o})),e.jsx(X,{headers:l,open:h,position:d,setOpen:v,setHiddenColumns:c,hiddenColumns:u})]})):null};!function(e){e.Left="left",e.Right="right"}(i||(i={}));var G=n.memo((function(t){var o=t.allowAnimations,f=void 0!==o&&o,h=t.columnEditorPosition,v=void 0===h?i.Right:h,g=t.columnEditorText,w=void 0===g?"Columns":g,m=t.columnResizing,p=void 0!==m&&m,x=t.defaultHeaders,R=t.editColumns,I=void 0!==R&&R,C=t.editColumnsInitOpen,b=void 0!==C&&C,y=t.columnReordering,M=void 0!==y&&y,H=t.height,j=t.hideFooter,S=void 0!==j&&j,E=t.nextIcon,D=void 0===E?e.jsx(d,{className:"st-next-prev-icon"}):E,k=t.onCellEdit,N=t.onColumnOrderChange,L=t.onNextPage,T=t.onPreviousPage,O=t.prevIcon,B=void 0===O?e.jsx(s,{className:"st-next-prev-icon"}):O,W=t.rowHeight,A=void 0===W?40:W,P=t.rows,F=t.rowsPerPage,z=void 0===F?10:F,q=t.selectableCells,J=void 0!==q&&q,X=t.selectableColumns,G=void 0!==X&&X,_=t.shouldPaginate,$=void 0!==_&&_,Q=t.sortDownIcon,Z=void 0===Q?e.jsx(u,{className:"st-sort-icon"}):Q,ee=t.sortUpIcon,ne=void 0===ee?e.jsx(c,{className:"st-sort-icon"}):ee,re=t.theme,te=void 0===re?"light":re,oe=t.totalPages,ie=n.useRef(null),ae=n.useRef(x),le=n.useRef(null),se=n.useRef(null),de=n.useRef(null),ce=n.useRef(null),ue=n.useRef(null),fe=n.useState(!1),he=fe[0],ve=fe[1],ge=n.useState(1),we=ge[0],me=ge[1],pe=n.useState(0),xe=pe[0],Re=pe[1],Ie=n.useState(0),Ce=Ie[0],be=Ie[1],ye=n.useState(0),Me=ye[0],He=ye[1],je=V({headers:ae.current,tableRows:P}),Se=je.sort,Ee=je.sortedRows,De=je.hiddenColumns,ke=je.setHiddenColumns,Ne=je.updateSort,Le=n.useMemo((function(){if(!$)return Ee;var e=(we-1)*z,n=e+z;return Ee.slice(e,n)}),[we,z,$,Ee]),Te=n.useState(Le),Oe=Te[0],Be=Te[1];n.useEffect((function(){Be(Le)}),[Le]);var We=n.useMemo((function(){var e;if(!H)return window.innerHeight-A;var n=document.querySelector(".simple-table-root"),r=0;if(H.endsWith("px"))r=parseInt(H,10);else if(H.endsWith("vh")){var t=parseInt(H,10);r=window.innerHeight*t/100}else if(H.endsWith("%")){var o=parseInt(H,10);r=((null===(e=null==n?void 0:n.parentElement)||void 0===e?void 0:e.clientHeight)||window.innerHeight)*o/100}else r=window.innerHeight;return Math.max(0,r-A)}),[H,A]),Ae=n.useMemo((function(){return function(e){var n=e.bufferRowCount,r=e.contentHeight,t=e.flattenedRows,o=e.rowHeight,i=e.scrollTop,a=[],l=0,s=Math.max(0,i-o*n),d=i+r+o*n,c=function(e,n){for(var r,t=0,i=e;t<i.length;t++){var u=i[t],f=l*o;if(f>=d)break;f+o>s&&a.push({row:u,depth:n,position:l,isLastGroupRow:Boolean(null===(r=u.rowMeta.children)||void 0===r?void 0:r.length)&&n>1}),l+=1,u.rowMeta.isExpanded&&u.rowMeta.children&&c(u.rowMeta.children,n+1)}};return c(t,0),a}({bufferRowCount:5,contentHeight:We,flattenedRows:Oe,rowHeight:A,scrollTop:Me})}),[We,A,Oe,Me]),Pe=n.useReducer((function(e){return e+1}),0)[1],Fe=function(e){var r=e.selectableCells,t=e.headers,o=e.visibleRows,i=n.useState(new Set),l=i[0],s=i[1],d=n.useState(null),c=d[0],u=d[1],f=n.useRef(!1),h=n.useRef(null),v=n.useCallback((function(){var e=Array.from(l).reduce((function(e,n){var r=n.split("-").map(Number),i=r[0],a=r[1];return e[i]||(e[i]=[]),e[i][a]=o[i].row.rowData[t[a].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");l.size>0&&navigator.clipboard.writeText(n)}),[t,l,o]),g=n.useCallback((function(e,n){for(var r=new Set,t=Math.min(e.rowIndex,n.rowIndex),i=Math.max(e.rowIndex,n.rowIndex),l=Math.min(e.colIndex,n.colIndex),d=Math.max(e.colIndex,n.colIndex),c=t;c<=i;c++)for(var u=l;u<=d;u++)if(c>=0&&c<o.length){var f=o[c].row.rowMeta.rowId;r.add(a({colIndex:u,rowIndex:c,rowId:f}))}s(r)}),[o]),w=n.useCallback((function(e){if(e.rowIndex>=0&&e.rowIndex<o.length&&e.colIndex>=0&&e.colIndex<t.length){var n=a(e);s(new Set([n])),u(e)}}),[t.length,o.length]);n.useEffect((function(){var e=function(e){if(r&&c){var n=c.rowIndex,i=c.colIndex,a=c.rowId;if(!e.ctrlKey&&!e.metaKey||"c"!==e.key){if(o[n].row.rowMeta.rowId!==a){var l=o.findIndex((function(e){return e.row.rowMeta.rowId===a}));if(-1===l)return;n=l}if("ArrowUp"===e.key){if(e.preventDefault(),n>0){var d={rowIndex:n-1,colIndex:i,rowId:o[n-1].row.rowMeta.rowId};w(d)}}else"ArrowDown"===e.key?(e.preventDefault(),n<o.length-1&&(d={rowIndex:n+1,colIndex:i,rowId:o[n+1].row.rowMeta.rowId},w(d))):"ArrowLeft"===e.key||"Tab"===e.key&&e.shiftKey?(e.preventDefault(),i>0&&(d={rowIndex:n,colIndex:i-1,rowId:o[n].row.rowMeta.rowId},w(d))):"ArrowRight"===e.key||"Tab"===e.key?(e.preventDefault(),i<t.length-1&&(d={rowIndex:n,colIndex:i+1,rowId:o[n].row.rowMeta.rowId},w(d))):"Escape"===e.key&&(s(new Set),h.current=null,u(null))}else v()}};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[v,t.length,c,g,w,r,o]);var m=n.useCallback((function(e){var n=e.colIndex,r=e.rowIndex,t=e.rowId,o=a({colIndex:n,rowIndex:r,rowId:t});return l.has(o)}),[l]),p=n.useCallback((function(e){var n,r,t,i,a,l,s=e.colIndex,d=e.rowIndex,c=e.rowId,u=[],f=null===(t=null===(r=null===(n=o[d-1])||void 0===n?void 0:n.row)||void 0===r?void 0:r.rowMeta)||void 0===t?void 0:t.rowId,h={colIndex:s,rowIndex:d+1,rowId:null===(l=null===(a=null===(i=o[d+1])||void 0===i?void 0:i.row)||void 0===a?void 0:a.rowMeta)||void 0===l?void 0:l.rowId},v={colIndex:s-1,rowIndex:d,rowId:c},g={colIndex:s+1,rowIndex:d,rowId:c};return m({colIndex:s,rowIndex:d-1,rowId:f})||u.push("st-selected-top-border"),m(h)||u.push("st-selected-bottom-border"),m(v)||u.push("st-selected-left-border"),m(g)||u.push("st-selected-right-border"),u.join(" ")}),[m,o]),x=n.useMemo((function(){return c?function(e){var n=e.rowIndex,r=e.colIndex,t=e.rowId;return n===c.rowIndex&&r===c.colIndex&&t===c.rowId}:function(){return!1}}),[c]);return{getBorderClass:p,handleMouseDown:function(e){var n=e.colIndex,t=e.rowIndex,o=e.rowId;if(r){f.current=!0,h.current={rowIndex:t,colIndex:n,rowId:o};var i=a({colIndex:n,rowIndex:t,rowId:o});s(new Set([i])),u({rowIndex:t,colIndex:n,rowId:o})}},handleMouseOver:function(e){var n=e.colIndex,t=e.rowIndex;if(e.rowId,r&&f.current&&h.current){for(var i=new Set,l=Math.min(h.current.rowIndex,t),d=Math.max(h.current.rowIndex,t),c=Math.min(h.current.colIndex,n),u=Math.max(h.current.colIndex,n),v=l;v<=d;v++)for(var g=c;g<=u;g++)if(v>=0&&v<o.length){var w=o[v].row.rowMeta.rowId;i.add(a({colIndex:g,rowIndex:v,rowId:w}))}s(i)}},handleMouseUp:function(){f.current=!1},isInitialFocusedCell:x,isSelected:m,selectedCells:l,setSelectedCells:s}}({selectableCells:J,headers:ae.current,visibleRows:Ae}),ze=Fe.handleMouseDown,Ue=Fe.handleMouseOver,qe=Fe.handleMouseUp,Ke=Fe.isSelected,Ve=Fe.getBorderClass,Je=Fe.isInitialFocusedCell,Xe=Fe.setSelectedCells,Ye=n.useCallback((function(e,n){Ne(e,n)}),[Ne]),Ge=n.useCallback((function(e){ae.current=e,Pe()}),[]);return n.useEffect((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||G&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||Xe(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[G,Xe]),n.useLayoutEffect((function(){if(ue.current){var e=ue.current.offsetWidth-ue.current.clientWidth,n=ue.current.clientWidth;Re(e),be(n)}}),[]),n.useLayoutEffect((function(){var e=function(){if(Pe(),ue.current){var e=ue.current.offsetWidth-ue.current.clientWidth,n=ue.current.clientWidth;Re(e),be(n)}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),e.jsxs("div",r({className:"simple-table-root st-wrapper theme-".concat(te),style:H?{height:H}:{}},{children:[e.jsxs("div",r({className:"st-table-wrapper-container"},{children:[e.jsxs("div",r({className:"st-table-wrapper",onMouseUp:qe,onMouseLeave:qe},{children:[e.jsx(U,{allowAnimations:f,columnReordering:M,columnResizing:p,currentRows:Le,draggedHeaderRef:ie,editColumns:I,flattenedRows:Oe,forceUpdate:Pe,getBorderClass:Ve,handleMouseDown:ze,handleMouseOver:Ue,headers:ae.current,headersRef:ae,hiddenColumns:De,hoveredHeaderRef:le,isInitialFocusedCell:Je,isSelected:Ke,isWidthDragging:he,mainBodyRef:se,onCellEdit:k,onColumnOrderChange:N,onSort:Ye,onTableHeaderDragEnd:Ge,pinnedLeftRef:de,pinnedRightRef:ce,rowHeight:A,scrollbarWidth:xe,selectableColumns:G,setIsWidthDragging:ve,setFlattenedRows:Be,setScrollTop:He,setSelectedCells:Xe,shouldPaginate:$,sort:Se,sortDownIcon:Z,sortUpIcon:ne,tableBodyContainerRef:ue,visibleRows:Ae}),e.jsx(Y,{columnEditorText:w,editColumns:I,editColumnsInitOpen:b,headers:ae.current,hiddenColumns:De,position:v,setHiddenColumns:ke})]})),e.jsx(K,{mainBodyRef:se,pinnedLeftRef:de,pinnedRightRef:ce,tableContentWidth:Ce})]})),e.jsx(l,{currentPage:we,hideFooter:S,nextIcon:D,onPageChange:me,onNextPage:L,onPreviousPage:T,prevIcon:B,shouldPaginate:$,totalPages:oe||Math.ceil(Ee.length/z)})]}))}));exports.SimpleTable=G;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=function(){return r=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},r.apply(this,arguments)};function t(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]])}return r}function o(e,n,r){if(r||2===arguments.length)for(var t,o=0,a=n.length;o<a;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var a,i=function(e){var n=e.rowIndex,r=e.colIndex,t=e.rowId;return"".concat(n,"-").concat(r,"-").concat(t)},l=function(n){var t=n.currentPage,o=n.hideFooter,a=n.nextIcon,i=n.onPageChange,l=n.onNextPage,s=n.onPreviousPage,d=n.prevIcon,c=n.shouldPaginate,u=n.totalPages;if(o||!c)return null;var f=!(t>1)&&!s,h=!(t<u)&&!l;return e.jsxs("div",r({className:"st-footer"},{children:[e.jsx("button",r({className:"st-next-prev-btn ".concat(f?"disabled":""),onClick:function(){var e=t-1;e>=1&&i(e),s&&s(e-1)},disabled:f},{children:d})),e.jsx("button",r({className:"st-next-prev-btn ".concat(h?"disabled":""),onClick:function(){var e=t+1;(e<=u||l)&&i(e),l&&l(t)},disabled:h},{children:a})),Array.from({length:u},(function(n,o){return e.jsx("button",r({onClick:function(){var e;(e=o+1)>=1&&e<=u&&(i(e),e>t&&l?l(e-1):e<t&&s&&s(e-1))},className:"st-page-btn ".concat(t===o+1?"active":"")},{children:o+1}),o)}))]}))},s=function(n){var t=n.className;return e.jsx("svg",r({className:t,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})}))},d=function(n){var t=n.className;return e.jsx("svg",r({className:t,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})}))},c=function(n){var t=n.className;return e.jsx("svg",r({className:t,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M5.41 11.41L10 6.83l4.59 4.58L16 10l-6-6-6 6z"})}))},u=function(n){var t=n.className;return e.jsx("svg",r({className:t,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M5.41 7.59L10 12.17l4.59-4.58L16 9l-6 6-6-6z"})}))},f=function(e){return e.position*(e.rowHeight+1)-1},h=function(e){return e.position*(e.rowHeight+1)},v=function(e){var n=e.accessor,r=e.rowIndex;return"cell-".concat(n,"-").concat(r)},g=function(e){var n=e.hiddenColumns,r=e.header,t=e.pinned;return n[r.accessor]?null:!t&&!r.pinned||r.pinned===t||null},w=function(n){var t=n.value,o=n.onBlur,a=n.onChange;return e.jsxs("select",r({value:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;a("true"===n)}},{children:[e.jsx("option",r({value:"true"},{children:"True"})),e.jsx("option",r({value:"false"},{children:"False"}))]}))},m=function(r){var t=r.defaultValue,o=r.onBlur,a=r.onChange,i=n.useRef(null);return e.jsx("input",{className:"editable-cell-input",ref:i,autoFocus:!0,type:"text",defaultValue:null!=t?t:"",onBlur:o,onChange:function(e){var n=e.target.value;a(n)}})},p=function(r){var t=r.defaultValue,o=r.onBlur,a=r.onChange,i=n.useRef(null);return e.jsx("input",{className:"editable-cell-input",ref:i,autoFocus:!0,defaultValue:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;/^\d*\.?\d*$/.test(n)&&a(n)}})},x=function(n){var r=n.onChange,t=n.setIsEditing,o=n.value,a=function(e){null==r||r(e)},i=function(){t(!1)};return e.jsx(e.Fragment,{children:"string"==typeof o||null==o?e.jsx(m,{defaultValue:o,onBlur:i,onChange:a}):"boolean"==typeof o?e.jsx(w,{onBlur:i,onChange:a,value:o}):"number"==typeof o?e.jsx(p,{defaultValue:o,onBlur:i,onChange:a}):null})},R=0,I=function(){return function(e){var n=e.callback,r=e.callbackProps,t=e.limit,o=Date.now();(0===R||o-R>=t)&&(R=o,n(r))}},C=Date.now(),b={screenX:0,screenY:0},y=function(e){var r,t,a=e.draggedHeaderRef,i=e.headersRef,l=e.hoveredHeaderRef,s=e.onColumnOrderChange,d=e.onTableHeaderDragEnd,c=(r=i.current,t=n.useRef(r),n.useEffect((function(){t.current=r}),[r]),t.current);return{handleDragStart:function(e){a.current=e,C=Date.now()},handleDragOver:function(e){var n,r=e.event,t=e.hoveredHeader;if(r.preventDefault(),i.current){var s=r.currentTarget.getAnimations().some((function(e){return"running"===e.playState})),u=r.screenX,f=r.screenY,h=Math.sqrt(Math.pow(u-b.screenX,2)+Math.pow(f-b.screenY,2));l.current=t;var v=o([],i.current,!0),g=v.findIndex((function(e){var n;return e.accessor===(null===(n=a.current)||void 0===n?void 0:n.accessor)})),w=v.findIndex((function(e){return e.accessor===t.accessor})),m=v.splice(g,1)[0];if(v.splice(w,0,m),!(s||t.accessor===(null===(n=a.current)||void 0===n?void 0:n.accessor)||null===a.current||h<10||void 0===g||void 0===w||JSON.stringify(v)===JSON.stringify(i.current))){var p=Date.now();JSON.stringify(v)===JSON.stringify(c)&&p-C<800&&h<50||(C=p,b={screenX:u,screenY:f},d(v))}}},handleDragEnd:function(){a.current=null,l.current=null,null==s||s(i.current)}}},M=n.forwardRef((function(t,o){var a,i,l=t.borderClass,s=t.colIndex,c=t.draggedHeaderRef,f=t.header,h=t.headersRef,g=t.hoveredHeaderRef,w=t.isSelected,m=t.isInitialFocusedCell,p=t.onCellEdit,R=t.onExpandRowClick,C=t.onMouseDown,b=t.onMouseOver,M=t.onTableHeaderDragEnd,H=t.rowIndex,j=t.visibleRow,S=j.depth,E=j.row,D=n.useState(E.rowData[f.accessor]),k=D[0],N=D[1],L=n.useState(!1),T=L[0],O=L[1],B=y({draggedHeaderRef:c,headersRef:h,hoveredHeaderRef:g,onTableHeaderDragEnd:M}).handleDragOver,W=I(),A="cell-".concat(H,"-").concat(s),P=Boolean(null===(i=null===(a=E.rowMeta)||void 0===a?void 0:a.children)||void 0===i?void 0:i.length),F=Boolean(null==f?void 0:f.isEditable),z=H%2==0,U="st-cell ".concat(S>0&&f.expandable?"st-cell-depth-".concat(S):""," ").concat(w?m?"st-cell-selected-first ".concat(l):"st-cell-selected ".concat(l):""," ").concat(z?"st-cell-odd-row":"st-cell-even-row"," ").concat(F?"clickable":"");n.useEffect((function(){N(E.rowData[f.accessor])}),[f.accessor,E]);return T?e.jsx("div",r({className:"st-cell-editing ".concat(z?"st-cell-odd-row":"st-cell-even-row"),id:v({accessor:f.accessor,rowIndex:H+1})},{children:e.jsx(x,{onChange:function(e){N(e),null==p||p({accessor:f.accessor,newValue:e,row:E})},setIsEditing:O,value:k})})):e.jsxs("div",r({className:U,id:A,onDoubleClick:function(){return f.isEditable&&O(!0)},onMouseDown:function(){return C({rowIndex:H,colIndex:s,rowId:E.rowMeta.rowId})},onMouseOver:function(){return b({rowIndex:H,colIndex:s,rowId:E.rowMeta.rowId})},onDragOver:function(e){return W({callback:B,callbackProps:{event:e,hoveredHeader:f},limit:50})},onKeyDown:function(e){"F2"!==e.key&&"Enter"!==e.key||!f.isEditable||T||(e.preventDefault(),O(!0))},ref:o,"data-row-index":H,"data-col-index":s,"aria-selected":w},{children:[f.expandable&&P?E.rowMeta.isExpanded?e.jsx("div",r({className:"st-sort-icon-container",onClick:function(){return R(E.rowMeta.rowId)}},{children:e.jsx(u,{className:"st-sort-icon"})})):e.jsx("div",r({className:"st-sort-icon-container",onClick:function(){return R(E.rowMeta.rowId)}},{children:e.jsx(d,{className:"st-sort-icon"})})):null,e.jsx("span",r({className:"st-cell-content ".concat("right"===f.align?"right-aligned":"center"===f.align?"center-aligned":"")},{children:f.cellRenderer?f.cellRenderer({accessor:f.accessor,colIndex:s,row:E}):k}))]}))})),H=function(n){var o=n.allowAnimations,a=n.children,i=t(n,["allowAnimations","children"]);return o?e.jsx(j,r({},i,{children:a})):e.jsx(e.Fragment,{children:a})},j=function(r){var t=r.allowHorizontalAnimate,o=void 0===t||t,a=r.children,i=r.draggedHeaderRef,l=r.headersRef,s=r.isBody,d=r.mainBodyRef,c=r.pauseAnimation,u=r.rowIndex,f=n.useRef(!1),h=n.useState({}),g=h[0],w=h[1],m=n.useRef({}),p=l.current;return n.useLayoutEffect((function(){if(p){var e=function(e){var n=e.currentHeaders,r=e.draggedHeaderRef,t=e.rowIndex,o={};return n.forEach((function(e){var n;if(e){var a=document.getElementById(v({accessor:e.accessor,rowIndex:t}));if(a){var i=a.getAnimations().some((function(e){return"running"===e.playState})),l=a.getBoundingClientRect();i&&(null===(n=null==r?void 0:r.current)||void 0===n?void 0:n.accessor)!==e.accessor?o[e.accessor]=!1:o[e.accessor]=l}}})),o}({currentHeaders:p,draggedHeaderRef:i,rowIndex:u});JSON.stringify(e)!==JSON.stringify(g)&&(m.current=g,w(e))}}),[g,p,i,s,u]),n.useLayoutEffect((function(){var e=d.current,n=function(){f.current=!0},r=function(){f.current=!1};return null==e||e.addEventListener("scroll",n),null==e||e.addEventListener("scrollend",r),function(){null==e||e.removeEventListener("scroll",n),null==e||e.removeEventListener("scrollend",r)}}),[i,d]),n.useEffect((function(){c||f.current||Object.keys(m.current).length&&p&&p.forEach((function(e){var n=document.getElementById(v({accessor:e.accessor,rowIndex:u}));if(n){var r=m.current[e.accessor],t=g[e.accessor];if(r&&t){var a=r.left-t.left,i=o?0:r.top-t.top,l=Math.abs(a),s=Math.abs(i);(l>10||s>10)&&requestAnimationFrame((function(){n.style.transform="translate(".concat(a,"px, ").concat(i,"px)"),n.style.transition="transform 0s",requestAnimationFrame((function(){n.style.transform="",n.style.transition="transform ".concat(400,"ms ease-out")}))}))}}}))}),[o,g,p,s,c,m,u]),e.jsx(e.Fragment,{children:a})},S=function(o){var a=o.getBorderClass,i=o.handleMouseDown,l=o.handleMouseOver,s=o.headers,d=o.hiddenColumns,c=o.isSelected,u=o.isInitialFocusedCell,f=o.onExpandRowClick,h=o.pinned,w=o.rowIndex,m=o.visibleRow,p=t(o,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isInitialFocusedCell","onExpandRowClick","pinned","rowIndex","visibleRow"]);return e.jsx(H,r({allowAnimations:p.allowAnimations,allowHorizontalAnimate:p.shouldPaginate,draggedHeaderRef:p.draggedHeaderRef,headersRef:p.headersRef,isBody:!0,mainBodyRef:p.mainBodyRef,pauseAnimation:p.isWidthDragging,rowIndex:w+1},{children:s.map((function(e,t){return g({hiddenColumns:d,header:e,pinned:h})?n.createElement(M,r({},p,{borderClass:a({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId}),colIndex:t,header:e,isSelected:c({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId}),isInitialFocusedCell:u({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId}),key:v({accessor:e.accessor,rowIndex:w+1}),onExpandRowClick:f,onMouseDown:function(){return i({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId})},onMouseOver:function(){return l({rowIndex:w,colIndex:t,rowId:m.row.rowMeta.rowId})},rowIndex:w,visibleRow:m})):null}))}))},E=function(n){var t=n.getNextRowIndex,o=n.gridTemplateColumns,a=n.index,i=n.pinned,l=n.props,s=n.rowHeight,d=n.visibleRow,c=d.position,u=t();return e.jsx("div",r({className:"st-table-row",style:{gridTemplateColumns:o,top:h({position:c,rowHeight:s}),height:"".concat(s,"px")}},{children:e.jsx(S,r({pinned:i,rowIndex:u,visibleRow:d},l),a)}))},D=function(n){var t=n.lastGroupRow,o=n.position,a=n.rowHeight,i=n.templateColumns;return e.jsx("div",r({className:"st-row-separator ".concat(t?"st-last-group-row":""),style:{display:"grid",gridTemplateColumns:i,position:"absolute",top:f({position:o,rowHeight:a}),minWidth:"100%"}},{children:e.jsx("div",{style:{gridColumn:"1 / -1"}})}))},k=function(o){o.headerContainerRef;var a=o.onExpandRowClick,i=o.pinned,l=o.rowHeight,s=o.sectionRef,d=o.templateColumns,c=o.totalHeight,u=o.visibleRows,f=o.width,h=t(o,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),v=i?"st-table-body-pinned-".concat(i):"st-table-body-main",g=n.useRef(0);n.useEffect((function(){g.current=0}));var w=function(){return g.current++};return e.jsx("div",r({className:v,ref:s,style:{position:"relative",height:"".concat(c,"px"),width:f}},{children:u.map((function(t,o){var s,c,f=Boolean(null===(c=null===(s=t.row.rowMeta)||void 0===s?void 0:s.children)||void 0===c?void 0:c.length);return e.jsxs(n.Fragment,{children:[e.jsx(E,{getNextRowIndex:w,gridTemplateColumns:d,index:o,pinned:i,props:r(r({},h),{onExpandRowClick:a,rowHeight:l,visibleRows:u}),rowHeight:l,visibleRow:t}),0!==o&&e.jsx(D,{lastGroupRow:f,position:t.position,rowHeight:l,templateColumns:d})]},o)}))}))},N=function(t){var o,a,i,l,s,d=t.centerHeaderRef,c=t.flattenedRows,u=t.headerContainerRef,f=t.mainBodyRef,h=t.mainTemplateColumns,v=t.pinnedLeftColumns,g=t.pinnedLeftHeaderRef,w=t.pinnedLeftRef,m=t.pinnedLeftTemplateColumns,p=t.pinnedRightColumns,x=t.pinnedRightHeaderRef,R=t.pinnedRightRef,I=t.pinnedRightTemplateColumns,C=t.rowHeight,b=t.scrollbarWidth,y=t.setFlattenedRows,M=t.setScrollTop,H=t.tableBodyContainerRef,j=t.visibleRows;!function(e){var r=e.headerContainerRef,t=e.mainSectionRef,o=e.scrollbarWidth,a=n.useState(!1),i=a[0],l=a[1];n.useEffect((function(){var e=null==r?void 0:r.current;if(i&&e)return e.classList.add("st-header-scroll-padding"),e.style.setProperty("--st-after-width","".concat(o,"px")),function(){e.classList.remove("st-header-scroll-padding")}}),[r,i,o]),n.useEffect((function(){var e=null==r?void 0:r.current,n=null==t?void 0:t.current;if(n&&e){var o=function(){if(n){var e=n.scrollHeight>n.clientHeight;l(e)}};o();var a=new ResizeObserver((function(){o()}));return a.observe(n),function(){n&&a.unobserve(n)}}}),[r,t])}({headerContainerRef:u,mainSectionRef:H,scrollbarWidth:b});var S,E,D=n.useRef(null),N=(S=0,(E=function(e){e.forEach((function(e){S+=1,e.rowMeta.isExpanded&&e.rowMeta.children&&E(e.rowMeta.children)}))})(c),S)*(C+1)-1,L=function(e){var n=function(t){return t.rowMeta.rowId===e&&t.rowMeta.children?r(r({},t),{rowMeta:r(r({},t.rowMeta),{isExpanded:!t.rowMeta.isExpanded})}):t.rowMeta.children?r(r({},t),{rowMeta:r(r({},t.rowMeta),{children:t.rowMeta.children.map(n)})}):t};y((function(e){return e.map(n)}))},T=(null===(o=g.current)||void 0===o?void 0:o.clientWidth)?(null===(a=g.current)||void 0===a?void 0:a.clientWidth)+1:0,O=null===(i=d.current)||void 0===i?void 0:i.clientWidth,B=(null===(l=x.current)||void 0===l?void 0:l.clientWidth)?(null===(s=x.current)||void 0===s?void 0:s.clientWidth)+1:0;return e.jsxs("div",r({className:"st-table-body-container",ref:H,onScroll:function(e){var n=e.currentTarget.scrollTop;D.current&&cancelAnimationFrame(D.current),D.current=requestAnimationFrame((function(){M(n)}))}},{children:[v.length>0&&e.jsx(k,r({},t,{onExpandRowClick:L,pinned:"left",rowHeight:C,sectionRef:w,templateColumns:m,totalHeight:N,visibleRows:j,width:T})),e.jsx(k,r({},t,{onExpandRowClick:L,rowHeight:C,sectionRef:f,templateColumns:h,totalHeight:N,visibleRows:j,width:O})),p.length>0&&e.jsx(k,r({},t,{onExpandRowClick:L,pinned:"right",rowHeight:C,sectionRef:R,templateColumns:I,totalHeight:N,visibleRows:j,width:B}))]}))},L={string:function(e,n,r){if(e===n)return 0;var t=e.localeCompare(n);return"ascending"===r?t:-t},number:function(e,n,r){if(e===n)return 0;var t=e-n;return"ascending"===r?t:-t},boolean:function(e,n,r){if(e===n)return 0;var t=e===n?0:e?-1:1;return"ascending"===r?t:-t},date:function(e,n,r){var t=new Date(e),o=new Date(n);if(t.getTime()===o.getTime())return 0;var a=t.getTime()-o.getTime();return"ascending"===r?a:-a},enum:function(e,n,r){return L.string(e,n,r)},default:function(e,n,r){return e===n?0:null==e?"ascending"===r?-1:1:null==n?"ascending"===r?1:-1:"string"==typeof e&&"string"==typeof n?L.string(e,n,r):"number"==typeof e&&"number"==typeof n?L.number(e,n,r):"boolean"==typeof e&&"boolean"==typeof n?L.boolean(e,n,r):L.string(String(e),String(n),r)}},T=function(e,n,r,t){if(void 0===r&&(r="string"),null==e||""===e)return"ascending"===t?-1:1;if(null==n||""===n)return"ascending"===t?1:-1;if("number"===r){var o=function(e){var n;if("number"==typeof e)return e;var r=String(e);if("string"==typeof r){var t=r.replace(/[$,]/g,"").match(/^([-+]?\d*\.?\d+)([TBMKtbmk])?/);if(t){var o=parseFloat(t[1]),a=null===(n=t[2])||void 0===n?void 0:n.toUpperCase();return"T"===a?o*=1e12:"B"===a?o*=1e9:"M"===a?o*=1e6:"K"===a&&(o*=1e3),o}}return parseFloat(r)||0},a=o(e),i=o(n);return L.number(a,i,t)}return"date"===r?L.date(String(e),String(n),t):"boolean"===r?L.boolean(Boolean(e),Boolean(n),t):"enum"===r?L.enum(String(e),String(n),t):L.string(String(e),String(n),t)},O=function(e,n,t){var a=t.find((function(e){return e.accessor===n.key.accessor})),i=(null==a?void 0:a.type)||"string",l=n.direction,s=new Map,d=new Map,c="";e.forEach((function(e){var r;if(e.rowData&&!e.rowData[n.key.accessor]&&void 0!==e.rowMeta.isExpanded){var t=(e.rowData.sector||"group_".concat(s.size)).toString();c=t,d.set(c,e),s.has(c)||s.set(c,[])}else if(c){var o=s.get(c)||[];o.push(e),s.set(c,o)}else{var a="default";s.has(a)||s.set(a,[]),null===(r=s.get(a))||void 0===r||r.push(e)}}));var u=[];return s.forEach((function(e,a){if(d.has(a)){var s=d.get(a);s.rowMeta.children&&s.rowMeta.children.length>0&&(s.rowMeta.children=B(s.rowMeta.children,n,t)),u.push(s)}var c=o([],e,!0).sort((function(e,r){if(!(null==e?void 0:e.rowData)||!(null==r?void 0:r.rowData))return 0;var t=n.key.accessor,o=e.rowData[t],a=r.rowData[t];return T(o,a,i,l)}));u.push.apply(u,c.map((function(e){var o=r({},e);if(o.rowMeta.children&&o.rowMeta.children.length>0){var a=B(o.rowMeta.children,n,t);o.rowMeta=r(r({},o.rowMeta),{children:a})}return o})))})),u},B=function(e,n,t){var a=t.find((function(e){return e.accessor===n.key.accessor})),i=(null==a?void 0:a.type)||"string",l=n.direction;return o([],e,!0).sort((function(e,r){if(!(null==e?void 0:e.rowData)||!(null==r?void 0:r.rowData))return 0;var t=n.key.accessor,o=e.rowData[t],a=r.rowData[t];return T(o,a,i,l)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?r(r({},e),{rowMeta:r(r({},e.rowMeta),{children:B(e.rowMeta.children,n,t)})}):e}))},W=function(e){var n=e.event,r=e.forceUpdate,t=e.header,o=e.headersRef,a=e.index;e.reverse;var i=e.setIsWidthDragging,l=e.startWidth;i(!0),n.preventDefault();var s=n.clientX;if(t){var d=function(e){var n=Math.max(l+(e.clientX-s),40);t&&o.current&&(o.current[a].width=n,r())},c=function(){document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",c),i(!1)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",c)}},A=n.forwardRef((function(t,o){var a,l=t.columnResizing,s=t.currentRows,d=t.columnReordering,c=t.draggedHeaderRef,u=t.forceUpdate,f=t.headersRef,h=t.hoveredHeaderRef,g=t.index,w=t.onColumnOrderChange,m=t.onSort,p=t.onTableHeaderDragEnd,x=t.reverse,R=t.rowHeight,C=t.selectableColumns,b=t.setIsWidthDragging,M=t.setSelectedCells,H=t.sort,j=t.sortDownIcon,S=t.sortUpIcon,E=n.useState(!1),D=E[0],k=E[1],N=null===(a=f.current)||void 0===a?void 0:a[g],L=Boolean(null==N?void 0:N.isSortable),T="st-header-cell ".concat(N===h.current?"st-hovered":""," ").concat(D?"st-dragging":""," ").concat(L?"clickable":""," ").concat(d&&!L?"columnReordering":""," ").concat("right"===(null==N?void 0:N.align)?"right-aligned":"center"===(null==N?void 0:N.align)?"center-aligned":""),O=y({draggedHeaderRef:c,headersRef:f,hoveredHeaderRef:h,onColumnOrderChange:w,onTableHeaderDragEnd:p}),B=O.handleDragStart,A=O.handleDragEnd,P=O.handleDragOver,F=I(),z=function(e){var n=e.event,r=e.header;if(C){var t=s.length,o=Array.from({length:t},(function(e,n){return i({rowIndex:n,colIndex:g,rowId:s[n].rowMeta.rowId})})),a=function(e,n){var r=new Set,o=Math.min(e,n),a=Math.max(e,n);return Array.from({length:t}).forEach((function(e,n){Array.from({length:a-o+1}).forEach((function(e,t){r.add(i({rowIndex:n,colIndex:o+t,rowId:s[n].rowMeta.rowId}))}))})),r};n.shiftKey?M((function(e){var n,r=Number(null===(n=Array.from(e)[0])||void 0===n?void 0:n.split("-")[1]),t=Number(o[0].split("-")[1]);return r===t?new Set(o):r>t?a(t,r):a(r,t)})):M(new Set(o))}else r.isSortable&&m(g,r.accessor)};if(n.useEffect((function(){var e=function(e){e.preventDefault(),e.dataTransfer.dropEffect="move"};return document.addEventListener("dragover",e),function(){document.removeEventListener("dragover",e)}}),[]),!N)return null;var U=l&&e.jsx("div",{className:"st-header-resize-handle",onMouseDown:function(e){var n;F({callback:W,callbackProps:{event:e,forceUpdate:u,header:N,headersRef:f,index:g,setIsWidthDragging:b,startWidth:"object"==typeof o&&null!==o&&"current"in o?null===(n=o.current)||void 0===n?void 0:n.offsetWidth:void 0},limit:10})}}),q=H&&H.key.accessor===N.accessor&&e.jsxs("div",r({className:"st-sort-icon-container",onClick:function(e){return z({event:e,header:N})}},{children:["ascending"===H.direction&&S&&S,"descending"===H.direction&&j&&j]}));return e.jsxs("div",r({className:T,id:v({accessor:N.accessor,rowIndex:0}),onDragOver:function(e){F({callback:P,callbackProps:{event:e,hoveredHeader:N},limit:50})},ref:o,style:{width:N.width,height:R}},{children:[x&&U,e.jsxs("div",r({className:"st-header-label ".concat("right"===N.align?"right-aligned":"center"===N.align?"center-aligned":""),draggable:d,onClick:function(e){return z({event:e,header:N})},onDragEnd:function(e){e.preventDefault(),k(!1),A()},onDragStart:function(e){d&&N&&function(e){k(!0),B(e)}(N)}},{children:["right"===N.align&&q,null==N?void 0:N.label,"right"!==N.align&&q]})),!x&&U]}))})),P=function(e,r){n.useEffect((function(){if(e.current){var n=e.current,t=function(){var e,t=null==n?void 0:n.scrollLeft;void 0!==t&&(null===(e=r.current)||void 0===e||e.scrollTo(t,0))};return n.addEventListener("scroll",t),function(){null==n||n.removeEventListener("scroll",t)}}}),[e,r])},F=function(t){var o,a,i,l=t.allowAnimations,s=t.centerHeaderRef,d=t.columnResizing,c=t.currentRows,u=t.columnReordering,f=t.draggedHeaderRef,h=t.forceUpdate,v=t.headerContainerRef,w=t.headersRef,m=t.hiddenColumns,p=t.hoveredHeaderRef,x=t.isWidthDragging,R=t.mainBodyRef,I=t.mainTemplateColumns,C=t.onColumnOrderChange,b=t.onSort,y=t.onTableHeaderDragEnd,M=t.pinnedLeftColumns,j=t.pinnedLeftHeaderRef,S=t.pinnedLeftTemplateColumns,E=t.pinnedRightColumns,D=t.pinnedRightHeaderRef,k=t.pinnedRightTemplateColumns,N=t.rowHeight,L=t.selectableColumns,T=t.setIsWidthDragging,O=t.setSelectedCells,B=t.sort,W=t.sortDownIcon,F=t.sortUpIcon;P(R,s);return e.jsxs("div",r({className:"st-header-container",ref:v},{children:[M.length>0&&e.jsx("div",r({className:"st-header-pinned-left",ref:j,style:{gridTemplateColumns:S}},{children:e.jsx(H,r({allowAnimations:l,draggedHeaderRef:f,headersRef:w,mainBodyRef:R,pauseAnimation:x,rowIndex:0},{children:null===(o=w.current)||void 0===o?void 0:o.map((function(r,t){return g({hiddenColumns:m,header:r,pinned:"left"})?e.jsx(A,{columnResizing:d,currentRows:c,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:t,onColumnOrderChange:C,onSort:b,onTableHeaderDragEnd:y,ref:n.createRef(),rowHeight:N,selectableColumns:L,setIsWidthDragging:T,setSelectedCells:O,sort:B,sortDownIcon:W,sortUpIcon:F},r.accessor):null}))}))})),e.jsx("div",r({className:"st-header-main",onScroll:function(e){var n,r,t=null===(n=s.current)||void 0===n?void 0:n.scrollLeft;void 0!==t&&(null===(r=R.current)||void 0===r||r.scrollTo(t,0))},ref:s,style:{gridTemplateColumns:I}},{children:e.jsx(H,r({allowAnimations:l,draggedHeaderRef:f,headersRef:w,mainBodyRef:R,pauseAnimation:x,rowIndex:0},{children:null===(a=w.current)||void 0===a?void 0:a.map((function(r,t){return g({hiddenColumns:m,header:r})?e.jsx(A,{columnResizing:d,currentRows:c,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:t,onColumnOrderChange:C,onSort:b,onTableHeaderDragEnd:y,ref:n.createRef(),rowHeight:N,selectableColumns:L,setIsWidthDragging:T,setSelectedCells:O,sort:B,sortDownIcon:W,sortUpIcon:F},r.accessor):null}))}))})),E.length>0&&e.jsx("div",r({className:"st-header-pinned-right",ref:D,style:{gridTemplateColumns:k}},{children:e.jsx(H,r({allowAnimations:l,draggedHeaderRef:f,headersRef:w,mainBodyRef:R,pauseAnimation:x,rowIndex:0},{children:null===(i=w.current)||void 0===i?void 0:i.map((function(r,t){return g({hiddenColumns:m,header:r,pinned:"right"})?e.jsx(A,{columnResizing:d,currentRows:c,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:w,hoveredHeaderRef:p,index:t,onColumnOrderChange:C,onSort:b,onTableHeaderDragEnd:y,reverse:!0,ref:n.createRef(),rowHeight:N,selectableColumns:L,setIsWidthDragging:T,setSelectedCells:O,sort:B,sortDownIcon:W,sortUpIcon:F},r.accessor):null}))}))}))]}))},z=function(e){var n=e.headers,r=e.hiddenColumns;return"".concat(n.filter((function(e){return!0!==r[e.accessor]})).map((function(e){return function(e){var n=e.minWidth,r=e.width;return"number"==typeof r&&(r="".concat(r,"px")),n&&"number"==typeof n&&(n="".concat(n,"px")),void 0!==n?"minmax(".concat(n,", ").concat(r,")"):r}(e)})).join(" "))},U=function(t){var o=t.allowAnimations,a=t.columnReordering,i=t.columnResizing,l=t.currentRows,s=t.draggedHeaderRef,d=t.editColumns,c=t.flattenedRows,u=t.forceUpdate,f=t.getBorderClass,h=t.handleMouseDown,v=t.handleMouseOver,g=t.headersRef,w=t.hiddenColumns,m=t.hoveredHeaderRef,p=t.isSelected,x=t.isInitialFocusedCell,R=t.isWidthDragging,I=t.mainBodyRef,C=t.onCellEdit,b=t.onColumnOrderChange,y=t.onSort,M=t.onTableHeaderDragEnd,H=t.pinnedLeftRef,j=t.pinnedRightRef,S=t.rowHeight,E=t.scrollbarWidth,D=t.selectableColumns,k=t.setIsWidthDragging,L=t.setFlattenedRows,T=t.setScrollTop,O=t.setSelectedCells,B=t.shouldPaginate,W=t.sort,A=t.sortDownIcon,P=t.sortUpIcon,U=t.tableBodyContainerRef,q=t.visibleRows,K=n.useRef(null),V=n.useRef(null),J=n.useRef(null),X=n.useRef(null),Y=g.current.filter((function(e){return!e.pinned})),G=g.current.filter((function(e){return"left"===e.pinned})),_=g.current.filter((function(e){return"right"===e.pinned})),$=n.useMemo((function(){return z({headers:G,hiddenColumns:w})}),[G,w]),Q=n.useMemo((function(){return z({headers:Y,hiddenColumns:w})}),[Y,w]),Z=n.useMemo((function(){return z({headers:_,hiddenColumns:w})}),[_,w]),ee={allowAnimations:o,centerHeaderRef:J,columnResizing:i,currentRows:l,columnReordering:a,draggedHeaderRef:s,forceUpdate:u,headerContainerRef:K,headersRef:g,hiddenColumns:w,hoveredHeaderRef:m,isWidthDragging:R,mainBodyRef:I,mainTemplateColumns:Q,onColumnOrderChange:b,onSort:y,onTableHeaderDragEnd:M,pinnedLeftColumns:G,pinnedLeftHeaderRef:V,pinnedLeftTemplateColumns:$,pinnedRightColumns:_,pinnedRightHeaderRef:X,pinnedRightTemplateColumns:Z,rowHeight:S,selectableColumns:D,setIsWidthDragging:k,setSelectedCells:O,sort:W,sortDownIcon:A,sortUpIcon:P,tableBodyContainerRef:U},ne={allowAnimations:o,centerHeaderRef:J,draggedHeaderRef:s,flattenedRows:c,getBorderClass:f,handleMouseDown:h,handleMouseOver:v,headerContainerRef:K,headers:g.current,headersRef:g,hiddenColumns:w,hoveredHeaderRef:m,isSelected:p,isInitialFocusedCell:x,isWidthDragging:R,mainBodyRef:I,mainTemplateColumns:Q,onCellEdit:C,onTableHeaderDragEnd:M,pinnedLeftColumns:G,pinnedLeftHeaderRef:V,pinnedLeftRef:H,pinnedLeftTemplateColumns:$,pinnedRightColumns:_,pinnedRightHeaderRef:X,pinnedRightRef:j,pinnedRightTemplateColumns:Z,rowHeight:S,scrollbarWidth:E,setFlattenedRows:L,shouldPaginate:B,setScrollTop:T,tableBodyContainerRef:U,visibleRows:q};return e.jsxs("div",r({className:"st-table-content",style:{width:d?"calc(100% - 27.5px)":"100%"}},{children:[e.jsx(F,r({},ee)),e.jsx(N,r({},ne))]}))},q=function(e){var r=e.callback,t=e.ref,o=e.widthAttribute;n.useEffect((function(){var e=t.current;if(e){var n=function(){r(e[o]||0)};n();var a=new ResizeObserver((function(){n()}));return a.observe(e),function(){return a.disconnect()}}}),[r,t,o])},K=function(t){var o=t.mainBodyRef,a=t.pinnedLeftRef,i=t.pinnedRightRef,l=t.tableContentWidth,s=n.useState(0),d=s[0],c=s[1],u=n.useState(0),f=u[0],h=u[1],v=n.useState(0),g=v[0],w=v[1],m=n.useRef(null);return q({widthAttribute:"offsetWidth",callback:c,ref:a}),q({widthAttribute:"scrollWidth",callback:w,ref:o}),q({widthAttribute:"offsetWidth",callback:h,ref:i}),P(o,m),!o.current||o.current.scrollWidth<=o.current.clientWidth?null:e.jsxs("div",r({className:"st-horizontal-scrollbar-container",style:{width:l}},{children:[d>0&&e.jsx("div",{className:"st-horizontal-scrollbar-left",style:{flexShrink:0,width:d}}),g>0&&e.jsx("div",r({className:"st-horizontal-scrollbar-middle",onScroll:function(e){var n=e.target.scrollLeft;void 0!==n&&o.current&&o.current.scrollTo({left:n,behavior:"auto"})},ref:m},{children:e.jsx("div",{style:{width:g}})})),f>0&&e.jsx("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:f}})]}))},V=function(e){var r=e.headers,t=e.tableRows,o=n.useState(null),a=o[0],i=o[1],l=n.useMemo((function(){var e={};return r.forEach((function(n){!0===n.hide&&(e[n.accessor]=!0)})),e}),[r]),s=n.useState(l),d=s[0],c=s[1],u=n.useMemo((function(){if(!a)return t;var e=function(e,n,r){return{sortedData:O(n,r,e),newSortConfig:r}}(r,t,a).sortedData;return e}),[t,a,r]);return{sort:a,setSort:i,updateSort:function(e,n){var t=r.find((function(e){return e.accessor===n}));t&&i((function(e){return e&&e.key.accessor===n?"ascending"===e.direction?{key:t,direction:"descending"}:null:{key:t,direction:"ascending"}}))},sortedRows:u,hiddenColumns:d,setHiddenColumns:c}},J=function(t){var o=t.checked,a=void 0!==o&&o,i=t.children,l=t.onChange,s=n.useState(a),d=s[0],c=s[1];return e.jsxs("label",r({className:"st-checkbox-label"},{children:[e.jsx("input",{checked:d,className:"st-checkbox-input",onChange:function(){var e=!d;c(e),l&&l(e)},type:"checkbox"}),e.jsx("span",r({className:"st-checkbox-custom ".concat(d?"st-checked":"")},{children:d&&e.jsx("span",{className:"st-checkbox-checkmark"})})),i]}))},X=function(n){var t=n.headers,o=n.open,a=n.position;n.setOpen;var i=n.setHiddenColumns,l=n.hiddenColumns,s="left"===a?"left":"";return e.jsx("div",r({className:"st-column-editor-popout ".concat(o?"open":""," ").concat(s),onClick:function(e){return e.stopPropagation()}},{children:e.jsx("div",r({className:"st-column-editor-popout-content"},{children:t.map((function(n,t){return e.jsx(J,r({checked:l[n.accessor],onChange:function(e){var t;return i(r(r({},l),((t={})[n.accessor]=e,t)))}},{children:n.label}),t)}))}))}))},Y=function(t){var o=t.columnEditorText,a=t.editColumns,i=t.editColumnsInitOpen,l=t.headers,s=t.position,d=void 0===s?"right":s,c=t.setHiddenColumns,u=t.hiddenColumns,f=n.useState(i),h=f[0],v=f[1];return a?e.jsxs("div",r({className:"st-column-editor ".concat(h?"open":""," ").concat(d),onClick:function(){return function(e){v(e)}(!h)}},{children:[e.jsx("div",r({className:"st-column-editor-text"},{children:o})),e.jsx(X,{headers:l,open:h,position:d,setOpen:v,setHiddenColumns:c,hiddenColumns:u})]})):null};!function(e){e.Left="left",e.Right="right"}(a||(a={}));var G=n.memo((function(t){var o=t.allowAnimations,f=void 0!==o&&o,h=t.columnEditorPosition,v=void 0===h?a.Right:h,g=t.columnEditorText,w=void 0===g?"Columns":g,m=t.columnResizing,p=void 0!==m&&m,x=t.defaultHeaders,R=t.editColumns,I=void 0!==R&&R,C=t.editColumnsInitOpen,b=void 0!==C&&C,y=t.columnReordering,M=void 0!==y&&y,H=t.height,j=t.hideFooter,S=void 0!==j&&j,E=t.nextIcon,D=void 0===E?e.jsx(d,{className:"st-next-prev-icon"}):E,k=t.onCellEdit,N=t.onColumnOrderChange,L=t.onNextPage,T=t.onPreviousPage,O=t.prevIcon,B=void 0===O?e.jsx(s,{className:"st-next-prev-icon"}):O,W=t.rowHeight,A=void 0===W?40:W,P=t.rows,F=t.rowsPerPage,z=void 0===F?10:F,q=t.selectableCells,J=void 0!==q&&q,X=t.selectableColumns,G=void 0!==X&&X,_=t.shouldPaginate,$=void 0!==_&&_,Q=t.sortDownIcon,Z=void 0===Q?e.jsx(u,{className:"st-sort-icon"}):Q,ee=t.sortUpIcon,ne=void 0===ee?e.jsx(c,{className:"st-sort-icon"}):ee,re=t.theme,te=void 0===re?"light":re,oe=t.totalPages,ae=n.useRef(null),ie=n.useRef(x),le=n.useRef(null),se=n.useRef(null),de=n.useRef(null),ce=n.useRef(null),ue=n.useRef(null),fe=n.useState(!1),he=fe[0],ve=fe[1],ge=n.useState(1),we=ge[0],me=ge[1],pe=n.useState(0),xe=pe[0],Re=pe[1],Ie=n.useState(0),Ce=Ie[0],be=Ie[1],ye=n.useState(0),Me=ye[0],He=ye[1],je=V({headers:ie.current,tableRows:P}),Se=je.sort,Ee=je.sortedRows,De=je.hiddenColumns,ke=je.setHiddenColumns,Ne=je.updateSort,Le=n.useMemo((function(){if(!$)return Ee;var e=(we-1)*z,n=e+z;return Ee.slice(e,n)}),[we,z,$,Ee]),Te=n.useState(Le),Oe=Te[0],Be=Te[1];n.useEffect((function(){Be(Le)}),[Le]);var We=n.useMemo((function(){var e;if(!H)return window.innerHeight-A;var n=document.querySelector(".simple-table-root"),r=0;if(H.endsWith("px"))r=parseInt(H,10);else if(H.endsWith("vh")){var t=parseInt(H,10);r=window.innerHeight*t/100}else if(H.endsWith("%")){var o=parseInt(H,10);r=((null===(e=null==n?void 0:n.parentElement)||void 0===e?void 0:e.clientHeight)||window.innerHeight)*o/100}else r=window.innerHeight;return Math.max(0,r-A)}),[H,A]),Ae=n.useMemo((function(){return function(e){var n=e.bufferRowCount,r=e.contentHeight,t=e.flattenedRows,o=e.rowHeight,a=e.scrollTop,i=[],l=0,s=Math.max(0,a-o*n),d=a+r+o*n,c=function(e,n){for(var r,t=0,a=e;t<a.length;t++){var u=a[t],f=l*o;if(f>=d)break;f+o>s&&i.push({row:u,depth:n,position:l,isLastGroupRow:Boolean(null===(r=u.rowMeta.children)||void 0===r?void 0:r.length)&&n>1}),l+=1,u.rowMeta.isExpanded&&u.rowMeta.children&&c(u.rowMeta.children,n+1)}};return c(t,0),i}({bufferRowCount:5,contentHeight:We,flattenedRows:Oe,rowHeight:A,scrollTop:Me})}),[We,A,Oe,Me]),Pe=n.useReducer((function(e){return e+1}),0)[1],Fe=function(e){var r=e.selectableCells,t=e.headers,o=e.visibleRows,a=n.useState(new Set),l=a[0],s=a[1],d=n.useState(null),c=d[0],u=d[1],f=n.useRef(!1),h=n.useRef(null),v=n.useCallback((function(){var e=Array.from(l).reduce((function(e,n){var r=n.split("-").map(Number),a=r[0],i=r[1];return e[a]||(e[a]=[]),e[a][i]=o[a].row.rowData[t[i].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");l.size>0&&navigator.clipboard.writeText(n)}),[t,l,o]),g=n.useCallback((function(e,n){for(var r=new Set,t=Math.min(e.rowIndex,n.rowIndex),a=Math.max(e.rowIndex,n.rowIndex),l=Math.min(e.colIndex,n.colIndex),d=Math.max(e.colIndex,n.colIndex),c=t;c<=a;c++)for(var u=l;u<=d;u++)if(c>=0&&c<o.length){var f=o[c].row.rowMeta.rowId;r.add(i({colIndex:u,rowIndex:c,rowId:f}))}s(r)}),[o]),w=n.useCallback((function(e){if(e.rowIndex>=0&&e.rowIndex<o.length&&e.colIndex>=0&&e.colIndex<t.length){var n=i(e);s(new Set([n])),u(e)}}),[t.length,o.length]);n.useEffect((function(){var e=function(e){if(r&&c){var n=c.rowIndex,a=c.colIndex,i=c.rowId;if(!e.ctrlKey&&!e.metaKey||"c"!==e.key){if(o[n].row.rowMeta.rowId!==i){var l=o.findIndex((function(e){return e.row.rowMeta.rowId===i}));if(-1===l)return;n=l}if("ArrowUp"===e.key){if(e.preventDefault(),n>0){var d={rowIndex:n-1,colIndex:a,rowId:o[n-1].row.rowMeta.rowId};w(d)}}else"ArrowDown"===e.key?(e.preventDefault(),n<o.length-1&&(d={rowIndex:n+1,colIndex:a,rowId:o[n+1].row.rowMeta.rowId},w(d))):"ArrowLeft"===e.key||"Tab"===e.key&&e.shiftKey?(e.preventDefault(),a>0&&(d={rowIndex:n,colIndex:a-1,rowId:o[n].row.rowMeta.rowId},w(d))):"ArrowRight"===e.key||"Tab"===e.key?(e.preventDefault(),a<t.length-1&&(d={rowIndex:n,colIndex:a+1,rowId:o[n].row.rowMeta.rowId},w(d))):"Escape"===e.key&&(s(new Set),h.current=null,u(null))}else v()}};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[v,t.length,c,g,w,r,o]);var m=n.useCallback((function(e){var n=e.colIndex,r=e.rowIndex,t=e.rowId,o=i({colIndex:n,rowIndex:r,rowId:t});return l.has(o)}),[l]),p=n.useCallback((function(e){var n,r,t,a,i,l,s=e.colIndex,d=e.rowIndex,c=e.rowId,u=[],f=null===(t=null===(r=null===(n=o[d-1])||void 0===n?void 0:n.row)||void 0===r?void 0:r.rowMeta)||void 0===t?void 0:t.rowId,h={colIndex:s,rowIndex:d+1,rowId:null===(l=null===(i=null===(a=o[d+1])||void 0===a?void 0:a.row)||void 0===i?void 0:i.rowMeta)||void 0===l?void 0:l.rowId},v={colIndex:s-1,rowIndex:d,rowId:c},g={colIndex:s+1,rowIndex:d,rowId:c};return m({colIndex:s,rowIndex:d-1,rowId:f})||u.push("st-selected-top-border"),m(h)||u.push("st-selected-bottom-border"),m(v)||u.push("st-selected-left-border"),m(g)||u.push("st-selected-right-border"),u.join(" ")}),[m,o]),x=n.useMemo((function(){return c?function(e){var n=e.rowIndex,r=e.colIndex,t=e.rowId;return n===c.rowIndex&&r===c.colIndex&&t===c.rowId}:function(){return!1}}),[c]);return{getBorderClass:p,handleMouseDown:function(e){var n=e.colIndex,t=e.rowIndex,o=e.rowId;if(r){f.current=!0,h.current={rowIndex:t,colIndex:n,rowId:o};var a=i({colIndex:n,rowIndex:t,rowId:o});s(new Set([a])),u({rowIndex:t,colIndex:n,rowId:o})}},handleMouseOver:function(e){var n=e.colIndex,t=e.rowIndex;if(e.rowId,r&&f.current&&h.current){for(var a=new Set,l=Math.min(h.current.rowIndex,t),d=Math.max(h.current.rowIndex,t),c=Math.min(h.current.colIndex,n),u=Math.max(h.current.colIndex,n),v=l;v<=d;v++)for(var g=c;g<=u;g++)if(v>=0&&v<o.length){var w=o[v].row.rowMeta.rowId;a.add(i({colIndex:g,rowIndex:v,rowId:w}))}s(a)}},handleMouseUp:function(){f.current=!1},isInitialFocusedCell:x,isSelected:m,selectedCells:l,setSelectedCells:s}}({selectableCells:J,headers:ie.current,visibleRows:Ae}),ze=Fe.handleMouseDown,Ue=Fe.handleMouseOver,qe=Fe.handleMouseUp,Ke=Fe.isSelected,Ve=Fe.getBorderClass,Je=Fe.isInitialFocusedCell,Xe=Fe.setSelectedCells,Ye=n.useCallback((function(e,n){Ne(e,n)}),[Ne]),Ge=n.useCallback((function(e){ie.current=e,Pe()}),[]);return n.useEffect((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||G&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||Xe(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[G,Xe]),n.useLayoutEffect((function(){if(ue.current){var e=ue.current.offsetWidth-ue.current.clientWidth,n=ue.current.clientWidth;Re(e),be(n)}}),[]),n.useLayoutEffect((function(){var e=function(){if(Pe(),ue.current){var e=ue.current.offsetWidth-ue.current.clientWidth,n=ue.current.clientWidth;Re(e),be(n)}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),e.jsxs("div",r({className:"simple-table-root st-wrapper theme-".concat(te),style:H?{height:H}:{}},{children:[e.jsxs("div",r({className:"st-table-wrapper-container"},{children:[e.jsxs("div",r({className:"st-table-wrapper",onMouseUp:qe,onMouseLeave:qe},{children:[e.jsx(U,{allowAnimations:f,columnReordering:M,columnResizing:p,currentRows:Le,draggedHeaderRef:ae,editColumns:I,flattenedRows:Oe,forceUpdate:Pe,getBorderClass:Ve,handleMouseDown:ze,handleMouseOver:Ue,headersRef:ie,hiddenColumns:De,hoveredHeaderRef:le,isInitialFocusedCell:Je,isSelected:Ke,isWidthDragging:he,mainBodyRef:se,onCellEdit:k,onColumnOrderChange:N,onSort:Ye,onTableHeaderDragEnd:Ge,pinnedLeftRef:de,pinnedRightRef:ce,rowHeight:A,scrollbarWidth:xe,selectableColumns:G,setIsWidthDragging:ve,setFlattenedRows:Be,setScrollTop:He,setSelectedCells:Xe,shouldPaginate:$,sort:Se,sortDownIcon:Z,sortUpIcon:ne,tableBodyContainerRef:ue,visibleRows:Ae}),e.jsx(Y,{columnEditorText:w,editColumns:I,editColumnsInitOpen:b,headers:ie.current,hiddenColumns:De,position:v,setHiddenColumns:ke})]})),e.jsx(K,{mainBodyRef:se,pinnedLeftRef:de,pinnedRightRef:ce,tableContentWidth:Ce})]})),e.jsx(l,{currentPage:we,hideFooter:S,nextIcon:D,onPageChange:me,onNextPage:L,onPreviousPage:T,prevIcon:B,shouldPaginate:$,totalPages:oe||Math.ceil(Ee.length/z)})]}))}));exports.SimpleTable=G;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  import { RefObject } from "react";
2
2
  import TableHeaderProps from "./TableHeaderProps";
3
3
  import TableBodyProps from "./TableBodyProps";
4
- type OmittedTableProps = "centerHeaderRef" | "headerContainerRef" | "mainTemplateColumns" | "pinnedLeftColumns" | "pinnedLeftHeaderRef" | "pinnedLeftTemplateColumns" | "pinnedRightColumns" | "pinnedRightHeaderRef" | "pinnedRightTemplateColumns";
4
+ type OmittedTableProps = "centerHeaderRef" | "headerContainerRef" | "mainTemplateColumns" | "pinnedLeftColumns" | "pinnedLeftHeaderRef" | "pinnedLeftTemplateColumns" | "pinnedRightColumns" | "pinnedRightHeaderRef" | "pinnedRightTemplateColumns" | "headers";
5
5
  interface TableContentProps extends Omit<TableHeaderProps, OmittedTableProps>, Omit<TableBodyProps, OmittedTableProps> {
6
6
  editColumns: boolean;
7
7
  pinnedLeftRef: RefObject<HTMLDivElement | null>;
@@ -1,2 +1,5 @@
1
1
  import HeaderObject from "../types/HeaderObject";
2
- export declare const getColumnWidth: (header: HeaderObject) => string;
2
+ export declare const createGridTemplateColumns: ({ headers, hiddenColumns, }: {
3
+ headers: HeaderObject[];
4
+ hiddenColumns: Record<string, boolean>;
5
+ }) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-table-core",
3
- "version": "0.7.23",
3
+ "version": "0.7.25",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",