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