simple-table-core 0.7.13 → 0.7.15

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 c,useLayoutEffect as s,createElement as d,createRef as u,memo as f,useReducer as h}from"react";var v=function(){return v=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},v.apply(this,arguments)};function g(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,t){return new(r||(r=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function l(e){try{c(t.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(a,l)}c((t=t.apply(e,n||[])).next())}))}function p(e,n){var r,t,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(c){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,t&&(o=2&l[0]?t.return:l[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,l[1])).done)return o;switch(t=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,t=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=n.call(e,i)}catch(e){l=[6,e],t=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}function w(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 R,b=function(r){var t=r.currentPage,o=r.hideFooter,i=r.nextIcon,a=r.onPageChange,l=r.prevIcon,c=r.rowsPerPage,s=r.shouldPaginate,d=r.totalRows,u=Math.ceil(d/c),f=t>1,h=t<u,g=function(e){e>=1&&e<=u&&a(e)};return o||!s?null:e("div",v({className:"st-footer"},{children:[n("button",v({className:"st-next-prev-btn ".concat(f?"":"disabled"),onClick:function(){return g(t-1)},disabled:!f},{children:l})),n("button",v({className:"st-next-prev-btn ".concat(h?"":"disabled"),onClick:function(){return g(t+1)},disabled:!h},{children:i})),Array.from({length:u},(function(e,r){return n("button",v({onClick:function(){return g(r+1)},className:"st-page-btn ".concat(t===r+1?"active":"")},{children:r+1}),r)}))]}))},C=function(e){var r=e.className;return n("svg",v({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"})}))},y=function(e){var r=e.className;return n("svg",v({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"})}))},x=function(e){var r=e.className;return n("svg",v({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"})}))},H=function(e){var r=e.className;return n("svg",v({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"})}))},I=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)},E=function(e){var n=e.hiddenColumns,r=e.header,t=e.pinned;return n[r.accessor]?null:!t&&!r.pinned||r.pinned===t||null},S=function(r){var t=r.value,o=r.onBlur,i=r.onChange;return e("select",v({value:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;i("true"===n)}},{children:[n("option",v({value:"true"},{children:"True"})),n("option",v({value:"false"},{children:"False"}))]}))},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,type:"text",defaultValue:null!=r?r:"",onBlur:t,onChange:function(e){var n=e.target.value;i(n)}})},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,defaultValue:r.toString(),onBlur:t,onChange:function(e){var n=e.target.value;/^\d*\.?\d*$/.test(n)&&i(n)}})},L=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(N,{defaultValue:i,onBlur:l,onChange:a}):"boolean"==typeof i?n(S,{onBlur:l,onChange:a,value:i}):"number"==typeof i?n(k,{defaultValue:i,onBlur:l,onChange:a}):null})},T=0,B=function(){return function(e){var n=e.callback,r=e.callbackProps,t=e.limit,o=Date.now();(0===T||o-T>=t)&&(T=o,n(r))}},O=Date.now(),W={screenX:0,screenY:0},A=function(e){var n,r,t=e.draggedHeaderRef,i=e.headersRef,l=e.hoveredHeaderRef,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,O=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=w([],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})),m=h.splice(v,1)[0];if(h.splice(g,0,m),!(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-O<800&&f<50||(O=p,W={screenX:d,screenY:u},c(h))}}},handleDragEnd:function(){t.current=null,l.current=null}}},P=c((function(r,o){var i,l,c=r.borderClass,s=r.colIndex,d=r.draggedHeaderRef,u=r.header,f=r.headersRef,h=r.hoveredHeaderRef,g=r.isSelected,m=r.isTopLeftCell,p=r.onCellEdit,w=r.onExpandRowClick,R=r.onMouseDown,b=r.onMouseOver,C=r.onTableHeaderDragEnd,x=r.rowIndex,I=r.visibleRow,M=I.depth,E=I.row,S=t(E.rowData[u.accessor]),N=S[0],k=S[1],T=t(!1),O=T[0],W=T[1],P=A({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:C}).handleDragOver,z=B(),U=Boolean(null===(l=null===(i=E.rowMeta)||void 0===i?void 0:i.children)||void 0===l?void 0:l.length),j=Boolean(null==u?void 0:u.isEditable),F=x%2==0,V="st-cell ".concat(M>0&&u.expandable?"st-cell-depth-".concat(M):""," ").concat(g?m?"st-cell-selected-first-cell ".concat(c):"st-cell-selected ".concat(c):""," ").concat(F?"st-cell-odd-row":"st-cell-even-row"," ").concat(j?"clickable":""," ").concat("right"===u.align?"right-aligned":"center"===u.align?"center-aligned":"left-aligned");return a((function(){k(E.rowData[u.accessor])}),[u.accessor,E]),O?n("div",v({className:"st-cell-editing ".concat(F?"st-cell-odd-row":"st-cell-even-row"),id:D({accessor:u.accessor,rowIndex:x+1})},{children:n(L,{onChange:function(e){k(e),null==p||p({accessor:u.accessor,newValue:e,row:E})},setIsEditing:W,value:N})})):e("div",v({className:V,id:D({accessor:u.accessor,rowIndex:x+1}),onDoubleClick:function(){return u.isEditable&&W(!0)},onMouseDown:function(){return R(x,s)},onMouseOver:function(){return b(x,s)},onDragOver:function(e){return z({callback:P,callbackProps:{event:e,hoveredHeader:u},limit:50})},ref:o},{children:[u.expandable&&U?E.rowMeta.isExpanded?n("div",v({className:"st-sort-icon-container",onClick:function(){return w(E.rowMeta.rowId)}},{children:n(H,{className:"st-sort-icon"})})):n("div",v({className:"st-sort-icon-container",onClick:function(){return w(E.rowMeta.rowId)}},{children:n(y,{className:"st-sort-icon"})})):null,n("span",v({className:"st-cell-content"},{children:u.cellRenderer?u.cellRenderer({accessor:u.accessor,colIndex:s,row:E}):N}))]}))})),z=function(e){var t=e.allowAnimations,o=e.children,i=g(e,["allowAnimations","children"]);return t?n(U,v({},i,{children:o})):n(r,{children:o})},U=function(e){var i=e.allowHorizontalAnimate,l=void 0===i||i,c=e.children,d=e.draggedHeaderRef,u=e.headersRef,f=e.isBody,h=e.mainBodyRef,v=e.pauseAnimation,g=e.rowIndex,m=o(!1),p=t({}),w=p[0],R=p[1],b=o({}),C=u.current;return s((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:d,rowIndex:g});JSON.stringify(e)!==JSON.stringify(w)&&(b.current=w,R(e))}}),[w,C,d,f,g]),s((function(){var e=h.current,n=function(){m.current=!0},r=function(){m.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)}}),[d,h]),a((function(){v||m.current||Object.keys(b.current).length&&C&&C.forEach((function(e){var n=document.getElementById(D({accessor:e.accessor,rowIndex:g}));if(n){var r=b.current[e.accessor],t=w[e.accessor];if(r&&t){var o=r.left-t.left,i=l?0:r.top-t.top,a=Math.abs(o),c=Math.abs(i);(a>10||c>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,w,C,f,v,b,g]),n(r,{children:c})},j=function(e){var r=e.getBorderClass,t=e.handleMouseDown,o=e.handleMouseOver,i=e.headers,a=e.hiddenColumns,l=e.isSelected,c=e.isTopLeftCell,s=e.onExpandRowClick,u=e.pinned,f=e.rowIndex,h=e.visibleRow,m=g(e,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isTopLeftCell","onExpandRowClick","pinned","rowIndex","visibleRow"]);return n(z,v({allowAnimations:m.allowAnimations,allowHorizontalAnimate:m.shouldPaginate,draggedHeaderRef:m.draggedHeaderRef,headersRef:m.headersRef,isBody:!0,mainBodyRef:m.mainBodyRef,pauseAnimation:m.isWidthDragging,rowIndex:f+1},{children:i.map((function(e,n){return E({hiddenColumns:a,header:e,pinned:u})?d(P,v({},m,{borderClass:r(f,n),colIndex:n,header:e,isSelected:l(f,n),isTopLeftCell:c(f,n),key:D({accessor:e.accessor,rowIndex:f+1}),onExpandRowClick:s,onMouseDown:function(){return t({rowIndex:f,colIndex:n})},onMouseOver:function(){return o(f,n)},rowIndex:f,visibleRow:h})):null}))}))},F=function(e){var r=e.getNextRowIndex,t=e.gridTemplateColumns,o=e.index,i=e.pinned,a=e.props,l=e.rowHeight,c=e.visibleRow,s=c.position,d=r();return n("div",v({className:"st-table-row",style:{gridTemplateColumns:t,top:M({position:s,rowHeight:l}),height:"".concat(l,"px")}},{children:n(j,v({pinned:i,rowIndex:d,visibleRow:c},a),o)}))},V=function(e){var r=e.lastGroupRow,t=e.position,o=e.rowHeight,i=e.templateColumns;return n("div",v({className:"st-row-separator ".concat(r?"st-last-group-row":""),style:{display:"grid",gridTemplateColumns:i,position:"absolute",top:I({position:t,rowHeight:o})}},{children:n("div",{style:{gridColumn:"1 / -1"}})}))},J=function(t){t.headerContainerRef;var i=t.onExpandRowClick,l=t.pinned,c=t.rowHeight,s=t.sectionRef,d=t.templateColumns,u=t.totalHeight,f=t.visibleRows,h=t.width,m=g(t,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),p=l?"st-table-body-pinned-".concat(l):"st-table-body-main",w=o(0);a((function(){w.current=0}));var R=function(){return w.current++};return n("div",v({className:p,ref:s,style:{position:"relative",height:"".concat(u,"px"),width:h}},{children:f.map((function(t,o){var a,s,u=Boolean(null===(s=null===(a=t.row.rowMeta)||void 0===a?void 0:a.children)||void 0===s?void 0:s.length);return e(r,{children:[n(F,{getNextRowIndex:R,gridTemplateColumns:d,index:o,pinned:l,props:v(v({},m),{onExpandRowClick:i}),rowHeight:c,visibleRow:t},o),0!==o&&n(V,{lastGroupRow:u,position:t.position,rowHeight:c,templateColumns:d})]})}))}))},X=function(r){var c,s,d,u,f,h=r.centerHeaderRef,g=r.currentRows,R=r.headerContainerRef,b=r.mainBodyRef,C=r.mainTemplateColumns,y=r.pinnedLeftColumns,x=r.pinnedLeftHeaderRef,H=r.pinnedLeftRef,I=r.pinnedLeftTemplateColumns,M=r.pinnedRightColumns,D=r.pinnedRightHeaderRef,E=r.pinnedRightRef,S=r.pinnedRightTemplateColumns,N=r.scrollbarWidth,k=r.tableBodyContainerRef;!function(e){var n=e.headerContainerRef,r=e.mainSectionRef,o=e.scrollbarWidth,i=t(!1),l=i[0],c=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;c(e)}};o();var i=new ResizeObserver((function(){o()}));return i.observe(t),function(){t&&i.unobserve(t)}}}),[n,r])}({headerContainerRef:R,mainSectionRef:k,scrollbarWidth:N});var L=o(null),T=o(null),B=t(g),O=B[0],W=B[1],A=t(1),P=A[0],z=A[1],U=t(!1),j=U[0],F=U[1],V=t(!0),X=V[0],q=V[1],G=t(0),Y=G[0],K=G[1],$=function(e){var n=0,r=function(e){e.forEach((function(e){n+=1,e.rowMeta.isExpanded&&e.rowMeta.children&&r(e.rowMeta.children)}))};return r(e),n}(O),Q=41*$-1,Z=function(e){var n=function(r){return r.rowMeta.rowId===e&&r.rowMeta.children?v(v({},r),{rowMeta:v(v({},r.rowMeta),{isExpanded:!r.rowMeta.isExpanded})}):r.rowMeta.children?v(v({},r),{rowMeta:v(v({},r.rowMeta),{children:r.rowMeta.children.map(n)})}):r};W((function(e){return e.map(n)}))},_=l((function(){return function(e){var n=e.bufferRowCount,r=e.containerHeight,t=e.rowHeight,o=e.rows,i=e.scrollTop,a=[],l=0,c=Math.max(0,i-t*n),s=i+r+t*n,d=function(e,n){for(var r,o=0,i=e;o<i.length;o++){var u=i[o],f=l*t;if(f>=s)break;f+t>c&&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&&d(u.rowMeta.children,n+1)}};return d(o,0),a}({bufferRowCount:5,containerHeight:600,rowHeight:40,rows:O,scrollTop:Y})}),[O,Y]),ee=i((function(){return m(void 0,void 0,void 0,(function(){var e;return p(this,(function(n){return j||!X||(F(!0),e=g.slice(20*P,20*(P+1)),W((function(n){return w(w([],n,!0),e,!0)})),z((function(e){return e+1})),F(!1),e.length<20/3&&q(!1)),[2]}))}))}),[g,X,j,P]),ne=i((function(e){e[0].isIntersecting&&X&&!j&&ee()}),[X,j,ee]);a((function(){return L.current=new IntersectionObserver(ne,{root:null,rootMargin:"100px",threshold:0}),k.current&&L.current.observe(k.current),function(){L.current&&L.current.disconnect()}}),[ne,O,k]);var re=(null===(c=x.current)||void 0===c?void 0:c.clientWidth)?(null===(s=x.current)||void 0===s?void 0:s.clientWidth)+1:0,te=null===(d=h.current)||void 0===d?void 0:d.clientWidth,oe=(null===(u=D.current)||void 0===u?void 0:u.clientWidth)?(null===(f=D.current)||void 0===f?void 0:f.clientWidth)+1:0;return e("div",v({className:"st-table-body-container",ref:k,onScroll:function(e){var n=e.currentTarget.scrollTop;T.current&&cancelAnimationFrame(T.current),T.current=requestAnimationFrame((function(){K(n)}))}},{children:[y.length>0&&n(J,v({},r,{onExpandRowClick:Z,pinned:"left",rowHeight:40,sectionRef:H,templateColumns:I,totalHeight:Q,visibleRows:_,width:re})),n(J,v({},r,{onExpandRowClick:Z,rowHeight:40,sectionRef:b,templateColumns:C,totalHeight:Q,visibleRows:_,width:te})),M.length>0&&n(J,v({},r,{onExpandRowClick:Z,pinned:"right",rowHeight:40,sectionRef:E,templateColumns:S,totalHeight:Q,visibleRows:_,width:oe}))]}))},q={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 q.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?q.string(e,n,r):"number"==typeof e&&"number"==typeof n?q.number(e,n,r):"boolean"==typeof e&&"boolean"==typeof n?q.boolean(e,n,r):q.string(String(e),String(n),r)}},G=function(e,n,r,t){switch(void 0===r&&(r="string"),r){case"string":return q.string(String(e||""),String(n||""),t);case"number":return q.number(Number(e||0),Number(n||0),t);case"boolean":return q.boolean(Boolean(e),Boolean(n),t);case"date":return q.date(String(e||""),String(n||""),t);case"enum":return q.enum(String(e||""),String(n||""),t);default:return q.default(e,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;return w([],e,!0).sort((function(e,r){var t,a,l=null===(t=null==e?void 0:e.rowData)||void 0===t?void 0:t[n.key.accessor],c=null===(a=null==r?void 0:r.rowData)||void 0===a?void 0:a[n.key.accessor];return G(l,c,o,i)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?v(v({},e),{rowMeta:v(v({},e.rowMeta),{children:Y(e.rowMeta.children,n,r)})}):e}))},K=function(e,n,r){var t=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=[],l=new Map;return e.forEach((function(n){e.some((function(e){var r;return null===(r=e.rowMeta.children)||void 0===r?void 0:r.some((function(e){return e.rowMeta.rowId===n.rowMeta.rowId}))}))||a.push(n),n.rowMeta.children&&n.rowMeta.children.length>0&&l.set(n.rowMeta.rowId,n.rowMeta.children)})),w([],a,!0).sort((function(e,r){var t,a,l=null===(t=null==e?void 0:e.rowData)||void 0===t?void 0:t[n.key.accessor],c=null===(a=null==r?void 0:r.rowData)||void 0===a?void 0:a[n.key.accessor];return G(l,c,o,i)})).map((function(e){var t=v({},e);if(l.has(e.rowMeta.rowId)){var o=l.get(e.rowMeta.rowId)||[],i=Y(o,n,r);t.rowMeta=v(v({},t.rowMeta),{children:i})}return t}))}(n,r,e);return{sortedData:t,newSortConfig:r}},$=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 c=n.clientX;if(t){var s=function(e){var n=Math.max(l+(e.clientX-c),40);t&&o.current&&(o.current[i].width=n,r())},d=function(){document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",d),a(!1)};document.addEventListener("mousemove",s),document.addEventListener("mouseup",d)}},Q=c((function(r,o){var i,l=r.columnResizing,c=r.currentRows,s=r.columnReordering,d=r.draggedHeaderRef,u=r.forceUpdate,f=r.headersRef,h=r.hoveredHeaderRef,g=r.index,m=r.onSort,p=r.onTableHeaderDragEnd,w=r.reverse,R=r.selectableColumns,b=r.setIsWidthDragging,C=r.setSelectedCells,y=r.sort,x=r.sortDownIcon,H=r.sortUpIcon,I=t(!1),M=I[0],E=I[1],S=null===(i=f.current)||void 0===i?void 0:i[g],N=Boolean(null==S?void 0:S.isSortable),k="st-header-cell ".concat(S===h.current?"st-hovered":""," ").concat(M?"st-dragging":""," ").concat(N?"clickable":""," ").concat(s&&!N?"columnReordering":""," ").concat("right"===(null==S?void 0:S.align)?"right-aligned":"center"===(null==S?void 0:S.align)?"center-aligned":""),L=A({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:p}),T=L.handleDragStart,O=L.handleDragEnd,W=A({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:p}).handleDragOver,P=B(),z=function(e){var n=e.event,r=e.header;if(R){var t=c.length,o=Array.from({length:t},(function(e,n){return"".concat(n,"-").concat(g)})),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("".concat(n,"-").concat(o+t))}))})),r};n.shiftKey?C((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)})):C(new Set(o))}else r.isSortable&&m(g,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)}}),[]),!S)return null;var U=l&&n("div",{className:"st-header-resize-handle",onMouseDown:function(e){var n;P({callback:$,callbackProps:{event:e,forceUpdate:u,header:S,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})}});return e("div",v({className:k,id:D({accessor:S.accessor,rowIndex:0}),onDragOver:function(e){P({callback:W,callbackProps:{event:e,hoveredHeader:S},limit:50})},ref:o,style:{width:S.width}},{children:[w&&U,n("div",v({className:"st-header-label",draggable:s,onClick:function(e){return z({event:e,header:S})},onDragEnd:function(e){e.preventDefault(),E(!1),O()},onDragStart:function(e){s&&S&&function(e){E(!0),T(e)}(S)}},{children:null==S?void 0:S.label})),y&&y.key.accessor===S.accessor&&e("div",v({className:"st-sort-icon-container",onClick:function(e){return z({event:e,header:S})}},{children:["ascending"===y.direction&&H&&H,"descending"===y.direction&&x&&x]})),!w&&U]}))})),Z=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])},_=function(r){var t,o,i,a=r.allowAnimations,l=r.centerHeaderRef,c=r.columnResizing,s=r.currentRows,d=r.columnReordering,f=r.draggedHeaderRef,h=r.forceUpdate,g=r.headerContainerRef,m=r.headersRef,p=r.hiddenColumns,w=r.hoveredHeaderRef,R=r.isWidthDragging,b=r.mainBodyRef,C=r.mainTemplateColumns,y=r.onSort,x=r.onTableHeaderDragEnd,H=r.pinnedLeftColumns,I=r.pinnedLeftHeaderRef,M=r.pinnedLeftTemplateColumns,D=r.pinnedRightColumns,S=r.pinnedRightHeaderRef,N=r.pinnedRightTemplateColumns,k=r.selectableColumns,L=r.setIsWidthDragging,T=r.setSelectedCells,B=r.sort,O=r.sortDownIcon,W=r.sortUpIcon;Z(b,l);return e("div",v({className:"st-header-container",ref:g},{children:[H.length>0&&n("div",v({className:"st-header-pinned-left",ref:I,style:{gridTemplateColumns:M}},{children:n(z,v({allowAnimations:a,draggedHeaderRef:f,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:null===(t=m.current)||void 0===t?void 0:t.map((function(e,r){return E({hiddenColumns:p,header:e,pinned:"left"})?n(Q,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,ref:u(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:B,sortDownIcon:O,sortUpIcon:W},e.accessor):null}))}))})),n("div",v({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=b.current)||void 0===r||r.scrollTo(t,0))},ref:l,style:{gridTemplateColumns:C}},{children:n(z,v({allowAnimations:a,draggedHeaderRef:f,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:null===(o=m.current)||void 0===o?void 0:o.map((function(e,r){return E({hiddenColumns:p,header:e})?n(Q,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,ref:u(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:B,sortDownIcon:O,sortUpIcon:W},e.accessor):null}))}))})),D.length>0&&n("div",v({className:"st-header-pinned-right",ref:S,style:{gridTemplateColumns:N}},{children:n(z,v({allowAnimations:a,draggedHeaderRef:f,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:null===(i=m.current)||void 0===i?void 0:i.map((function(e,r){return E({hiddenColumns:p,header:e,pinned:"right"})?n(Q,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,reverse:!0,ref:u(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:B,sortDownIcon:O,sortUpIcon:W},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.columnResizing,a=r.currentRows,c=r.columnReordering,s=r.draggedHeaderRef,d=r.editColumns,u=r.forceUpdate,f=r.getBorderClass,h=r.handleMouseDown,g=r.handleMouseOver,m=r.headersRef,p=r.hiddenColumns,w=r.hoveredHeaderRef,R=r.isSelected,b=r.isTopLeftCell,C=r.isWidthDragging,y=r.mainBodyRef,x=r.onCellEdit,H=r.onSort,I=r.onTableHeaderDragEnd,M=r.pinnedLeftRef,D=r.pinnedRightRef,E=r.scrollbarWidth,S=r.selectableColumns,N=r.setIsWidthDragging,k=r.setSelectedCells,L=r.shouldPaginate,T=r.sort,B=r.sortDownIcon,O=r.sortUpIcon,W=r.tableBodyContainerRef,A=o(null),P=o(null),z=o(null),U=o(null),j=m.current.filter((function(e){return!e.hide&&!e.pinned})),F=m.current.filter((function(e){return"left"===e.pinned&&!0!==e.hide})),V=m.current.filter((function(e){return"right"===e.pinned&&!0!==e.hide})),J=l((function(){return"".concat(F.map((function(e){return ee(e)})).join(" "))}),[F]),q=l((function(){return"".concat(j.filter((function(e){return!0!==p[e.accessor]})).map((function(e){return ee(e)})).join(" "))}),[j,p]),G=l((function(){return"".concat(V.map((function(e){return ee(e)})).join(" "))}),[V]),Y={allowAnimations:t,centerHeaderRef:z,columnResizing:i,currentRows:a,columnReordering:c,draggedHeaderRef:s,forceUpdate:u,headerContainerRef:A,headersRef:m,hiddenColumns:p,hoveredHeaderRef:w,isWidthDragging:C,mainBodyRef:y,mainTemplateColumns:q,onSort:H,onTableHeaderDragEnd:I,pinnedLeftColumns:F,pinnedLeftHeaderRef:P,pinnedLeftTemplateColumns:J,pinnedRightColumns:V,pinnedRightHeaderRef:U,pinnedRightTemplateColumns:G,selectableColumns:S,setIsWidthDragging:N,setSelectedCells:k,sort:T,sortDownIcon:B,sortUpIcon:O,tableBodyContainerRef:W},K={allowAnimations:t,centerHeaderRef:z,currentRows:a,draggedHeaderRef:s,getBorderClass:f,handleMouseDown:h,handleMouseOver:g,headerContainerRef:A,headers:m.current,headersRef:m,hiddenColumns:p,hoveredHeaderRef:w,isSelected:R,isTopLeftCell:b,isWidthDragging:C,mainBodyRef:y,mainTemplateColumns:q,onCellEdit:x,onTableHeaderDragEnd:I,pinnedLeftColumns:F,pinnedLeftHeaderRef:P,pinnedLeftRef:M,pinnedLeftTemplateColumns:J,pinnedRightColumns:V,pinnedRightHeaderRef:U,pinnedRightRef:D,pinnedRightTemplateColumns:G,scrollbarWidth:E,shouldPaginate:L,tableBodyContainerRef:W};return e("div",v({className:"st-table-content",style:{width:d?"calc(100% - 27.5px)":"100%"}},{children:[n(_,v({},Y)),n(X,v({},K))]}))},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,c=r.tableContentWidth,s=t(0),d=s[0],u=s[1],f=t(0),h=f[0],g=f[1],m=t(0),p=m[0],w=m[1],R=o(null);return re({widthAttribute:"offsetWidth",callback:u,ref:a}),re({widthAttribute:"scrollWidth",callback:w,ref:i}),re({widthAttribute:"offsetWidth",callback:g,ref:l}),Z(i,R),!i.current||i.current.scrollWidth<=i.current.clientWidth?null:e("div",v({className:"st-horizontal-scrollbar-container",style:{width:c}},{children:[d>0&&n("div",{className:"st-horizontal-scrollbar-left",style:{flexShrink:0,width:d}}),p>0&&n("div",v({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:p}})})),h>0&&n("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:h}})]}))},oe=function(r){var o=r.checked,i=void 0!==o&&o,a=r.children,l=r.onChange,c=t(i),s=c[0],d=c[1];return e("label",v({className:"st-checkbox-label"},{children:[n("input",{checked:s,className:"st-checkbox-input",onChange:function(){var e=!s;d(e),l&&l(e)},type:"checkbox"}),n("span",v({className:"st-checkbox-custom ".concat(s?"st-checked":"")},{children:s&&n("span",{className:"st-checkbox-checkmark"})})),a]}))},ie=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",v({className:"st-column-editor-popout ".concat(t?"open":""," ").concat(l),onClick:function(e){return e.stopPropagation()}},{children:n("div",v({className:"st-column-editor-popout-content"},{children:r.map((function(e,r){return n(oe,v({checked:a[e.accessor],onChange:function(n){var r;return i(v(v({},a),((r={})[e.accessor]=n,r)))}},{children:e.label}),r)}))}))}))},ae=function(r){var o=r.columnEditorText,i=r.editColumns,a=r.editColumnsInitOpen,l=r.headers,c=r.position,s=void 0===c?"right":c,d=r.setHiddenColumns,u=r.hiddenColumns,f=t(a),h=f[0],g=f[1];return i?e("div",v({className:"st-column-editor ".concat(h?"open":""," ").concat(s),onClick:function(){return function(e){g(e)}(!h)}},{children:[n("div",v({className:"st-column-editor-text"},{children:o})),n(ie,{headers:l,open:h,position:s,setOpen:g,setHiddenColumns:d,hiddenColumns:u})]})):null};!function(e){e.Left="left",e.Right="right"}(R||(R={}));var le=function(r){var c=r.allowAnimations,d=void 0!==c&&c,u=r.columnEditorPosition,f=void 0===u?R.Right:u,g=r.columnEditorText,m=void 0===g?"Columns":g,p=r.columnResizing,w=void 0!==p&&p,I=r.defaultHeaders,M=r.editColumns,D=void 0!==M&&M,E=r.editColumnsInitOpen,S=void 0!==E&&E,N=r.columnReordering,k=void 0!==N&&N,L=r.height,T=r.hideFooter,B=void 0!==T&&T,O=r.nextIcon,W=void 0===O?n(y,{className:"st-next-prev-icon"}):O,A=r.onCellEdit,P=r.onColumnOrderChange,z=r.prevIcon,U=void 0===z?n(C,{className:"st-next-prev-icon"}):z,j=r.rows,F=r.rowsPerPage,V=void 0===F?10:F,J=r.selectableCells,X=void 0!==J&&J,q=r.selectableColumns,G=void 0!==q&&q,Y=r.shouldPaginate,$=void 0!==Y&&Y,Q=r.sortDownIcon,Z=void 0===Q?n(H,{className:"st-sort-icon"}):Q,_=r.sortUpIcon,ee=void 0===_?n(x,{className:"st-sort-icon"}):_,re=r.theme,oe=void 0===re?"light":re,ie=o(null),le=o(I),ce=o(null),se=o(null),de=o(null),ue=o(null),fe=o(null),he=t(!1),ve=he[0],ge=he[1],me=t(1),pe=me[0],we=me[1],Re=t(0),be=Re[0],Ce=Re[1],ye=t(0),xe=ye[0],He=ye[1],Ie=function(e){var n=e.headers,r=e.tableRows,o=t(null),i=o[0],a=o[1],c=l((function(){var e={};return n.forEach((function(n){!0===n.hide&&(e[n.accessor]=!0)})),e}),[n]),s=t(c),d=s[0],u=s[1],f=l((function(){return i?K(n,r,i).sortedData:r}),[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:d,setHiddenColumns:u}}({headers:le.current,tableRows:j}),Me=Ie.sort,De=Ie.sortedRows,Ee=Ie.hiddenColumns,Se=Ie.setHiddenColumns,Ne=Ie.updateSort,ke=h((function(e){return e+1}),0)[1],Le=function(e){var n=e.selectableCells,r=e.headers,c=e.rows,s=t(new Set),d=s[0],u=s[1],f=o(!1),h=o(null),v=i((function(){var e=Array.from(d).reduce((function(e,n){var t=n.split("-").map(Number),o=t[0],i=t[1];return e[o]||(e[o]=[]),e[o][i]=c[o][r[i].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");d.size>0&&navigator.clipboard.writeText(n)}),[d,c,r]);a((function(){var e=function(e){(e.ctrlKey||e.metaKey)&&"c"===e.key&&v()};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[v]);var g=i((function(e,n){return d.has("".concat(e,"-").concat(n))}),[d]),m=i((function(e,n){var r=[];return g(e-1,n)||r.push("st-selected-top-border"),g(e+1,n)||r.push("st-selected-bottom-border"),g(e,n-1)||r.push("st-selected-left-border"),g(e,n+1)||r.push("st-selected-right-border"),r.join(" ")}),[g]),p=l((function(){var e=Math.min.apply(Math,Array.from(d).map((function(e){return parseInt(e.split("-")[0])}))),n=Math.min.apply(Math,Array.from(d).map((function(e){return parseInt(e.split("-")[1])})));return function(r,t){return r===e&&t===n}}),[d]);return{selectedCells:d,handleMouseDown:function(e){var r=e.colIndex,t=e.rowIndex;n&&(f.current=!0,h.current={row:t,col:r},u(new Set(["".concat(t,"-").concat(r)])))},handleMouseOver:function(e,r){if(n&&f.current&&h.current){for(var t=new Set,o=Math.min(h.current.row,e),i=Math.max(h.current.row,e),a=Math.min(h.current.col,r),l=Math.max(h.current.col,r),c=o;c<=i;c++)for(var s=a;s<=l;s++)t.add("".concat(c,"-").concat(s));u(t)}},handleMouseUp:function(){f.current=!1,h.current=null},isSelected:g,getBorderClass:m,isTopLeftCell:p,setSelectedCells:u}}({selectableCells:X,headers:le.current,rows:De}),Te=Le.handleMouseDown,Be=Le.handleMouseOver,Oe=Le.handleMouseUp,We=Le.isSelected,Ae=Le.getBorderClass,Pe=Le.isTopLeftCell,ze=Le.setSelectedCells,Ue=l((function(){return $?De.slice((pe-1)*V,pe*V):De}),[pe,V,$,De]),je=i((function(e,n){Ne(e,n)}),[Ne]),Fe=i((function(e){le.current=e,ke(),null==P||P(e)}),[P]);return a((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"))||ze(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[G,ze]),s((function(){if(fe.current){var e=fe.current.offsetWidth-fe.current.clientWidth,n=fe.current.clientWidth;Ce(e),He(n)}}),[]),s((function(){var e=function(){if(ke(),fe.current){var e=fe.current.offsetWidth-fe.current.clientWidth,n=fe.current.clientWidth;Ce(e),He(n)}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),e("div",v({className:"simple-table-root st-wrapper theme-".concat(oe),style:L?{height:L}:{}},{children:[e("div",v({className:"st-table-wrapper-container"},{children:[e("div",v({className:"st-table-wrapper",onMouseUp:Oe,onMouseLeave:Oe},{children:[n(ne,{allowAnimations:d,columnResizing:w,currentRows:Ue,draggedHeaderRef:ie,editColumns:D,columnReordering:k,forceUpdate:ke,getBorderClass:Ae,handleMouseDown:Te,handleMouseOver:Be,headers:le.current,headersRef:le,hiddenColumns:Ee,hoveredHeaderRef:ce,isSelected:We,isTopLeftCell:Pe,isWidthDragging:ve,mainBodyRef:se,onCellEdit:A,onSort:je,onTableHeaderDragEnd:Fe,pinnedLeftRef:de,pinnedRightRef:ue,scrollbarWidth:be,selectableColumns:G,setIsWidthDragging:ge,setSelectedCells:ze,shouldPaginate:$,sort:Me,sortDownIcon:Z,sortUpIcon:ee,tableBodyContainerRef:fe}),n(ae,{columnEditorText:m,editColumns:D,editColumnsInitOpen:S,headers:le.current,hiddenColumns:Ee,position:f,setHiddenColumns:Se})]})),n(te,{mainBodyRef:se,pinnedLeftRef:de,pinnedRightRef:ue,tableContentWidth:xe})]})),n(b,{currentPage:pe,hideFooter:B,nextIcon:W,onPageChange:we,prevIcon:U,rowsPerPage:V,shouldPaginate:$,totalRows:De.length})]}))};le.defaultProps={allowAnimations:!1,columnEditorPosition:R.Right,columnEditorText:"Columns",columnResizing:!1,defaultHeaders:[],editColumns:!1,editColumnsInitOpen:!1,columnReordering:!1,height:"",hideFooter:!1,nextIcon:n(y,{className:"st-next-prev-icon"}),onCellEdit:function(){},prevIcon:n(C,{className:"st-next-prev-icon"}),rows:[],rowsPerPage:10,selectableCells:!1,selectableColumns:!1,shouldPaginate:!1,sortDownIcon:n(H,{className:"st-sort-icon"}),sortUpIcon:n(x,{className:"st-sort-icon"}),theme:"light"};var ce=f(le);export{ce 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 c,useLayoutEffect as s,createElement as d,createRef as u,memo as f,useReducer as h}from"react";var v=function(){return v=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},v.apply(this,arguments)};function g(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,t){return new(r||(r=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function l(e){try{c(t.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(a,l)}c((t=t.apply(e,n||[])).next())}))}function p(e,n){var r,t,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(c){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,t&&(o=2&l[0]?t.return:l[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,l[1])).done)return o;switch(t=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,t=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=n.call(e,i)}catch(e){l=[6,e],t=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}function w(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 R,b=function(r){var t=r.currentPage,o=r.hideFooter,i=r.nextIcon,a=r.onPageChange,l=r.prevIcon,c=r.rowsPerPage,s=r.shouldPaginate,d=r.totalRows,u=Math.ceil(d/c),f=t>1,h=t<u,g=function(e){e>=1&&e<=u&&a(e)};return o||!s?null:e("div",v({className:"st-footer"},{children:[n("button",v({className:"st-next-prev-btn ".concat(f?"":"disabled"),onClick:function(){return g(t-1)},disabled:!f},{children:l})),n("button",v({className:"st-next-prev-btn ".concat(h?"":"disabled"),onClick:function(){return g(t+1)},disabled:!h},{children:i})),Array.from({length:u},(function(e,r){return n("button",v({onClick:function(){return g(r+1)},className:"st-page-btn ".concat(t===r+1?"active":"")},{children:r+1}),r)}))]}))},C=function(e){var r=e.className;return n("svg",v({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"})}))},y=function(e){var r=e.className;return n("svg",v({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"})}))},x=function(e){var r=e.className;return n("svg",v({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"})}))},H=function(e){var r=e.className;return n("svg",v({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"})}))},I=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)},E=function(e){var n=e.hiddenColumns,r=e.header,t=e.pinned;return n[r.accessor]?null:!t&&!r.pinned||r.pinned===t||null},S=function(r){var t=r.value,o=r.onBlur,i=r.onChange;return e("select",v({value:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;i("true"===n)}},{children:[n("option",v({value:"true"},{children:"True"})),n("option",v({value:"false"},{children:"False"}))]}))},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,type:"text",defaultValue:null!=r?r:"",onBlur:t,onChange:function(e){var n=e.target.value;i(n)}})},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,defaultValue:r.toString(),onBlur:t,onChange:function(e){var n=e.target.value;/^\d*\.?\d*$/.test(n)&&i(n)}})},L=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(N,{defaultValue:i,onBlur:l,onChange:a}):"boolean"==typeof i?n(S,{onBlur:l,onChange:a,value:i}):"number"==typeof i?n(k,{defaultValue:i,onBlur:l,onChange:a}):null})},T=0,B=function(){return function(e){var n=e.callback,r=e.callbackProps,t=e.limit,o=Date.now();(0===T||o-T>=t)&&(T=o,n(r))}},O=Date.now(),W={screenX:0,screenY:0},A=function(e){var n,r,t=e.draggedHeaderRef,i=e.headersRef,l=e.hoveredHeaderRef,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,O=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=w([],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})),m=h.splice(v,1)[0];if(h.splice(g,0,m),!(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-O<800&&f<50||(O=p,W={screenX:d,screenY:u},c(h))}}},handleDragEnd:function(){t.current=null,l.current=null}}},P=c((function(r,o){var i,l,c=r.borderClass,s=r.colIndex,d=r.draggedHeaderRef,u=r.header,f=r.headersRef,h=r.hoveredHeaderRef,g=r.isSelected,m=r.isTopLeftCell,p=r.onCellEdit,w=r.onExpandRowClick,R=r.onMouseDown,b=r.onMouseOver,C=r.onTableHeaderDragEnd,x=r.rowIndex,I=r.visibleRow,M=I.depth,E=I.row,S=t(E.rowData[u.accessor]),N=S[0],k=S[1],T=t(!1),O=T[0],W=T[1],P=A({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:C}).handleDragOver,z=B(),U=Boolean(null===(l=null===(i=E.rowMeta)||void 0===i?void 0:i.children)||void 0===l?void 0:l.length),j=Boolean(null==u?void 0:u.isEditable),F=x%2==0,V="st-cell ".concat(M>0&&u.expandable?"st-cell-depth-".concat(M):""," ").concat(g?m?"st-cell-selected-first-cell ".concat(c):"st-cell-selected ".concat(c):""," ").concat(F?"st-cell-odd-row":"st-cell-even-row"," ").concat(j?"clickable":""," ").concat("right"===u.align?"right-aligned":"center"===u.align?"center-aligned":"left-aligned");return a((function(){k(E.rowData[u.accessor])}),[u.accessor,E]),O?n("div",v({className:"st-cell-editing ".concat(F?"st-cell-odd-row":"st-cell-even-row"),id:D({accessor:u.accessor,rowIndex:x+1})},{children:n(L,{onChange:function(e){k(e),null==p||p({accessor:u.accessor,newValue:e,row:E})},setIsEditing:W,value:N})})):e("div",v({className:V,id:D({accessor:u.accessor,rowIndex:x+1}),onDoubleClick:function(){return u.isEditable&&W(!0)},onMouseDown:function(){return R(x,s)},onMouseOver:function(){return b(x,s)},onDragOver:function(e){return z({callback:P,callbackProps:{event:e,hoveredHeader:u},limit:50})},ref:o},{children:[u.expandable&&U?E.rowMeta.isExpanded?n("div",v({className:"st-sort-icon-container",onClick:function(){return w(E.rowMeta.rowId)}},{children:n(H,{className:"st-sort-icon"})})):n("div",v({className:"st-sort-icon-container",onClick:function(){return w(E.rowMeta.rowId)}},{children:n(y,{className:"st-sort-icon"})})):null,n("span",v({className:"st-cell-content"},{children:u.cellRenderer?u.cellRenderer({accessor:u.accessor,colIndex:s,row:E}):N}))]}))})),z=function(e){var t=e.allowAnimations,o=e.children,i=g(e,["allowAnimations","children"]);return t?n(U,v({},i,{children:o})):n(r,{children:o})},U=function(e){var i=e.allowHorizontalAnimate,l=void 0===i||i,c=e.children,d=e.draggedHeaderRef,u=e.headersRef,f=e.isBody,h=e.mainBodyRef,v=e.pauseAnimation,g=e.rowIndex,m=o(!1),p=t({}),w=p[0],R=p[1],b=o({}),C=u.current;return s((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:d,rowIndex:g});JSON.stringify(e)!==JSON.stringify(w)&&(b.current=w,R(e))}}),[w,C,d,f,g]),s((function(){var e=h.current,n=function(){m.current=!0},r=function(){m.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)}}),[d,h]),a((function(){v||m.current||Object.keys(b.current).length&&C&&C.forEach((function(e){var n=document.getElementById(D({accessor:e.accessor,rowIndex:g}));if(n){var r=b.current[e.accessor],t=w[e.accessor];if(r&&t){var o=r.left-t.left,i=l?0:r.top-t.top,a=Math.abs(o),c=Math.abs(i);(a>10||c>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,w,C,f,v,b,g]),n(r,{children:c})},j=function(e){var r=e.getBorderClass,t=e.handleMouseDown,o=e.handleMouseOver,i=e.headers,a=e.hiddenColumns,l=e.isSelected,c=e.isTopLeftCell,s=e.onExpandRowClick,u=e.pinned,f=e.rowIndex,h=e.visibleRow,m=g(e,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isTopLeftCell","onExpandRowClick","pinned","rowIndex","visibleRow"]);return n(z,v({allowAnimations:m.allowAnimations,allowHorizontalAnimate:m.shouldPaginate,draggedHeaderRef:m.draggedHeaderRef,headersRef:m.headersRef,isBody:!0,mainBodyRef:m.mainBodyRef,pauseAnimation:m.isWidthDragging,rowIndex:f+1},{children:i.map((function(e,n){return E({hiddenColumns:a,header:e,pinned:u})?d(P,v({},m,{borderClass:r(f,n),colIndex:n,header:e,isSelected:l(f,n),isTopLeftCell:c(f,n),key:D({accessor:e.accessor,rowIndex:f+1}),onExpandRowClick:s,onMouseDown:function(){return t({rowIndex:f,colIndex:n})},onMouseOver:function(){return o(f,n)},rowIndex:f,visibleRow:h})):null}))}))},F=function(e){var r=e.getNextRowIndex,t=e.gridTemplateColumns,o=e.index,i=e.pinned,a=e.props,l=e.rowHeight,c=e.visibleRow,s=c.position,d=r();return n("div",v({className:"st-table-row",style:{gridTemplateColumns:t,top:M({position:s,rowHeight:l}),height:"".concat(l,"px")}},{children:n(j,v({pinned:i,rowIndex:d,visibleRow:c},a),o)}))},V=function(e){var r=e.lastGroupRow,t=e.position,o=e.rowHeight,i=e.templateColumns;return n("div",v({className:"st-row-separator ".concat(r?"st-last-group-row":""),style:{display:"grid",gridTemplateColumns:i,position:"absolute",top:I({position:t,rowHeight:o}),minWidth:"100%"}},{children:n("div",{style:{gridColumn:"1 / -1"}})}))},J=function(t){t.headerContainerRef;var i=t.onExpandRowClick,l=t.pinned,c=t.rowHeight,s=t.sectionRef,d=t.templateColumns,u=t.totalHeight,f=t.visibleRows,h=t.width,m=g(t,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),p=l?"st-table-body-pinned-".concat(l):"st-table-body-main",w=o(0);a((function(){w.current=0}));var R=function(){return w.current++};return n("div",v({className:p,ref:s,style:{position:"relative",height:"".concat(u,"px"),width:h}},{children:f.map((function(t,o){var a,s,u=Boolean(null===(s=null===(a=t.row.rowMeta)||void 0===a?void 0:a.children)||void 0===s?void 0:s.length);return e(r,{children:[n(F,{getNextRowIndex:R,gridTemplateColumns:d,index:o,pinned:l,props:v(v({},m),{onExpandRowClick:i}),rowHeight:c,visibleRow:t},o),0!==o&&n(V,{lastGroupRow:u,position:t.position,rowHeight:c,templateColumns:d})]})}))}))},X=function(r){var c,s,d,u,f,h=r.centerHeaderRef,g=r.currentRows,R=r.headerContainerRef,b=r.mainBodyRef,C=r.mainTemplateColumns,y=r.pinnedLeftColumns,x=r.pinnedLeftHeaderRef,H=r.pinnedLeftRef,I=r.pinnedLeftTemplateColumns,M=r.pinnedRightColumns,D=r.pinnedRightHeaderRef,E=r.pinnedRightRef,S=r.pinnedRightTemplateColumns,N=r.scrollbarWidth,k=r.tableBodyContainerRef;!function(e){var n=e.headerContainerRef,r=e.mainSectionRef,o=e.scrollbarWidth,i=t(!1),l=i[0],c=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;c(e)}};o();var i=new ResizeObserver((function(){o()}));return i.observe(t),function(){t&&i.unobserve(t)}}}),[n,r])}({headerContainerRef:R,mainSectionRef:k,scrollbarWidth:N});var L=o(null),T=o(null),B=t(g),O=B[0],W=B[1],A=t(1),P=A[0],z=A[1],U=t(!1),j=U[0],F=U[1],V=t(!0),X=V[0],q=V[1],G=t(0),Y=G[0],K=G[1],$=function(e){var n=0,r=function(e){e.forEach((function(e){n+=1,e.rowMeta.isExpanded&&e.rowMeta.children&&r(e.rowMeta.children)}))};return r(e),n}(O),Q=41*$-1,Z=function(e){var n=function(r){return r.rowMeta.rowId===e&&r.rowMeta.children?v(v({},r),{rowMeta:v(v({},r.rowMeta),{isExpanded:!r.rowMeta.isExpanded})}):r.rowMeta.children?v(v({},r),{rowMeta:v(v({},r.rowMeta),{children:r.rowMeta.children.map(n)})}):r};W((function(e){return e.map(n)}))},_=l((function(){return function(e){var n=e.bufferRowCount,r=e.containerHeight,t=e.rowHeight,o=e.rows,i=e.scrollTop,a=[],l=0,c=Math.max(0,i-t*n),s=i+r+t*n,d=function(e,n){for(var r,o=0,i=e;o<i.length;o++){var u=i[o],f=l*t;if(f>=s)break;f+t>c&&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&&d(u.rowMeta.children,n+1)}};return d(o,0),a}({bufferRowCount:5,containerHeight:600,rowHeight:40,rows:O,scrollTop:Y})}),[O,Y]),ee=i((function(){return m(void 0,void 0,void 0,(function(){var e;return p(this,(function(n){return j||!X||(F(!0),e=g.slice(20*P,20*(P+1)),W((function(n){return w(w([],n,!0),e,!0)})),z((function(e){return e+1})),F(!1),e.length<20/3&&q(!1)),[2]}))}))}),[g,X,j,P]),ne=i((function(e){e[0].isIntersecting&&X&&!j&&ee()}),[X,j,ee]);a((function(){return L.current=new IntersectionObserver(ne,{root:null,rootMargin:"100px",threshold:0}),k.current&&L.current.observe(k.current),function(){L.current&&L.current.disconnect()}}),[ne,O,k]);var re=(null===(c=x.current)||void 0===c?void 0:c.clientWidth)?(null===(s=x.current)||void 0===s?void 0:s.clientWidth)+1:0,te=null===(d=h.current)||void 0===d?void 0:d.clientWidth,oe=(null===(u=D.current)||void 0===u?void 0:u.clientWidth)?(null===(f=D.current)||void 0===f?void 0:f.clientWidth)+1:0;return e("div",v({className:"st-table-body-container",ref:k,onScroll:function(e){var n=e.currentTarget.scrollTop;T.current&&cancelAnimationFrame(T.current),T.current=requestAnimationFrame((function(){K(n)}))}},{children:[y.length>0&&n(J,v({},r,{onExpandRowClick:Z,pinned:"left",rowHeight:40,sectionRef:H,templateColumns:I,totalHeight:Q,visibleRows:_,width:re})),n(J,v({},r,{onExpandRowClick:Z,rowHeight:40,sectionRef:b,templateColumns:C,totalHeight:Q,visibleRows:_,width:te})),M.length>0&&n(J,v({},r,{onExpandRowClick:Z,pinned:"right",rowHeight:40,sectionRef:E,templateColumns:S,totalHeight:Q,visibleRows:_,width:oe}))]}))},q={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 q.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?q.string(e,n,r):"number"==typeof e&&"number"==typeof n?q.number(e,n,r):"boolean"==typeof e&&"boolean"==typeof n?q.boolean(e,n,r):q.string(String(e),String(n),r)}},G=function(e,n,r,t){switch(void 0===r&&(r="string"),r){case"string":return q.string(String(e||""),String(n||""),t);case"number":return q.number(Number(e||0),Number(n||0),t);case"boolean":return q.boolean(Boolean(e),Boolean(n),t);case"date":return q.date(String(e||""),String(n||""),t);case"enum":return q.enum(String(e||""),String(n||""),t);default:return q.default(e,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;return w([],e,!0).sort((function(e,r){var t,a,l=null===(t=null==e?void 0:e.rowData)||void 0===t?void 0:t[n.key.accessor],c=null===(a=null==r?void 0:r.rowData)||void 0===a?void 0:a[n.key.accessor];return G(l,c,o,i)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?v(v({},e),{rowMeta:v(v({},e.rowMeta),{children:Y(e.rowMeta.children,n,r)})}):e}))},K=function(e,n,r){var t=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=[],l=new Map;return e.forEach((function(n){e.some((function(e){var r;return null===(r=e.rowMeta.children)||void 0===r?void 0:r.some((function(e){return e.rowMeta.rowId===n.rowMeta.rowId}))}))||a.push(n),n.rowMeta.children&&n.rowMeta.children.length>0&&l.set(n.rowMeta.rowId,n.rowMeta.children)})),w([],a,!0).sort((function(e,r){var t,a,l=null===(t=null==e?void 0:e.rowData)||void 0===t?void 0:t[n.key.accessor],c=null===(a=null==r?void 0:r.rowData)||void 0===a?void 0:a[n.key.accessor];return G(l,c,o,i)})).map((function(e){var t=v({},e);if(l.has(e.rowMeta.rowId)){var o=l.get(e.rowMeta.rowId)||[],i=Y(o,n,r);t.rowMeta=v(v({},t.rowMeta),{children:i})}return t}))}(n,r,e);return{sortedData:t,newSortConfig:r}},$=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 c=n.clientX;if(t){var s=function(e){var n=Math.max(l+(e.clientX-c),40);t&&o.current&&(o.current[i].width=n,r())},d=function(){document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",d),a(!1)};document.addEventListener("mousemove",s),document.addEventListener("mouseup",d)}},Q=c((function(r,o){var i,l=r.columnResizing,c=r.currentRows,s=r.columnReordering,d=r.draggedHeaderRef,u=r.forceUpdate,f=r.headersRef,h=r.hoveredHeaderRef,g=r.index,m=r.onSort,p=r.onTableHeaderDragEnd,w=r.reverse,R=r.selectableColumns,b=r.setIsWidthDragging,C=r.setSelectedCells,y=r.sort,x=r.sortDownIcon,H=r.sortUpIcon,I=t(!1),M=I[0],E=I[1],S=null===(i=f.current)||void 0===i?void 0:i[g],N=Boolean(null==S?void 0:S.isSortable),k="st-header-cell ".concat(S===h.current?"st-hovered":""," ").concat(M?"st-dragging":""," ").concat(N?"clickable":""," ").concat(s&&!N?"columnReordering":""," ").concat("right"===(null==S?void 0:S.align)?"right-aligned":"center"===(null==S?void 0:S.align)?"center-aligned":""),L=A({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:p}),T=L.handleDragStart,O=L.handleDragEnd,W=A({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:p}).handleDragOver,P=B(),z=function(e){var n=e.event,r=e.header;if(R){var t=c.length,o=Array.from({length:t},(function(e,n){return"".concat(n,"-").concat(g)})),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("".concat(n,"-").concat(o+t))}))})),r};n.shiftKey?C((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)})):C(new Set(o))}else r.isSortable&&m(g,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)}}),[]),!S)return null;var U=l&&n("div",{className:"st-header-resize-handle",onMouseDown:function(e){var n;P({callback:$,callbackProps:{event:e,forceUpdate:u,header:S,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})}});return e("div",v({className:k,id:D({accessor:S.accessor,rowIndex:0}),onDragOver:function(e){P({callback:W,callbackProps:{event:e,hoveredHeader:S},limit:50})},ref:o,style:{width:S.width}},{children:[w&&U,n("div",v({className:"st-header-label",draggable:s,onClick:function(e){return z({event:e,header:S})},onDragEnd:function(e){e.preventDefault(),E(!1),O()},onDragStart:function(e){s&&S&&function(e){E(!0),T(e)}(S)}},{children:null==S?void 0:S.label})),y&&y.key.accessor===S.accessor&&e("div",v({className:"st-sort-icon-container",onClick:function(e){return z({event:e,header:S})}},{children:["ascending"===y.direction&&H&&H,"descending"===y.direction&&x&&x]})),!w&&U]}))})),Z=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])},_=function(r){var t,o,i,a=r.allowAnimations,l=r.centerHeaderRef,c=r.columnResizing,s=r.currentRows,d=r.columnReordering,f=r.draggedHeaderRef,h=r.forceUpdate,g=r.headerContainerRef,m=r.headersRef,p=r.hiddenColumns,w=r.hoveredHeaderRef,R=r.isWidthDragging,b=r.mainBodyRef,C=r.mainTemplateColumns,y=r.onSort,x=r.onTableHeaderDragEnd,H=r.pinnedLeftColumns,I=r.pinnedLeftHeaderRef,M=r.pinnedLeftTemplateColumns,D=r.pinnedRightColumns,S=r.pinnedRightHeaderRef,N=r.pinnedRightTemplateColumns,k=r.selectableColumns,L=r.setIsWidthDragging,T=r.setSelectedCells,B=r.sort,O=r.sortDownIcon,W=r.sortUpIcon;Z(b,l);return e("div",v({className:"st-header-container",ref:g},{children:[H.length>0&&n("div",v({className:"st-header-pinned-left",ref:I,style:{gridTemplateColumns:M}},{children:n(z,v({allowAnimations:a,draggedHeaderRef:f,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:null===(t=m.current)||void 0===t?void 0:t.map((function(e,r){return E({hiddenColumns:p,header:e,pinned:"left"})?n(Q,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,ref:u(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:B,sortDownIcon:O,sortUpIcon:W},e.accessor):null}))}))})),n("div",v({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=b.current)||void 0===r||r.scrollTo(t,0))},ref:l,style:{gridTemplateColumns:C}},{children:n(z,v({allowAnimations:a,draggedHeaderRef:f,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:null===(o=m.current)||void 0===o?void 0:o.map((function(e,r){return E({hiddenColumns:p,header:e})?n(Q,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,ref:u(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:B,sortDownIcon:O,sortUpIcon:W},e.accessor):null}))}))})),D.length>0&&n("div",v({className:"st-header-pinned-right",ref:S,style:{gridTemplateColumns:N}},{children:n(z,v({allowAnimations:a,draggedHeaderRef:f,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:null===(i=m.current)||void 0===i?void 0:i.map((function(e,r){return E({hiddenColumns:p,header:e,pinned:"right"})?n(Q,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,reverse:!0,ref:u(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:B,sortDownIcon:O,sortUpIcon:W},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.columnResizing,a=r.currentRows,c=r.columnReordering,s=r.draggedHeaderRef,d=r.editColumns,u=r.forceUpdate,f=r.getBorderClass,h=r.handleMouseDown,g=r.handleMouseOver,m=r.headersRef,p=r.hiddenColumns,w=r.hoveredHeaderRef,R=r.isSelected,b=r.isTopLeftCell,C=r.isWidthDragging,y=r.mainBodyRef,x=r.onCellEdit,H=r.onSort,I=r.onTableHeaderDragEnd,M=r.pinnedLeftRef,D=r.pinnedRightRef,E=r.scrollbarWidth,S=r.selectableColumns,N=r.setIsWidthDragging,k=r.setSelectedCells,L=r.shouldPaginate,T=r.sort,B=r.sortDownIcon,O=r.sortUpIcon,W=r.tableBodyContainerRef,A=o(null),P=o(null),z=o(null),U=o(null),j=m.current.filter((function(e){return!e.hide&&!e.pinned})),F=m.current.filter((function(e){return"left"===e.pinned&&!0!==e.hide})),V=m.current.filter((function(e){return"right"===e.pinned&&!0!==e.hide})),J=l((function(){return"".concat(F.map((function(e){return ee(e)})).join(" "))}),[F]),q=l((function(){return"".concat(j.filter((function(e){return!0!==p[e.accessor]})).map((function(e){return ee(e)})).join(" "))}),[j,p]),G=l((function(){return"".concat(V.map((function(e){return ee(e)})).join(" "))}),[V]),Y={allowAnimations:t,centerHeaderRef:z,columnResizing:i,currentRows:a,columnReordering:c,draggedHeaderRef:s,forceUpdate:u,headerContainerRef:A,headersRef:m,hiddenColumns:p,hoveredHeaderRef:w,isWidthDragging:C,mainBodyRef:y,mainTemplateColumns:q,onSort:H,onTableHeaderDragEnd:I,pinnedLeftColumns:F,pinnedLeftHeaderRef:P,pinnedLeftTemplateColumns:J,pinnedRightColumns:V,pinnedRightHeaderRef:U,pinnedRightTemplateColumns:G,selectableColumns:S,setIsWidthDragging:N,setSelectedCells:k,sort:T,sortDownIcon:B,sortUpIcon:O,tableBodyContainerRef:W},K={allowAnimations:t,centerHeaderRef:z,currentRows:a,draggedHeaderRef:s,getBorderClass:f,handleMouseDown:h,handleMouseOver:g,headerContainerRef:A,headers:m.current,headersRef:m,hiddenColumns:p,hoveredHeaderRef:w,isSelected:R,isTopLeftCell:b,isWidthDragging:C,mainBodyRef:y,mainTemplateColumns:q,onCellEdit:x,onTableHeaderDragEnd:I,pinnedLeftColumns:F,pinnedLeftHeaderRef:P,pinnedLeftRef:M,pinnedLeftTemplateColumns:J,pinnedRightColumns:V,pinnedRightHeaderRef:U,pinnedRightRef:D,pinnedRightTemplateColumns:G,scrollbarWidth:E,shouldPaginate:L,tableBodyContainerRef:W};return e("div",v({className:"st-table-content",style:{width:d?"calc(100% - 27.5px)":"100%"}},{children:[n(_,v({},Y)),n(X,v({},K))]}))},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,c=r.tableContentWidth,s=t(0),d=s[0],u=s[1],f=t(0),h=f[0],g=f[1],m=t(0),p=m[0],w=m[1],R=o(null);return re({widthAttribute:"offsetWidth",callback:u,ref:a}),re({widthAttribute:"scrollWidth",callback:w,ref:i}),re({widthAttribute:"offsetWidth",callback:g,ref:l}),Z(i,R),!i.current||i.current.scrollWidth<=i.current.clientWidth?null:e("div",v({className:"st-horizontal-scrollbar-container",style:{width:c}},{children:[d>0&&n("div",{className:"st-horizontal-scrollbar-left",style:{flexShrink:0,width:d}}),p>0&&n("div",v({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:p}})})),h>0&&n("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:h}})]}))},oe=function(r){var o=r.checked,i=void 0!==o&&o,a=r.children,l=r.onChange,c=t(i),s=c[0],d=c[1];return e("label",v({className:"st-checkbox-label"},{children:[n("input",{checked:s,className:"st-checkbox-input",onChange:function(){var e=!s;d(e),l&&l(e)},type:"checkbox"}),n("span",v({className:"st-checkbox-custom ".concat(s?"st-checked":"")},{children:s&&n("span",{className:"st-checkbox-checkmark"})})),a]}))},ie=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",v({className:"st-column-editor-popout ".concat(t?"open":""," ").concat(l),onClick:function(e){return e.stopPropagation()}},{children:n("div",v({className:"st-column-editor-popout-content"},{children:r.map((function(e,r){return n(oe,v({checked:a[e.accessor],onChange:function(n){var r;return i(v(v({},a),((r={})[e.accessor]=n,r)))}},{children:e.label}),r)}))}))}))},ae=function(r){var o=r.columnEditorText,i=r.editColumns,a=r.editColumnsInitOpen,l=r.headers,c=r.position,s=void 0===c?"right":c,d=r.setHiddenColumns,u=r.hiddenColumns,f=t(a),h=f[0],g=f[1];return i?e("div",v({className:"st-column-editor ".concat(h?"open":""," ").concat(s),onClick:function(){return function(e){g(e)}(!h)}},{children:[n("div",v({className:"st-column-editor-text"},{children:o})),n(ie,{headers:l,open:h,position:s,setOpen:g,setHiddenColumns:d,hiddenColumns:u})]})):null};!function(e){e.Left="left",e.Right="right"}(R||(R={}));var le=function(r){var c=r.allowAnimations,d=void 0!==c&&c,u=r.columnEditorPosition,f=void 0===u?R.Right:u,g=r.columnEditorText,m=void 0===g?"Columns":g,p=r.columnResizing,w=void 0!==p&&p,I=r.defaultHeaders,M=r.editColumns,D=void 0!==M&&M,E=r.editColumnsInitOpen,S=void 0!==E&&E,N=r.columnReordering,k=void 0!==N&&N,L=r.height,T=r.hideFooter,B=void 0!==T&&T,O=r.nextIcon,W=void 0===O?n(y,{className:"st-next-prev-icon"}):O,A=r.onCellEdit,P=r.onColumnOrderChange,z=r.prevIcon,U=void 0===z?n(C,{className:"st-next-prev-icon"}):z,j=r.rows,F=r.rowsPerPage,V=void 0===F?10:F,J=r.selectableCells,X=void 0!==J&&J,q=r.selectableColumns,G=void 0!==q&&q,Y=r.shouldPaginate,$=void 0!==Y&&Y,Q=r.sortDownIcon,Z=void 0===Q?n(H,{className:"st-sort-icon"}):Q,_=r.sortUpIcon,ee=void 0===_?n(x,{className:"st-sort-icon"}):_,re=r.theme,oe=void 0===re?"light":re,ie=o(null),le=o(I),ce=o(null),se=o(null),de=o(null),ue=o(null),fe=o(null),he=t(!1),ve=he[0],ge=he[1],me=t(1),pe=me[0],we=me[1],Re=t(0),be=Re[0],Ce=Re[1],ye=t(0),xe=ye[0],He=ye[1],Ie=function(e){var n=e.headers,r=e.tableRows,o=t(null),i=o[0],a=o[1],c=l((function(){var e={};return n.forEach((function(n){!0===n.hide&&(e[n.accessor]=!0)})),e}),[n]),s=t(c),d=s[0],u=s[1],f=l((function(){return i?K(n,r,i).sortedData:r}),[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:d,setHiddenColumns:u}}({headers:le.current,tableRows:j}),Me=Ie.sort,De=Ie.sortedRows,Ee=Ie.hiddenColumns,Se=Ie.setHiddenColumns,Ne=Ie.updateSort,ke=h((function(e){return e+1}),0)[1],Le=function(e){var n=e.selectableCells,r=e.headers,c=e.rows,s=t(new Set),d=s[0],u=s[1],f=o(!1),h=o(null),v=i((function(){var e=Array.from(d).reduce((function(e,n){var t=n.split("-").map(Number),o=t[0],i=t[1];return e[o]||(e[o]=[]),e[o][i]=c[o][r[i].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");d.size>0&&navigator.clipboard.writeText(n)}),[d,c,r]);a((function(){var e=function(e){(e.ctrlKey||e.metaKey)&&"c"===e.key&&v()};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[v]);var g=i((function(e,n){return d.has("".concat(e,"-").concat(n))}),[d]),m=i((function(e,n){var r=[];return g(e-1,n)||r.push("st-selected-top-border"),g(e+1,n)||r.push("st-selected-bottom-border"),g(e,n-1)||r.push("st-selected-left-border"),g(e,n+1)||r.push("st-selected-right-border"),r.join(" ")}),[g]),p=l((function(){var e=Math.min.apply(Math,Array.from(d).map((function(e){return parseInt(e.split("-")[0])}))),n=Math.min.apply(Math,Array.from(d).map((function(e){return parseInt(e.split("-")[1])})));return function(r,t){return r===e&&t===n}}),[d]);return{selectedCells:d,handleMouseDown:function(e){var r=e.colIndex,t=e.rowIndex;n&&(f.current=!0,h.current={row:t,col:r},u(new Set(["".concat(t,"-").concat(r)])))},handleMouseOver:function(e,r){if(n&&f.current&&h.current){for(var t=new Set,o=Math.min(h.current.row,e),i=Math.max(h.current.row,e),a=Math.min(h.current.col,r),l=Math.max(h.current.col,r),c=o;c<=i;c++)for(var s=a;s<=l;s++)t.add("".concat(c,"-").concat(s));u(t)}},handleMouseUp:function(){f.current=!1,h.current=null},isSelected:g,getBorderClass:m,isTopLeftCell:p,setSelectedCells:u}}({selectableCells:X,headers:le.current,rows:De}),Te=Le.handleMouseDown,Be=Le.handleMouseOver,Oe=Le.handleMouseUp,We=Le.isSelected,Ae=Le.getBorderClass,Pe=Le.isTopLeftCell,ze=Le.setSelectedCells,Ue=l((function(){return $?De.slice((pe-1)*V,pe*V):De}),[pe,V,$,De]),je=i((function(e,n){Ne(e,n)}),[Ne]),Fe=i((function(e){le.current=e,ke(),null==P||P(e)}),[P]);return a((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"))||ze(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[G,ze]),s((function(){if(fe.current){var e=fe.current.offsetWidth-fe.current.clientWidth,n=fe.current.clientWidth;Ce(e),He(n)}}),[]),s((function(){var e=function(){if(ke(),fe.current){var e=fe.current.offsetWidth-fe.current.clientWidth,n=fe.current.clientWidth;Ce(e),He(n)}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),e("div",v({className:"simple-table-root st-wrapper theme-".concat(oe),style:L?{height:L}:{}},{children:[e("div",v({className:"st-table-wrapper-container"},{children:[e("div",v({className:"st-table-wrapper",onMouseUp:Oe,onMouseLeave:Oe},{children:[n(ne,{allowAnimations:d,columnResizing:w,currentRows:Ue,draggedHeaderRef:ie,editColumns:D,columnReordering:k,forceUpdate:ke,getBorderClass:Ae,handleMouseDown:Te,handleMouseOver:Be,headers:le.current,headersRef:le,hiddenColumns:Ee,hoveredHeaderRef:ce,isSelected:We,isTopLeftCell:Pe,isWidthDragging:ve,mainBodyRef:se,onCellEdit:A,onSort:je,onTableHeaderDragEnd:Fe,pinnedLeftRef:de,pinnedRightRef:ue,scrollbarWidth:be,selectableColumns:G,setIsWidthDragging:ge,setSelectedCells:ze,shouldPaginate:$,sort:Me,sortDownIcon:Z,sortUpIcon:ee,tableBodyContainerRef:fe}),n(ae,{columnEditorText:m,editColumns:D,editColumnsInitOpen:S,headers:le.current,hiddenColumns:Ee,position:f,setHiddenColumns:Se})]})),n(te,{mainBodyRef:se,pinnedLeftRef:de,pinnedRightRef:ue,tableContentWidth:xe})]})),n(b,{currentPage:pe,hideFooter:B,nextIcon:W,onPageChange:we,prevIcon:U,rowsPerPage:V,shouldPaginate:$,totalRows:De.length})]}))};le.defaultProps={allowAnimations:!1,columnEditorPosition:R.Right,columnEditorText:"Columns",columnResizing:!1,defaultHeaders:[],editColumns:!1,editColumnsInitOpen:!1,columnReordering:!1,height:"",hideFooter:!1,nextIcon:n(y,{className:"st-next-prev-icon"}),onCellEdit:function(){},prevIcon:n(C,{className:"st-next-prev-icon"}),rows:[],rowsPerPage:10,selectableCells:!1,selectableColumns:!1,shouldPaginate:!1,sortDownIcon:n(H,{className:"st-sort-icon"}),sortUpIcon:n(x,{className:"st-sort-icon"}),theme:"light"};var ce=f(le);export{ce 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"),t=function(){return t=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},t.apply(this,arguments)};function r(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}function o(e,n,t,r){return new(t||(t=Promise))((function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,s)}l((r=r.apply(e,n||[])).next())}))}function a(e,n){var t,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(t=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=n.call(e,a)}catch(e){s=[6,e],r=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function i(e,n,t){if(t||2===arguments.length)for(var r,o=0,a=n.length;o<a;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var s,l=function(n){var r=n.currentPage,o=n.hideFooter,a=n.nextIcon,i=n.onPageChange,s=n.prevIcon,l=n.rowsPerPage,c=n.shouldPaginate,d=n.totalRows,u=Math.ceil(d/l),f=r>1,h=r<u,v=function(e){e>=1&&e<=u&&i(e)};return o||!c?null:e.jsxs("div",t({className:"st-footer"},{children:[e.jsx("button",t({className:"st-next-prev-btn ".concat(f?"":"disabled"),onClick:function(){return v(r-1)},disabled:!f},{children:s})),e.jsx("button",t({className:"st-next-prev-btn ".concat(h?"":"disabled"),onClick:function(){return v(r+1)},disabled:!h},{children:a})),Array.from({length:u},(function(n,o){return e.jsx("button",t({onClick:function(){return v(o+1)},className:"st-page-btn ".concat(r===o+1?"active":"")},{children:o+1}),o)}))]}))},c=function(n){var r=n.className;return e.jsx("svg",t({className:r,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 r=n.className;return e.jsx("svg",t({className:r,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"})}))},u=function(n){var r=n.className;return e.jsx("svg",t({className:r,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"})}))},f=function(n){var r=n.className;return e.jsx("svg",t({className:r,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"})}))},h=function(e){return e.position*(e.rowHeight+1)-1},v=function(e){return e.position*(e.rowHeight+1)},m=function(e){var n=e.accessor,t=e.rowIndex;return"cell-".concat(n,"-").concat(t)},g=function(e){var n=e.hiddenColumns,t=e.header,r=e.pinned;return n[t.accessor]?null:!r&&!t.pinned||t.pinned===r||null},p=function(n){var r=n.value,o=n.onBlur,a=n.onChange;return e.jsxs("select",t({value:r.toString(),onBlur:o,onChange:function(e){var n=e.target.value;a("true"===n)}},{children:[e.jsx("option",t({value:"true"},{children:"True"})),e.jsx("option",t({value:"false"},{children:"False"}))]}))},w=function(t){var r=t.defaultValue,o=t.onBlur,a=t.onChange,i=n.useRef(null);return e.jsx("input",{className:"editable-cell-input",ref:i,autoFocus:!0,type:"text",defaultValue:null!=r?r:"",onBlur:o,onChange:function(e){var n=e.target.value;a(n)}})},R=function(t){var r=t.defaultValue,o=t.onBlur,a=t.onChange,i=n.useRef(null);return e.jsx("input",{className:"editable-cell-input",ref:i,autoFocus:!0,defaultValue:r.toString(),onBlur:o,onChange:function(e){var n=e.target.value;/^\d*\.?\d*$/.test(n)&&a(n)}})},x=function(n){var t=n.onChange,r=n.setIsEditing,o=n.value,a=function(e){null==t||t(e)},i=function(){r(!1)};return e.jsx(e.Fragment,{children:"string"==typeof o||null==o?e.jsx(w,{defaultValue:o,onBlur:i,onChange:a}):"boolean"==typeof o?e.jsx(p,{onBlur:i,onChange:a,value:o}):"number"==typeof o?e.jsx(R,{defaultValue:o,onBlur:i,onChange:a}):null})},b=0,C=function(){return function(e){var n=e.callback,t=e.callbackProps,r=e.limit,o=Date.now();(0===b||o-b>=r)&&(b=o,n(t))}},y=Date.now(),j={screenX:0,screenY:0},H=function(e){var t,r,o=e.draggedHeaderRef,a=e.headersRef,s=e.hoveredHeaderRef,l=e.onTableHeaderDragEnd,c=(t=a.current,r=n.useRef(t),n.useEffect((function(){r.current=t}),[t]),r.current);return{handleDragStart:function(e){o.current=e,y=Date.now()},handleDragOver:function(e){var n,t=e.event,r=e.hoveredHeader;if(t.preventDefault(),a.current){var d=t.currentTarget.getAnimations().some((function(e){return"running"===e.playState})),u=t.screenX,f=t.screenY,h=Math.sqrt(Math.pow(u-j.screenX,2)+Math.pow(f-j.screenY,2));s.current=r;var v=i([],a.current,!0),m=v.findIndex((function(e){var n;return e.accessor===(null===(n=o.current)||void 0===n?void 0:n.accessor)})),g=v.findIndex((function(e){return e.accessor===r.accessor})),p=v.splice(m,1)[0];if(v.splice(g,0,p),!(d||r.accessor===(null===(n=o.current)||void 0===n?void 0:n.accessor)||null===o.current||h<10||void 0===m||void 0===g||JSON.stringify(v)===JSON.stringify(a.current))){var w=Date.now();JSON.stringify(v)===JSON.stringify(c)&&w-y<800&&h<50||(y=w,j={screenX:u,screenY:f},l(v))}}},handleDragEnd:function(){o.current=null,s.current=null}}},E=n.forwardRef((function(r,o){var a,i,s=r.borderClass,l=r.colIndex,c=r.draggedHeaderRef,u=r.header,h=r.headersRef,v=r.hoveredHeaderRef,g=r.isSelected,p=r.isTopLeftCell,w=r.onCellEdit,R=r.onExpandRowClick,b=r.onMouseDown,y=r.onMouseOver,j=r.onTableHeaderDragEnd,E=r.rowIndex,S=r.visibleRow,M=S.depth,I=S.row,D=n.useState(I.rowData[u.accessor]),k=D[0],N=D[1],L=n.useState(!1),T=L[0],B=L[1],O=H({draggedHeaderRef:c,headersRef:h,hoveredHeaderRef:v,onTableHeaderDragEnd:j}).handleDragOver,W=C(),A=Boolean(null===(i=null===(a=I.rowMeta)||void 0===a?void 0:a.children)||void 0===i?void 0:i.length),P=Boolean(null==u?void 0:u.isEditable),z=E%2==0,U="st-cell ".concat(M>0&&u.expandable?"st-cell-depth-".concat(M):""," ").concat(g?p?"st-cell-selected-first-cell ".concat(s):"st-cell-selected ".concat(s):""," ").concat(z?"st-cell-odd-row":"st-cell-even-row"," ").concat(P?"clickable":""," ").concat("right"===u.align?"right-aligned":"center"===u.align?"center-aligned":"left-aligned");return n.useEffect((function(){N(I.rowData[u.accessor])}),[u.accessor,I]),T?e.jsx("div",t({className:"st-cell-editing ".concat(z?"st-cell-odd-row":"st-cell-even-row"),id:m({accessor:u.accessor,rowIndex:E+1})},{children:e.jsx(x,{onChange:function(e){N(e),null==w||w({accessor:u.accessor,newValue:e,row:I})},setIsEditing:B,value:k})})):e.jsxs("div",t({className:U,id:m({accessor:u.accessor,rowIndex:E+1}),onDoubleClick:function(){return u.isEditable&&B(!0)},onMouseDown:function(){return b(E,l)},onMouseOver:function(){return y(E,l)},onDragOver:function(e){return W({callback:O,callbackProps:{event:e,hoveredHeader:u},limit:50})},ref:o},{children:[u.expandable&&A?I.rowMeta.isExpanded?e.jsx("div",t({className:"st-sort-icon-container",onClick:function(){return R(I.rowMeta.rowId)}},{children:e.jsx(f,{className:"st-sort-icon"})})):e.jsx("div",t({className:"st-sort-icon-container",onClick:function(){return R(I.rowMeta.rowId)}},{children:e.jsx(d,{className:"st-sort-icon"})})):null,e.jsx("span",t({className:"st-cell-content"},{children:u.cellRenderer?u.cellRenderer({accessor:u.accessor,colIndex:l,row:I}):k}))]}))})),S=function(n){var o=n.allowAnimations,a=n.children,i=r(n,["allowAnimations","children"]);return o?e.jsx(M,t({},i,{children:a})):e.jsx(e.Fragment,{children:a})},M=function(t){var r=t.allowHorizontalAnimate,o=void 0===r||r,a=t.children,i=t.draggedHeaderRef,s=t.headersRef,l=t.isBody,c=t.mainBodyRef,d=t.pauseAnimation,u=t.rowIndex,f=n.useRef(!1),h=n.useState({}),v=h[0],g=h[1],p=n.useRef({}),w=s.current;return n.useLayoutEffect((function(){if(w){var e=function(e){var n=e.currentHeaders,t=e.draggedHeaderRef,r=e.rowIndex,o={};return n.forEach((function(e){var n;if(e){var a=document.getElementById(m({accessor:e.accessor,rowIndex:r}));if(a){var i=a.getAnimations().some((function(e){return"running"===e.playState})),s=a.getBoundingClientRect();i&&(null===(n=null==t?void 0:t.current)||void 0===n?void 0:n.accessor)!==e.accessor?o[e.accessor]=!1:o[e.accessor]=s}}})),o}({currentHeaders:w,draggedHeaderRef:i,rowIndex:u});JSON.stringify(e)!==JSON.stringify(v)&&(p.current=v,g(e))}}),[v,w,i,l,u]),n.useLayoutEffect((function(){var e=c.current,n=function(){f.current=!0},t=function(){f.current=!1};return null==e||e.addEventListener("scroll",n),null==e||e.addEventListener("scrollend",t),function(){null==e||e.removeEventListener("scroll",n),null==e||e.removeEventListener("scrollend",t)}}),[i,c]),n.useEffect((function(){d||f.current||Object.keys(p.current).length&&w&&w.forEach((function(e){var n=document.getElementById(m({accessor:e.accessor,rowIndex:u}));if(n){var t=p.current[e.accessor],r=v[e.accessor];if(t&&r){var a=t.left-r.left,i=o?0:t.top-r.top,s=Math.abs(a),l=Math.abs(i);(s>10||l>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,v,w,l,d,p,u]),e.jsx(e.Fragment,{children:a})},I=function(o){var a=o.getBorderClass,i=o.handleMouseDown,s=o.handleMouseOver,l=o.headers,c=o.hiddenColumns,d=o.isSelected,u=o.isTopLeftCell,f=o.onExpandRowClick,h=o.pinned,v=o.rowIndex,p=o.visibleRow,w=r(o,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isTopLeftCell","onExpandRowClick","pinned","rowIndex","visibleRow"]);return e.jsx(S,t({allowAnimations:w.allowAnimations,allowHorizontalAnimate:w.shouldPaginate,draggedHeaderRef:w.draggedHeaderRef,headersRef:w.headersRef,isBody:!0,mainBodyRef:w.mainBodyRef,pauseAnimation:w.isWidthDragging,rowIndex:v+1},{children:l.map((function(e,r){return g({hiddenColumns:c,header:e,pinned:h})?n.createElement(E,t({},w,{borderClass:a(v,r),colIndex:r,header:e,isSelected:d(v,r),isTopLeftCell:u(v,r),key:m({accessor:e.accessor,rowIndex:v+1}),onExpandRowClick:f,onMouseDown:function(){return i({rowIndex:v,colIndex:r})},onMouseOver:function(){return s(v,r)},rowIndex:v,visibleRow:p})):null}))}))},D=function(n){var r=n.getNextRowIndex,o=n.gridTemplateColumns,a=n.index,i=n.pinned,s=n.props,l=n.rowHeight,c=n.visibleRow,d=c.position,u=r();return e.jsx("div",t({className:"st-table-row",style:{gridTemplateColumns:o,top:v({position:d,rowHeight:l}),height:"".concat(l,"px")}},{children:e.jsx(I,t({pinned:i,rowIndex:u,visibleRow:c},s),a)}))},k=function(n){var r=n.lastGroupRow,o=n.position,a=n.rowHeight,i=n.templateColumns;return e.jsx("div",t({className:"st-row-separator ".concat(r?"st-last-group-row":""),style:{display:"grid",gridTemplateColumns:i,position:"absolute",top:h({position:o,rowHeight:a})}},{children:e.jsx("div",{style:{gridColumn:"1 / -1"}})}))},N=function(o){o.headerContainerRef;var a=o.onExpandRowClick,i=o.pinned,s=o.rowHeight,l=o.sectionRef,c=o.templateColumns,d=o.totalHeight,u=o.visibleRows,f=o.width,h=r(o,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),v=i?"st-table-body-pinned-".concat(i):"st-table-body-main",m=n.useRef(0);n.useEffect((function(){m.current=0}));var g=function(){return m.current++};return e.jsx("div",t({className:v,ref:l,style:{position:"relative",height:"".concat(d,"px"),width:f}},{children:u.map((function(n,r){var o,l,d=Boolean(null===(l=null===(o=n.row.rowMeta)||void 0===o?void 0:o.children)||void 0===l?void 0:l.length);return e.jsxs(e.Fragment,{children:[e.jsx(D,{getNextRowIndex:g,gridTemplateColumns:c,index:r,pinned:i,props:t(t({},h),{onExpandRowClick:a}),rowHeight:s,visibleRow:n},r),0!==r&&e.jsx(k,{lastGroupRow:d,position:n.position,rowHeight:s,templateColumns:c})]})}))}))},L=function(r){var s,l,c,d,u,f=r.centerHeaderRef,h=r.currentRows,v=r.headerContainerRef,m=r.mainBodyRef,g=r.mainTemplateColumns,p=r.pinnedLeftColumns,w=r.pinnedLeftHeaderRef,R=r.pinnedLeftRef,x=r.pinnedLeftTemplateColumns,b=r.pinnedRightColumns,C=r.pinnedRightHeaderRef,y=r.pinnedRightRef,j=r.pinnedRightTemplateColumns,H=r.scrollbarWidth,E=r.tableBodyContainerRef;!function(e){var t=e.headerContainerRef,r=e.mainSectionRef,o=e.scrollbarWidth,a=n.useState(!1),i=a[0],s=a[1];n.useEffect((function(){var e=null==t?void 0:t.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")}}),[t,i,o]),n.useEffect((function(){var e=null==t?void 0:t.current,n=null==r?void 0:r.current;if(n&&e){var o=function(){if(n){var e=n.scrollHeight>n.clientHeight;s(e)}};o();var a=new ResizeObserver((function(){o()}));return a.observe(n),function(){n&&a.unobserve(n)}}}),[t,r])}({headerContainerRef:v,mainSectionRef:E,scrollbarWidth:H});var S=n.useRef(null),M=n.useRef(null),I=n.useState(h),D=I[0],k=I[1],L=n.useState(1),T=L[0],B=L[1],O=n.useState(!1),W=O[0],A=O[1],P=n.useState(!0),z=P[0],U=P[1],F=n.useState(0),V=F[0],q=F[1],J=function(e){var n=0,t=function(e){e.forEach((function(e){n+=1,e.rowMeta.isExpanded&&e.rowMeta.children&&t(e.rowMeta.children)}))};return t(e),n}(D),X=41*J-1,G=function(e){var n=function(r){return r.rowMeta.rowId===e&&r.rowMeta.children?t(t({},r),{rowMeta:t(t({},r.rowMeta),{isExpanded:!r.rowMeta.isExpanded})}):r.rowMeta.children?t(t({},r),{rowMeta:t(t({},r.rowMeta),{children:r.rowMeta.children.map(n)})}):r};k((function(e){return e.map(n)}))},Y=n.useMemo((function(){return function(e){var n=e.bufferRowCount,t=e.containerHeight,r=e.rowHeight,o=e.rows,a=e.scrollTop,i=[],s=0,l=Math.max(0,a-r*n),c=a+t+r*n,d=function(e,n){for(var t,o=0,a=e;o<a.length;o++){var u=a[o],f=s*r;if(f>=c)break;f+r>l&&i.push({row:u,depth:n,position:s,isLastGroupRow:Boolean(null===(t=u.rowMeta.children)||void 0===t?void 0:t.length)&&n>1}),s+=1,u.rowMeta.isExpanded&&u.rowMeta.children&&d(u.rowMeta.children,n+1)}};return d(o,0),i}({bufferRowCount:5,containerHeight:600,rowHeight:40,rows:D,scrollTop:V})}),[D,V]),K=n.useCallback((function(){return o(void 0,void 0,void 0,(function(){var e;return a(this,(function(n){return W||!z||(A(!0),e=h.slice(20*T,20*(T+1)),k((function(n){return i(i([],n,!0),e,!0)})),B((function(e){return e+1})),A(!1),e.length<20/3&&U(!1)),[2]}))}))}),[h,z,W,T]),_=n.useCallback((function(e){e[0].isIntersecting&&z&&!W&&K()}),[z,W,K]);n.useEffect((function(){return S.current=new IntersectionObserver(_,{root:null,rootMargin:"100px",threshold:0}),E.current&&S.current.observe(E.current),function(){S.current&&S.current.disconnect()}}),[_,D,E]);var $=(null===(s=w.current)||void 0===s?void 0:s.clientWidth)?(null===(l=w.current)||void 0===l?void 0:l.clientWidth)+1:0,Q=null===(c=f.current)||void 0===c?void 0:c.clientWidth,Z=(null===(d=C.current)||void 0===d?void 0:d.clientWidth)?(null===(u=C.current)||void 0===u?void 0:u.clientWidth)+1:0;return e.jsxs("div",t({className:"st-table-body-container",ref:E,onScroll:function(e){var n=e.currentTarget.scrollTop;M.current&&cancelAnimationFrame(M.current),M.current=requestAnimationFrame((function(){q(n)}))}},{children:[p.length>0&&e.jsx(N,t({},r,{onExpandRowClick:G,pinned:"left",rowHeight:40,sectionRef:R,templateColumns:x,totalHeight:X,visibleRows:Y,width:$})),e.jsx(N,t({},r,{onExpandRowClick:G,rowHeight:40,sectionRef:m,templateColumns:g,totalHeight:X,visibleRows:Y,width:Q})),b.length>0&&e.jsx(N,t({},r,{onExpandRowClick:G,pinned:"right",rowHeight:40,sectionRef:y,templateColumns:j,totalHeight:X,visibleRows:Y,width:Z}))]}))},T={string:function(e,n,t){if(e===n)return 0;var r=e.localeCompare(n);return"ascending"===t?r:-r},number:function(e,n,t){if(e===n)return 0;var r=e-n;return"ascending"===t?r:-r},boolean:function(e,n,t){if(e===n)return 0;var r=e===n?0:e?-1:1;return"ascending"===t?r:-r},date:function(e,n,t){var r=new Date(e),o=new Date(n);if(r.getTime()===o.getTime())return 0;var a=r.getTime()-o.getTime();return"ascending"===t?a:-a},enum:function(e,n,t){return T.string(e,n,t)},default:function(e,n,t){return e===n?0:null==e?"ascending"===t?-1:1:null==n?"ascending"===t?1:-1:"string"==typeof e&&"string"==typeof n?T.string(e,n,t):"number"==typeof e&&"number"==typeof n?T.number(e,n,t):"boolean"==typeof e&&"boolean"==typeof n?T.boolean(e,n,t):T.string(String(e),String(n),t)}},B=function(e,n,t,r){switch(void 0===t&&(t="string"),t){case"string":return T.string(String(e||""),String(n||""),r);case"number":return T.number(Number(e||0),Number(n||0),r);case"boolean":return T.boolean(Boolean(e),Boolean(n),r);case"date":return T.date(String(e||""),String(n||""),r);case"enum":return T.enum(String(e||""),String(n||""),r);default:return T.default(e,n,r)}},O=function(e,n,r){var o=r.find((function(e){return e.accessor===n.key.accessor})),a=(null==o?void 0:o.type)||"string",s=n.direction;return i([],e,!0).sort((function(e,t){var r,o,i=null===(r=null==e?void 0:e.rowData)||void 0===r?void 0:r[n.key.accessor],l=null===(o=null==t?void 0:t.rowData)||void 0===o?void 0:o[n.key.accessor];return B(i,l,a,s)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?t(t({},e),{rowMeta:t(t({},e.rowMeta),{children:O(e.rowMeta.children,n,r)})}):e}))},W=function(e,n,r){var o=function(e,n,r){var o=r.find((function(e){return e.accessor===n.key.accessor})),a=(null==o?void 0:o.type)||"string",s=n.direction,l=[],c=new Map;return e.forEach((function(n){e.some((function(e){var t;return null===(t=e.rowMeta.children)||void 0===t?void 0:t.some((function(e){return e.rowMeta.rowId===n.rowMeta.rowId}))}))||l.push(n),n.rowMeta.children&&n.rowMeta.children.length>0&&c.set(n.rowMeta.rowId,n.rowMeta.children)})),i([],l,!0).sort((function(e,t){var r,o,i=null===(r=null==e?void 0:e.rowData)||void 0===r?void 0:r[n.key.accessor],l=null===(o=null==t?void 0:t.rowData)||void 0===o?void 0:o[n.key.accessor];return B(i,l,a,s)})).map((function(e){var o=t({},e);if(c.has(e.rowMeta.rowId)){var a=c.get(e.rowMeta.rowId)||[],i=O(a,n,r);o.rowMeta=t(t({},o.rowMeta),{children:i})}return o}))}(n,r,e);return{sortedData:o,newSortConfig:r}},A=function(e){var n=e.event,t=e.forceUpdate,r=e.header,o=e.headersRef,a=e.index;e.reverse;var i=e.setIsWidthDragging,s=e.startWidth;i(!0),n.preventDefault();var l=n.clientX;if(r){var c=function(e){var n=Math.max(s+(e.clientX-l),40);r&&o.current&&(o.current[a].width=n,t())},d=function(){document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d),i(!1)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",d)}},P=n.forwardRef((function(r,o){var a,i=r.columnResizing,s=r.currentRows,l=r.columnReordering,c=r.draggedHeaderRef,d=r.forceUpdate,u=r.headersRef,f=r.hoveredHeaderRef,h=r.index,v=r.onSort,g=r.onTableHeaderDragEnd,p=r.reverse,w=r.selectableColumns,R=r.setIsWidthDragging,x=r.setSelectedCells,b=r.sort,y=r.sortDownIcon,j=r.sortUpIcon,E=n.useState(!1),S=E[0],M=E[1],I=null===(a=u.current)||void 0===a?void 0:a[h],D=Boolean(null==I?void 0:I.isSortable),k="st-header-cell ".concat(I===f.current?"st-hovered":""," ").concat(S?"st-dragging":""," ").concat(D?"clickable":""," ").concat(l&&!D?"columnReordering":""," ").concat("right"===(null==I?void 0:I.align)?"right-aligned":"center"===(null==I?void 0:I.align)?"center-aligned":""),N=H({draggedHeaderRef:c,headersRef:u,hoveredHeaderRef:f,onTableHeaderDragEnd:g}),L=N.handleDragStart,T=N.handleDragEnd,B=H({draggedHeaderRef:c,headersRef:u,hoveredHeaderRef:f,onTableHeaderDragEnd:g}).handleDragOver,O=C(),W=function(e){var n=e.event,t=e.header;if(w){var r=s.length,o=Array.from({length:r},(function(e,n){return"".concat(n,"-").concat(h)})),a=function(e,n){var t=new Set,o=Math.min(e,n),a=Math.max(e,n);return Array.from({length:r}).forEach((function(e,n){Array.from({length:a-o+1}).forEach((function(e,r){t.add("".concat(n,"-").concat(o+r))}))})),t};n.shiftKey?x((function(e){var n,t=Number(null===(n=Array.from(e)[0])||void 0===n?void 0:n.split("-")[1]),r=Number(o[0].split("-")[1]);return t===r?new Set(o):t>r?a(r,t):a(t,r)})):x(new Set(o))}else t.isSortable&&v(h,t.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)}}),[]),!I)return null;var P=i&&e.jsx("div",{className:"st-header-resize-handle",onMouseDown:function(e){var n;O({callback:A,callbackProps:{event:e,forceUpdate:d,header:I,headersRef:u,index:h,setIsWidthDragging:R,startWidth:"object"==typeof o&&null!==o&&"current"in o?null===(n=o.current)||void 0===n?void 0:n.offsetWidth:void 0},limit:10})}});return e.jsxs("div",t({className:k,id:m({accessor:I.accessor,rowIndex:0}),onDragOver:function(e){O({callback:B,callbackProps:{event:e,hoveredHeader:I},limit:50})},ref:o,style:{width:I.width}},{children:[p&&P,e.jsx("div",t({className:"st-header-label",draggable:l,onClick:function(e){return W({event:e,header:I})},onDragEnd:function(e){e.preventDefault(),M(!1),T()},onDragStart:function(e){l&&I&&function(e){M(!0),L(e)}(I)}},{children:null==I?void 0:I.label})),b&&b.key.accessor===I.accessor&&e.jsxs("div",t({className:"st-sort-icon-container",onClick:function(e){return W({event:e,header:I})}},{children:["ascending"===b.direction&&j&&j,"descending"===b.direction&&y&&y]})),!p&&P]}))})),z=function(e,t){n.useEffect((function(){if(e.current){var n=e.current,r=function(){var e,r=null==n?void 0:n.scrollLeft;void 0!==r&&(null===(e=t.current)||void 0===e||e.scrollTo(r,0))};return n.addEventListener("scroll",r),function(){null==n||n.removeEventListener("scroll",r)}}}),[e,t])},U=function(r){var o,a,i,s=r.allowAnimations,l=r.centerHeaderRef,c=r.columnResizing,d=r.currentRows,u=r.columnReordering,f=r.draggedHeaderRef,h=r.forceUpdate,v=r.headerContainerRef,m=r.headersRef,p=r.hiddenColumns,w=r.hoveredHeaderRef,R=r.isWidthDragging,x=r.mainBodyRef,b=r.mainTemplateColumns,C=r.onSort,y=r.onTableHeaderDragEnd,j=r.pinnedLeftColumns,H=r.pinnedLeftHeaderRef,E=r.pinnedLeftTemplateColumns,M=r.pinnedRightColumns,I=r.pinnedRightHeaderRef,D=r.pinnedRightTemplateColumns,k=r.selectableColumns,N=r.setIsWidthDragging,L=r.setSelectedCells,T=r.sort,B=r.sortDownIcon,O=r.sortUpIcon;z(x,l);return e.jsxs("div",t({className:"st-header-container",ref:v},{children:[j.length>0&&e.jsx("div",t({className:"st-header-pinned-left",ref:H,style:{gridTemplateColumns:E}},{children:e.jsx(S,t({allowAnimations:s,draggedHeaderRef:f,headersRef:m,mainBodyRef:x,pauseAnimation:R,rowIndex:0},{children:null===(o=m.current)||void 0===o?void 0:o.map((function(t,r){return g({hiddenColumns:p,header:t,pinned:"left"})?e.jsx(P,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:C,onTableHeaderDragEnd:y,ref:n.createRef(),selectableColumns:k,setIsWidthDragging:N,setSelectedCells:L,sort:T,sortDownIcon:B,sortUpIcon:O},t.accessor):null}))}))})),e.jsx("div",t({className:"st-header-main",onScroll:function(e){var n,t,r=null===(n=l.current)||void 0===n?void 0:n.scrollLeft;void 0!==r&&(null===(t=x.current)||void 0===t||t.scrollTo(r,0))},ref:l,style:{gridTemplateColumns:b}},{children:e.jsx(S,t({allowAnimations:s,draggedHeaderRef:f,headersRef:m,mainBodyRef:x,pauseAnimation:R,rowIndex:0},{children:null===(a=m.current)||void 0===a?void 0:a.map((function(t,r){return g({hiddenColumns:p,header:t})?e.jsx(P,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:C,onTableHeaderDragEnd:y,ref:n.createRef(),selectableColumns:k,setIsWidthDragging:N,setSelectedCells:L,sort:T,sortDownIcon:B,sortUpIcon:O},t.accessor):null}))}))})),M.length>0&&e.jsx("div",t({className:"st-header-pinned-right",ref:I,style:{gridTemplateColumns:D}},{children:e.jsx(S,t({allowAnimations:s,draggedHeaderRef:f,headersRef:m,mainBodyRef:x,pauseAnimation:R,rowIndex:0},{children:null===(i=m.current)||void 0===i?void 0:i.map((function(t,r){return g({hiddenColumns:p,header:t,pinned:"right"})?e.jsx(P,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:C,onTableHeaderDragEnd:y,reverse:!0,ref:n.createRef(),selectableColumns:k,setIsWidthDragging:N,setSelectedCells:L,sort:T,sortDownIcon:B,sortUpIcon:O},t.accessor):null}))}))}))]}))},F=function(e){var n=e.minWidth,t=e.width;return"number"==typeof t&&(t="".concat(t,"px")),n&&"number"==typeof n&&(n="".concat(n,"px")),void 0!==n?"minmax(".concat(n,", ").concat(t,")"):t},V=function(r){var o=r.allowAnimations,a=r.columnResizing,i=r.currentRows,s=r.columnReordering,l=r.draggedHeaderRef,c=r.editColumns,d=r.forceUpdate,u=r.getBorderClass,f=r.handleMouseDown,h=r.handleMouseOver,v=r.headersRef,m=r.hiddenColumns,g=r.hoveredHeaderRef,p=r.isSelected,w=r.isTopLeftCell,R=r.isWidthDragging,x=r.mainBodyRef,b=r.onCellEdit,C=r.onSort,y=r.onTableHeaderDragEnd,j=r.pinnedLeftRef,H=r.pinnedRightRef,E=r.scrollbarWidth,S=r.selectableColumns,M=r.setIsWidthDragging,I=r.setSelectedCells,D=r.shouldPaginate,k=r.sort,N=r.sortDownIcon,T=r.sortUpIcon,B=r.tableBodyContainerRef,O=n.useRef(null),W=n.useRef(null),A=n.useRef(null),P=n.useRef(null),z=v.current.filter((function(e){return!e.hide&&!e.pinned})),V=v.current.filter((function(e){return"left"===e.pinned&&!0!==e.hide})),q=v.current.filter((function(e){return"right"===e.pinned&&!0!==e.hide})),J=n.useMemo((function(){return"".concat(V.map((function(e){return F(e)})).join(" "))}),[V]),X=n.useMemo((function(){return"".concat(z.filter((function(e){return!0!==m[e.accessor]})).map((function(e){return F(e)})).join(" "))}),[z,m]),G=n.useMemo((function(){return"".concat(q.map((function(e){return F(e)})).join(" "))}),[q]),Y={allowAnimations:o,centerHeaderRef:A,columnResizing:a,currentRows:i,columnReordering:s,draggedHeaderRef:l,forceUpdate:d,headerContainerRef:O,headersRef:v,hiddenColumns:m,hoveredHeaderRef:g,isWidthDragging:R,mainBodyRef:x,mainTemplateColumns:X,onSort:C,onTableHeaderDragEnd:y,pinnedLeftColumns:V,pinnedLeftHeaderRef:W,pinnedLeftTemplateColumns:J,pinnedRightColumns:q,pinnedRightHeaderRef:P,pinnedRightTemplateColumns:G,selectableColumns:S,setIsWidthDragging:M,setSelectedCells:I,sort:k,sortDownIcon:N,sortUpIcon:T,tableBodyContainerRef:B},K={allowAnimations:o,centerHeaderRef:A,currentRows:i,draggedHeaderRef:l,getBorderClass:u,handleMouseDown:f,handleMouseOver:h,headerContainerRef:O,headers:v.current,headersRef:v,hiddenColumns:m,hoveredHeaderRef:g,isSelected:p,isTopLeftCell:w,isWidthDragging:R,mainBodyRef:x,mainTemplateColumns:X,onCellEdit:b,onTableHeaderDragEnd:y,pinnedLeftColumns:V,pinnedLeftHeaderRef:W,pinnedLeftRef:j,pinnedLeftTemplateColumns:J,pinnedRightColumns:q,pinnedRightHeaderRef:P,pinnedRightRef:H,pinnedRightTemplateColumns:G,scrollbarWidth:E,shouldPaginate:D,tableBodyContainerRef:B};return e.jsxs("div",t({className:"st-table-content",style:{width:c?"calc(100% - 27.5px)":"100%"}},{children:[e.jsx(U,t({},Y)),e.jsx(L,t({},K))]}))},q=function(e){var t=e.callback,r=e.ref,o=e.widthAttribute;n.useEffect((function(){var e=r.current;if(e){var n=function(){t(e[o]||0)};n();var a=new ResizeObserver((function(){n()}));return a.observe(e),function(){return a.disconnect()}}}),[t,r,o])},J=function(r){var o=r.mainBodyRef,a=r.pinnedLeftRef,i=r.pinnedRightRef,s=r.tableContentWidth,l=n.useState(0),c=l[0],d=l[1],u=n.useState(0),f=u[0],h=u[1],v=n.useState(0),m=v[0],g=v[1],p=n.useRef(null);return q({widthAttribute:"offsetWidth",callback:d,ref:a}),q({widthAttribute:"scrollWidth",callback:g,ref:o}),q({widthAttribute:"offsetWidth",callback:h,ref:i}),z(o,p),!o.current||o.current.scrollWidth<=o.current.clientWidth?null:e.jsxs("div",t({className:"st-horizontal-scrollbar-container",style:{width:s}},{children:[c>0&&e.jsx("div",{className:"st-horizontal-scrollbar-left",style:{flexShrink:0,width:c}}),m>0&&e.jsx("div",t({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:p},{children:e.jsx("div",{style:{width:m}})})),f>0&&e.jsx("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:f}})]}))},X=function(r){var o=r.checked,a=void 0!==o&&o,i=r.children,s=r.onChange,l=n.useState(a),c=l[0],d=l[1];return e.jsxs("label",t({className:"st-checkbox-label"},{children:[e.jsx("input",{checked:c,className:"st-checkbox-input",onChange:function(){var e=!c;d(e),s&&s(e)},type:"checkbox"}),e.jsx("span",t({className:"st-checkbox-custom ".concat(c?"st-checked":"")},{children:c&&e.jsx("span",{className:"st-checkbox-checkmark"})})),i]}))},G=function(n){var r=n.headers,o=n.open,a=n.position;n.setOpen;var i=n.setHiddenColumns,s=n.hiddenColumns,l="left"===a?"left":"";return e.jsx("div",t({className:"st-column-editor-popout ".concat(o?"open":""," ").concat(l),onClick:function(e){return e.stopPropagation()}},{children:e.jsx("div",t({className:"st-column-editor-popout-content"},{children:r.map((function(n,r){return e.jsx(X,t({checked:s[n.accessor],onChange:function(e){var r;return i(t(t({},s),((r={})[n.accessor]=e,r)))}},{children:n.label}),r)}))}))}))},Y=function(r){var o=r.columnEditorText,a=r.editColumns,i=r.editColumnsInitOpen,s=r.headers,l=r.position,c=void 0===l?"right":l,d=r.setHiddenColumns,u=r.hiddenColumns,f=n.useState(i),h=f[0],v=f[1];return a?e.jsxs("div",t({className:"st-column-editor ".concat(h?"open":""," ").concat(c),onClick:function(){return function(e){v(e)}(!h)}},{children:[e.jsx("div",t({className:"st-column-editor-text"},{children:o})),e.jsx(G,{headers:s,open:h,position:c,setOpen:v,setHiddenColumns:d,hiddenColumns:u})]})):null};!function(e){e.Left="left",e.Right="right"}(s||(s={}));var K=function(r){var o=r.allowAnimations,a=void 0!==o&&o,i=r.columnEditorPosition,h=void 0===i?s.Right:i,v=r.columnEditorText,m=void 0===v?"Columns":v,g=r.columnResizing,p=void 0!==g&&g,w=r.defaultHeaders,R=r.editColumns,x=void 0!==R&&R,b=r.editColumnsInitOpen,C=void 0!==b&&b,y=r.columnReordering,j=void 0!==y&&y,H=r.height,E=r.hideFooter,S=void 0!==E&&E,M=r.nextIcon,I=void 0===M?e.jsx(d,{className:"st-next-prev-icon"}):M,D=r.onCellEdit,k=r.onColumnOrderChange,N=r.prevIcon,L=void 0===N?e.jsx(c,{className:"st-next-prev-icon"}):N,T=r.rows,B=r.rowsPerPage,O=void 0===B?10:B,A=r.selectableCells,P=void 0!==A&&A,z=r.selectableColumns,U=void 0!==z&&z,F=r.shouldPaginate,q=void 0!==F&&F,X=r.sortDownIcon,G=void 0===X?e.jsx(f,{className:"st-sort-icon"}):X,K=r.sortUpIcon,_=void 0===K?e.jsx(u,{className:"st-sort-icon"}):K,$=r.theme,Q=void 0===$?"light":$,Z=n.useRef(null),ee=n.useRef(w),ne=n.useRef(null),te=n.useRef(null),re=n.useRef(null),oe=n.useRef(null),ae=n.useRef(null),ie=n.useState(!1),se=ie[0],le=ie[1],ce=n.useState(1),de=ce[0],ue=ce[1],fe=n.useState(0),he=fe[0],ve=fe[1],me=n.useState(0),ge=me[0],pe=me[1],we=function(e){var t=e.headers,r=e.tableRows,o=n.useState(null),a=o[0],i=o[1],s=n.useMemo((function(){var e={};return t.forEach((function(n){!0===n.hide&&(e[n.accessor]=!0)})),e}),[t]),l=n.useState(s),c=l[0],d=l[1],u=n.useMemo((function(){return a?W(t,r,a).sortedData:r}),[r,a,t]);return{sort:a,setSort:i,updateSort:function(e,n){var r=t.find((function(e){return e.accessor===n}));r&&i((function(e){return e&&e.key.accessor===n?"ascending"===e.direction?{key:r,direction:"descending"}:null:{key:r,direction:"ascending"}}))},sortedRows:u,hiddenColumns:c,setHiddenColumns:d}}({headers:ee.current,tableRows:T}),Re=we.sort,xe=we.sortedRows,be=we.hiddenColumns,Ce=we.setHiddenColumns,ye=we.updateSort,je=n.useReducer((function(e){return e+1}),0)[1],He=function(e){var t=e.selectableCells,r=e.headers,o=e.rows,a=n.useState(new Set),i=a[0],s=a[1],l=n.useRef(!1),c=n.useRef(null),d=n.useCallback((function(){var e=Array.from(i).reduce((function(e,n){var t=n.split("-").map(Number),a=t[0],i=t[1];return e[a]||(e[a]=[]),e[a][i]=o[a][r[i].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");i.size>0&&navigator.clipboard.writeText(n)}),[i,o,r]);n.useEffect((function(){var e=function(e){(e.ctrlKey||e.metaKey)&&"c"===e.key&&d()};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[d]);var u=n.useCallback((function(e,n){return i.has("".concat(e,"-").concat(n))}),[i]),f=n.useCallback((function(e,n){var t=[];return u(e-1,n)||t.push("st-selected-top-border"),u(e+1,n)||t.push("st-selected-bottom-border"),u(e,n-1)||t.push("st-selected-left-border"),u(e,n+1)||t.push("st-selected-right-border"),t.join(" ")}),[u]),h=n.useMemo((function(){var e=Math.min.apply(Math,Array.from(i).map((function(e){return parseInt(e.split("-")[0])}))),n=Math.min.apply(Math,Array.from(i).map((function(e){return parseInt(e.split("-")[1])})));return function(t,r){return t===e&&r===n}}),[i]);return{selectedCells:i,handleMouseDown:function(e){var n=e.colIndex,r=e.rowIndex;t&&(l.current=!0,c.current={row:r,col:n},s(new Set(["".concat(r,"-").concat(n)])))},handleMouseOver:function(e,n){if(t&&l.current&&c.current){for(var r=new Set,o=Math.min(c.current.row,e),a=Math.max(c.current.row,e),i=Math.min(c.current.col,n),d=Math.max(c.current.col,n),u=o;u<=a;u++)for(var f=i;f<=d;f++)r.add("".concat(u,"-").concat(f));s(r)}},handleMouseUp:function(){l.current=!1,c.current=null},isSelected:u,getBorderClass:f,isTopLeftCell:h,setSelectedCells:s}}({selectableCells:P,headers:ee.current,rows:xe}),Ee=He.handleMouseDown,Se=He.handleMouseOver,Me=He.handleMouseUp,Ie=He.isSelected,De=He.getBorderClass,ke=He.isTopLeftCell,Ne=He.setSelectedCells,Le=n.useMemo((function(){return q?xe.slice((de-1)*O,de*O):xe}),[de,O,q,xe]),Te=n.useCallback((function(e,n){ye(e,n)}),[ye]),Be=n.useCallback((function(e){ee.current=e,je(),null==k||k(e)}),[k]);return n.useEffect((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||U&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||Ne(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[U,Ne]),n.useLayoutEffect((function(){if(ae.current){var e=ae.current.offsetWidth-ae.current.clientWidth,n=ae.current.clientWidth;ve(e),pe(n)}}),[]),n.useLayoutEffect((function(){var e=function(){if(je(),ae.current){var e=ae.current.offsetWidth-ae.current.clientWidth,n=ae.current.clientWidth;ve(e),pe(n)}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),e.jsxs("div",t({className:"simple-table-root st-wrapper theme-".concat(Q),style:H?{height:H}:{}},{children:[e.jsxs("div",t({className:"st-table-wrapper-container"},{children:[e.jsxs("div",t({className:"st-table-wrapper",onMouseUp:Me,onMouseLeave:Me},{children:[e.jsx(V,{allowAnimations:a,columnResizing:p,currentRows:Le,draggedHeaderRef:Z,editColumns:x,columnReordering:j,forceUpdate:je,getBorderClass:De,handleMouseDown:Ee,handleMouseOver:Se,headers:ee.current,headersRef:ee,hiddenColumns:be,hoveredHeaderRef:ne,isSelected:Ie,isTopLeftCell:ke,isWidthDragging:se,mainBodyRef:te,onCellEdit:D,onSort:Te,onTableHeaderDragEnd:Be,pinnedLeftRef:re,pinnedRightRef:oe,scrollbarWidth:he,selectableColumns:U,setIsWidthDragging:le,setSelectedCells:Ne,shouldPaginate:q,sort:Re,sortDownIcon:G,sortUpIcon:_,tableBodyContainerRef:ae}),e.jsx(Y,{columnEditorText:m,editColumns:x,editColumnsInitOpen:C,headers:ee.current,hiddenColumns:be,position:h,setHiddenColumns:Ce})]})),e.jsx(J,{mainBodyRef:te,pinnedLeftRef:re,pinnedRightRef:oe,tableContentWidth:ge})]})),e.jsx(l,{currentPage:de,hideFooter:S,nextIcon:I,onPageChange:ue,prevIcon:L,rowsPerPage:O,shouldPaginate:q,totalRows:xe.length})]}))};K.defaultProps={allowAnimations:!1,columnEditorPosition:s.Right,columnEditorText:"Columns",columnResizing:!1,defaultHeaders:[],editColumns:!1,editColumnsInitOpen:!1,columnReordering:!1,height:"",hideFooter:!1,nextIcon:e.jsx(d,{className:"st-next-prev-icon"}),onCellEdit:function(){},prevIcon:e.jsx(c,{className:"st-next-prev-icon"}),rows:[],rowsPerPage:10,selectableCells:!1,selectableColumns:!1,shouldPaginate:!1,sortDownIcon:e.jsx(f,{className:"st-sort-icon"}),sortUpIcon:e.jsx(u,{className:"st-sort-icon"}),theme:"light"};var _=n.memo(K);exports.SimpleTable=_;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),t=function(){return t=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},t.apply(this,arguments)};function r(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}function o(e,n,t,r){return new(t||(t=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,s)}l((r=r.apply(e,n||[])).next())}))}function i(e,n){var t,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(t=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=n.call(e,i)}catch(e){s=[6,e],r=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function a(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var s,l=function(n){var r=n.currentPage,o=n.hideFooter,i=n.nextIcon,a=n.onPageChange,s=n.prevIcon,l=n.rowsPerPage,c=n.shouldPaginate,d=n.totalRows,u=Math.ceil(d/l),f=r>1,h=r<u,v=function(e){e>=1&&e<=u&&a(e)};return o||!c?null:e.jsxs("div",t({className:"st-footer"},{children:[e.jsx("button",t({className:"st-next-prev-btn ".concat(f?"":"disabled"),onClick:function(){return v(r-1)},disabled:!f},{children:s})),e.jsx("button",t({className:"st-next-prev-btn ".concat(h?"":"disabled"),onClick:function(){return v(r+1)},disabled:!h},{children:i})),Array.from({length:u},(function(n,o){return e.jsx("button",t({onClick:function(){return v(o+1)},className:"st-page-btn ".concat(r===o+1?"active":"")},{children:o+1}),o)}))]}))},c=function(n){var r=n.className;return e.jsx("svg",t({className:r,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 r=n.className;return e.jsx("svg",t({className:r,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"})}))},u=function(n){var r=n.className;return e.jsx("svg",t({className:r,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"})}))},f=function(n){var r=n.className;return e.jsx("svg",t({className:r,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"})}))},h=function(e){return e.position*(e.rowHeight+1)-1},v=function(e){return e.position*(e.rowHeight+1)},m=function(e){var n=e.accessor,t=e.rowIndex;return"cell-".concat(n,"-").concat(t)},g=function(e){var n=e.hiddenColumns,t=e.header,r=e.pinned;return n[t.accessor]?null:!r&&!t.pinned||t.pinned===r||null},p=function(n){var r=n.value,o=n.onBlur,i=n.onChange;return e.jsxs("select",t({value:r.toString(),onBlur:o,onChange:function(e){var n=e.target.value;i("true"===n)}},{children:[e.jsx("option",t({value:"true"},{children:"True"})),e.jsx("option",t({value:"false"},{children:"False"}))]}))},w=function(t){var r=t.defaultValue,o=t.onBlur,i=t.onChange,a=n.useRef(null);return e.jsx("input",{className:"editable-cell-input",ref:a,autoFocus:!0,type:"text",defaultValue:null!=r?r:"",onBlur:o,onChange:function(e){var n=e.target.value;i(n)}})},R=function(t){var r=t.defaultValue,o=t.onBlur,i=t.onChange,a=n.useRef(null);return e.jsx("input",{className:"editable-cell-input",ref:a,autoFocus:!0,defaultValue:r.toString(),onBlur:o,onChange:function(e){var n=e.target.value;/^\d*\.?\d*$/.test(n)&&i(n)}})},x=function(n){var t=n.onChange,r=n.setIsEditing,o=n.value,i=function(e){null==t||t(e)},a=function(){r(!1)};return e.jsx(e.Fragment,{children:"string"==typeof o||null==o?e.jsx(w,{defaultValue:o,onBlur:a,onChange:i}):"boolean"==typeof o?e.jsx(p,{onBlur:a,onChange:i,value:o}):"number"==typeof o?e.jsx(R,{defaultValue:o,onBlur:a,onChange:i}):null})},b=0,C=function(){return function(e){var n=e.callback,t=e.callbackProps,r=e.limit,o=Date.now();(0===b||o-b>=r)&&(b=o,n(t))}},y=Date.now(),j={screenX:0,screenY:0},H=function(e){var t,r,o=e.draggedHeaderRef,i=e.headersRef,s=e.hoveredHeaderRef,l=e.onTableHeaderDragEnd,c=(t=i.current,r=n.useRef(t),n.useEffect((function(){r.current=t}),[t]),r.current);return{handleDragStart:function(e){o.current=e,y=Date.now()},handleDragOver:function(e){var n,t=e.event,r=e.hoveredHeader;if(t.preventDefault(),i.current){var d=t.currentTarget.getAnimations().some((function(e){return"running"===e.playState})),u=t.screenX,f=t.screenY,h=Math.sqrt(Math.pow(u-j.screenX,2)+Math.pow(f-j.screenY,2));s.current=r;var v=a([],i.current,!0),m=v.findIndex((function(e){var n;return e.accessor===(null===(n=o.current)||void 0===n?void 0:n.accessor)})),g=v.findIndex((function(e){return e.accessor===r.accessor})),p=v.splice(m,1)[0];if(v.splice(g,0,p),!(d||r.accessor===(null===(n=o.current)||void 0===n?void 0:n.accessor)||null===o.current||h<10||void 0===m||void 0===g||JSON.stringify(v)===JSON.stringify(i.current))){var w=Date.now();JSON.stringify(v)===JSON.stringify(c)&&w-y<800&&h<50||(y=w,j={screenX:u,screenY:f},l(v))}}},handleDragEnd:function(){o.current=null,s.current=null}}},E=n.forwardRef((function(r,o){var i,a,s=r.borderClass,l=r.colIndex,c=r.draggedHeaderRef,u=r.header,h=r.headersRef,v=r.hoveredHeaderRef,g=r.isSelected,p=r.isTopLeftCell,w=r.onCellEdit,R=r.onExpandRowClick,b=r.onMouseDown,y=r.onMouseOver,j=r.onTableHeaderDragEnd,E=r.rowIndex,S=r.visibleRow,M=S.depth,I=S.row,D=n.useState(I.rowData[u.accessor]),k=D[0],N=D[1],L=n.useState(!1),T=L[0],B=L[1],O=H({draggedHeaderRef:c,headersRef:h,hoveredHeaderRef:v,onTableHeaderDragEnd:j}).handleDragOver,W=C(),A=Boolean(null===(a=null===(i=I.rowMeta)||void 0===i?void 0:i.children)||void 0===a?void 0:a.length),P=Boolean(null==u?void 0:u.isEditable),z=E%2==0,U="st-cell ".concat(M>0&&u.expandable?"st-cell-depth-".concat(M):""," ").concat(g?p?"st-cell-selected-first-cell ".concat(s):"st-cell-selected ".concat(s):""," ").concat(z?"st-cell-odd-row":"st-cell-even-row"," ").concat(P?"clickable":""," ").concat("right"===u.align?"right-aligned":"center"===u.align?"center-aligned":"left-aligned");return n.useEffect((function(){N(I.rowData[u.accessor])}),[u.accessor,I]),T?e.jsx("div",t({className:"st-cell-editing ".concat(z?"st-cell-odd-row":"st-cell-even-row"),id:m({accessor:u.accessor,rowIndex:E+1})},{children:e.jsx(x,{onChange:function(e){N(e),null==w||w({accessor:u.accessor,newValue:e,row:I})},setIsEditing:B,value:k})})):e.jsxs("div",t({className:U,id:m({accessor:u.accessor,rowIndex:E+1}),onDoubleClick:function(){return u.isEditable&&B(!0)},onMouseDown:function(){return b(E,l)},onMouseOver:function(){return y(E,l)},onDragOver:function(e){return W({callback:O,callbackProps:{event:e,hoveredHeader:u},limit:50})},ref:o},{children:[u.expandable&&A?I.rowMeta.isExpanded?e.jsx("div",t({className:"st-sort-icon-container",onClick:function(){return R(I.rowMeta.rowId)}},{children:e.jsx(f,{className:"st-sort-icon"})})):e.jsx("div",t({className:"st-sort-icon-container",onClick:function(){return R(I.rowMeta.rowId)}},{children:e.jsx(d,{className:"st-sort-icon"})})):null,e.jsx("span",t({className:"st-cell-content"},{children:u.cellRenderer?u.cellRenderer({accessor:u.accessor,colIndex:l,row:I}):k}))]}))})),S=function(n){var o=n.allowAnimations,i=n.children,a=r(n,["allowAnimations","children"]);return o?e.jsx(M,t({},a,{children:i})):e.jsx(e.Fragment,{children:i})},M=function(t){var r=t.allowHorizontalAnimate,o=void 0===r||r,i=t.children,a=t.draggedHeaderRef,s=t.headersRef,l=t.isBody,c=t.mainBodyRef,d=t.pauseAnimation,u=t.rowIndex,f=n.useRef(!1),h=n.useState({}),v=h[0],g=h[1],p=n.useRef({}),w=s.current;return n.useLayoutEffect((function(){if(w){var e=function(e){var n=e.currentHeaders,t=e.draggedHeaderRef,r=e.rowIndex,o={};return n.forEach((function(e){var n;if(e){var i=document.getElementById(m({accessor:e.accessor,rowIndex:r}));if(i){var a=i.getAnimations().some((function(e){return"running"===e.playState})),s=i.getBoundingClientRect();a&&(null===(n=null==t?void 0:t.current)||void 0===n?void 0:n.accessor)!==e.accessor?o[e.accessor]=!1:o[e.accessor]=s}}})),o}({currentHeaders:w,draggedHeaderRef:a,rowIndex:u});JSON.stringify(e)!==JSON.stringify(v)&&(p.current=v,g(e))}}),[v,w,a,l,u]),n.useLayoutEffect((function(){var e=c.current,n=function(){f.current=!0},t=function(){f.current=!1};return null==e||e.addEventListener("scroll",n),null==e||e.addEventListener("scrollend",t),function(){null==e||e.removeEventListener("scroll",n),null==e||e.removeEventListener("scrollend",t)}}),[a,c]),n.useEffect((function(){d||f.current||Object.keys(p.current).length&&w&&w.forEach((function(e){var n=document.getElementById(m({accessor:e.accessor,rowIndex:u}));if(n){var t=p.current[e.accessor],r=v[e.accessor];if(t&&r){var i=t.left-r.left,a=o?0:t.top-r.top,s=Math.abs(i),l=Math.abs(a);(s>10||l>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,v,w,l,d,p,u]),e.jsx(e.Fragment,{children:i})},I=function(o){var i=o.getBorderClass,a=o.handleMouseDown,s=o.handleMouseOver,l=o.headers,c=o.hiddenColumns,d=o.isSelected,u=o.isTopLeftCell,f=o.onExpandRowClick,h=o.pinned,v=o.rowIndex,p=o.visibleRow,w=r(o,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isTopLeftCell","onExpandRowClick","pinned","rowIndex","visibleRow"]);return e.jsx(S,t({allowAnimations:w.allowAnimations,allowHorizontalAnimate:w.shouldPaginate,draggedHeaderRef:w.draggedHeaderRef,headersRef:w.headersRef,isBody:!0,mainBodyRef:w.mainBodyRef,pauseAnimation:w.isWidthDragging,rowIndex:v+1},{children:l.map((function(e,r){return g({hiddenColumns:c,header:e,pinned:h})?n.createElement(E,t({},w,{borderClass:i(v,r),colIndex:r,header:e,isSelected:d(v,r),isTopLeftCell:u(v,r),key:m({accessor:e.accessor,rowIndex:v+1}),onExpandRowClick:f,onMouseDown:function(){return a({rowIndex:v,colIndex:r})},onMouseOver:function(){return s(v,r)},rowIndex:v,visibleRow:p})):null}))}))},D=function(n){var r=n.getNextRowIndex,o=n.gridTemplateColumns,i=n.index,a=n.pinned,s=n.props,l=n.rowHeight,c=n.visibleRow,d=c.position,u=r();return e.jsx("div",t({className:"st-table-row",style:{gridTemplateColumns:o,top:v({position:d,rowHeight:l}),height:"".concat(l,"px")}},{children:e.jsx(I,t({pinned:a,rowIndex:u,visibleRow:c},s),i)}))},k=function(n){var r=n.lastGroupRow,o=n.position,i=n.rowHeight,a=n.templateColumns;return e.jsx("div",t({className:"st-row-separator ".concat(r?"st-last-group-row":""),style:{display:"grid",gridTemplateColumns:a,position:"absolute",top:h({position:o,rowHeight:i}),minWidth:"100%"}},{children:e.jsx("div",{style:{gridColumn:"1 / -1"}})}))},N=function(o){o.headerContainerRef;var i=o.onExpandRowClick,a=o.pinned,s=o.rowHeight,l=o.sectionRef,c=o.templateColumns,d=o.totalHeight,u=o.visibleRows,f=o.width,h=r(o,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),v=a?"st-table-body-pinned-".concat(a):"st-table-body-main",m=n.useRef(0);n.useEffect((function(){m.current=0}));var g=function(){return m.current++};return e.jsx("div",t({className:v,ref:l,style:{position:"relative",height:"".concat(d,"px"),width:f}},{children:u.map((function(n,r){var o,l,d=Boolean(null===(l=null===(o=n.row.rowMeta)||void 0===o?void 0:o.children)||void 0===l?void 0:l.length);return e.jsxs(e.Fragment,{children:[e.jsx(D,{getNextRowIndex:g,gridTemplateColumns:c,index:r,pinned:a,props:t(t({},h),{onExpandRowClick:i}),rowHeight:s,visibleRow:n},r),0!==r&&e.jsx(k,{lastGroupRow:d,position:n.position,rowHeight:s,templateColumns:c})]})}))}))},L=function(r){var s,l,c,d,u,f=r.centerHeaderRef,h=r.currentRows,v=r.headerContainerRef,m=r.mainBodyRef,g=r.mainTemplateColumns,p=r.pinnedLeftColumns,w=r.pinnedLeftHeaderRef,R=r.pinnedLeftRef,x=r.pinnedLeftTemplateColumns,b=r.pinnedRightColumns,C=r.pinnedRightHeaderRef,y=r.pinnedRightRef,j=r.pinnedRightTemplateColumns,H=r.scrollbarWidth,E=r.tableBodyContainerRef;!function(e){var t=e.headerContainerRef,r=e.mainSectionRef,o=e.scrollbarWidth,i=n.useState(!1),a=i[0],s=i[1];n.useEffect((function(){var e=null==t?void 0:t.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")}}),[t,a,o]),n.useEffect((function(){var e=null==t?void 0:t.current,n=null==r?void 0:r.current;if(n&&e){var o=function(){if(n){var e=n.scrollHeight>n.clientHeight;s(e)}};o();var i=new ResizeObserver((function(){o()}));return i.observe(n),function(){n&&i.unobserve(n)}}}),[t,r])}({headerContainerRef:v,mainSectionRef:E,scrollbarWidth:H});var S=n.useRef(null),M=n.useRef(null),I=n.useState(h),D=I[0],k=I[1],L=n.useState(1),T=L[0],B=L[1],O=n.useState(!1),W=O[0],A=O[1],P=n.useState(!0),z=P[0],U=P[1],F=n.useState(0),V=F[0],q=F[1],J=function(e){var n=0,t=function(e){e.forEach((function(e){n+=1,e.rowMeta.isExpanded&&e.rowMeta.children&&t(e.rowMeta.children)}))};return t(e),n}(D),X=41*J-1,G=function(e){var n=function(r){return r.rowMeta.rowId===e&&r.rowMeta.children?t(t({},r),{rowMeta:t(t({},r.rowMeta),{isExpanded:!r.rowMeta.isExpanded})}):r.rowMeta.children?t(t({},r),{rowMeta:t(t({},r.rowMeta),{children:r.rowMeta.children.map(n)})}):r};k((function(e){return e.map(n)}))},Y=n.useMemo((function(){return function(e){var n=e.bufferRowCount,t=e.containerHeight,r=e.rowHeight,o=e.rows,i=e.scrollTop,a=[],s=0,l=Math.max(0,i-r*n),c=i+t+r*n,d=function(e,n){for(var t,o=0,i=e;o<i.length;o++){var u=i[o],f=s*r;if(f>=c)break;f+r>l&&a.push({row:u,depth:n,position:s,isLastGroupRow:Boolean(null===(t=u.rowMeta.children)||void 0===t?void 0:t.length)&&n>1}),s+=1,u.rowMeta.isExpanded&&u.rowMeta.children&&d(u.rowMeta.children,n+1)}};return d(o,0),a}({bufferRowCount:5,containerHeight:600,rowHeight:40,rows:D,scrollTop:V})}),[D,V]),K=n.useCallback((function(){return o(void 0,void 0,void 0,(function(){var e;return i(this,(function(n){return W||!z||(A(!0),e=h.slice(20*T,20*(T+1)),k((function(n){return a(a([],n,!0),e,!0)})),B((function(e){return e+1})),A(!1),e.length<20/3&&U(!1)),[2]}))}))}),[h,z,W,T]),_=n.useCallback((function(e){e[0].isIntersecting&&z&&!W&&K()}),[z,W,K]);n.useEffect((function(){return S.current=new IntersectionObserver(_,{root:null,rootMargin:"100px",threshold:0}),E.current&&S.current.observe(E.current),function(){S.current&&S.current.disconnect()}}),[_,D,E]);var $=(null===(s=w.current)||void 0===s?void 0:s.clientWidth)?(null===(l=w.current)||void 0===l?void 0:l.clientWidth)+1:0,Q=null===(c=f.current)||void 0===c?void 0:c.clientWidth,Z=(null===(d=C.current)||void 0===d?void 0:d.clientWidth)?(null===(u=C.current)||void 0===u?void 0:u.clientWidth)+1:0;return e.jsxs("div",t({className:"st-table-body-container",ref:E,onScroll:function(e){var n=e.currentTarget.scrollTop;M.current&&cancelAnimationFrame(M.current),M.current=requestAnimationFrame((function(){q(n)}))}},{children:[p.length>0&&e.jsx(N,t({},r,{onExpandRowClick:G,pinned:"left",rowHeight:40,sectionRef:R,templateColumns:x,totalHeight:X,visibleRows:Y,width:$})),e.jsx(N,t({},r,{onExpandRowClick:G,rowHeight:40,sectionRef:m,templateColumns:g,totalHeight:X,visibleRows:Y,width:Q})),b.length>0&&e.jsx(N,t({},r,{onExpandRowClick:G,pinned:"right",rowHeight:40,sectionRef:y,templateColumns:j,totalHeight:X,visibleRows:Y,width:Z}))]}))},T={string:function(e,n,t){if(e===n)return 0;var r=e.localeCompare(n);return"ascending"===t?r:-r},number:function(e,n,t){if(e===n)return 0;var r=e-n;return"ascending"===t?r:-r},boolean:function(e,n,t){if(e===n)return 0;var r=e===n?0:e?-1:1;return"ascending"===t?r:-r},date:function(e,n,t){var r=new Date(e),o=new Date(n);if(r.getTime()===o.getTime())return 0;var i=r.getTime()-o.getTime();return"ascending"===t?i:-i},enum:function(e,n,t){return T.string(e,n,t)},default:function(e,n,t){return e===n?0:null==e?"ascending"===t?-1:1:null==n?"ascending"===t?1:-1:"string"==typeof e&&"string"==typeof n?T.string(e,n,t):"number"==typeof e&&"number"==typeof n?T.number(e,n,t):"boolean"==typeof e&&"boolean"==typeof n?T.boolean(e,n,t):T.string(String(e),String(n),t)}},B=function(e,n,t,r){switch(void 0===t&&(t="string"),t){case"string":return T.string(String(e||""),String(n||""),r);case"number":return T.number(Number(e||0),Number(n||0),r);case"boolean":return T.boolean(Boolean(e),Boolean(n),r);case"date":return T.date(String(e||""),String(n||""),r);case"enum":return T.enum(String(e||""),String(n||""),r);default:return T.default(e,n,r)}},O=function(e,n,r){var o=r.find((function(e){return e.accessor===n.key.accessor})),i=(null==o?void 0:o.type)||"string",s=n.direction;return a([],e,!0).sort((function(e,t){var r,o,a=null===(r=null==e?void 0:e.rowData)||void 0===r?void 0:r[n.key.accessor],l=null===(o=null==t?void 0:t.rowData)||void 0===o?void 0:o[n.key.accessor];return B(a,l,i,s)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?t(t({},e),{rowMeta:t(t({},e.rowMeta),{children:O(e.rowMeta.children,n,r)})}):e}))},W=function(e,n,r){var o=function(e,n,r){var o=r.find((function(e){return e.accessor===n.key.accessor})),i=(null==o?void 0:o.type)||"string",s=n.direction,l=[],c=new Map;return e.forEach((function(n){e.some((function(e){var t;return null===(t=e.rowMeta.children)||void 0===t?void 0:t.some((function(e){return e.rowMeta.rowId===n.rowMeta.rowId}))}))||l.push(n),n.rowMeta.children&&n.rowMeta.children.length>0&&c.set(n.rowMeta.rowId,n.rowMeta.children)})),a([],l,!0).sort((function(e,t){var r,o,a=null===(r=null==e?void 0:e.rowData)||void 0===r?void 0:r[n.key.accessor],l=null===(o=null==t?void 0:t.rowData)||void 0===o?void 0:o[n.key.accessor];return B(a,l,i,s)})).map((function(e){var o=t({},e);if(c.has(e.rowMeta.rowId)){var i=c.get(e.rowMeta.rowId)||[],a=O(i,n,r);o.rowMeta=t(t({},o.rowMeta),{children:a})}return o}))}(n,r,e);return{sortedData:o,newSortConfig:r}},A=function(e){var n=e.event,t=e.forceUpdate,r=e.header,o=e.headersRef,i=e.index;e.reverse;var a=e.setIsWidthDragging,s=e.startWidth;a(!0),n.preventDefault();var l=n.clientX;if(r){var c=function(e){var n=Math.max(s+(e.clientX-l),40);r&&o.current&&(o.current[i].width=n,t())},d=function(){document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d),a(!1)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",d)}},P=n.forwardRef((function(r,o){var i,a=r.columnResizing,s=r.currentRows,l=r.columnReordering,c=r.draggedHeaderRef,d=r.forceUpdate,u=r.headersRef,f=r.hoveredHeaderRef,h=r.index,v=r.onSort,g=r.onTableHeaderDragEnd,p=r.reverse,w=r.selectableColumns,R=r.setIsWidthDragging,x=r.setSelectedCells,b=r.sort,y=r.sortDownIcon,j=r.sortUpIcon,E=n.useState(!1),S=E[0],M=E[1],I=null===(i=u.current)||void 0===i?void 0:i[h],D=Boolean(null==I?void 0:I.isSortable),k="st-header-cell ".concat(I===f.current?"st-hovered":""," ").concat(S?"st-dragging":""," ").concat(D?"clickable":""," ").concat(l&&!D?"columnReordering":""," ").concat("right"===(null==I?void 0:I.align)?"right-aligned":"center"===(null==I?void 0:I.align)?"center-aligned":""),N=H({draggedHeaderRef:c,headersRef:u,hoveredHeaderRef:f,onTableHeaderDragEnd:g}),L=N.handleDragStart,T=N.handleDragEnd,B=H({draggedHeaderRef:c,headersRef:u,hoveredHeaderRef:f,onTableHeaderDragEnd:g}).handleDragOver,O=C(),W=function(e){var n=e.event,t=e.header;if(w){var r=s.length,o=Array.from({length:r},(function(e,n){return"".concat(n,"-").concat(h)})),i=function(e,n){var t=new Set,o=Math.min(e,n),i=Math.max(e,n);return Array.from({length:r}).forEach((function(e,n){Array.from({length:i-o+1}).forEach((function(e,r){t.add("".concat(n,"-").concat(o+r))}))})),t};n.shiftKey?x((function(e){var n,t=Number(null===(n=Array.from(e)[0])||void 0===n?void 0:n.split("-")[1]),r=Number(o[0].split("-")[1]);return t===r?new Set(o):t>r?i(r,t):i(t,r)})):x(new Set(o))}else t.isSortable&&v(h,t.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)}}),[]),!I)return null;var P=a&&e.jsx("div",{className:"st-header-resize-handle",onMouseDown:function(e){var n;O({callback:A,callbackProps:{event:e,forceUpdate:d,header:I,headersRef:u,index:h,setIsWidthDragging:R,startWidth:"object"==typeof o&&null!==o&&"current"in o?null===(n=o.current)||void 0===n?void 0:n.offsetWidth:void 0},limit:10})}});return e.jsxs("div",t({className:k,id:m({accessor:I.accessor,rowIndex:0}),onDragOver:function(e){O({callback:B,callbackProps:{event:e,hoveredHeader:I},limit:50})},ref:o,style:{width:I.width}},{children:[p&&P,e.jsx("div",t({className:"st-header-label",draggable:l,onClick:function(e){return W({event:e,header:I})},onDragEnd:function(e){e.preventDefault(),M(!1),T()},onDragStart:function(e){l&&I&&function(e){M(!0),L(e)}(I)}},{children:null==I?void 0:I.label})),b&&b.key.accessor===I.accessor&&e.jsxs("div",t({className:"st-sort-icon-container",onClick:function(e){return W({event:e,header:I})}},{children:["ascending"===b.direction&&j&&j,"descending"===b.direction&&y&&y]})),!p&&P]}))})),z=function(e,t){n.useEffect((function(){if(e.current){var n=e.current,r=function(){var e,r=null==n?void 0:n.scrollLeft;void 0!==r&&(null===(e=t.current)||void 0===e||e.scrollTo(r,0))};return n.addEventListener("scroll",r),function(){null==n||n.removeEventListener("scroll",r)}}}),[e,t])},U=function(r){var o,i,a,s=r.allowAnimations,l=r.centerHeaderRef,c=r.columnResizing,d=r.currentRows,u=r.columnReordering,f=r.draggedHeaderRef,h=r.forceUpdate,v=r.headerContainerRef,m=r.headersRef,p=r.hiddenColumns,w=r.hoveredHeaderRef,R=r.isWidthDragging,x=r.mainBodyRef,b=r.mainTemplateColumns,C=r.onSort,y=r.onTableHeaderDragEnd,j=r.pinnedLeftColumns,H=r.pinnedLeftHeaderRef,E=r.pinnedLeftTemplateColumns,M=r.pinnedRightColumns,I=r.pinnedRightHeaderRef,D=r.pinnedRightTemplateColumns,k=r.selectableColumns,N=r.setIsWidthDragging,L=r.setSelectedCells,T=r.sort,B=r.sortDownIcon,O=r.sortUpIcon;z(x,l);return e.jsxs("div",t({className:"st-header-container",ref:v},{children:[j.length>0&&e.jsx("div",t({className:"st-header-pinned-left",ref:H,style:{gridTemplateColumns:E}},{children:e.jsx(S,t({allowAnimations:s,draggedHeaderRef:f,headersRef:m,mainBodyRef:x,pauseAnimation:R,rowIndex:0},{children:null===(o=m.current)||void 0===o?void 0:o.map((function(t,r){return g({hiddenColumns:p,header:t,pinned:"left"})?e.jsx(P,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:C,onTableHeaderDragEnd:y,ref:n.createRef(),selectableColumns:k,setIsWidthDragging:N,setSelectedCells:L,sort:T,sortDownIcon:B,sortUpIcon:O},t.accessor):null}))}))})),e.jsx("div",t({className:"st-header-main",onScroll:function(e){var n,t,r=null===(n=l.current)||void 0===n?void 0:n.scrollLeft;void 0!==r&&(null===(t=x.current)||void 0===t||t.scrollTo(r,0))},ref:l,style:{gridTemplateColumns:b}},{children:e.jsx(S,t({allowAnimations:s,draggedHeaderRef:f,headersRef:m,mainBodyRef:x,pauseAnimation:R,rowIndex:0},{children:null===(i=m.current)||void 0===i?void 0:i.map((function(t,r){return g({hiddenColumns:p,header:t})?e.jsx(P,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:C,onTableHeaderDragEnd:y,ref:n.createRef(),selectableColumns:k,setIsWidthDragging:N,setSelectedCells:L,sort:T,sortDownIcon:B,sortUpIcon:O},t.accessor):null}))}))})),M.length>0&&e.jsx("div",t({className:"st-header-pinned-right",ref:I,style:{gridTemplateColumns:D}},{children:e.jsx(S,t({allowAnimations:s,draggedHeaderRef:f,headersRef:m,mainBodyRef:x,pauseAnimation:R,rowIndex:0},{children:null===(a=m.current)||void 0===a?void 0:a.map((function(t,r){return g({hiddenColumns:p,header:t,pinned:"right"})?e.jsx(P,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:C,onTableHeaderDragEnd:y,reverse:!0,ref:n.createRef(),selectableColumns:k,setIsWidthDragging:N,setSelectedCells:L,sort:T,sortDownIcon:B,sortUpIcon:O},t.accessor):null}))}))}))]}))},F=function(e){var n=e.minWidth,t=e.width;return"number"==typeof t&&(t="".concat(t,"px")),n&&"number"==typeof n&&(n="".concat(n,"px")),void 0!==n?"minmax(".concat(n,", ").concat(t,")"):t},V=function(r){var o=r.allowAnimations,i=r.columnResizing,a=r.currentRows,s=r.columnReordering,l=r.draggedHeaderRef,c=r.editColumns,d=r.forceUpdate,u=r.getBorderClass,f=r.handleMouseDown,h=r.handleMouseOver,v=r.headersRef,m=r.hiddenColumns,g=r.hoveredHeaderRef,p=r.isSelected,w=r.isTopLeftCell,R=r.isWidthDragging,x=r.mainBodyRef,b=r.onCellEdit,C=r.onSort,y=r.onTableHeaderDragEnd,j=r.pinnedLeftRef,H=r.pinnedRightRef,E=r.scrollbarWidth,S=r.selectableColumns,M=r.setIsWidthDragging,I=r.setSelectedCells,D=r.shouldPaginate,k=r.sort,N=r.sortDownIcon,T=r.sortUpIcon,B=r.tableBodyContainerRef,O=n.useRef(null),W=n.useRef(null),A=n.useRef(null),P=n.useRef(null),z=v.current.filter((function(e){return!e.hide&&!e.pinned})),V=v.current.filter((function(e){return"left"===e.pinned&&!0!==e.hide})),q=v.current.filter((function(e){return"right"===e.pinned&&!0!==e.hide})),J=n.useMemo((function(){return"".concat(V.map((function(e){return F(e)})).join(" "))}),[V]),X=n.useMemo((function(){return"".concat(z.filter((function(e){return!0!==m[e.accessor]})).map((function(e){return F(e)})).join(" "))}),[z,m]),G=n.useMemo((function(){return"".concat(q.map((function(e){return F(e)})).join(" "))}),[q]),Y={allowAnimations:o,centerHeaderRef:A,columnResizing:i,currentRows:a,columnReordering:s,draggedHeaderRef:l,forceUpdate:d,headerContainerRef:O,headersRef:v,hiddenColumns:m,hoveredHeaderRef:g,isWidthDragging:R,mainBodyRef:x,mainTemplateColumns:X,onSort:C,onTableHeaderDragEnd:y,pinnedLeftColumns:V,pinnedLeftHeaderRef:W,pinnedLeftTemplateColumns:J,pinnedRightColumns:q,pinnedRightHeaderRef:P,pinnedRightTemplateColumns:G,selectableColumns:S,setIsWidthDragging:M,setSelectedCells:I,sort:k,sortDownIcon:N,sortUpIcon:T,tableBodyContainerRef:B},K={allowAnimations:o,centerHeaderRef:A,currentRows:a,draggedHeaderRef:l,getBorderClass:u,handleMouseDown:f,handleMouseOver:h,headerContainerRef:O,headers:v.current,headersRef:v,hiddenColumns:m,hoveredHeaderRef:g,isSelected:p,isTopLeftCell:w,isWidthDragging:R,mainBodyRef:x,mainTemplateColumns:X,onCellEdit:b,onTableHeaderDragEnd:y,pinnedLeftColumns:V,pinnedLeftHeaderRef:W,pinnedLeftRef:j,pinnedLeftTemplateColumns:J,pinnedRightColumns:q,pinnedRightHeaderRef:P,pinnedRightRef:H,pinnedRightTemplateColumns:G,scrollbarWidth:E,shouldPaginate:D,tableBodyContainerRef:B};return e.jsxs("div",t({className:"st-table-content",style:{width:c?"calc(100% - 27.5px)":"100%"}},{children:[e.jsx(U,t({},Y)),e.jsx(L,t({},K))]}))},q=function(e){var t=e.callback,r=e.ref,o=e.widthAttribute;n.useEffect((function(){var e=r.current;if(e){var n=function(){t(e[o]||0)};n();var i=new ResizeObserver((function(){n()}));return i.observe(e),function(){return i.disconnect()}}}),[t,r,o])},J=function(r){var o=r.mainBodyRef,i=r.pinnedLeftRef,a=r.pinnedRightRef,s=r.tableContentWidth,l=n.useState(0),c=l[0],d=l[1],u=n.useState(0),f=u[0],h=u[1],v=n.useState(0),m=v[0],g=v[1],p=n.useRef(null);return q({widthAttribute:"offsetWidth",callback:d,ref:i}),q({widthAttribute:"scrollWidth",callback:g,ref:o}),q({widthAttribute:"offsetWidth",callback:h,ref:a}),z(o,p),!o.current||o.current.scrollWidth<=o.current.clientWidth?null:e.jsxs("div",t({className:"st-horizontal-scrollbar-container",style:{width:s}},{children:[c>0&&e.jsx("div",{className:"st-horizontal-scrollbar-left",style:{flexShrink:0,width:c}}),m>0&&e.jsx("div",t({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:p},{children:e.jsx("div",{style:{width:m}})})),f>0&&e.jsx("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:f}})]}))},X=function(r){var o=r.checked,i=void 0!==o&&o,a=r.children,s=r.onChange,l=n.useState(i),c=l[0],d=l[1];return e.jsxs("label",t({className:"st-checkbox-label"},{children:[e.jsx("input",{checked:c,className:"st-checkbox-input",onChange:function(){var e=!c;d(e),s&&s(e)},type:"checkbox"}),e.jsx("span",t({className:"st-checkbox-custom ".concat(c?"st-checked":"")},{children:c&&e.jsx("span",{className:"st-checkbox-checkmark"})})),a]}))},G=function(n){var r=n.headers,o=n.open,i=n.position;n.setOpen;var a=n.setHiddenColumns,s=n.hiddenColumns,l="left"===i?"left":"";return e.jsx("div",t({className:"st-column-editor-popout ".concat(o?"open":""," ").concat(l),onClick:function(e){return e.stopPropagation()}},{children:e.jsx("div",t({className:"st-column-editor-popout-content"},{children:r.map((function(n,r){return e.jsx(X,t({checked:s[n.accessor],onChange:function(e){var r;return a(t(t({},s),((r={})[n.accessor]=e,r)))}},{children:n.label}),r)}))}))}))},Y=function(r){var o=r.columnEditorText,i=r.editColumns,a=r.editColumnsInitOpen,s=r.headers,l=r.position,c=void 0===l?"right":l,d=r.setHiddenColumns,u=r.hiddenColumns,f=n.useState(a),h=f[0],v=f[1];return i?e.jsxs("div",t({className:"st-column-editor ".concat(h?"open":""," ").concat(c),onClick:function(){return function(e){v(e)}(!h)}},{children:[e.jsx("div",t({className:"st-column-editor-text"},{children:o})),e.jsx(G,{headers:s,open:h,position:c,setOpen:v,setHiddenColumns:d,hiddenColumns:u})]})):null};!function(e){e.Left="left",e.Right="right"}(s||(s={}));var K=function(r){var o=r.allowAnimations,i=void 0!==o&&o,a=r.columnEditorPosition,h=void 0===a?s.Right:a,v=r.columnEditorText,m=void 0===v?"Columns":v,g=r.columnResizing,p=void 0!==g&&g,w=r.defaultHeaders,R=r.editColumns,x=void 0!==R&&R,b=r.editColumnsInitOpen,C=void 0!==b&&b,y=r.columnReordering,j=void 0!==y&&y,H=r.height,E=r.hideFooter,S=void 0!==E&&E,M=r.nextIcon,I=void 0===M?e.jsx(d,{className:"st-next-prev-icon"}):M,D=r.onCellEdit,k=r.onColumnOrderChange,N=r.prevIcon,L=void 0===N?e.jsx(c,{className:"st-next-prev-icon"}):N,T=r.rows,B=r.rowsPerPage,O=void 0===B?10:B,A=r.selectableCells,P=void 0!==A&&A,z=r.selectableColumns,U=void 0!==z&&z,F=r.shouldPaginate,q=void 0!==F&&F,X=r.sortDownIcon,G=void 0===X?e.jsx(f,{className:"st-sort-icon"}):X,K=r.sortUpIcon,_=void 0===K?e.jsx(u,{className:"st-sort-icon"}):K,$=r.theme,Q=void 0===$?"light":$,Z=n.useRef(null),ee=n.useRef(w),ne=n.useRef(null),te=n.useRef(null),re=n.useRef(null),oe=n.useRef(null),ie=n.useRef(null),ae=n.useState(!1),se=ae[0],le=ae[1],ce=n.useState(1),de=ce[0],ue=ce[1],fe=n.useState(0),he=fe[0],ve=fe[1],me=n.useState(0),ge=me[0],pe=me[1],we=function(e){var t=e.headers,r=e.tableRows,o=n.useState(null),i=o[0],a=o[1],s=n.useMemo((function(){var e={};return t.forEach((function(n){!0===n.hide&&(e[n.accessor]=!0)})),e}),[t]),l=n.useState(s),c=l[0],d=l[1],u=n.useMemo((function(){return i?W(t,r,i).sortedData:r}),[r,i,t]);return{sort:i,setSort:a,updateSort:function(e,n){var r=t.find((function(e){return e.accessor===n}));r&&a((function(e){return e&&e.key.accessor===n?"ascending"===e.direction?{key:r,direction:"descending"}:null:{key:r,direction:"ascending"}}))},sortedRows:u,hiddenColumns:c,setHiddenColumns:d}}({headers:ee.current,tableRows:T}),Re=we.sort,xe=we.sortedRows,be=we.hiddenColumns,Ce=we.setHiddenColumns,ye=we.updateSort,je=n.useReducer((function(e){return e+1}),0)[1],He=function(e){var t=e.selectableCells,r=e.headers,o=e.rows,i=n.useState(new Set),a=i[0],s=i[1],l=n.useRef(!1),c=n.useRef(null),d=n.useCallback((function(){var e=Array.from(a).reduce((function(e,n){var t=n.split("-").map(Number),i=t[0],a=t[1];return e[i]||(e[i]=[]),e[i][a]=o[i][r[a].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");a.size>0&&navigator.clipboard.writeText(n)}),[a,o,r]);n.useEffect((function(){var e=function(e){(e.ctrlKey||e.metaKey)&&"c"===e.key&&d()};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[d]);var u=n.useCallback((function(e,n){return a.has("".concat(e,"-").concat(n))}),[a]),f=n.useCallback((function(e,n){var t=[];return u(e-1,n)||t.push("st-selected-top-border"),u(e+1,n)||t.push("st-selected-bottom-border"),u(e,n-1)||t.push("st-selected-left-border"),u(e,n+1)||t.push("st-selected-right-border"),t.join(" ")}),[u]),h=n.useMemo((function(){var e=Math.min.apply(Math,Array.from(a).map((function(e){return parseInt(e.split("-")[0])}))),n=Math.min.apply(Math,Array.from(a).map((function(e){return parseInt(e.split("-")[1])})));return function(t,r){return t===e&&r===n}}),[a]);return{selectedCells:a,handleMouseDown:function(e){var n=e.colIndex,r=e.rowIndex;t&&(l.current=!0,c.current={row:r,col:n},s(new Set(["".concat(r,"-").concat(n)])))},handleMouseOver:function(e,n){if(t&&l.current&&c.current){for(var r=new Set,o=Math.min(c.current.row,e),i=Math.max(c.current.row,e),a=Math.min(c.current.col,n),d=Math.max(c.current.col,n),u=o;u<=i;u++)for(var f=a;f<=d;f++)r.add("".concat(u,"-").concat(f));s(r)}},handleMouseUp:function(){l.current=!1,c.current=null},isSelected:u,getBorderClass:f,isTopLeftCell:h,setSelectedCells:s}}({selectableCells:P,headers:ee.current,rows:xe}),Ee=He.handleMouseDown,Se=He.handleMouseOver,Me=He.handleMouseUp,Ie=He.isSelected,De=He.getBorderClass,ke=He.isTopLeftCell,Ne=He.setSelectedCells,Le=n.useMemo((function(){return q?xe.slice((de-1)*O,de*O):xe}),[de,O,q,xe]),Te=n.useCallback((function(e,n){ye(e,n)}),[ye]),Be=n.useCallback((function(e){ee.current=e,je(),null==k||k(e)}),[k]);return n.useEffect((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||U&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||Ne(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[U,Ne]),n.useLayoutEffect((function(){if(ie.current){var e=ie.current.offsetWidth-ie.current.clientWidth,n=ie.current.clientWidth;ve(e),pe(n)}}),[]),n.useLayoutEffect((function(){var e=function(){if(je(),ie.current){var e=ie.current.offsetWidth-ie.current.clientWidth,n=ie.current.clientWidth;ve(e),pe(n)}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),e.jsxs("div",t({className:"simple-table-root st-wrapper theme-".concat(Q),style:H?{height:H}:{}},{children:[e.jsxs("div",t({className:"st-table-wrapper-container"},{children:[e.jsxs("div",t({className:"st-table-wrapper",onMouseUp:Me,onMouseLeave:Me},{children:[e.jsx(V,{allowAnimations:i,columnResizing:p,currentRows:Le,draggedHeaderRef:Z,editColumns:x,columnReordering:j,forceUpdate:je,getBorderClass:De,handleMouseDown:Ee,handleMouseOver:Se,headers:ee.current,headersRef:ee,hiddenColumns:be,hoveredHeaderRef:ne,isSelected:Ie,isTopLeftCell:ke,isWidthDragging:se,mainBodyRef:te,onCellEdit:D,onSort:Te,onTableHeaderDragEnd:Be,pinnedLeftRef:re,pinnedRightRef:oe,scrollbarWidth:he,selectableColumns:U,setIsWidthDragging:le,setSelectedCells:Ne,shouldPaginate:q,sort:Re,sortDownIcon:G,sortUpIcon:_,tableBodyContainerRef:ie}),e.jsx(Y,{columnEditorText:m,editColumns:x,editColumnsInitOpen:C,headers:ee.current,hiddenColumns:be,position:h,setHiddenColumns:Ce})]})),e.jsx(J,{mainBodyRef:te,pinnedLeftRef:re,pinnedRightRef:oe,tableContentWidth:ge})]})),e.jsx(l,{currentPage:de,hideFooter:S,nextIcon:I,onPageChange:ue,prevIcon:L,rowsPerPage:O,shouldPaginate:q,totalRows:xe.length})]}))};K.defaultProps={allowAnimations:!1,columnEditorPosition:s.Right,columnEditorText:"Columns",columnResizing:!1,defaultHeaders:[],editColumns:!1,editColumnsInitOpen:!1,columnReordering:!1,height:"",hideFooter:!1,nextIcon:e.jsx(d,{className:"st-next-prev-icon"}),onCellEdit:function(){},prevIcon:e.jsx(c,{className:"st-next-prev-icon"}),rows:[],rowsPerPage:10,selectableCells:!1,selectableColumns:!1,shouldPaginate:!1,sortDownIcon:e.jsx(f,{className:"st-sort-icon"}),sortUpIcon:e.jsx(u,{className:"st-sort-icon"}),theme:"light"};var _=n.memo(K);exports.SimpleTable=_;
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-table-core",
3
- "version": "0.7.13",
3
+ "version": "0.7.15",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",