simple-table-core 0.7.11 → 0.7.12
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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
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,createContext as c,forwardRef as s,useLayoutEffect as d,createElement as u,createRef as f,memo as h,useReducer as v}from"react";var g=function(){return g=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},g.apply(this,arguments)};function m(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 p(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 w(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 R(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 b,C=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,v=function(e){e>=1&&e<=u&&a(e)};return o||!s?null:(console.log("totalPages",u),e("div",g({className:"st-footer"},{children:[n("button",g({className:"st-next-prev-btn ".concat(f?"":"disabled"),onClick:function(){return v(t-1)},disabled:!f},{children:l})),n("button",g({className:"st-next-prev-btn ".concat(h?"":"disabled"),onClick:function(){return v(t+1)},disabled:!h},{children:i})),Array.from({length:u},(function(e,r){return n("button",g({onClick:function(){return v(r+1)},className:"st-page-btn ".concat(t===r+1?"active":"")},{children:r+1}),r)}))]})))},y=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})}))},x=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})}))},H=c({rows:[],tableRows:[]}),I=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M5.41 11.41L10 6.83l4.59 4.58L16 10l-6-6-6 6z"})}))},M=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M5.41 7.59L10 12.17l4.59-4.58L16 9l-6 6-6-6z"})}))},D=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",g({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",g({className:"st-checkbox-custom ".concat(s?"st-checked":"")},{children:s&&n("span",{className:"st-checkbox-checkmark"})})),a]}))},E=function(e){var r=e.headers,t=e.open,o=e.position;e.setOpen;var i=e.setHiddenColumns,a=e.hiddenColumns,l="left"===o?"left":"";return n("div",g({className:"st-column-editor-popout ".concat(t?"open":""," ").concat(l),onClick:function(e){return e.stopPropagation()}},{children:n("div",g({className:"st-column-editor-popout-content"},{children:r.map((function(e,r){return n(D,g({checked:a[e.accessor],onChange:function(n){var r;return i(g(g({},a),((r={})[e.accessor]=n,r)))}},{children:e.label}),r)}))}))}))},S=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],v=f[1];return i?e("div",g({className:"st-column-editor ".concat(h?"open":""," ").concat(s),onClick:function(){return function(e){v(e)}(!h)}},{children:[n("div",g({className:"st-column-editor-text"},{children:o})),n(E,{headers:l,open:h,position:s,setOpen:v,setHiddenColumns:d,hiddenColumns:u})]})):null},k=function(e){var n=e.accessor,r=e.rowIndex;return"cell-".concat(n,"-").concat(r)},N=function(e){var n=e.hiddenColumns,r=e.header,t=e.pinned;return n[r.accessor]?null:!t&&!r.pinned||r.pinned===t||null},L=function(r){var t=r.value,o=r.onBlur,i=r.onChange;return e("select",g({value:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;i("true"===n)}},{children:[n("option",g({value:"true"},{children:"True"})),n("option",g({value:"false"},{children:"False"}))]}))},T=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)}})},B=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)}})},O=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(T,{defaultValue:i,onBlur:l,onChange:a}):"boolean"==typeof i?n(L,{onBlur:l,onChange:a,value:i}):"number"==typeof i?n(B,{defaultValue:i,onBlur:l,onChange:a}):null})},A=0,W=function(){return function(e){var n=e.callback,r=e.callbackProps,t=e.limit,o=Date.now();(0===A||o-A>=t)&&(A=o,n(r))}},P=Date.now(),z={screenX:0,screenY:0},U=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,P=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-z.screenX,2)+Math.pow(u-z.screenY,2));l.current=o;var h=R([],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-P<800&&f<50||(P=p,z={screenX:d,screenY:u},c(h))}}},handleDragEnd:function(){t.current=null,l.current=null}}},j=s((function(r,o){var i=r.borderClass,l=r.cellHasChildren,c=r.colIndex,s=r.content,d=r.depth,u=r.draggedHeaderRef,f=r.header,h=r.headersRef,v=r.hoveredHeaderRef,m=r.isSelected,p=r.isTopLeftCell,w=r.onCellEdit,R=r.onExpandRowClick,b=r.onMouseDown,C=r.onMouseOver,y=r.onTableHeaderDragEnd,H=r.row,I=r.rowIndex,D=t(s),E=D[0],S=D[1],N=t(!1),L=N[0],T=N[1],B=U({draggedHeaderRef:u,headersRef:h,hoveredHeaderRef:v,onTableHeaderDragEnd:y}).handleDragOver,A=W(),P=Boolean(null==f?void 0:f.isEditable),z=I%2==0,j="st-cell ".concat(d>0&&f.expandable?"st-cell-depth-".concat(d):""," ").concat(m?p?"st-cell-selected-first-cell ".concat(i):"st-cell-selected ".concat(i):""," ").concat(z?"st-cell-odd-row":"st-cell-even-row"," ").concat(P?"clickable":""," ").concat("right"===f.align?"right-aligned":"");a((function(){"object"!=typeof s&&S(s)}),[s]);return L?n("div",g({className:"st-cell-editing ".concat(z?"st-cell-odd-row":"st-cell-even-row"),id:k({accessor:f.accessor,rowIndex:I+1})},{children:n(O,{onChange:function(e){S(e),null==w||w({accessor:f.accessor,newValue:e,row:H})},setIsEditing:T,value:E})})):e("div",g({className:j,id:k({accessor:f.accessor,rowIndex:I+1}),onDoubleClick:function(){return f.isEditable&&T(!0)},onMouseDown:function(){return b(I,c)},onMouseOver:function(){return C(I,c)},onDragOver:function(e){return A({callback:B,callbackProps:{event:e,hoveredHeader:f},limit:50})},ref:o},{children:[f.expandable&&l?H.rowMeta.isExpanded?n("div",g({className:"st-sort-icon-container",onClick:function(){return R(H.rowMeta.rowId)}},{children:n(M,{className:"st-sort-icon"})})):n("div",g({className:"st-sort-icon-container",onClick:function(){return R(H.rowMeta.rowId)}},{children:n(x,{className:"st-sort-icon"})})):null,n("span",{children:E})]}))})),F=s((function(e,r){return e.visible?n("div",{className:"st-cell",ref:r}):n("div",{ref:r})})),G=function(e){var r=e.lastGroupRow;return n("div",{className:"st-row-separator ".concat(r?"st-last-group-row":"")})},V=function(e){var t=e.allowAnimations,o=e.children,i=m(e,["allowAnimations","children"]);return t?n(J,g({},i,{children:o})):n(r,{children:o})},J=function(e){var i=e.allowHorizontalAnimate,l=void 0===i||i,c=e.children,s=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 d((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(k({accessor:e.accessor,rowIndex:t}));if(i){var a=i.getAnimations().some((function(e){return"running"===e.playState})),l=i.getBoundingClientRect();a&&(null===(n=null==r?void 0:r.current)||void 0===n?void 0:n.accessor)!==e.accessor?o[e.accessor]=!1:o[e.accessor]=l}}})),o}({currentHeaders:C,draggedHeaderRef:s,rowIndex:g});JSON.stringify(e)!==JSON.stringify(w)&&(b.current=w,R(e))}}),[w,C,s,f,g]),d((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)}}),[s,h]),a((function(){v||m.current||Object.keys(b.current).length&&C&&C.forEach((function(e){var n=document.getElementById(k({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})},X=function(r){var t,o=r.getBorderClass,i=r.handleMouseDown,a=r.handleMouseOver,l=r.headers,c=r.hiddenColumns,s=r.isSelected,d=r.isTopLeftCell,h=r.lastGroupRow,v=r.onExpandRowClick,p=r.pinned,w=r.row,R=r.rowIndex,b=r.shouldDisplayLastColumnCell,C=m(r,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isTopLeftCell","lastGroupRow","onExpandRowClick","pinned","row","rowIndex","shouldDisplayLastColumnCell"]),y=null===(t=w.rowMeta)||void 0===t?void 0:t.children;return e(V,g({allowAnimations:C.allowAnimations,allowHorizontalAnimate:C.shouldPaginate,draggedHeaderRef:C.draggedHeaderRef,headersRef:C.headersRef,isBody:!0,mainBodyRef:C.mainBodyRef,pauseAnimation:C.isWidthDragging,rowIndex:R+1},{children:[0!==R&&n(G,{lastGroupRow:h}),l.map((function(e,n){if(!N({hiddenColumns:c,header:e,pinned:p}))return null;var r=w.rowData[e.accessor];return e.cellRenderer&&(r=e.cellRenderer({accessor:e.accessor,colIndex:n,row:w})),u(j,g({},C,{borderClass:o(R,n),cellHasChildren:((null==y?void 0:y.length)||0)>0,colIndex:n,content:r,header:e,isSelected:s(R,n),isTopLeftCell:d(R,n),key:n,onExpandRowClick:v,onMouseDown:function(){return i({rowIndex:R,colIndex:n})},onMouseOver:function(){return a(R,n)},row:w,rowIndex:R}))})),n(F,{ref:f(),visible:b})]}))},q=function(e){var r=e.depth,t=void 0===r?0:r,o=e.getNextRowIndex,i=e.index,a=e.lastGroupRow,l=e.pinned,c=e.props,s=e.rowHeight,d=e.visibleRow,f=d.row,h=d.position,v=o(),m=c.headers.filter((function(e){return l===e.pinned})).map((function(e){return"".concat(e.width,"px")})).join(" ");return n("div",g({style:{display:"grid",gridTemplateColumns:m,position:"absolute",top:"".concat(h*s,"px"),height:"".concat(s,"px"),transform:"translateZ(0)",transition:"background 0.2s ease"}},{children:u(X,g({},c,{depth:t,lastGroupRow:a,key:i,pinned:l,row:f,rowIndex:v}))}))},Y=function(e){e.headerContainerRef;var r=e.onExpandRowClick,t=e.pinned,i=e.rowHeight,l=e.sectionRef;e.templateColumns;var c=e.totalHeight,s=e.visibleRows,d=e.width,u=m(e,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),f=t?"st-table-body-pinned-".concat(t):"st-table-body-main",h=o(0);a((function(){h.current=0}));var v=function(){return h.current++};return n("div",g({className:f,ref:l,style:{position:"relative",height:"".concat(c,"px"),width:d}},{children:s.map((function(e,o){var a,l;return n(q,{getNextRowIndex:v,index:o,lastGroupRow:Boolean(null===(l=null===(a=e.row.rowMeta)||void 0===a?void 0:a.children)||void 0===l?void 0:l.length),pinned:t,props:g(g({},u),{onExpandRowClick:r}),rowHeight:i,visibleRow:e},o)}))}))},K=function(r){var c,s,d,u,f,h=r.centerHeaderRef,v=r.currentRows,m=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,k=r.scrollbarWidth,N=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:m,mainSectionRef:N,scrollbarWidth:k});var L=o(null),T=o(null),B=t(v),O=B[0],A=B[1],W=t(1),P=W[0],z=W[1],U=t(!1),j=U[0],F=U[1],G=t(!0),V=G[0],J=G[1],X=t(0),q=X[0],K=X[1],Z=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),$=40*Z,Q=function(e){var n=function(r){return r.rowMeta.rowId===e&&r.rowMeta.children?g(g({},r),{rowMeta:g(g({},r.rowMeta),{isExpanded:!r.rowMeta.isExpanded})}):r.rowMeta.children?g(g({},r),{rowMeta:g(g({},r.rowMeta),{children:r.rowMeta.children.map(n)})}):r};A((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}({rows:O,scrollTop:q,containerHeight:600,rowHeight:40,bufferRowCount:15})}),[O,q]),ee=i((function(){return p(void 0,void 0,void 0,(function(){var e;return w(this,(function(n){return j||!V||(F(!0),e=v.slice(15*P,15*(P+1)),A((function(n){return R(R([],n,!0),e,!0)})),z((function(e){return e+1})),F(!1),e.length<5&&J(!1)),[2]}))}))}),[v,V,j,P]),ne=i((function(e){e[0].isIntersecting&&V&&!j&&ee()}),[V,j,ee]);a((function(){return L.current=new IntersectionObserver(ne,{root:null,rootMargin:"100px",threshold:0}),N.current&&L.current.observe(N.current),function(){L.current&&L.current.disconnect()}}),[ne,O,N]);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",g({className:"st-table-body-container",ref:N,onScroll:function(e){var n=e.currentTarget.scrollTop;T.current&&cancelAnimationFrame(T.current),T.current=requestAnimationFrame((function(){K(n)}))}},{children:[y.length>0&&n(Y,g({},r,{onExpandRowClick:Q,pinned:"left",rowHeight:40,sectionRef:H,templateColumns:I,totalHeight:$,visibleRows:_,width:re})),n(Y,g({},r,{onExpandRowClick:Q,rowHeight:40,sectionRef:b,templateColumns:C,totalHeight:$,visibleRows:_,width:te})),M.length>0&&n(Y,g({},r,{onExpandRowClick:Q,pinned:"right",rowHeight:40,sectionRef:E,templateColumns:S,totalHeight:$,visibleRows:_,width:oe}))]}))},Z={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 Z.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?Z.string(e,n,r):"number"==typeof e&&"number"==typeof n?Z.number(e,n,r):"boolean"==typeof e&&"boolean"==typeof n?Z.boolean(e,n,r):Z.string(String(e),String(n),r)}},$=function(e,n,r,t){switch(void 0===r&&(r="string"),r){case"string":return Z.string(String(e||""),String(n||""),t);case"number":return Z.number(Number(e||0),Number(n||0),t);case"boolean":return Z.boolean(Boolean(e),Boolean(n),t);case"date":return Z.date(String(e||""),String(n||""),t);case"enum":return Z.enum(String(e||""),String(n||""),t);default:return Z.default(e,n,t)}},Q=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 R([],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 $(l,c,o,i)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?g(g({},e),{rowMeta:g(g({},e.rowMeta),{children:Q(e.rowMeta.children,n,r)})}):e}))},_=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)})),R([],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 $(l,c,o,i)})).map((function(e){var t=g({},e);if(l.has(e.rowMeta.rowId)){var o=l.get(e.rowMeta.rowId)||[],i=Q(o,n,r);t.rowMeta=g(g({},t.rowMeta),{children:i})}return t}))}(n,r,e);return{sortedData:t,newSortConfig:r}},ee=function(e){var n=e.event,r=e.forceUpdate,t=e.header,o=e.headersRef,i=e.index;e.reverse;var a=e.setIsWidthDragging;a(!0),n.preventDefault();var l=n.clientX;if(t){var c=t.width,s=function(e){var n=Math.max(c+(e.clientX-l),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)}},ne=s((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,v=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],D=I[1],E=null===(i=f.current)||void 0===i?void 0:i[v],S=Boolean(null==E?void 0:E.isSortable),N="st-header-cell ".concat(E===h.current?"st-hovered":""," ").concat(M?"st-dragging":""," ").concat(S?"clickable":""," ").concat(s&&!S?"columnReordering":""," ").concat("right"===(null==E?void 0:E.align)?"right-aligned":""),L=U({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:p}),T=L.handleDragStart,B=L.handleDragEnd,O=U({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:p}).handleDragOver,A=W(),P=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(v)})),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(v,r.accessor)};if(a((function(){var e=function(e){e.preventDefault(),e.dataTransfer.dropEffect="move"};return document.addEventListener("dragover",e),function(){document.removeEventListener("dragover",e)}}),[]),!E)return null;var z=l&&n("div",{className:"st-header-resize-handle",onMouseDown:function(e){A({callback:ee,callbackProps:{event:e,forceUpdate:u,header:E,headersRef:f,index:v,setIsWidthDragging:b},limit:10})}});return e("div",g({className:N,id:k({accessor:E.accessor,rowIndex:0}),onDragOver:function(e){A({callback:O,callbackProps:{event:e,hoveredHeader:E},limit:50})},ref:o,style:{width:E.width}},{children:[w&&z,n("div",g({className:"st-header-label",draggable:s,onClick:function(e){return P({event:e,header:E})},onDragEnd:function(e){e.preventDefault(),D(!1),B()},onDragStart:function(e){s&&E&&function(e){D(!0),T(e)}(E)}},{children:null==E?void 0:E.label})),y&&y.key.accessor===E.accessor&&e("div",g({className:"st-sort-icon-container",onClick:function(e){return P({event:e,header:E})}},{children:["ascending"===y.direction&&H&&H,"descending"===y.direction&&x&&x]})),!w&&z]}))})),re=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])},te=function(r){var t,o,i,a=r.allowAnimations,l=r.centerHeaderRef,c=r.columnResizing,s=r.currentRows,d=r.columnReordering,u=r.draggedHeaderRef,h=r.forceUpdate,v=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,E=r.pinnedRightHeaderRef,S=r.pinnedRightTemplateColumns,k=r.selectableColumns,L=r.setIsWidthDragging,T=r.setSelectedCells,B=r.shouldDisplayLastColumnCell,O=r.sort,A=r.sortDownIcon,W=r.sortUpIcon;re(b,l);return e("div",g({className:"st-header-container",ref:v},{children:[H.length>0&&n("div",g({className:"st-header-pinned-left",ref:I,style:{gridTemplateColumns:M}},{children:n(V,g({allowAnimations:a,draggedHeaderRef:u,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:null===(t=m.current)||void 0===t?void 0:t.map((function(e,r){return N({hiddenColumns:p,header:e,pinned:"left"})?n(ne,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:u,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,ref:f(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},e.accessor):null}))}))})),n("div",g({className:"st-header-main",onScroll:function(e){var n,r,t=null===(n=l.current)||void 0===n?void 0:n.scrollLeft;void 0!==t&&(null===(r=b.current)||void 0===r||r.scrollTo(t,0))},ref:l,style:{gridTemplateColumns:C}},{children:e(V,g({allowAnimations:a,draggedHeaderRef:u,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:[null===(o=m.current)||void 0===o?void 0:o.map((function(e,r){return N({hiddenColumns:p,header:e})?n(ne,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:u,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,ref:f(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},e.accessor):null})),n(F,{ref:f(),visible:B})]}))})),D.length>0&&n("div",g({className:"st-header-pinned-right",ref:E,style:{gridTemplateColumns:S}},{children:e(V,g({allowAnimations:a,draggedHeaderRef:u,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:[null===(i=m.current)||void 0===i?void 0:i.map((function(e,r){return N({hiddenColumns:p,header:e,pinned:"right"})?n(ne,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:u,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,reverse:!0,ref:f(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},e.accessor):null})),n(F,{ref:f(),visible:B})]}))}))]}))},oe=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,v=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,k=r.setIsWidthDragging,N=r.setSelectedCells,L=r.shouldPaginate,T=r.sort,B=r.sortDownIcon,O=r.sortUpIcon,A=r.tableBodyContainerRef,W=o(null),P=o(null),z=o(null),U=o(null),j=m.current.filter((function(e){return!e.hide&&!e.pinned})),F=l((function(){return!!y.current&&j.reduce((function(e,n){return e+n.width}),0)<y.current.clientWidth}),[j,y]),G=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(G.map((function(e){return"".concat(e.width,"px")})).join(" "))}),[G]),X=l((function(){return"".concat(j.filter((function(e){return!0!==p[e.accessor]})).map((function(e){return"".concat(e.width,"px")})).join(" ")," 1fr")}),[j,p]),q=l((function(){return"".concat(V.map((function(e){return"".concat(e.width,"px")})).join(" "))}),[V]),Y={allowAnimations:t,centerHeaderRef:z,columnResizing:i,currentRows:a,columnReordering:c,draggedHeaderRef:s,forceUpdate:u,headerContainerRef:W,headersRef:m,hiddenColumns:p,hoveredHeaderRef:w,isWidthDragging:C,mainBodyRef:y,mainTemplateColumns:X,onSort:H,onTableHeaderDragEnd:I,pinnedLeftColumns:G,pinnedLeftHeaderRef:P,pinnedLeftTemplateColumns:J,pinnedRightColumns:V,pinnedRightHeaderRef:U,pinnedRightTemplateColumns:q,selectableColumns:S,setIsWidthDragging:k,setSelectedCells:N,shouldDisplayLastColumnCell:F,sort:T,sortDownIcon:B,sortUpIcon:O,tableBodyContainerRef:A},Z={allowAnimations:t,centerHeaderRef:z,currentRows:a,draggedHeaderRef:s,getBorderClass:f,handleMouseDown:h,handleMouseOver:v,headerContainerRef:W,headers:m.current,headersRef:m,hiddenColumns:p,hoveredHeaderRef:w,isSelected:R,isTopLeftCell:b,isWidthDragging:C,mainBodyRef:y,mainTemplateColumns:X,onCellEdit:x,onTableHeaderDragEnd:I,pinnedLeftColumns:G,pinnedLeftHeaderRef:P,pinnedLeftRef:M,pinnedLeftTemplateColumns:J,pinnedRightColumns:V,pinnedRightHeaderRef:U,pinnedRightRef:D,pinnedRightTemplateColumns:q,scrollbarWidth:E,shouldDisplayLastColumnCell:F,shouldPaginate:L,tableBodyContainerRef:A};return e("div",g({className:"st-table-content",style:{width:d?"calc(100% - 27.5px)":"100%"}},{children:[n(te,g({},Y)),n(K,g({},Z))]}))},ie=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])},ae=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],v=f[1],m=t(0),p=m[0],w=m[1],R=o(null);return ie({widthAttribute:"offsetWidth",callback:u,ref:a}),ie({widthAttribute:"scrollWidth",callback:w,ref:i}),ie({widthAttribute:"offsetWidth",callback:v,ref:l}),re(i,R),!i.current||i.current.scrollWidth<=i.current.clientWidth?null:e("div",g({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",g({className:"st-horizontal-scrollbar-middle",onScroll:function(e){var n=e.target.scrollLeft;void 0!==n&&i.current&&i.current.scrollTo({left:n,behavior:"auto"})},ref:R},{children:n("div",{style:{width:p}})})),h>0&&n("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:h}})]}))};!function(e){e.Left="left",e.Right="right"}(b||(b={}));var le=function(r){var c=r.allowAnimations,s=void 0!==c&&c,u=r.columnEditorPosition,f=void 0===u?b.Right:u,h=r.columnEditorText,m=void 0===h?"Columns":h,p=r.columnResizing,w=void 0!==p&&p,R=r.defaultHeaders,D=r.editColumns,E=void 0!==D&&D,k=r.editColumnsInitOpen,N=void 0!==k&&k,L=r.columnReordering,T=void 0!==L&&L,B=r.height,O=r.hideFooter,A=void 0!==O&&O,W=r.nextIcon,P=void 0===W?n(x,{className:"st-next-prev-icon"}):W,z=r.onCellEdit,U=r.onColumnOrderChange,j=r.prevIcon,F=void 0===j?n(y,{className:"st-next-prev-icon"}):j,G=r.rows,V=r.rowsPerPage,J=void 0===V?10:V,X=r.selectableCells,q=void 0!==X&&X,Y=r.selectableColumns,K=void 0!==Y&&Y,Z=r.shouldPaginate,$=void 0!==Z&&Z,Q=r.sortDownIcon,ee=void 0===Q?n(M,{className:"st-sort-icon"}):Q,ne=r.sortUpIcon,re=void 0===ne?n(I,{className:"st-sort-icon"}):ne,te=r.theme,ie=void 0===te?"light":te,le=l((function(){return G.map((function(e,n){return g(g({},e),{originalRowIndex:n})}))}),[G]),ce=o(null),se=o(R),de=o(null),ue=o(null),fe=o(null),he=o(null),ve=o(null),ge=t(!1),me=ge[0],pe=ge[1],we=t(1),Re=we[0],be=we[1],Ce=t(0),ye=Ce[0],xe=Ce[1],He=t(0),Ie=He[0],Me=He[1],De=function(e,n){var r=t(null),o=r[0],i=r[1],a=t({}),c=a[0],s=a[1],d=l((function(){return o?_(n,e,o).sortedData:e}),[e,o,n]);return{sort:o,setSort:i,updateSort:function(e,r){var t=n.find((function(e){return e.accessor===r}));t&&i((function(e){return e&&e.key.accessor===r?"ascending"===e.direction?{key:t,direction:"descending"}:null:{key:t,direction:"ascending"}}))},sortedRows:d,hiddenColumns:c,setHiddenColumns:s}}(le,se.current),Ee=De.sort,Se=De.sortedRows,ke=De.hiddenColumns,Ne=De.setHiddenColumns,Le=De.updateSort,Te=v((function(e){return e+1}),0)[1],Be=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");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:q,headers:se.current,rows:Se}),Oe=Be.handleMouseDown,Ae=Be.handleMouseOver,We=Be.handleMouseUp,Pe=Be.isSelected,ze=Be.getBorderClass,Ue=Be.isTopLeftCell,je=Be.setSelectedCells,Fe=l((function(){return $?Se.slice((Re-1)*J,Re*J):Se}),[Re,J,$,Se]),Ge=i((function(e,n){Le(e,n)}),[Le]),Ve=i((function(e){se.current=e,Te(),null==U||U(e)}),[]);return a((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||K&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||je(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[K,je]),d((function(){if(ve.current){var e=ve.current.offsetWidth-ve.current.clientWidth,n=ve.current.clientWidth;xe(e),Me(n)}}),[]),n(H.Provider,g({value:{rows:G,tableRows:le}},{children:e("div",g({className:"simple-table-root st-wrapper theme-".concat(ie),style:B?{height:B}:{}},{children:[e("div",g({className:"st-table-wrapper-container"},{children:[e("div",g({className:"st-table-wrapper",onMouseUp:We,onMouseLeave:We},{children:[n(oe,{allowAnimations:s,columnResizing:w,currentRows:Fe,draggedHeaderRef:ce,editColumns:E,columnReordering:T,forceUpdate:Te,getBorderClass:ze,handleMouseDown:Oe,handleMouseOver:Ae,headers:se.current,headersRef:se,hiddenColumns:ke,hoveredHeaderRef:de,isSelected:Pe,isTopLeftCell:Ue,isWidthDragging:me,mainBodyRef:ue,onCellEdit:z,onSort:Ge,onTableHeaderDragEnd:Ve,pinnedLeftRef:fe,pinnedRightRef:he,scrollbarWidth:ye,selectableColumns:K,setIsWidthDragging:pe,setSelectedCells:je,shouldPaginate:$,sort:Ee,sortDownIcon:ee,sortUpIcon:re,tableBodyContainerRef:ve}),n(S,{columnEditorText:m,editColumns:E,editColumnsInitOpen:N,headers:se.current,hiddenColumns:ke,position:f,setHiddenColumns:Ne})]})),n(ae,{mainBodyRef:ue,pinnedLeftRef:fe,pinnedRightRef:he,tableContentWidth:Ie})]})),n(C,{currentPage:Re,hideFooter:A,nextIcon:P,onPageChange:be,prevIcon:F,rowsPerPage:J,shouldPaginate:$,totalRows:Se.length})]}))}))};le.defaultProps={allowAnimations:!1,columnEditorPosition:b.Right,columnEditorText:"Columns",columnResizing:!1,defaultHeaders:[],editColumns:!1,editColumnsInitOpen:!1,columnReordering:!1,height:"",hideFooter:!1,nextIcon:n(x,{className:"st-next-prev-icon"}),onCellEdit:function(){},prevIcon:n(y,{className:"st-next-prev-icon"}),rows:[],rowsPerPage:10,selectableCells:!1,selectableColumns:!1,shouldPaginate:!1,sortDownIcon:n(M,{className:"st-sort-icon"}),sortUpIcon:n(I,{className:"st-sort-icon"}),theme:"light"};var ce=h(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,createContext as c,forwardRef as s,useLayoutEffect as d,createElement as u,createRef as f,memo as h,useReducer as v}from"react";var g=function(){return g=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},g.apply(this,arguments)};function m(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 p(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 w(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 R(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 b,C=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,v=function(e){e>=1&&e<=u&&a(e)};return o||!s?null:(console.log("totalPages",u),e("div",g({className:"st-footer"},{children:[n("button",g({className:"st-next-prev-btn ".concat(f?"":"disabled"),onClick:function(){return v(t-1)},disabled:!f},{children:l})),n("button",g({className:"st-next-prev-btn ".concat(h?"":"disabled"),onClick:function(){return v(t+1)},disabled:!h},{children:i})),Array.from({length:u},(function(e,r){return n("button",g({onClick:function(){return v(r+1)},className:"st-page-btn ".concat(t===r+1?"active":"")},{children:r+1}),r)}))]})))},y=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})}))},x=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})}))},H=c({rows:[],tableRows:[]}),I=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M5.41 11.41L10 6.83l4.59 4.58L16 10l-6-6-6 6z"})}))},M=function(e){var r=e.className;return n("svg",g({className:r,viewBox:"0 0 24 24",width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M5.41 7.59L10 12.17l4.59-4.58L16 9l-6 6-6-6z"})}))},D=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",g({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",g({className:"st-checkbox-custom ".concat(s?"st-checked":"")},{children:s&&n("span",{className:"st-checkbox-checkmark"})})),a]}))},E=function(e){var r=e.headers,t=e.open,o=e.position;e.setOpen;var i=e.setHiddenColumns,a=e.hiddenColumns,l="left"===o?"left":"";return n("div",g({className:"st-column-editor-popout ".concat(t?"open":""," ").concat(l),onClick:function(e){return e.stopPropagation()}},{children:n("div",g({className:"st-column-editor-popout-content"},{children:r.map((function(e,r){return n(D,g({checked:a[e.accessor],onChange:function(n){var r;return i(g(g({},a),((r={})[e.accessor]=n,r)))}},{children:e.label}),r)}))}))}))},S=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],v=f[1];return i?e("div",g({className:"st-column-editor ".concat(h?"open":""," ").concat(s),onClick:function(){return function(e){v(e)}(!h)}},{children:[n("div",g({className:"st-column-editor-text"},{children:o})),n(E,{headers:l,open:h,position:s,setOpen:v,setHiddenColumns:d,hiddenColumns:u})]})):null},k=function(e){var n=e.accessor,r=e.rowIndex;return"cell-".concat(n,"-").concat(r)},N=function(e){var n=e.hiddenColumns,r=e.header,t=e.pinned;return n[r.accessor]?null:!t&&!r.pinned||r.pinned===t||null},L=function(r){var t=r.value,o=r.onBlur,i=r.onChange;return e("select",g({value:t.toString(),onBlur:o,onChange:function(e){var n=e.target.value;i("true"===n)}},{children:[n("option",g({value:"true"},{children:"True"})),n("option",g({value:"false"},{children:"False"}))]}))},T=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)}})},B=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)}})},O=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(T,{defaultValue:i,onBlur:l,onChange:a}):"boolean"==typeof i?n(L,{onBlur:l,onChange:a,value:i}):"number"==typeof i?n(B,{defaultValue:i,onBlur:l,onChange:a}):null})},A=0,W=function(){return function(e){var n=e.callback,r=e.callbackProps,t=e.limit,o=Date.now();(0===A||o-A>=t)&&(A=o,n(r))}},P=Date.now(),z={screenX:0,screenY:0},U=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,P=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-z.screenX,2)+Math.pow(u-z.screenY,2));l.current=o;var h=R([],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-P<800&&f<50||(P=p,z={screenX:d,screenY:u},c(h))}}},handleDragEnd:function(){t.current=null,l.current=null}}},j=s((function(r,o){var i=r.borderClass,l=r.cellHasChildren,c=r.colIndex,s=r.content,d=r.depth,u=r.draggedHeaderRef,f=r.header,h=r.headersRef,v=r.hoveredHeaderRef,m=r.isSelected,p=r.isTopLeftCell,w=r.onCellEdit,R=r.onExpandRowClick,b=r.onMouseDown,C=r.onMouseOver,y=r.onTableHeaderDragEnd,H=r.row,I=r.rowIndex,D=t(s),E=D[0],S=D[1],N=t(!1),L=N[0],T=N[1],B=U({draggedHeaderRef:u,headersRef:h,hoveredHeaderRef:v,onTableHeaderDragEnd:y}).handleDragOver,A=W(),P=Boolean(null==f?void 0:f.isEditable),z=I%2==0,j="st-cell ".concat(d>0&&f.expandable?"st-cell-depth-".concat(d):""," ").concat(m?p?"st-cell-selected-first-cell ".concat(i):"st-cell-selected ".concat(i):""," ").concat(z?"st-cell-odd-row":"st-cell-even-row"," ").concat(P?"clickable":""," ").concat("right"===f.align?"right-aligned":"");a((function(){"object"!=typeof s&&S(s)}),[s]);return L?n("div",g({className:"st-cell-editing ".concat(z?"st-cell-odd-row":"st-cell-even-row"),id:k({accessor:f.accessor,rowIndex:I+1})},{children:n(O,{onChange:function(e){S(e),null==w||w({accessor:f.accessor,newValue:e,row:H})},setIsEditing:T,value:E})})):e("div",g({className:j,id:k({accessor:f.accessor,rowIndex:I+1}),onDoubleClick:function(){return f.isEditable&&T(!0)},onMouseDown:function(){return b(I,c)},onMouseOver:function(){return C(I,c)},onDragOver:function(e){return A({callback:B,callbackProps:{event:e,hoveredHeader:f},limit:50})},ref:o},{children:[f.expandable&&l?H.rowMeta.isExpanded?n("div",g({className:"st-sort-icon-container",onClick:function(){return R(H.rowMeta.rowId)}},{children:n(M,{className:"st-sort-icon"})})):n("div",g({className:"st-sort-icon-container",onClick:function(){return R(H.rowMeta.rowId)}},{children:n(x,{className:"st-sort-icon"})})):null,n("span",{children:E})]}))})),F=s((function(e,r){return e.visible?n("div",{className:"st-cell",ref:r}):n("div",{ref:r})})),G=function(e){var r=e.lastGroupRow;return n("div",{className:"st-row-separator ".concat(r?"st-last-group-row":"")})},V=function(e){var t=e.allowAnimations,o=e.children,i=m(e,["allowAnimations","children"]);return t?n(J,g({},i,{children:o})):n(r,{children:o})},J=function(e){var i=e.allowHorizontalAnimate,l=void 0===i||i,c=e.children,s=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 d((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(k({accessor:e.accessor,rowIndex:t}));if(i){var a=i.getAnimations().some((function(e){return"running"===e.playState})),l=i.getBoundingClientRect();a&&(null===(n=null==r?void 0:r.current)||void 0===n?void 0:n.accessor)!==e.accessor?o[e.accessor]=!1:o[e.accessor]=l}}})),o}({currentHeaders:C,draggedHeaderRef:s,rowIndex:g});JSON.stringify(e)!==JSON.stringify(w)&&(b.current=w,R(e))}}),[w,C,s,f,g]),d((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)}}),[s,h]),a((function(){v||m.current||Object.keys(b.current).length&&C&&C.forEach((function(e){var n=document.getElementById(k({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})},X=function(r){var t,o=r.getBorderClass,i=r.handleMouseDown,a=r.handleMouseOver,l=r.headers,c=r.hiddenColumns,s=r.isSelected,d=r.isTopLeftCell,h=r.lastGroupRow,v=r.onExpandRowClick,p=r.pinned,w=r.row,R=r.rowIndex,b=r.shouldDisplayLastColumnCell,C=m(r,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isTopLeftCell","lastGroupRow","onExpandRowClick","pinned","row","rowIndex","shouldDisplayLastColumnCell"]),y=null===(t=w.rowMeta)||void 0===t?void 0:t.children;return e(V,g({allowAnimations:C.allowAnimations,allowHorizontalAnimate:C.shouldPaginate,draggedHeaderRef:C.draggedHeaderRef,headersRef:C.headersRef,isBody:!0,mainBodyRef:C.mainBodyRef,pauseAnimation:C.isWidthDragging,rowIndex:R+1},{children:[0!==R&&n(G,{lastGroupRow:h}),l.map((function(e,n){if(!N({hiddenColumns:c,header:e,pinned:p}))return null;var r=w.rowData[e.accessor];return e.cellRenderer&&(r=e.cellRenderer({accessor:e.accessor,colIndex:n,row:w})),u(j,g({},C,{borderClass:o(R,n),cellHasChildren:((null==y?void 0:y.length)||0)>0,colIndex:n,content:r,header:e,isSelected:s(R,n),isTopLeftCell:d(R,n),key:n,onExpandRowClick:v,onMouseDown:function(){return i({rowIndex:R,colIndex:n})},onMouseOver:function(){return a(R,n)},row:w,rowIndex:R}))})),n(F,{ref:f(),visible:b})]}))},q=function(e){var r=e.depth,t=void 0===r?0:r,o=e.getNextRowIndex,i=e.index,a=e.lastGroupRow,l=e.pinned,c=e.props,s=e.rowHeight,d=e.visibleRow,f=d.row,h=d.position,v=o(),m=c.headers.filter((function(e){return l===e.pinned})).map((function(e){return"".concat(e.width,"px")})).join(" ");return n("div",g({style:{display:"grid",gridTemplateColumns:m,position:"absolute",top:"".concat(h*s,"px"),height:"".concat(s,"px"),transform:"translateZ(0)",transition:"background 0.2s ease"}},{children:u(X,g({},c,{depth:t,lastGroupRow:a,key:i,pinned:l,row:f,rowIndex:v}))}))},Y=function(e){e.headerContainerRef;var r=e.onExpandRowClick,t=e.pinned,i=e.rowHeight,l=e.sectionRef;e.templateColumns;var c=e.totalHeight,s=e.visibleRows,d=e.width,u=m(e,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),f=t?"st-table-body-pinned-".concat(t):"st-table-body-main",h=o(0);a((function(){h.current=0}));var v=function(){return h.current++};return n("div",g({className:f,ref:l,style:{position:"relative",height:"".concat(c,"px"),width:d}},{children:s.map((function(e,o){var a,l;return n(q,{getNextRowIndex:v,index:o,lastGroupRow:Boolean(null===(l=null===(a=e.row.rowMeta)||void 0===a?void 0:a.children)||void 0===l?void 0:l.length),pinned:t,props:g(g({},u),{onExpandRowClick:r}),rowHeight:i,visibleRow:e},o)}))}))},K=function(r){var c,s,d,u,f,h=r.centerHeaderRef,v=r.currentRows,m=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,k=r.scrollbarWidth,N=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:m,mainSectionRef:N,scrollbarWidth:k});var L=o(null),T=o(null),B=t(v),O=B[0],A=B[1],W=t(1),P=W[0],z=W[1],U=t(!1),j=U[0],F=U[1],G=t(!0),V=G[0],J=G[1],X=t(0),q=X[0],K=X[1],Z=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),$=40*Z,Q=function(e){var n=function(r){return r.rowMeta.rowId===e&&r.rowMeta.children?g(g({},r),{rowMeta:g(g({},r.rowMeta),{isExpanded:!r.rowMeta.isExpanded})}):r.rowMeta.children?g(g({},r),{rowMeta:g(g({},r.rowMeta),{children:r.rowMeta.children.map(n)})}):r};A((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}({rows:O,scrollTop:q,containerHeight:600,rowHeight:40,bufferRowCount:15})}),[O,q]),ee=i((function(){return p(void 0,void 0,void 0,(function(){var e;return w(this,(function(n){return j||!V||(F(!0),e=v.slice(15*P,15*(P+1)),A((function(n){return R(R([],n,!0),e,!0)})),z((function(e){return e+1})),F(!1),e.length<5&&J(!1)),[2]}))}))}),[v,V,j,P]),ne=i((function(e){e[0].isIntersecting&&V&&!j&&ee()}),[V,j,ee]);a((function(){return L.current=new IntersectionObserver(ne,{root:null,rootMargin:"100px",threshold:0}),N.current&&L.current.observe(N.current),function(){L.current&&L.current.disconnect()}}),[ne,O,N]);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",g({className:"st-table-body-container",ref:N,onScroll:function(e){var n=e.currentTarget.scrollTop;T.current&&cancelAnimationFrame(T.current),T.current=requestAnimationFrame((function(){K(n)}))}},{children:[y.length>0&&n(Y,g({},r,{onExpandRowClick:Q,pinned:"left",rowHeight:40,sectionRef:H,templateColumns:I,totalHeight:$,visibleRows:_,width:re})),n(Y,g({},r,{onExpandRowClick:Q,rowHeight:40,sectionRef:b,templateColumns:C,totalHeight:$,visibleRows:_,width:te})),M.length>0&&n(Y,g({},r,{onExpandRowClick:Q,pinned:"right",rowHeight:40,sectionRef:E,templateColumns:S,totalHeight:$,visibleRows:_,width:oe}))]}))},Z={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 Z.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?Z.string(e,n,r):"number"==typeof e&&"number"==typeof n?Z.number(e,n,r):"boolean"==typeof e&&"boolean"==typeof n?Z.boolean(e,n,r):Z.string(String(e),String(n),r)}},$=function(e,n,r,t){switch(void 0===r&&(r="string"),r){case"string":return Z.string(String(e||""),String(n||""),t);case"number":return Z.number(Number(e||0),Number(n||0),t);case"boolean":return Z.boolean(Boolean(e),Boolean(n),t);case"date":return Z.date(String(e||""),String(n||""),t);case"enum":return Z.enum(String(e||""),String(n||""),t);default:return Z.default(e,n,t)}},Q=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 R([],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 $(l,c,o,i)})).map((function(e){return e.rowMeta.children&&e.rowMeta.children.length>0?g(g({},e),{rowMeta:g(g({},e.rowMeta),{children:Q(e.rowMeta.children,n,r)})}):e}))},_=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)})),R([],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 $(l,c,o,i)})).map((function(e){var t=g({},e);if(l.has(e.rowMeta.rowId)){var o=l.get(e.rowMeta.rowId)||[],i=Q(o,n,r);t.rowMeta=g(g({},t.rowMeta),{children:i})}return t}))}(n,r,e);return{sortedData:t,newSortConfig:r}},ee=function(e){var n=e.event,r=e.forceUpdate,t=e.header,o=e.headersRef,i=e.index;e.reverse;var a=e.setIsWidthDragging;a(!0),n.preventDefault();var l=n.clientX;if(t){var c=t.width,s=function(e){var n=Math.max(c+(e.clientX-l),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)}},ne=s((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,v=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],D=I[1],E=null===(i=f.current)||void 0===i?void 0:i[v],S=Boolean(null==E?void 0:E.isSortable),N="st-header-cell ".concat(E===h.current?"st-hovered":""," ").concat(M?"st-dragging":""," ").concat(S?"clickable":""," ").concat(s&&!S?"columnReordering":""," ").concat("right"===(null==E?void 0:E.align)?"right-aligned":""),L=U({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:p}),T=L.handleDragStart,B=L.handleDragEnd,O=U({draggedHeaderRef:d,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:p}).handleDragOver,A=W(),P=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(v)})),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(v,r.accessor)};if(a((function(){var e=function(e){e.preventDefault(),e.dataTransfer.dropEffect="move"};return document.addEventListener("dragover",e),function(){document.removeEventListener("dragover",e)}}),[]),!E)return null;var z=l&&n("div",{className:"st-header-resize-handle",onMouseDown:function(e){A({callback:ee,callbackProps:{event:e,forceUpdate:u,header:E,headersRef:f,index:v,setIsWidthDragging:b},limit:10})}});return e("div",g({className:N,id:k({accessor:E.accessor,rowIndex:0}),onDragOver:function(e){A({callback:O,callbackProps:{event:e,hoveredHeader:E},limit:50})},ref:o,style:{width:E.width}},{children:[w&&z,n("div",g({className:"st-header-label",draggable:s,onClick:function(e){return P({event:e,header:E})},onDragEnd:function(e){e.preventDefault(),D(!1),B()},onDragStart:function(e){s&&E&&function(e){D(!0),T(e)}(E)}},{children:null==E?void 0:E.label})),y&&y.key.accessor===E.accessor&&e("div",g({className:"st-sort-icon-container",onClick:function(e){return P({event:e,header:E})}},{children:["ascending"===y.direction&&H&&H,"descending"===y.direction&&x&&x]})),!w&&z]}))})),re=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])},te=function(r){var t,o,i,a=r.allowAnimations,l=r.centerHeaderRef,c=r.columnResizing,s=r.currentRows,d=r.columnReordering,u=r.draggedHeaderRef,h=r.forceUpdate,v=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,E=r.pinnedRightHeaderRef,S=r.pinnedRightTemplateColumns,k=r.selectableColumns,L=r.setIsWidthDragging,T=r.setSelectedCells,B=r.shouldDisplayLastColumnCell,O=r.sort,A=r.sortDownIcon,W=r.sortUpIcon;re(b,l);return e("div",g({className:"st-header-container",ref:v},{children:[H.length>0&&n("div",g({className:"st-header-pinned-left",ref:I,style:{gridTemplateColumns:M}},{children:n(V,g({allowAnimations:a,draggedHeaderRef:u,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:null===(t=m.current)||void 0===t?void 0:t.map((function(e,r){return N({hiddenColumns:p,header:e,pinned:"left"})?n(ne,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:u,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,ref:f(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},e.accessor):null}))}))})),n("div",g({className:"st-header-main",onScroll:function(e){var n,r,t=null===(n=l.current)||void 0===n?void 0:n.scrollLeft;void 0!==t&&(null===(r=b.current)||void 0===r||r.scrollTo(t,0))},ref:l,style:{gridTemplateColumns:C}},{children:e(V,g({allowAnimations:a,draggedHeaderRef:u,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:[null===(o=m.current)||void 0===o?void 0:o.map((function(e,r){return N({hiddenColumns:p,header:e})?n(ne,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:u,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,ref:f(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},e.accessor):null})),n(F,{ref:f(),visible:B})]}))})),D.length>0&&n("div",g({className:"st-header-pinned-right",ref:E,style:{gridTemplateColumns:S}},{children:e(V,g({allowAnimations:a,draggedHeaderRef:u,headersRef:m,mainBodyRef:b,pauseAnimation:R,rowIndex:0},{children:[null===(i=m.current)||void 0===i?void 0:i.map((function(e,r){return N({hiddenColumns:p,header:e,pinned:"right"})?n(ne,{columnResizing:c,currentRows:s,columnReordering:d,draggedHeaderRef:u,forceUpdate:h,headersRef:m,hoveredHeaderRef:w,index:r,onSort:y,onTableHeaderDragEnd:x,reverse:!0,ref:f(),selectableColumns:k,setIsWidthDragging:L,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},e.accessor):null})),n(F,{ref:f(),visible:B})]}))}))]}))},oe=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,v=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,k=r.setIsWidthDragging,N=r.setSelectedCells,L=r.shouldPaginate,T=r.sort,B=r.sortDownIcon,O=r.sortUpIcon,A=r.tableBodyContainerRef,W=o(null),P=o(null),z=o(null),U=o(null),j=m.current.filter((function(e){return!e.hide&&!e.pinned})),F=l((function(){return!!y.current&&j.reduce((function(e,n){return e+n.width}),0)<y.current.clientWidth}),[j,y]),G=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(G.map((function(e){return"".concat(e.width,"px")})).join(" "))}),[G]),X=l((function(){return"".concat(j.filter((function(e){return!0!==p[e.accessor]})).map((function(e){return"".concat(e.width,"px")})).join(" ")," 1fr")}),[j,p]),q=l((function(){return"".concat(V.map((function(e){return"".concat(e.width,"px")})).join(" "))}),[V]),Y={allowAnimations:t,centerHeaderRef:z,columnResizing:i,currentRows:a,columnReordering:c,draggedHeaderRef:s,forceUpdate:u,headerContainerRef:W,headersRef:m,hiddenColumns:p,hoveredHeaderRef:w,isWidthDragging:C,mainBodyRef:y,mainTemplateColumns:X,onSort:H,onTableHeaderDragEnd:I,pinnedLeftColumns:G,pinnedLeftHeaderRef:P,pinnedLeftTemplateColumns:J,pinnedRightColumns:V,pinnedRightHeaderRef:U,pinnedRightTemplateColumns:q,selectableColumns:S,setIsWidthDragging:k,setSelectedCells:N,shouldDisplayLastColumnCell:F,sort:T,sortDownIcon:B,sortUpIcon:O,tableBodyContainerRef:A},Z={allowAnimations:t,centerHeaderRef:z,currentRows:a,draggedHeaderRef:s,getBorderClass:f,handleMouseDown:h,handleMouseOver:v,headerContainerRef:W,headers:m.current,headersRef:m,hiddenColumns:p,hoveredHeaderRef:w,isSelected:R,isTopLeftCell:b,isWidthDragging:C,mainBodyRef:y,mainTemplateColumns:X,onCellEdit:x,onTableHeaderDragEnd:I,pinnedLeftColumns:G,pinnedLeftHeaderRef:P,pinnedLeftRef:M,pinnedLeftTemplateColumns:J,pinnedRightColumns:V,pinnedRightHeaderRef:U,pinnedRightRef:D,pinnedRightTemplateColumns:q,scrollbarWidth:E,shouldDisplayLastColumnCell:F,shouldPaginate:L,tableBodyContainerRef:A};return e("div",g({className:"st-table-content",style:{width:d?"calc(100% - 27.5px)":"100%"}},{children:[n(te,g({},Y)),n(K,g({},Z))]}))},ie=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])},ae=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],v=f[1],m=t(0),p=m[0],w=m[1],R=o(null);return ie({widthAttribute:"offsetWidth",callback:u,ref:a}),ie({widthAttribute:"scrollWidth",callback:w,ref:i}),ie({widthAttribute:"offsetWidth",callback:v,ref:l}),re(i,R),!i.current||i.current.scrollWidth<=i.current.clientWidth?null:e("div",g({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",g({className:"st-horizontal-scrollbar-middle",onScroll:function(e){var n=e.target.scrollLeft;void 0!==n&&i.current&&i.current.scrollTo({left:n,behavior:"auto"})},ref:R},{children:n("div",{style:{width:p}})})),h>0&&n("div",{className:"st-horizontal-scrollbar-right",style:{flexShrink:0,minWidth:h}})]}))};!function(e){e.Left="left",e.Right="right"}(b||(b={}));var le=function(r){var c=r.allowAnimations,s=void 0!==c&&c,u=r.columnEditorPosition,f=void 0===u?b.Right:u,h=r.columnEditorText,m=void 0===h?"Columns":h,p=r.columnResizing,w=void 0!==p&&p,R=r.defaultHeaders,D=r.editColumns,E=void 0!==D&&D,k=r.editColumnsInitOpen,N=void 0!==k&&k,L=r.columnReordering,T=void 0!==L&&L,B=r.height,O=r.hideFooter,A=void 0!==O&&O,W=r.nextIcon,P=void 0===W?n(x,{className:"st-next-prev-icon"}):W,z=r.onCellEdit,U=r.onColumnOrderChange,j=r.prevIcon,F=void 0===j?n(y,{className:"st-next-prev-icon"}):j,G=r.rows,V=r.rowsPerPage,J=void 0===V?10:V,X=r.selectableCells,q=void 0!==X&&X,Y=r.selectableColumns,K=void 0!==Y&&Y,Z=r.shouldPaginate,$=void 0!==Z&&Z,Q=r.sortDownIcon,ee=void 0===Q?n(M,{className:"st-sort-icon"}):Q,ne=r.sortUpIcon,re=void 0===ne?n(I,{className:"st-sort-icon"}):ne,te=r.theme,ie=void 0===te?"light":te,le=l((function(){return G.map((function(e,n){return g(g({},e),{originalRowIndex:n})}))}),[G]),ce=o(null),se=o(R),de=o(null),ue=o(null),fe=o(null),he=o(null),ve=o(null),ge=t(!1),me=ge[0],pe=ge[1],we=t(1),Re=we[0],be=we[1],Ce=t(0),ye=Ce[0],xe=Ce[1],He=t(0),Ie=He[0],Me=He[1],De=function(e,n){var r=t(null),o=r[0],i=r[1],a=t({}),c=a[0],s=a[1],d=l((function(){return o?_(n,e,o).sortedData:e}),[e,o,n]);return{sort:o,setSort:i,updateSort:function(e,r){var t=n.find((function(e){return e.accessor===r}));t&&i((function(e){return e&&e.key.accessor===r?"ascending"===e.direction?{key:t,direction:"descending"}:null:{key:t,direction:"ascending"}}))},sortedRows:d,hiddenColumns:c,setHiddenColumns:s}}(le,se.current),Ee=De.sort,Se=De.sortedRows,ke=De.hiddenColumns,Ne=De.setHiddenColumns,Le=De.updateSort,Te=v((function(e){return e+1}),0)[1],Be=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:q,headers:se.current,rows:Se}),Oe=Be.handleMouseDown,Ae=Be.handleMouseOver,We=Be.handleMouseUp,Pe=Be.isSelected,ze=Be.getBorderClass,Ue=Be.isTopLeftCell,je=Be.setSelectedCells,Fe=l((function(){return $?Se.slice((Re-1)*J,Re*J):Se}),[Re,J,$,Se]),Ge=i((function(e,n){Le(e,n)}),[Le]),Ve=i((function(e){se.current=e,Te(),null==U||U(e)}),[]);return a((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||K&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||je(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[K,je]),d((function(){if(ve.current){var e=ve.current.offsetWidth-ve.current.clientWidth,n=ve.current.clientWidth;xe(e),Me(n)}}),[]),n(H.Provider,g({value:{rows:G,tableRows:le}},{children:e("div",g({className:"simple-table-root st-wrapper theme-".concat(ie),style:B?{height:B}:{}},{children:[e("div",g({className:"st-table-wrapper-container"},{children:[e("div",g({className:"st-table-wrapper",onMouseUp:We,onMouseLeave:We},{children:[n(oe,{allowAnimations:s,columnResizing:w,currentRows:Fe,draggedHeaderRef:ce,editColumns:E,columnReordering:T,forceUpdate:Te,getBorderClass:ze,handleMouseDown:Oe,handleMouseOver:Ae,headers:se.current,headersRef:se,hiddenColumns:ke,hoveredHeaderRef:de,isSelected:Pe,isTopLeftCell:Ue,isWidthDragging:me,mainBodyRef:ue,onCellEdit:z,onSort:Ge,onTableHeaderDragEnd:Ve,pinnedLeftRef:fe,pinnedRightRef:he,scrollbarWidth:ye,selectableColumns:K,setIsWidthDragging:pe,setSelectedCells:je,shouldPaginate:$,sort:Ee,sortDownIcon:ee,sortUpIcon:re,tableBodyContainerRef:ve}),n(S,{columnEditorText:m,editColumns:E,editColumnsInitOpen:N,headers:se.current,hiddenColumns:ke,position:f,setHiddenColumns:Ne})]})),n(ae,{mainBodyRef:ue,pinnedLeftRef:fe,pinnedRightRef:he,tableContentWidth:Ie})]})),n(C,{currentPage:Re,hideFooter:A,nextIcon:P,onPageChange:be,prevIcon:F,rowsPerPage:J,shouldPaginate:$,totalRows:Se.length})]}))}))};le.defaultProps={allowAnimations:!1,columnEditorPosition:b.Right,columnEditorText:"Columns",columnResizing:!1,defaultHeaders:[],editColumns:!1,editColumnsInitOpen:!1,columnReordering:!1,height:"",hideFooter:!1,nextIcon:n(x,{className:"st-next-prev-icon"}),onCellEdit:function(){},prevIcon:n(y,{className:"st-next-prev-icon"}),rows:[],rowsPerPage:10,selectableCells:!1,selectableColumns:!1,shouldPaginate:!1,sortDownIcon:n(M,{className:"st-sort-icon"}),sortUpIcon:n(I,{className:"st-sort-icon"}),theme:"light"};var ce=h(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:(console.log("totalPages",u),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=n.createContext({rows:[],tableRows:[]}),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 11.41L10 6.83l4.59 4.58L16 10l-6-6-6 6z"})}))},h=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"})}))},v=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]}))},m=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(v,t({checked:s[n.accessor],onChange:function(e){var r;return i(t(t({},s),((r={})[n.accessor]=e,r)))}},{children:n.label}),r)}))}))}))},g=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(m,{headers:s,open:h,position:c,setOpen:v,setHiddenColumns:d,hiddenColumns:u})]})):null},p=function(e){var n=e.accessor,t=e.rowIndex;return"cell-".concat(n,"-").concat(t)},w=function(e){var n=e.hiddenColumns,t=e.header,r=e.pinned;return n[t.accessor]?null:!r&&!t.pinned||t.pinned===r||null},R=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"}))]}))},x=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)}})},b=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)}})},C=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(x,{defaultValue:o,onBlur:i,onChange:a}):"boolean"==typeof o?e.jsx(R,{onBlur:i,onChange:a,value:o}):"number"==typeof o?e.jsx(b,{defaultValue:o,onBlur:i,onChange:a}):null})},y=0,j=function(){return function(e){var n=e.callback,t=e.callbackProps,r=e.limit,o=Date.now();(0===y||o-y>=r)&&(y=o,n(t))}},H=Date.now(),S={screenX:0,screenY:0},M=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,H=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-S.screenX,2)+Math.pow(f-S.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-H<800&&h<50||(H=w,S={screenX:u,screenY:f},l(v))}}},handleDragEnd:function(){o.current=null,s.current=null}}},E=n.forwardRef((function(r,o){var a=r.borderClass,i=r.cellHasChildren,s=r.colIndex,l=r.content,c=r.depth,u=r.draggedHeaderRef,f=r.header,v=r.headersRef,m=r.hoveredHeaderRef,g=r.isSelected,w=r.isTopLeftCell,R=r.onCellEdit,x=r.onExpandRowClick,b=r.onMouseDown,y=r.onMouseOver,H=r.onTableHeaderDragEnd,S=r.row,E=r.rowIndex,I=n.useState(l),D=I[0],k=I[1],L=n.useState(!1),N=L[0],T=L[1],B=M({draggedHeaderRef:u,headersRef:v,hoveredHeaderRef:m,onTableHeaderDragEnd:H}).handleDragOver,O=j(),A=Boolean(null==f?void 0:f.isEditable),W=E%2==0,P="st-cell ".concat(c>0&&f.expandable?"st-cell-depth-".concat(c):""," ").concat(g?w?"st-cell-selected-first-cell ".concat(a):"st-cell-selected ".concat(a):""," ").concat(W?"st-cell-odd-row":"st-cell-even-row"," ").concat(A?"clickable":""," ").concat("right"===f.align?"right-aligned":"");n.useEffect((function(){"object"!=typeof l&&k(l)}),[l]);return N?e.jsx("div",t({className:"st-cell-editing ".concat(W?"st-cell-odd-row":"st-cell-even-row"),id:p({accessor:f.accessor,rowIndex:E+1})},{children:e.jsx(C,{onChange:function(e){k(e),null==R||R({accessor:f.accessor,newValue:e,row:S})},setIsEditing:T,value:D})})):e.jsxs("div",t({className:P,id:p({accessor:f.accessor,rowIndex:E+1}),onDoubleClick:function(){return f.isEditable&&T(!0)},onMouseDown:function(){return b(E,s)},onMouseOver:function(){return y(E,s)},onDragOver:function(e){return O({callback:B,callbackProps:{event:e,hoveredHeader:f},limit:50})},ref:o},{children:[f.expandable&&i?S.rowMeta.isExpanded?e.jsx("div",t({className:"st-sort-icon-container",onClick:function(){return x(S.rowMeta.rowId)}},{children:e.jsx(h,{className:"st-sort-icon"})})):e.jsx("div",t({className:"st-sort-icon-container",onClick:function(){return x(S.rowMeta.rowId)}},{children:e.jsx(d,{className:"st-sort-icon"})})):null,e.jsx("span",{children:D})]}))})),I=n.forwardRef((function(n,t){return n.visible?e.jsx("div",{className:"st-cell",ref:t}):e.jsx("div",{ref:t})})),D=function(n){var t=n.lastGroupRow;return e.jsx("div",{className:"st-row-separator ".concat(t?"st-last-group-row":"")})},k=function(n){var o=n.allowAnimations,a=n.children,i=r(n,["allowAnimations","children"]);return o?e.jsx(L,t({},i,{children:a})):e.jsx(e.Fragment,{children:a})},L=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],m=h[1],g=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(p({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)&&(g.current=v,m(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(g.current).length&&w&&w.forEach((function(e){var n=document.getElementById(p({accessor:e.accessor,rowIndex:u}));if(n){var t=g.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,g,u]),e.jsx(e.Fragment,{children:a})},N=function(o){var a,i=o.getBorderClass,s=o.handleMouseDown,l=o.handleMouseOver,c=o.headers,d=o.hiddenColumns,u=o.isSelected,f=o.isTopLeftCell,h=o.lastGroupRow,v=o.onExpandRowClick,m=o.pinned,g=o.row,p=o.rowIndex,R=o.shouldDisplayLastColumnCell,x=r(o,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isTopLeftCell","lastGroupRow","onExpandRowClick","pinned","row","rowIndex","shouldDisplayLastColumnCell"]),b=null===(a=g.rowMeta)||void 0===a?void 0:a.children;return e.jsxs(k,t({allowAnimations:x.allowAnimations,allowHorizontalAnimate:x.shouldPaginate,draggedHeaderRef:x.draggedHeaderRef,headersRef:x.headersRef,isBody:!0,mainBodyRef:x.mainBodyRef,pauseAnimation:x.isWidthDragging,rowIndex:p+1},{children:[0!==p&&e.jsx(D,{lastGroupRow:h}),c.map((function(e,r){if(!w({hiddenColumns:d,header:e,pinned:m}))return null;var o=g.rowData[e.accessor];return e.cellRenderer&&(o=e.cellRenderer({accessor:e.accessor,colIndex:r,row:g})),n.createElement(E,t({},x,{borderClass:i(p,r),cellHasChildren:((null==b?void 0:b.length)||0)>0,colIndex:r,content:o,header:e,isSelected:u(p,r),isTopLeftCell:f(p,r),key:r,onExpandRowClick:v,onMouseDown:function(){return s({rowIndex:p,colIndex:r})},onMouseOver:function(){return l(p,r)},row:g,rowIndex:p}))})),e.jsx(I,{ref:n.createRef(),visible:R})]}))},T=function(r){var o=r.depth,a=void 0===o?0:o,i=r.getNextRowIndex,s=r.index,l=r.lastGroupRow,c=r.pinned,d=r.props,u=r.rowHeight,f=r.visibleRow,h=f.row,v=f.position,m=i(),g=d.headers.filter((function(e){return c===e.pinned})).map((function(e){return"".concat(e.width,"px")})).join(" ");return e.jsx("div",t({style:{display:"grid",gridTemplateColumns:g,position:"absolute",top:"".concat(v*u,"px"),height:"".concat(u,"px"),transform:"translateZ(0)",transition:"background 0.2s ease"}},{children:n.createElement(N,t({},d,{depth:a,lastGroupRow:l,key:s,pinned:c,row:h,rowIndex:m}))}))},B=function(o){o.headerContainerRef;var a=o.onExpandRowClick,i=o.pinned,s=o.rowHeight,l=o.sectionRef;o.templateColumns;var c=o.totalHeight,d=o.visibleRows,u=o.width,f=r(o,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),h=i?"st-table-body-pinned-".concat(i):"st-table-body-main",v=n.useRef(0);n.useEffect((function(){v.current=0}));var m=function(){return v.current++};return e.jsx("div",t({className:h,ref:l,style:{position:"relative",height:"".concat(c,"px"),width:u}},{children:d.map((function(n,r){var o,l;return e.jsx(T,{getNextRowIndex:m,index:r,lastGroupRow:Boolean(null===(l=null===(o=n.row.rowMeta)||void 0===o?void 0:o.children)||void 0===l?void 0:l.length),pinned:i,props:t(t({},f),{onExpandRowClick:a}),rowHeight:s,visibleRow:n},r)}))}))},O=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,S=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:S,scrollbarWidth:H});var M=n.useRef(null),E=n.useRef(null),I=n.useState(h),D=I[0],k=I[1],L=n.useState(1),N=L[0],T=L[1],O=n.useState(!1),A=O[0],W=O[1],P=n.useState(!0),z=P[0],U=P[1],F=n.useState(0),G=F[0],V=F[1],q=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),J=40*q,X=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}({rows:D,scrollTop:G,containerHeight:600,rowHeight:40,bufferRowCount:15})}),[D,G]),K=n.useCallback((function(){return o(void 0,void 0,void 0,(function(){var e;return a(this,(function(n){return A||!z||(W(!0),e=h.slice(15*N,15*(N+1)),k((function(n){return i(i([],n,!0),e,!0)})),T((function(e){return e+1})),W(!1),e.length<5&&U(!1)),[2]}))}))}),[h,z,A,N]),_=n.useCallback((function(e){e[0].isIntersecting&&z&&!A&&K()}),[z,A,K]);n.useEffect((function(){return M.current=new IntersectionObserver(_,{root:null,rootMargin:"100px",threshold:0}),S.current&&M.current.observe(S.current),function(){M.current&&M.current.disconnect()}}),[_,D,S]);var Z=(null===(s=w.current)||void 0===s?void 0:s.clientWidth)?(null===(l=w.current)||void 0===l?void 0:l.clientWidth)+1:0,$=null===(c=f.current)||void 0===c?void 0:c.clientWidth,Q=(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:S,onScroll:function(e){var n=e.currentTarget.scrollTop;E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame((function(){V(n)}))}},{children:[p.length>0&&e.jsx(B,t({},r,{onExpandRowClick:X,pinned:"left",rowHeight:40,sectionRef:R,templateColumns:x,totalHeight:J,visibleRows:Y,width:Z})),e.jsx(B,t({},r,{onExpandRowClick:X,rowHeight:40,sectionRef:m,templateColumns:g,totalHeight:J,visibleRows:Y,width:$})),b.length>0&&e.jsx(B,t({},r,{onExpandRowClick:X,pinned:"right",rowHeight:40,sectionRef:y,templateColumns:j,totalHeight:J,visibleRows:Y,width:Q}))]}))},A={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 A.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?A.string(e,n,t):"number"==typeof e&&"number"==typeof n?A.number(e,n,t):"boolean"==typeof e&&"boolean"==typeof n?A.boolean(e,n,t):A.string(String(e),String(n),t)}},W=function(e,n,t,r){switch(void 0===t&&(t="string"),t){case"string":return A.string(String(e||""),String(n||""),r);case"number":return A.number(Number(e||0),Number(n||0),r);case"boolean":return A.boolean(Boolean(e),Boolean(n),r);case"date":return A.date(String(e||""),String(n||""),r);case"enum":return A.enum(String(e||""),String(n||""),r);default:return A.default(e,n,r)}},P=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 W(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:P(e.rowMeta.children,n,r)})}):e}))},z=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 W(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=P(a,n,r);o.rowMeta=t(t({},o.rowMeta),{children:i})}return o}))}(n,r,e);return{sortedData:o,newSortConfig:r}},U=function(e){var n=e.event,t=e.forceUpdate,r=e.header,o=e.headersRef,a=e.index;e.reverse;var i=e.setIsWidthDragging;i(!0),n.preventDefault();var s=n.clientX;if(r){var l=r.width,c=function(e){var n=Math.max(l+(e.clientX-s),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)}},F=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,m=r.onTableHeaderDragEnd,g=r.reverse,w=r.selectableColumns,R=r.setIsWidthDragging,x=r.setSelectedCells,b=r.sort,C=r.sortDownIcon,y=r.sortUpIcon,H=n.useState(!1),S=H[0],E=H[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":""),L=M({draggedHeaderRef:c,headersRef:u,hoveredHeaderRef:f,onTableHeaderDragEnd:m}),N=L.handleDragStart,T=L.handleDragEnd,B=M({draggedHeaderRef:c,headersRef:u,hoveredHeaderRef:f,onTableHeaderDragEnd:m}).handleDragOver,O=j(),A=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 W=i&&e.jsx("div",{className:"st-header-resize-handle",onMouseDown:function(e){O({callback:U,callbackProps:{event:e,forceUpdate:d,header:I,headersRef:u,index:h,setIsWidthDragging:R},limit:10})}});return e.jsxs("div",t({className:k,id:p({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:[g&&W,e.jsx("div",t({className:"st-header-label",draggable:l,onClick:function(e){return A({event:e,header:I})},onDragEnd:function(e){e.preventDefault(),E(!1),T()},onDragStart:function(e){l&&I&&function(e){E(!0),N(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 A({event:e,header:I})}},{children:["ascending"===b.direction&&y&&y,"descending"===b.direction&&C&&C]})),!g&&W]}))})),G=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])},V=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,g=r.hiddenColumns,p=r.hoveredHeaderRef,R=r.isWidthDragging,x=r.mainBodyRef,b=r.mainTemplateColumns,C=r.onSort,y=r.onTableHeaderDragEnd,j=r.pinnedLeftColumns,H=r.pinnedLeftHeaderRef,S=r.pinnedLeftTemplateColumns,M=r.pinnedRightColumns,E=r.pinnedRightHeaderRef,D=r.pinnedRightTemplateColumns,L=r.selectableColumns,N=r.setIsWidthDragging,T=r.setSelectedCells,B=r.shouldDisplayLastColumnCell,O=r.sort,A=r.sortDownIcon,W=r.sortUpIcon;G(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:S}},{children:e.jsx(k,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 w({hiddenColumns:g,header:t,pinned:"left"})?e.jsx(F,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:p,index:r,onSort:C,onTableHeaderDragEnd:y,ref:n.createRef(),selectableColumns:L,setIsWidthDragging:N,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},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.jsxs(k,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 w({hiddenColumns:g,header:t})?e.jsx(F,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:p,index:r,onSort:C,onTableHeaderDragEnd:y,ref:n.createRef(),selectableColumns:L,setIsWidthDragging:N,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},t.accessor):null})),e.jsx(I,{ref:n.createRef(),visible:B})]}))})),M.length>0&&e.jsx("div",t({className:"st-header-pinned-right",ref:E,style:{gridTemplateColumns:D}},{children:e.jsxs(k,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 w({hiddenColumns:g,header:t,pinned:"right"})?e.jsx(F,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:p,index:r,onSort:C,onTableHeaderDragEnd:y,reverse:!0,ref:n.createRef(),selectableColumns:L,setIsWidthDragging:N,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},t.accessor):null})),e.jsx(I,{ref:n.createRef(),visible:B})]}))}))]}))},q=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,S=r.scrollbarWidth,M=r.selectableColumns,E=r.setIsWidthDragging,I=r.setSelectedCells,D=r.shouldPaginate,k=r.sort,L=r.sortDownIcon,N=r.sortUpIcon,T=r.tableBodyContainerRef,B=n.useRef(null),A=n.useRef(null),W=n.useRef(null),P=n.useRef(null),z=v.current.filter((function(e){return!e.hide&&!e.pinned})),U=n.useMemo((function(){return!!x.current&&z.reduce((function(e,n){return e+n.width}),0)<x.current.clientWidth}),[z,x]),F=v.current.filter((function(e){return"left"===e.pinned&&!0!==e.hide})),G=v.current.filter((function(e){return"right"===e.pinned&&!0!==e.hide})),q=n.useMemo((function(){return"".concat(F.map((function(e){return"".concat(e.width,"px")})).join(" "))}),[F]),J=n.useMemo((function(){return"".concat(z.filter((function(e){return!0!==m[e.accessor]})).map((function(e){return"".concat(e.width,"px")})).join(" ")," 1fr")}),[z,m]),X=n.useMemo((function(){return"".concat(G.map((function(e){return"".concat(e.width,"px")})).join(" "))}),[G]),Y={allowAnimations:o,centerHeaderRef:W,columnResizing:a,currentRows:i,columnReordering:s,draggedHeaderRef:l,forceUpdate:d,headerContainerRef:B,headersRef:v,hiddenColumns:m,hoveredHeaderRef:g,isWidthDragging:R,mainBodyRef:x,mainTemplateColumns:J,onSort:C,onTableHeaderDragEnd:y,pinnedLeftColumns:F,pinnedLeftHeaderRef:A,pinnedLeftTemplateColumns:q,pinnedRightColumns:G,pinnedRightHeaderRef:P,pinnedRightTemplateColumns:X,selectableColumns:M,setIsWidthDragging:E,setSelectedCells:I,shouldDisplayLastColumnCell:U,sort:k,sortDownIcon:L,sortUpIcon:N,tableBodyContainerRef:T},K={allowAnimations:o,centerHeaderRef:W,currentRows:i,draggedHeaderRef:l,getBorderClass:u,handleMouseDown:f,handleMouseOver:h,headerContainerRef:B,headers:v.current,headersRef:v,hiddenColumns:m,hoveredHeaderRef:g,isSelected:p,isTopLeftCell:w,isWidthDragging:R,mainBodyRef:x,mainTemplateColumns:J,onCellEdit:b,onTableHeaderDragEnd:y,pinnedLeftColumns:F,pinnedLeftHeaderRef:A,pinnedLeftRef:j,pinnedLeftTemplateColumns:q,pinnedRightColumns:G,pinnedRightHeaderRef:P,pinnedRightRef:H,pinnedRightTemplateColumns:X,scrollbarWidth:S,shouldDisplayLastColumnCell:U,shouldPaginate:D,tableBodyContainerRef:T};return e.jsxs("div",t({className:"st-table-content",style:{width:c?"calc(100% - 27.5px)":"100%"}},{children:[e.jsx(V,t({},Y)),e.jsx(O,t({},K))]}))},J=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])},X=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 J({widthAttribute:"offsetWidth",callback:d,ref:a}),J({widthAttribute:"scrollWidth",callback:g,ref:o}),J({widthAttribute:"offsetWidth",callback:h,ref:i}),G(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}})]}))};!function(e){e.Left="left",e.Right="right"}(s||(s={}));var Y=function(r){var o=r.allowAnimations,a=void 0!==o&&o,i=r.columnEditorPosition,v=void 0===i?s.Right:i,m=r.columnEditorText,p=void 0===m?"Columns":m,w=r.columnResizing,R=void 0!==w&&w,x=r.defaultHeaders,b=r.editColumns,C=void 0!==b&&b,y=r.editColumnsInitOpen,j=void 0!==y&&y,H=r.columnReordering,S=void 0!==H&&H,M=r.height,E=r.hideFooter,I=void 0!==E&&E,D=r.nextIcon,k=void 0===D?e.jsx(d,{className:"st-next-prev-icon"}):D,L=r.onCellEdit,N=r.onColumnOrderChange,T=r.prevIcon,B=void 0===T?e.jsx(c,{className:"st-next-prev-icon"}):T,O=r.rows,A=r.rowsPerPage,W=void 0===A?10:A,P=r.selectableCells,U=void 0!==P&&P,F=r.selectableColumns,G=void 0!==F&&F,V=r.shouldPaginate,J=void 0!==V&&V,Y=r.sortDownIcon,K=void 0===Y?e.jsx(h,{className:"st-sort-icon"}):Y,_=r.sortUpIcon,Z=void 0===_?e.jsx(f,{className:"st-sort-icon"}):_,$=r.theme,Q=void 0===$?"light":$,ee=n.useMemo((function(){return O.map((function(e,n){return t(t({},e),{originalRowIndex:n})}))}),[O]),ne=n.useRef(null),te=n.useRef(x),re=n.useRef(null),oe=n.useRef(null),ae=n.useRef(null),ie=n.useRef(null),se=n.useRef(null),le=n.useState(!1),ce=le[0],de=le[1],ue=n.useState(1),fe=ue[0],he=ue[1],ve=n.useState(0),me=ve[0],ge=ve[1],pe=n.useState(0),we=pe[0],Re=pe[1],xe=function(e,t){var r=n.useState(null),o=r[0],a=r[1],i=n.useState({}),s=i[0],l=i[1],c=n.useMemo((function(){return o?z(t,e,o).sortedData:e}),[e,o,t]);return{sort:o,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:c,hiddenColumns:s,setHiddenColumns:l}}(ee,te.current),be=xe.sort,Ce=xe.sortedRows,ye=xe.hiddenColumns,je=xe.setHiddenColumns,He=xe.updateSort,Se=n.useReducer((function(e){return e+1}),0)[1],Me=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");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:U,headers:te.current,rows:Ce}),Ee=Me.handleMouseDown,Ie=Me.handleMouseOver,De=Me.handleMouseUp,ke=Me.isSelected,Le=Me.getBorderClass,Ne=Me.isTopLeftCell,Te=Me.setSelectedCells,Be=n.useMemo((function(){return J?Ce.slice((fe-1)*W,fe*W):Ce}),[fe,W,J,Ce]),Oe=n.useCallback((function(e,n){He(e,n)}),[He]),Ae=n.useCallback((function(e){te.current=e,Se(),null==N||N(e)}),[]);return n.useEffect((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||G&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||Te(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[G,Te]),n.useLayoutEffect((function(){if(se.current){var e=se.current.offsetWidth-se.current.clientWidth,n=se.current.clientWidth;ge(e),Re(n)}}),[]),e.jsx(u.Provider,t({value:{rows:O,tableRows:ee}},{children:e.jsxs("div",t({className:"simple-table-root st-wrapper theme-".concat(Q),style:M?{height:M}:{}},{children:[e.jsxs("div",t({className:"st-table-wrapper-container"},{children:[e.jsxs("div",t({className:"st-table-wrapper",onMouseUp:De,onMouseLeave:De},{children:[e.jsx(q,{allowAnimations:a,columnResizing:R,currentRows:Be,draggedHeaderRef:ne,editColumns:C,columnReordering:S,forceUpdate:Se,getBorderClass:Le,handleMouseDown:Ee,handleMouseOver:Ie,headers:te.current,headersRef:te,hiddenColumns:ye,hoveredHeaderRef:re,isSelected:ke,isTopLeftCell:Ne,isWidthDragging:ce,mainBodyRef:oe,onCellEdit:L,onSort:Oe,onTableHeaderDragEnd:Ae,pinnedLeftRef:ae,pinnedRightRef:ie,scrollbarWidth:me,selectableColumns:G,setIsWidthDragging:de,setSelectedCells:Te,shouldPaginate:J,sort:be,sortDownIcon:K,sortUpIcon:Z,tableBodyContainerRef:se}),e.jsx(g,{columnEditorText:p,editColumns:C,editColumnsInitOpen:j,headers:te.current,hiddenColumns:ye,position:v,setHiddenColumns:je})]})),e.jsx(X,{mainBodyRef:oe,pinnedLeftRef:ae,pinnedRightRef:ie,tableContentWidth:we})]})),e.jsx(l,{currentPage:fe,hideFooter:I,nextIcon:k,onPageChange:he,prevIcon:B,rowsPerPage:W,shouldPaginate:J,totalRows:Ce.length})]}))}))};Y.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(h,{className:"st-sort-icon"}),sortUpIcon:e.jsx(f,{className:"st-sort-icon"}),theme:"light"};var K=n.memo(Y);exports.SimpleTable=K;
|
|
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:(console.log("totalPages",u),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=n.createContext({rows:[],tableRows:[]}),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 11.41L10 6.83l4.59 4.58L16 10l-6-6-6 6z"})}))},h=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"})}))},v=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]}))},m=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(v,t({checked:s[n.accessor],onChange:function(e){var r;return i(t(t({},s),((r={})[n.accessor]=e,r)))}},{children:n.label}),r)}))}))}))},g=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(m,{headers:s,open:h,position:c,setOpen:v,setHiddenColumns:d,hiddenColumns:u})]})):null},p=function(e){var n=e.accessor,t=e.rowIndex;return"cell-".concat(n,"-").concat(t)},w=function(e){var n=e.hiddenColumns,t=e.header,r=e.pinned;return n[t.accessor]?null:!r&&!t.pinned||t.pinned===r||null},R=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"}))]}))},x=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)}})},b=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)}})},C=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(x,{defaultValue:o,onBlur:i,onChange:a}):"boolean"==typeof o?e.jsx(R,{onBlur:i,onChange:a,value:o}):"number"==typeof o?e.jsx(b,{defaultValue:o,onBlur:i,onChange:a}):null})},y=0,j=function(){return function(e){var n=e.callback,t=e.callbackProps,r=e.limit,o=Date.now();(0===y||o-y>=r)&&(y=o,n(t))}},H=Date.now(),S={screenX:0,screenY:0},M=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,H=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-S.screenX,2)+Math.pow(f-S.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-H<800&&h<50||(H=w,S={screenX:u,screenY:f},l(v))}}},handleDragEnd:function(){o.current=null,s.current=null}}},E=n.forwardRef((function(r,o){var a=r.borderClass,i=r.cellHasChildren,s=r.colIndex,l=r.content,c=r.depth,u=r.draggedHeaderRef,f=r.header,v=r.headersRef,m=r.hoveredHeaderRef,g=r.isSelected,w=r.isTopLeftCell,R=r.onCellEdit,x=r.onExpandRowClick,b=r.onMouseDown,y=r.onMouseOver,H=r.onTableHeaderDragEnd,S=r.row,E=r.rowIndex,I=n.useState(l),D=I[0],k=I[1],L=n.useState(!1),N=L[0],T=L[1],B=M({draggedHeaderRef:u,headersRef:v,hoveredHeaderRef:m,onTableHeaderDragEnd:H}).handleDragOver,O=j(),A=Boolean(null==f?void 0:f.isEditable),W=E%2==0,P="st-cell ".concat(c>0&&f.expandable?"st-cell-depth-".concat(c):""," ").concat(g?w?"st-cell-selected-first-cell ".concat(a):"st-cell-selected ".concat(a):""," ").concat(W?"st-cell-odd-row":"st-cell-even-row"," ").concat(A?"clickable":""," ").concat("right"===f.align?"right-aligned":"");n.useEffect((function(){"object"!=typeof l&&k(l)}),[l]);return N?e.jsx("div",t({className:"st-cell-editing ".concat(W?"st-cell-odd-row":"st-cell-even-row"),id:p({accessor:f.accessor,rowIndex:E+1})},{children:e.jsx(C,{onChange:function(e){k(e),null==R||R({accessor:f.accessor,newValue:e,row:S})},setIsEditing:T,value:D})})):e.jsxs("div",t({className:P,id:p({accessor:f.accessor,rowIndex:E+1}),onDoubleClick:function(){return f.isEditable&&T(!0)},onMouseDown:function(){return b(E,s)},onMouseOver:function(){return y(E,s)},onDragOver:function(e){return O({callback:B,callbackProps:{event:e,hoveredHeader:f},limit:50})},ref:o},{children:[f.expandable&&i?S.rowMeta.isExpanded?e.jsx("div",t({className:"st-sort-icon-container",onClick:function(){return x(S.rowMeta.rowId)}},{children:e.jsx(h,{className:"st-sort-icon"})})):e.jsx("div",t({className:"st-sort-icon-container",onClick:function(){return x(S.rowMeta.rowId)}},{children:e.jsx(d,{className:"st-sort-icon"})})):null,e.jsx("span",{children:D})]}))})),I=n.forwardRef((function(n,t){return n.visible?e.jsx("div",{className:"st-cell",ref:t}):e.jsx("div",{ref:t})})),D=function(n){var t=n.lastGroupRow;return e.jsx("div",{className:"st-row-separator ".concat(t?"st-last-group-row":"")})},k=function(n){var o=n.allowAnimations,a=n.children,i=r(n,["allowAnimations","children"]);return o?e.jsx(L,t({},i,{children:a})):e.jsx(e.Fragment,{children:a})},L=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],m=h[1],g=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(p({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)&&(g.current=v,m(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(g.current).length&&w&&w.forEach((function(e){var n=document.getElementById(p({accessor:e.accessor,rowIndex:u}));if(n){var t=g.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,g,u]),e.jsx(e.Fragment,{children:a})},N=function(o){var a,i=o.getBorderClass,s=o.handleMouseDown,l=o.handleMouseOver,c=o.headers,d=o.hiddenColumns,u=o.isSelected,f=o.isTopLeftCell,h=o.lastGroupRow,v=o.onExpandRowClick,m=o.pinned,g=o.row,p=o.rowIndex,R=o.shouldDisplayLastColumnCell,x=r(o,["getBorderClass","handleMouseDown","handleMouseOver","headers","hiddenColumns","isSelected","isTopLeftCell","lastGroupRow","onExpandRowClick","pinned","row","rowIndex","shouldDisplayLastColumnCell"]),b=null===(a=g.rowMeta)||void 0===a?void 0:a.children;return e.jsxs(k,t({allowAnimations:x.allowAnimations,allowHorizontalAnimate:x.shouldPaginate,draggedHeaderRef:x.draggedHeaderRef,headersRef:x.headersRef,isBody:!0,mainBodyRef:x.mainBodyRef,pauseAnimation:x.isWidthDragging,rowIndex:p+1},{children:[0!==p&&e.jsx(D,{lastGroupRow:h}),c.map((function(e,r){if(!w({hiddenColumns:d,header:e,pinned:m}))return null;var o=g.rowData[e.accessor];return e.cellRenderer&&(o=e.cellRenderer({accessor:e.accessor,colIndex:r,row:g})),n.createElement(E,t({},x,{borderClass:i(p,r),cellHasChildren:((null==b?void 0:b.length)||0)>0,colIndex:r,content:o,header:e,isSelected:u(p,r),isTopLeftCell:f(p,r),key:r,onExpandRowClick:v,onMouseDown:function(){return s({rowIndex:p,colIndex:r})},onMouseOver:function(){return l(p,r)},row:g,rowIndex:p}))})),e.jsx(I,{ref:n.createRef(),visible:R})]}))},T=function(r){var o=r.depth,a=void 0===o?0:o,i=r.getNextRowIndex,s=r.index,l=r.lastGroupRow,c=r.pinned,d=r.props,u=r.rowHeight,f=r.visibleRow,h=f.row,v=f.position,m=i(),g=d.headers.filter((function(e){return c===e.pinned})).map((function(e){return"".concat(e.width,"px")})).join(" ");return e.jsx("div",t({style:{display:"grid",gridTemplateColumns:g,position:"absolute",top:"".concat(v*u,"px"),height:"".concat(u,"px"),transform:"translateZ(0)",transition:"background 0.2s ease"}},{children:n.createElement(N,t({},d,{depth:a,lastGroupRow:l,key:s,pinned:c,row:h,rowIndex:m}))}))},B=function(o){o.headerContainerRef;var a=o.onExpandRowClick,i=o.pinned,s=o.rowHeight,l=o.sectionRef;o.templateColumns;var c=o.totalHeight,d=o.visibleRows,u=o.width,f=r(o,["headerContainerRef","onExpandRowClick","pinned","rowHeight","sectionRef","templateColumns","totalHeight","visibleRows","width"]),h=i?"st-table-body-pinned-".concat(i):"st-table-body-main",v=n.useRef(0);n.useEffect((function(){v.current=0}));var m=function(){return v.current++};return e.jsx("div",t({className:h,ref:l,style:{position:"relative",height:"".concat(c,"px"),width:u}},{children:d.map((function(n,r){var o,l;return e.jsx(T,{getNextRowIndex:m,index:r,lastGroupRow:Boolean(null===(l=null===(o=n.row.rowMeta)||void 0===o?void 0:o.children)||void 0===l?void 0:l.length),pinned:i,props:t(t({},f),{onExpandRowClick:a}),rowHeight:s,visibleRow:n},r)}))}))},O=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,S=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:S,scrollbarWidth:H});var M=n.useRef(null),E=n.useRef(null),I=n.useState(h),D=I[0],k=I[1],L=n.useState(1),N=L[0],T=L[1],O=n.useState(!1),A=O[0],W=O[1],P=n.useState(!0),z=P[0],U=P[1],F=n.useState(0),G=F[0],V=F[1],q=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),J=40*q,X=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}({rows:D,scrollTop:G,containerHeight:600,rowHeight:40,bufferRowCount:15})}),[D,G]),K=n.useCallback((function(){return o(void 0,void 0,void 0,(function(){var e;return a(this,(function(n){return A||!z||(W(!0),e=h.slice(15*N,15*(N+1)),k((function(n){return i(i([],n,!0),e,!0)})),T((function(e){return e+1})),W(!1),e.length<5&&U(!1)),[2]}))}))}),[h,z,A,N]),_=n.useCallback((function(e){e[0].isIntersecting&&z&&!A&&K()}),[z,A,K]);n.useEffect((function(){return M.current=new IntersectionObserver(_,{root:null,rootMargin:"100px",threshold:0}),S.current&&M.current.observe(S.current),function(){M.current&&M.current.disconnect()}}),[_,D,S]);var Z=(null===(s=w.current)||void 0===s?void 0:s.clientWidth)?(null===(l=w.current)||void 0===l?void 0:l.clientWidth)+1:0,$=null===(c=f.current)||void 0===c?void 0:c.clientWidth,Q=(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:S,onScroll:function(e){var n=e.currentTarget.scrollTop;E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame((function(){V(n)}))}},{children:[p.length>0&&e.jsx(B,t({},r,{onExpandRowClick:X,pinned:"left",rowHeight:40,sectionRef:R,templateColumns:x,totalHeight:J,visibleRows:Y,width:Z})),e.jsx(B,t({},r,{onExpandRowClick:X,rowHeight:40,sectionRef:m,templateColumns:g,totalHeight:J,visibleRows:Y,width:$})),b.length>0&&e.jsx(B,t({},r,{onExpandRowClick:X,pinned:"right",rowHeight:40,sectionRef:y,templateColumns:j,totalHeight:J,visibleRows:Y,width:Q}))]}))},A={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 A.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?A.string(e,n,t):"number"==typeof e&&"number"==typeof n?A.number(e,n,t):"boolean"==typeof e&&"boolean"==typeof n?A.boolean(e,n,t):A.string(String(e),String(n),t)}},W=function(e,n,t,r){switch(void 0===t&&(t="string"),t){case"string":return A.string(String(e||""),String(n||""),r);case"number":return A.number(Number(e||0),Number(n||0),r);case"boolean":return A.boolean(Boolean(e),Boolean(n),r);case"date":return A.date(String(e||""),String(n||""),r);case"enum":return A.enum(String(e||""),String(n||""),r);default:return A.default(e,n,r)}},P=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 W(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:P(e.rowMeta.children,n,r)})}):e}))},z=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 W(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=P(a,n,r);o.rowMeta=t(t({},o.rowMeta),{children:i})}return o}))}(n,r,e);return{sortedData:o,newSortConfig:r}},U=function(e){var n=e.event,t=e.forceUpdate,r=e.header,o=e.headersRef,a=e.index;e.reverse;var i=e.setIsWidthDragging;i(!0),n.preventDefault();var s=n.clientX;if(r){var l=r.width,c=function(e){var n=Math.max(l+(e.clientX-s),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)}},F=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,m=r.onTableHeaderDragEnd,g=r.reverse,w=r.selectableColumns,R=r.setIsWidthDragging,x=r.setSelectedCells,b=r.sort,C=r.sortDownIcon,y=r.sortUpIcon,H=n.useState(!1),S=H[0],E=H[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":""),L=M({draggedHeaderRef:c,headersRef:u,hoveredHeaderRef:f,onTableHeaderDragEnd:m}),N=L.handleDragStart,T=L.handleDragEnd,B=M({draggedHeaderRef:c,headersRef:u,hoveredHeaderRef:f,onTableHeaderDragEnd:m}).handleDragOver,O=j(),A=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 W=i&&e.jsx("div",{className:"st-header-resize-handle",onMouseDown:function(e){O({callback:U,callbackProps:{event:e,forceUpdate:d,header:I,headersRef:u,index:h,setIsWidthDragging:R},limit:10})}});return e.jsxs("div",t({className:k,id:p({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:[g&&W,e.jsx("div",t({className:"st-header-label",draggable:l,onClick:function(e){return A({event:e,header:I})},onDragEnd:function(e){e.preventDefault(),E(!1),T()},onDragStart:function(e){l&&I&&function(e){E(!0),N(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 A({event:e,header:I})}},{children:["ascending"===b.direction&&y&&y,"descending"===b.direction&&C&&C]})),!g&&W]}))})),G=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])},V=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,g=r.hiddenColumns,p=r.hoveredHeaderRef,R=r.isWidthDragging,x=r.mainBodyRef,b=r.mainTemplateColumns,C=r.onSort,y=r.onTableHeaderDragEnd,j=r.pinnedLeftColumns,H=r.pinnedLeftHeaderRef,S=r.pinnedLeftTemplateColumns,M=r.pinnedRightColumns,E=r.pinnedRightHeaderRef,D=r.pinnedRightTemplateColumns,L=r.selectableColumns,N=r.setIsWidthDragging,T=r.setSelectedCells,B=r.shouldDisplayLastColumnCell,O=r.sort,A=r.sortDownIcon,W=r.sortUpIcon;G(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:S}},{children:e.jsx(k,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 w({hiddenColumns:g,header:t,pinned:"left"})?e.jsx(F,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:p,index:r,onSort:C,onTableHeaderDragEnd:y,ref:n.createRef(),selectableColumns:L,setIsWidthDragging:N,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},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.jsxs(k,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 w({hiddenColumns:g,header:t})?e.jsx(F,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:p,index:r,onSort:C,onTableHeaderDragEnd:y,ref:n.createRef(),selectableColumns:L,setIsWidthDragging:N,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},t.accessor):null})),e.jsx(I,{ref:n.createRef(),visible:B})]}))})),M.length>0&&e.jsx("div",t({className:"st-header-pinned-right",ref:E,style:{gridTemplateColumns:D}},{children:e.jsxs(k,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 w({hiddenColumns:g,header:t,pinned:"right"})?e.jsx(F,{columnResizing:c,currentRows:d,columnReordering:u,draggedHeaderRef:f,forceUpdate:h,headersRef:m,hoveredHeaderRef:p,index:r,onSort:C,onTableHeaderDragEnd:y,reverse:!0,ref:n.createRef(),selectableColumns:L,setIsWidthDragging:N,setSelectedCells:T,sort:O,sortDownIcon:A,sortUpIcon:W},t.accessor):null})),e.jsx(I,{ref:n.createRef(),visible:B})]}))}))]}))},q=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,S=r.scrollbarWidth,M=r.selectableColumns,E=r.setIsWidthDragging,I=r.setSelectedCells,D=r.shouldPaginate,k=r.sort,L=r.sortDownIcon,N=r.sortUpIcon,T=r.tableBodyContainerRef,B=n.useRef(null),A=n.useRef(null),W=n.useRef(null),P=n.useRef(null),z=v.current.filter((function(e){return!e.hide&&!e.pinned})),U=n.useMemo((function(){return!!x.current&&z.reduce((function(e,n){return e+n.width}),0)<x.current.clientWidth}),[z,x]),F=v.current.filter((function(e){return"left"===e.pinned&&!0!==e.hide})),G=v.current.filter((function(e){return"right"===e.pinned&&!0!==e.hide})),q=n.useMemo((function(){return"".concat(F.map((function(e){return"".concat(e.width,"px")})).join(" "))}),[F]),J=n.useMemo((function(){return"".concat(z.filter((function(e){return!0!==m[e.accessor]})).map((function(e){return"".concat(e.width,"px")})).join(" ")," 1fr")}),[z,m]),X=n.useMemo((function(){return"".concat(G.map((function(e){return"".concat(e.width,"px")})).join(" "))}),[G]),Y={allowAnimations:o,centerHeaderRef:W,columnResizing:a,currentRows:i,columnReordering:s,draggedHeaderRef:l,forceUpdate:d,headerContainerRef:B,headersRef:v,hiddenColumns:m,hoveredHeaderRef:g,isWidthDragging:R,mainBodyRef:x,mainTemplateColumns:J,onSort:C,onTableHeaderDragEnd:y,pinnedLeftColumns:F,pinnedLeftHeaderRef:A,pinnedLeftTemplateColumns:q,pinnedRightColumns:G,pinnedRightHeaderRef:P,pinnedRightTemplateColumns:X,selectableColumns:M,setIsWidthDragging:E,setSelectedCells:I,shouldDisplayLastColumnCell:U,sort:k,sortDownIcon:L,sortUpIcon:N,tableBodyContainerRef:T},K={allowAnimations:o,centerHeaderRef:W,currentRows:i,draggedHeaderRef:l,getBorderClass:u,handleMouseDown:f,handleMouseOver:h,headerContainerRef:B,headers:v.current,headersRef:v,hiddenColumns:m,hoveredHeaderRef:g,isSelected:p,isTopLeftCell:w,isWidthDragging:R,mainBodyRef:x,mainTemplateColumns:J,onCellEdit:b,onTableHeaderDragEnd:y,pinnedLeftColumns:F,pinnedLeftHeaderRef:A,pinnedLeftRef:j,pinnedLeftTemplateColumns:q,pinnedRightColumns:G,pinnedRightHeaderRef:P,pinnedRightRef:H,pinnedRightTemplateColumns:X,scrollbarWidth:S,shouldDisplayLastColumnCell:U,shouldPaginate:D,tableBodyContainerRef:T};return e.jsxs("div",t({className:"st-table-content",style:{width:c?"calc(100% - 27.5px)":"100%"}},{children:[e.jsx(V,t({},Y)),e.jsx(O,t({},K))]}))},J=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])},X=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 J({widthAttribute:"offsetWidth",callback:d,ref:a}),J({widthAttribute:"scrollWidth",callback:g,ref:o}),J({widthAttribute:"offsetWidth",callback:h,ref:i}),G(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}})]}))};!function(e){e.Left="left",e.Right="right"}(s||(s={}));var Y=function(r){var o=r.allowAnimations,a=void 0!==o&&o,i=r.columnEditorPosition,v=void 0===i?s.Right:i,m=r.columnEditorText,p=void 0===m?"Columns":m,w=r.columnResizing,R=void 0!==w&&w,x=r.defaultHeaders,b=r.editColumns,C=void 0!==b&&b,y=r.editColumnsInitOpen,j=void 0!==y&&y,H=r.columnReordering,S=void 0!==H&&H,M=r.height,E=r.hideFooter,I=void 0!==E&&E,D=r.nextIcon,k=void 0===D?e.jsx(d,{className:"st-next-prev-icon"}):D,L=r.onCellEdit,N=r.onColumnOrderChange,T=r.prevIcon,B=void 0===T?e.jsx(c,{className:"st-next-prev-icon"}):T,O=r.rows,A=r.rowsPerPage,W=void 0===A?10:A,P=r.selectableCells,U=void 0!==P&&P,F=r.selectableColumns,G=void 0!==F&&F,V=r.shouldPaginate,J=void 0!==V&&V,Y=r.sortDownIcon,K=void 0===Y?e.jsx(h,{className:"st-sort-icon"}):Y,_=r.sortUpIcon,Z=void 0===_?e.jsx(f,{className:"st-sort-icon"}):_,$=r.theme,Q=void 0===$?"light":$,ee=n.useMemo((function(){return O.map((function(e,n){return t(t({},e),{originalRowIndex:n})}))}),[O]),ne=n.useRef(null),te=n.useRef(x),re=n.useRef(null),oe=n.useRef(null),ae=n.useRef(null),ie=n.useRef(null),se=n.useRef(null),le=n.useState(!1),ce=le[0],de=le[1],ue=n.useState(1),fe=ue[0],he=ue[1],ve=n.useState(0),me=ve[0],ge=ve[1],pe=n.useState(0),we=pe[0],Re=pe[1],xe=function(e,t){var r=n.useState(null),o=r[0],a=r[1],i=n.useState({}),s=i[0],l=i[1],c=n.useMemo((function(){return o?z(t,e,o).sortedData:e}),[e,o,t]);return{sort:o,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:c,hiddenColumns:s,setHiddenColumns:l}}(ee,te.current),be=xe.sort,Ce=xe.sortedRows,ye=xe.hiddenColumns,je=xe.setHiddenColumns,He=xe.updateSort,Se=n.useReducer((function(e){return e+1}),0)[1],Me=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:U,headers:te.current,rows:Ce}),Ee=Me.handleMouseDown,Ie=Me.handleMouseOver,De=Me.handleMouseUp,ke=Me.isSelected,Le=Me.getBorderClass,Ne=Me.isTopLeftCell,Te=Me.setSelectedCells,Be=n.useMemo((function(){return J?Ce.slice((fe-1)*W,fe*W):Ce}),[fe,W,J,Ce]),Oe=n.useCallback((function(e,n){He(e,n)}),[He]),Ae=n.useCallback((function(e){te.current=e,Se(),null==N||N(e)}),[]);return n.useEffect((function(){var e=function(e){var n=e.target;n.closest(".st-cell")||G&&(n.classList.contains("st-header-cell")||n.classList.contains("st-header-label"))||Te(new Set)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[G,Te]),n.useLayoutEffect((function(){if(se.current){var e=se.current.offsetWidth-se.current.clientWidth,n=se.current.clientWidth;ge(e),Re(n)}}),[]),e.jsx(u.Provider,t({value:{rows:O,tableRows:ee}},{children:e.jsxs("div",t({className:"simple-table-root st-wrapper theme-".concat(Q),style:M?{height:M}:{}},{children:[e.jsxs("div",t({className:"st-table-wrapper-container"},{children:[e.jsxs("div",t({className:"st-table-wrapper",onMouseUp:De,onMouseLeave:De},{children:[e.jsx(q,{allowAnimations:a,columnResizing:R,currentRows:Be,draggedHeaderRef:ne,editColumns:C,columnReordering:S,forceUpdate:Se,getBorderClass:Le,handleMouseDown:Ee,handleMouseOver:Ie,headers:te.current,headersRef:te,hiddenColumns:ye,hoveredHeaderRef:re,isSelected:ke,isTopLeftCell:Ne,isWidthDragging:ce,mainBodyRef:oe,onCellEdit:L,onSort:Oe,onTableHeaderDragEnd:Ae,pinnedLeftRef:ae,pinnedRightRef:ie,scrollbarWidth:me,selectableColumns:G,setIsWidthDragging:de,setSelectedCells:Te,shouldPaginate:J,sort:be,sortDownIcon:K,sortUpIcon:Z,tableBodyContainerRef:se}),e.jsx(g,{columnEditorText:p,editColumns:C,editColumnsInitOpen:j,headers:te.current,hiddenColumns:ye,position:v,setHiddenColumns:je})]})),e.jsx(X,{mainBodyRef:oe,pinnedLeftRef:ae,pinnedRightRef:ie,tableContentWidth:we})]})),e.jsx(l,{currentPage:fe,hideFooter:I,nextIcon:k,onPageChange:he,prevIcon:B,rowsPerPage:W,shouldPaginate:J,totalRows:Ce.length})]}))}))};Y.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(h,{className:"st-sort-icon"}),sortUpIcon:e.jsx(f,{className:"st-sort-icon"}),theme:"light"};var K=n.memo(Y);exports.SimpleTable=K;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|