simple-table-core 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.js +1 -1
- package/dist/styles/simple-table.css +433 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Simple Table
|
|
2
2
|
|
|
3
|
-
Any questions, support or features requests join me on Dicord <a href="https://discord.gg/RvKHCfg3PC" target="_blank">https://discord.gg/RvKHCfg3PC</a>. I am happy to help and make this table even better!
|
|
3
|
+
Any questions, support or features requests join me on Dicord <a href="https://discord.gg/RvKHCfg3PC" target="_blank" rel="noopener noreferrer">https://discord.gg/RvKHCfg3PC</a>. I am happy to help and make this table even better!
|
|
4
4
|
|
|
5
5
|
Simple Table is a React grid package designed to provide a flexible and easy-to-use table component for your React applications.
|
|
6
6
|
|
|
7
7
|
## Live Demo
|
|
8
8
|
|
|
9
|
-
Check out the live demo on CodeSandbox: <a href="https://codesandbox.io/p/sandbox/simple-table-pagination-example-rdjm5d?file=%2Fsrc%2FApp.tsx%3A33%2C24" target="_blank">Simple Table Pagination Example</a>
|
|
9
|
+
Check out the live demo on CodeSandbox: <a href="https://codesandbox.io/p/sandbox/simple-table-pagination-example-rdjm5d?file=%2Fsrc%2FApp.tsx%3A33%2C24" target="_blank" rel="noopener noreferrer">Simple Table Pagination Example</a>
|
|
10
10
|
|
|
11
11
|
<div align="center">
|
|
12
|
-
<a href="https://github.com/petera2c/simple-table-marketing/blob/main/src/assets/simple-table-demo-fast.gif?raw=true" target="_blank">
|
|
12
|
+
<a href="https://github.com/petera2c/simple-table-marketing/blob/main/src/assets/simple-table-demo-fast.gif?raw=true" target="_blank" rel="noopener noreferrer">
|
|
13
13
|
<img src="https://github.com/petera2c/simple-table-marketing/blob/main/src/assets/simple-table-demo-fast.gif?raw=true" alt="Simple Table Demo" />
|
|
14
14
|
</a>
|
|
15
15
|
</div>
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as n,Fragment as r}from"react/jsx-runtime";import t,{useState as o,useRef as a,useCallback as c,useEffect as i,Children as s,useLayoutEffect as l,forwardRef as u,createRef as d,createContext as f,useContext as h,Fragment as v,useMemo as g,useReducer as m}from"react";var p=function(){return p=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},p.apply(this,arguments)};function w(e,n,r){if(r||2===arguments.length)for(var t,o=0,a=n.length;o<a;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var b=function(e){var n={};return s.forEach(e,(function(e){if(e&&e.ref&&e.ref.current){var r=e.ref.current.getBoundingClientRect();n[e.key]=r}})),n},C=function(e){var n,r,c=e.allowHorizontalAnimate,s=void 0===c||c,u=e.children,d=e.pauseAnimation,f=e.tableRef,h=a(!1),v=o({}),g=v[0],m=v[1],p=o({}),w=p[0],C=p[1],y=(n=u,r=a(),i((function(){r.current=n}),[n]),r.current);return l((function(){var e=b(u);m(e)}),[u]),l((function(){var e=b(y);C(e);var n=f.current,r=function(){h.current=!0;var e=b(y);m(e),C(e)},t=function(){h.current=!1};return null==n||n.addEventListener("scroll",r),null==n||n.addEventListener("scrollend",t),function(){null==n||n.removeEventListener("scroll",r),null==n||n.removeEventListener("scrollend",t)}}),[y,f]),i((function(){d||h.current||Object.keys(w).length&&t.Children.forEach(u,(function(e){if(e){var n=e.ref.current,r=w[e.key],t=g[e.key];if(r&&t){var o=r.left-t.left,a=s?0:r.top-t.top,c=Math.abs(o),i=Math.abs(a);(c>10||i>10)&&requestAnimationFrame((function(){n.style.transform="translate(".concat(o,"px, ").concat(a,"px)"),n.style.transition="transform 0s, opacity 0s",requestAnimationFrame((function(){n.style.transform="",n.style.transition="transform 300ms ease-out, opacity 300ms ease-out"}))}))}}}))}),[s,g,u,d,w]),u},y=!1,x=function(e){var n=e.draggedHeaderRef,r=e.headersRef,t=e.hoveredHeaderRef,o=e.onTableHeaderDragEnd;return{handleDragStart:function(e){n.current=e},handleDragOver:function(e){!function(e){var a;if(!y&&(t.current=e,e.accessor!==(null===(a=n.current)||void 0===a?void 0:a.accessor)&&null!==n.current&&!y)){if(y=!0,!r.current)return;var c=w([],r.current,!0),i=c.findIndex((function(e){var r;return e.accessor===(null===(r=n.current)||void 0===r?void 0:r.accessor)})),s=c.findIndex((function(n){return n.accessor===e.accessor}));if(void 0===i||void 0===s)return;var l=c.splice(i,1)[0];c.splice(s,0,l),JSON.stringify(c)!==JSON.stringify(r.current)&&setTimeout((function(){o(c),setTimeout((function(){y=!1}),500)}),50)}}(e)},handleDragEnd:function(){n.current=null,t.current=null}}},D=function(e,n){var r=!0,t=!0;return function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];if(r)return r=!1,void setTimeout((function(){return t=!1}),n);t||(e.apply(this,o),t=!0,setTimeout((function(){return t=!1}),n))}},R=u((function(r,t){var c,s=r.draggable,l=r.draggedHeaderRef,u=r.columnResizing,d=r.forceUpdate,f=r.headersRef,h=r.hoveredHeaderRef,v=r.index,g=r.onSort,m=r.onTableHeaderDragEnd,w=r.setIsWidthDragging,b=r.sort,C=r.sortDownIcon,y=r.sortUpIcon,R=a({pageX:0,pageY:0}),I=o(!1),E=I[0],N=I[1],M=null===(c=f.current)||void 0===c?void 0:c[v],k=Boolean(null==M?void 0:M.isSortable),L="st-header-cell ".concat(M===h.current?"st-hovered":""," ").concat(E?"st-dragging":""," ").concat(k?"clickable":""," ").concat(s&&!k?"draggable":""),A=x({draggedHeaderRef:l,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:m}),T=A.handleDragStart,S=A.handleDragOver,B=A.handleDragEnd,H=a(D((function(e){S(e)}),100)).current,O=function(e){e.isSortable&&g(v,e.accessor)};return i((function(){var e=function(e){var n=new Image;n.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=",e.dataTransfer.setDragImage(n,0,0)};return document.addEventListener("dragend",e,!1),function(){document.removeEventListener("dragend",e)}}),[]),M?e("div",p({className:L,ref:t,style:{width:M.width}},{children:[n("div",p({className:"st-header-label",draggable:s,onClick:function(){return O(M)},onDragStart:function(e){s&&M&&(e.dataTransfer.dropEffect="move",function(e){N(!0),T(e)}(M))},onDragOver:function(e){return function(e,n){e.preventDefault(),e.dataTransfer.dropEffect="move";var r=e.pageX,t=e.pageY;r===R.current.pageX&&t===R.current.pageY||(R.current={pageX:r,pageY:t},H(n,e))}(e,M)},onDragEnd:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",N(!1),B()},onMouseEnter:function(){return document.body.style.overflow="hidden"},onMouseLeave:function(){return document.body.style.overflow="auto"}},{children:null==M?void 0:M.label})),b&&b.key.accessor===M.accessor&&e("div",p({className:"st-sort-icon-container",onClick:function(){return O(M)}},{children:["ascending"===b.direction&&y&&y,"descending"===b.direction&&C&&C]})),u&&n("div",{className:"st-header-resize-handle",onMouseDown:function(e){w(!0),e.preventDefault();var n=e.clientX;if(M){var r=M.width,t=D((function(e){var t=Math.max(r+(e.clientX-n),40);M&&(f.current[v].width=t,d())}),10),o=function(){document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",o),w(!1)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",o)}}})]})):null})),I=u((function(e,r){return e.visible?n("div",{className:"st-cell",ref:r}):n("div",{ref:r})})),E=function(t){var o,c=t.draggable,i=t.columnResizing,s=t.forceUpdate,l=t.headersRef,u=t.hiddenColumns,f=t.isWidthDragging,h=t.onSort,v=t.onTableHeaderDragEnd,g=t.setIsWidthDragging,m=t.shouldDisplayLastColumnCell,w=t.sort,b=t.sortDownIcon,y=t.sortUpIcon,x=t.tableRef,D=a(null),E=a(null);return n(r,{children:e(C,p({pauseAnimation:f,tableRef:x},{children:[null===(o=l.current)||void 0===o?void 0:o.map((function(e,r){return u[e.accessor]?null:n(R,{draggable:c,draggedHeaderRef:D,columnResizing:i,forceUpdate:s,headersRef:l,hoveredHeaderRef:E,index:r,onSort:h,onTableHeaderDragEnd:v,ref:d(),setIsWidthDragging:g,sort:w,sortDownIcon:b,sortUpIcon:y},e.accessor)})),n(I,{ref:d(),visible:m})]}))})},N=function(r){var t=r.value,o=r.onBlur,a=r.onChange;return e("select",p({value:t.toString(),onBlur:o,onChange:a},{children:[n("option",p({value:"true"},{children:"True"})),n("option",p({value:"false"},{children:"False"}))]}))},M=function(e){var r=e.defaultValue,t=e.onBlur,o=e.onChange,c=a(null);return n("input",{className:"editable-cell-input",ref:c,autoFocus:!0,type:"text",defaultValue:r,onBlur:t,onChange:o})},k=function(e){var t=e.onChange,o=e.setIsEditing,a=e.value,c=function(e){var n=e.target.value;null==t||t(n)},i=function(){o(!1)};return n(r,{children:"string"==typeof a?n(M,{defaultValue:a,onBlur:i,onChange:c}):"boolean"==typeof a?n(N,{value:a,onBlur:i,onChange:c}):null})},L=f({rows:[],tableRows:[]}),A=u((function(e,r){var t=e.borderClass,a=e.colIndex,c=e.content,s=e.header,l=e.isSelected,u=e.isTopLeftCell,d=e.onCellChange,f=e.onMouseDown,v=e.onMouseOver,g=e.row,m=e.rowIndex,w=h(L),b=w.rows,C=w.tableRows,y=o(c),x=y[0],D=y[1],R=o(!1),I=R[0],E=R[1],N=Boolean(null==s?void 0:s.isEditable),M=m%2==0,A="st-cell ".concat(l?u?"st-cell-selected-first-cell ".concat(t):"st-cell-selected ".concat(t):""," ").concat(M?"st-cell-odd-row":""," ").concat(N?"clickable":"");i((function(){D(c)}),[c]),i((function(){if(void 0!==g.originalRowIndex&&"number"==typeof g.originalRowIndex){var e=b[g.originalRowIndex];e[s.accessor]!==x?D(e[s.accessor]):C[g.originalRowIndex][s.accessor]=x}}),[s.accessor,x,b,g.originalRowIndex,C]);return n("div",I?p({className:"st-cell-editing ".concat(M?"st-cell-odd-row":"")},{children:n(k,{onChange:function(e){D(e),null==d||d({accessor:s.accessor,newValue:e,newRowIndex:m,originalRowIndex:g.originalRowIndex,row:g})},setIsEditing:E,value:x})}):p({className:A,onDoubleClick:function(){return s.isEditable&&E(!0)},onMouseDown:function(){return f(m,a)},onMouseOver:function(){return v(m,a)},ref:r},{children:x}))})),T=function(){return n("div",{className:"st-row-separator"})},S=function(t){var o=t.getBorderClass,a=t.handleMouseDown,c=t.handleMouseOver,i=t.headers,s=t.hiddenColumns,l=t.isSelected,u=t.isTopLeftCell,f=t.isWidthDragging,h=t.onCellChange,g=t.shouldDisplayLastColumnCell,m=t.shouldPaginate,w=t.sortedRows,b=t.tableRef;return n(r,{children:w.map((function(r,t){return e(v,{children:[e(C,p({allowHorizontalAnimate:m,pauseAnimation:f,tableRef:b},{children:[i.map((function(e,i){if(s[e.accessor])return null;var f=r[e.accessor];return e.cellRenderer&&(f=e.cellRenderer(r)),n(A,{borderClass:o(t,i),colIndex:i,content:f,header:e,isSelected:l(t,i),isTopLeftCell:u(t,i),onCellChange:h,onMouseDown:function(){return a(t,i)},onMouseOver:function(){return c(t,i)},ref:d(),row:r,rowIndex:t},e.accessor)})),n(I,{ref:d(),visible:g})]})),t!==w.length-1&&n(T,{})]},r.originalRowIndex)}))})},B=function(r){var t=r.currentPage,o=r.hideFooter,a=r.nextIcon,c=r.onPageChange,i=r.prevIcon,s=r.rowsPerPage,l=r.shouldPaginate,u=r.totalRows,d=Math.ceil(u/s),f=t>1,h=t<d,v=function(e){e>=1&&e<=d&&c(e)};return o||!l?null:e("div",p({className:"st-footer"},{children:[n("button",p({className:"st-next-prev-btn ".concat(f?"":"disabled"),onClick:function(){return v(t-1)},disabled:!f},{children:i})),n("button",p({className:"st-next-prev-btn ".concat(h?"":"disabled"),onClick:function(){return v(t+1)},disabled:!h},{children:a})),Array.from({length:d},(function(e,r){return n("button",p({onClick:function(){return v(r+1)},className:"st-page-btn ".concat(t===r+1?"active":"")},{children:r+1}),r)}))]}))},H=function(e){var r=e.className;return n("svg",p({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"})}))},O=function(e){var r=e.className;return n("svg",p({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"})}))},P=function(e){var r=e.className;return n("svg",p({className:r,viewBox:"0 0 20 20",width:"20",height:"20",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"})}))},U=function(e){var r=e.className;return n("svg",p({className:r,viewBox:"0 0 20 20",width:"20",height:"20",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"})}))},z=function(r){var t=r.checked,a=void 0!==t&&t,c=r.children,i=r.onChange,s=o(a),l=s[0],u=s[1];return e("label",p({className:"st-checkbox-label"},{children:[n("input",{checked:l,className:"st-checkbox-input",onChange:function(){var e=!l;u(e),i&&i(e)},type:"checkbox"}),n("span",p({className:"st-checkbox-custom ".concat(l?"st-checked":"")},{children:l&&n("span",{className:"st-checkbox-checkmark"})})),c]}))},j=function(e){var r=e.headers,t=e.open,o=e.position;e.setOpen;var a=e.setHiddenColumns,c=e.hiddenColumns,i="left"===o?"left":"";return n("div",p({className:"st-column-editor-popout ".concat(t?"open":""," ").concat(i),onClick:function(e){return e.stopPropagation()}},{children:n("div",p({className:"st-column-editor-popout-content"},{children:r.map((function(e,r){return n(z,p({checked:c[e.accessor],onChange:function(n){var r;return a(p(p({},c),((r={})[e.accessor]=n,r)))}},{children:e.label}),r)}))}))}))},W=function(r){var t=r.columnEditorText,a=r.editColumns,c=r.headers,i=r.position,s=void 0===i?"right":i,l=r.setHiddenColumns,u=r.hiddenColumns,d=o(!1),f=d[0],h=d[1];return a?e("div",p({className:"st-column-editor ".concat(f?"open":""," ").concat(s),onClick:function(){return function(e){h(e)}(!f)}},{children:[n("div",p({className:"st-column-editor-text"},{children:t})),n(j,{headers:c,open:f,position:s,setOpen:h,setHiddenColumns:l,hiddenColumns:u})]})):null},F=function(r){var t=r.columnEditorPosition,s=void 0===t?"right":t,l=r.columnEditorText,u=void 0===l?"Columns":l,d=r.columnResizing,f=void 0!==d&&d,h=r.defaultHeaders,v=r.draggable,b=void 0!==v&&v,C=r.editColumns,y=void 0!==C&&C,x=r.height,D=r.hideFooter,R=void 0!==D&&D,I=r.importStyles,N=void 0===I||I,M=r.nextIcon,k=void 0===M?n(O,{className:"st-next-prev-icon"}):M,A=r.onCellChange,T=r.prevIcon,z=void 0===T?n(H,{className:"st-next-prev-icon"}):T,j=r.rows,F=r.rowsPerPage,X=void 0===F?10:F,V=r.selectableCells,Y=void 0!==V&&V,q=r.shouldPaginate,Q=void 0!==q&&q,J=r.sortDownIcon,K=void 0===J?n(U,{className:"st-sort-icon"}):J,G=r.sortUpIcon,Z=void 0===G?n(P,{className:"st-sort-icon"}):G,$=g((function(){return j.map((function(e,n){return p(p({},e),{originalRowIndex:n})}))}),[j]),_=a(null),ee=o(!1),ne=ee[0],re=ee[1],te=a(h),oe=o(null),ae=oe[0],ce=oe[1],ie=o({}),se=ie[0],le=ie[1],ue=o(1),de=ue[0],fe=ue[1],he=g((function(){if(!ae)return $;var e=function(e,n,r){var t=r?r.key:e[0],o="ascending";return r&&r.key.accessor===t.accessor&&"ascending"===r.direction&&(o="descending"),{sortedData:w([],n,!0).sort((function(e,n){return e[t.accessor]<n[t.accessor]?"ascending"===o?1:-1:e[t.accessor]>n[t.accessor]?"ascending"===o?-1:1:0})),newSortConfig:{key:t,direction:o}}}(te.current,$,ae).sortedData;return e}),[$,ae]),ve=m((function(e){return e+1}),0)[1],ge=function(e){var n=e.selectableCells,r=e.headers,t=e.rows,s=o([]),l=s[0],u=s[1],d=a(!1),f=a(null),h=c((function(){var e=l.reduce((function(e,n){var o=n.row,a=n.col;return e[o]||(e[o]=[]),e[o][a]=t[o][r[a].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");navigator.clipboard.writeText(n)}),[l,t,r]);i((function(){var e=function(e){(e.ctrlKey||e.metaKey)&&"c"===e.key&&h()};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[h,l]);var v=function(e,n){return l.some((function(r){return r.row===e&&r.col===n}))};return{selectedCells:l,handleMouseDown:function(e,r){n&&(d.current=!0,f.current={row:e,col:r},u([{row:e,col:r}]))},handleMouseOver:function(e,r){if(n&&d.current&&f.current){for(var t=[],o=Math.min(f.current.row,e),a=Math.max(f.current.row,e),c=Math.min(f.current.col,r),i=Math.max(f.current.col,r),s=o;s<=a;s++)for(var l=c;l<=i;l++)t.push({row:s,col:l});u(t)}},handleMouseUp:function(){d.current=!1,f.current=null},isSelected:v,getBorderClass:function(e,n){var r=[];return v(e-1,n)||r.push("st-selected-top-border"),v(e+1,n)||r.push("st-selected-bottom-border"),v(e,n-1)||r.push("st-selected-left-border"),v(e,n+1)||r.push("st-selected-right-border"),r.join(" ")},isTopLeftCell:function(e,n){return e===Math.min.apply(Math,l.map((function(e){return e.row})))&&n===Math.min.apply(Math,l.map((function(e){return e.col})))},setSelectedCells:u}}({selectableCells:Y,headers:te.current,rows:he}),me=ge.handleMouseDown,pe=ge.handleMouseOver,we=ge.handleMouseUp,be=ge.isSelected,Ce=ge.getBorderClass,ye=ge.isTopLeftCell,xe=ge.setSelectedCells,De=te.current.filter((function(e){return!e.hide})),Re=g((function(){return!!_.current&&De.reduce((function(e,n){return e+n.width}),0)<_.current.clientWidth}),[De]),Ie=Q?he.slice((de-1)*X,de*X):he;i((function(){var e=function(e){e.target.closest(".st-cell")||xe([])};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[xe]);var Ee=g((function(){return"".concat(De.filter((function(e){return!0!==se[e.accessor]})).map((function(e){return"".concat(e.width,"px")})).join(" ")," 1fr")}),[De,se]);return i((function(){N&&require("../../styles/simple-table.css")}),[N]),n(L.Provider,p({value:{rows:j,tableRows:$}},{children:e("div",p({className:"st-wrapper",style:x?{height:x}:{}},{children:[e("div",p({className:"st-table-wrapper"},{children:[e("div",p({className:"st-table",onMouseUp:we,onMouseLeave:we,ref:_,style:{gridTemplateColumns:Ee}},{children:[n(E,{columnResizing:f,draggable:b,forceUpdate:ve,headersRef:te,hiddenColumns:se,isWidthDragging:ne,onSort:function(e,n){ce((function(r){return(null==r?void 0:r.key.accessor)!==n?{key:te.current[e],direction:"ascending"}:"ascending"===(null==r?void 0:r.direction)?{key:te.current[e],direction:"descending"}:null}))},onTableHeaderDragEnd:function(e){te.current=e,ve()},setIsWidthDragging:re,shouldDisplayLastColumnCell:Re,sort:ae,sortDownIcon:K,sortUpIcon:Z,tableRef:_}),n(S,{getBorderClass:Ce,handleMouseDown:me,handleMouseOver:pe,headers:te.current,hiddenColumns:se,isSelected:be,isTopLeftCell:ye,isWidthDragging:ne,onCellChange:A,shouldDisplayLastColumnCell:Re,shouldPaginate:Q,sortedRows:Ie,tableRef:_})]})),n(W,{headers:te.current,columnEditorText:u,editColumns:y,position:s,setHiddenColumns:le,hiddenColumns:se})]})),n(B,{currentPage:de,hideFooter:R,nextIcon:k,onPageChange:fe,prevIcon:z,rowsPerPage:X,shouldPaginate:Q,totalRows:he.length})]}))}))};export{F as SimpleTable};
|
|
1
|
+
import{jsxs as e,jsx as n,Fragment as r}from"react/jsx-runtime";import t,{useState as o,useRef as a,useCallback as c,useEffect as i,Children as s,useLayoutEffect as l,forwardRef as u,createRef as d,createContext as f,useContext as h,Fragment as v,useMemo as g,useReducer as m}from"react";var p=function(){return p=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},p.apply(this,arguments)};function w(e,n,r){if(r||2===arguments.length)for(var t,o=0,a=n.length;o<a;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var b=function(e){var n={};return s.forEach(e,(function(e){if(e&&e.ref&&e.ref.current){var r=e.ref.current.getBoundingClientRect();n[e.key]=r}})),n},C=function(e){var n,r,c=e.allowHorizontalAnimate,s=void 0===c||c,u=e.children,d=e.pauseAnimation,f=e.tableRef,h=a(!1),v=o({}),g=v[0],m=v[1],p=o({}),w=p[0],C=p[1],y=(n=u,r=a(),i((function(){r.current=n}),[n]),r.current);return l((function(){var e=b(u);m(e)}),[u]),l((function(){var e=b(y);C(e);var n=f.current,r=function(){h.current=!0;var e=b(y);m(e),C(e)},t=function(){h.current=!1};return null==n||n.addEventListener("scroll",r),null==n||n.addEventListener("scrollend",t),function(){null==n||n.removeEventListener("scroll",r),null==n||n.removeEventListener("scrollend",t)}}),[y,f]),i((function(){d||h.current||Object.keys(w).length&&t.Children.forEach(u,(function(e){if(e){var n=e.ref.current,r=w[e.key],t=g[e.key];if(r&&t){var o=r.left-t.left,a=s?0:r.top-t.top,c=Math.abs(o),i=Math.abs(a);(c>10||i>10)&&requestAnimationFrame((function(){n.style.transform="translate(".concat(o,"px, ").concat(a,"px)"),n.style.transition="transform 0s, opacity 0s",requestAnimationFrame((function(){n.style.transform="",n.style.transition="transform 300ms ease-out, opacity 300ms ease-out"}))}))}}}))}),[s,g,u,d,w]),u},y=!1,x=function(e){var n=e.draggedHeaderRef,r=e.headersRef,t=e.hoveredHeaderRef,o=e.onTableHeaderDragEnd;return{handleDragStart:function(e){n.current=e},handleDragOver:function(e){!function(e){var a;if(!y&&(t.current=e,e.accessor!==(null===(a=n.current)||void 0===a?void 0:a.accessor)&&null!==n.current&&!y)){if(y=!0,!r.current)return;var c=w([],r.current,!0),i=c.findIndex((function(e){var r;return e.accessor===(null===(r=n.current)||void 0===r?void 0:r.accessor)})),s=c.findIndex((function(n){return n.accessor===e.accessor}));if(void 0===i||void 0===s)return;var l=c.splice(i,1)[0];c.splice(s,0,l),JSON.stringify(c)!==JSON.stringify(r.current)&&setTimeout((function(){o(c),setTimeout((function(){y=!1}),500)}),50)}}(e)},handleDragEnd:function(){n.current=null,t.current=null}}},D=function(e,n){var r=!0,t=!0;return function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];if(r)return r=!1,void setTimeout((function(){return t=!1}),n);t||(e.apply(this,o),t=!0,setTimeout((function(){return t=!1}),n))}},R=u((function(r,t){var c,s=r.draggable,l=r.draggedHeaderRef,u=r.columnResizing,d=r.forceUpdate,f=r.headersRef,h=r.hoveredHeaderRef,v=r.index,g=r.onSort,m=r.onTableHeaderDragEnd,w=r.setIsWidthDragging,b=r.sort,C=r.sortDownIcon,y=r.sortUpIcon,R=a({pageX:0,pageY:0}),E=o(!1),I=E[0],N=E[1],M=null===(c=f.current)||void 0===c?void 0:c[v],k=Boolean(null==M?void 0:M.isSortable),L="st-header-cell ".concat(M===h.current?"st-hovered":""," ").concat(I?"st-dragging":""," ").concat(k?"clickable":""," ").concat(s&&!k?"draggable":""),A=x({draggedHeaderRef:l,headersRef:f,hoveredHeaderRef:h,onTableHeaderDragEnd:m}),T=A.handleDragStart,S=A.handleDragOver,O=A.handleDragEnd,B=a(D((function(e){S(e)}),100)).current,H=function(e){e.isSortable&&g(v,e.accessor)};return i((function(){var e=function(e){var n=new Image;n.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=",e.dataTransfer.setDragImage(n,0,0)};return document.addEventListener("dragend",e,!1),function(){document.removeEventListener("dragend",e)}}),[]),M?e("div",p({className:L,ref:t,style:{width:M.width}},{children:[n("div",p({className:"st-header-label",draggable:s,onClick:function(){return H(M)},onDragStart:function(e){s&&M&&(e.dataTransfer.dropEffect="move",function(e){N(!0),T(e)}(M))},onDragOver:function(e){return function(e,n){e.preventDefault(),e.dataTransfer.dropEffect="move";var r=e.pageX,t=e.pageY;r===R.current.pageX&&t===R.current.pageY||(R.current={pageX:r,pageY:t},B(n,e))}(e,M)},onDragEnd:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",N(!1),O()},onMouseEnter:function(){return document.body.style.overflow="hidden"},onMouseLeave:function(){return document.body.style.overflow="auto"}},{children:null==M?void 0:M.label})),b&&b.key.accessor===M.accessor&&e("div",p({className:"st-sort-icon-container",onClick:function(){return H(M)}},{children:["ascending"===b.direction&&y&&y,"descending"===b.direction&&C&&C]})),u&&n("div",{className:"st-header-resize-handle",onMouseDown:function(e){w(!0),e.preventDefault();var n=e.clientX;if(M){var r=M.width,t=D((function(e){var t=Math.max(r+(e.clientX-n),40);M&&(f.current[v].width=t,d())}),10),o=function(){document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",o),w(!1)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",o)}}})]})):null})),E=u((function(e,r){return e.visible?n("div",{className:"st-cell",ref:r}):n("div",{ref:r})})),I=function(t){var o,c=t.draggable,i=t.columnResizing,s=t.forceUpdate,l=t.headersRef,u=t.hiddenColumns,f=t.isWidthDragging,h=t.onSort,v=t.onTableHeaderDragEnd,g=t.setIsWidthDragging,m=t.shouldDisplayLastColumnCell,w=t.sort,b=t.sortDownIcon,y=t.sortUpIcon,x=t.tableRef,D=a(null),I=a(null);return n(r,{children:e(C,p({pauseAnimation:f,tableRef:x},{children:[null===(o=l.current)||void 0===o?void 0:o.map((function(e,r){return u[e.accessor]?null:n(R,{draggable:c,draggedHeaderRef:D,columnResizing:i,forceUpdate:s,headersRef:l,hoveredHeaderRef:I,index:r,onSort:h,onTableHeaderDragEnd:v,ref:d(),setIsWidthDragging:g,sort:w,sortDownIcon:b,sortUpIcon:y},e.accessor)})),n(E,{ref:d(),visible:m})]}))})},N=function(r){var t=r.value,o=r.onBlur,a=r.onChange;return e("select",p({value:t.toString(),onBlur:o,onChange:a},{children:[n("option",p({value:"true"},{children:"True"})),n("option",p({value:"false"},{children:"False"}))]}))},M=function(e){var r=e.defaultValue,t=e.onBlur,o=e.onChange,c=a(null);return n("input",{className:"editable-cell-input",ref:c,autoFocus:!0,type:"text",defaultValue:r,onBlur:t,onChange:o})},k=function(e){var t=e.onChange,o=e.setIsEditing,a=e.value,c=function(e){var n=e.target.value;null==t||t(n)},i=function(){o(!1)};return n(r,{children:"string"==typeof a?n(M,{defaultValue:a,onBlur:i,onChange:c}):"boolean"==typeof a?n(N,{value:a,onBlur:i,onChange:c}):null})},L=f({rows:[],tableRows:[]}),A=u((function(e,r){var t=e.borderClass,a=e.colIndex,c=e.content,s=e.header,l=e.isSelected,u=e.isTopLeftCell,d=e.onCellChange,f=e.onMouseDown,v=e.onMouseOver,g=e.row,m=e.rowIndex,w=h(L),b=w.rows,C=w.tableRows,y=o(c),x=y[0],D=y[1],R=o(!1),E=R[0],I=R[1],N=Boolean(null==s?void 0:s.isEditable),M=m%2==0,A="st-cell ".concat(l?u?"st-cell-selected-first-cell ".concat(t):"st-cell-selected ".concat(t):""," ").concat(M?"st-cell-odd-row":""," ").concat(N?"clickable":"");i((function(){D(c)}),[c]),i((function(){if(void 0!==g.originalRowIndex&&"number"==typeof g.originalRowIndex){var e=b[g.originalRowIndex];e[s.accessor]!==x?D(e[s.accessor]):C[g.originalRowIndex][s.accessor]=x}}),[s.accessor,x,b,g.originalRowIndex,C]);return n("div",E?p({className:"st-cell-editing ".concat(M?"st-cell-odd-row":"")},{children:n(k,{onChange:function(e){D(e),null==d||d({accessor:s.accessor,newValue:e,newRowIndex:m,originalRowIndex:g.originalRowIndex,row:g})},setIsEditing:I,value:x})}):p({className:A,onDoubleClick:function(){return s.isEditable&&I(!0)},onMouseDown:function(){return f(m,a)},onMouseOver:function(){return v(m,a)},ref:r},{children:x}))})),T=function(){return n("div",{className:"st-row-separator"})},S=function(t){var o=t.getBorderClass,a=t.handleMouseDown,c=t.handleMouseOver,i=t.headers,s=t.hiddenColumns,l=t.isSelected,u=t.isTopLeftCell,f=t.isWidthDragging,h=t.onCellChange,g=t.shouldDisplayLastColumnCell,m=t.shouldPaginate,w=t.sortedRows,b=t.tableRef;return n(r,{children:w.map((function(r,t){return e(v,{children:[e(C,p({allowHorizontalAnimate:m,pauseAnimation:f,tableRef:b},{children:[i.map((function(e,i){if(s[e.accessor])return null;var f=r[e.accessor];return e.cellRenderer&&(f=e.cellRenderer(r)),n(A,{borderClass:o(t,i),colIndex:i,content:f,header:e,isSelected:l(t,i),isTopLeftCell:u(t,i),onCellChange:h,onMouseDown:function(){return a(t,i)},onMouseOver:function(){return c(t,i)},ref:d(),row:r,rowIndex:t},e.accessor)})),n(E,{ref:d(),visible:g})]})),t!==w.length-1&&n(T,{})]},r.originalRowIndex)}))})},O=function(r){var t=r.currentPage,o=r.hideFooter,a=r.nextIcon,c=r.onPageChange,i=r.prevIcon,s=r.rowsPerPage,l=r.shouldPaginate,u=r.totalRows,d=Math.ceil(u/s),f=t>1,h=t<d,v=function(e){e>=1&&e<=d&&c(e)};return o||!l?null:e("div",p({className:"st-footer"},{children:[n("button",p({className:"st-next-prev-btn ".concat(f?"":"disabled"),onClick:function(){return v(t-1)},disabled:!f},{children:i})),n("button",p({className:"st-next-prev-btn ".concat(h?"":"disabled"),onClick:function(){return v(t+1)},disabled:!h},{children:a})),Array.from({length:d},(function(e,r){return n("button",p({onClick:function(){return v(r+1)},className:"st-page-btn ".concat(t===r+1?"active":"")},{children:r+1}),r)}))]}))},B=function(e){var r=e.className;return n("svg",p({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"})}))},H=function(e){var r=e.className;return n("svg",p({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"})}))},P=function(e){var r=e.className;return n("svg",p({className:r,viewBox:"0 0 20 20",width:"20",height:"20",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"})}))},U=function(e){var r=e.className;return n("svg",p({className:r,viewBox:"0 0 20 20",width:"20",height:"20",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"})}))},z=function(r){var t=r.checked,a=void 0!==t&&t,c=r.children,i=r.onChange,s=o(a),l=s[0],u=s[1];return e("label",p({className:"st-checkbox-label"},{children:[n("input",{checked:l,className:"st-checkbox-input",onChange:function(){var e=!l;u(e),i&&i(e)},type:"checkbox"}),n("span",p({className:"st-checkbox-custom ".concat(l?"st-checked":"")},{children:l&&n("span",{className:"st-checkbox-checkmark"})})),c]}))},j=function(e){var r=e.headers,t=e.open,o=e.position;e.setOpen;var a=e.setHiddenColumns,c=e.hiddenColumns,i="left"===o?"left":"";return n("div",p({className:"st-column-editor-popout ".concat(t?"open":""," ").concat(i),onClick:function(e){return e.stopPropagation()}},{children:n("div",p({className:"st-column-editor-popout-content"},{children:r.map((function(e,r){return n(z,p({checked:c[e.accessor],onChange:function(n){var r;return a(p(p({},c),((r={})[e.accessor]=n,r)))}},{children:e.label}),r)}))}))}))},W=function(r){var t=r.columnEditorText,a=r.editColumns,c=r.headers,i=r.position,s=void 0===i?"right":i,l=r.setHiddenColumns,u=r.hiddenColumns,d=o(!1),f=d[0],h=d[1];return a?e("div",p({className:"st-column-editor ".concat(f?"open":""," ").concat(s),onClick:function(){return function(e){h(e)}(!f)}},{children:[n("div",p({className:"st-column-editor-text"},{children:t})),n(j,{headers:c,open:f,position:s,setOpen:h,setHiddenColumns:l,hiddenColumns:u})]})):null},F=function(r){var t=r.columnEditorPosition,s=void 0===t?"right":t,l=r.columnEditorText,u=void 0===l?"Columns":l,d=r.columnResizing,f=void 0!==d&&d,h=r.defaultHeaders,v=r.draggable,b=void 0!==v&&v,C=r.editColumns,y=void 0!==C&&C,x=r.height,D=r.hideFooter,R=void 0!==D&&D,E=r.importStyles,N=void 0===E||E,M=r.nextIcon,k=void 0===M?n(H,{className:"st-next-prev-icon"}):M,A=r.onCellChange,T=r.prevIcon,z=void 0===T?n(B,{className:"st-next-prev-icon"}):T,j=r.rows,F=r.rowsPerPage,X=void 0===F?10:F,V=r.selectableCells,Y=void 0!==V&&V,q=r.shouldPaginate,Q=void 0!==q&&q,J=r.sortDownIcon,K=void 0===J?n(U,{className:"st-sort-icon"}):J,G=r.sortUpIcon,_=void 0===G?n(P,{className:"st-sort-icon"}):G,Z=g((function(){return j.map((function(e,n){return p(p({},e),{originalRowIndex:n})}))}),[j]),$=a(null),ee=o(!1),ne=ee[0],re=ee[1],te=a(h),oe=o(null),ae=oe[0],ce=oe[1],ie=o({}),se=ie[0],le=ie[1],ue=o(1),de=ue[0],fe=ue[1],he=g((function(){if(!ae)return Z;var e=function(e,n,r){var t=r?r.key:e[0],o="ascending";return r&&r.key.accessor===t.accessor&&"ascending"===r.direction&&(o="descending"),{sortedData:w([],n,!0).sort((function(e,n){return e[t.accessor]<n[t.accessor]?"ascending"===o?1:-1:e[t.accessor]>n[t.accessor]?"ascending"===o?-1:1:0})),newSortConfig:{key:t,direction:o}}}(te.current,Z,ae).sortedData;return e}),[Z,ae]),ve=m((function(e){return e+1}),0)[1],ge=function(e){var n=e.selectableCells,r=e.headers,t=e.rows,s=o([]),l=s[0],u=s[1],d=a(!1),f=a(null),h=c((function(){var e=l.reduce((function(e,n){var o=n.row,a=n.col;return e[o]||(e[o]=[]),e[o][a]=t[o][r[a].accessor],e}),{}),n=Object.values(e).map((function(e){return Object.values(e).join("\t")})).join("\n");navigator.clipboard.writeText(n)}),[l,t,r]);i((function(){var e=function(e){(e.ctrlKey||e.metaKey)&&"c"===e.key&&h()};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[h,l]);var v=function(e,n){return l.some((function(r){return r.row===e&&r.col===n}))};return{selectedCells:l,handleMouseDown:function(e,r){n&&(d.current=!0,f.current={row:e,col:r},u([{row:e,col:r}]))},handleMouseOver:function(e,r){if(n&&d.current&&f.current){for(var t=[],o=Math.min(f.current.row,e),a=Math.max(f.current.row,e),c=Math.min(f.current.col,r),i=Math.max(f.current.col,r),s=o;s<=a;s++)for(var l=c;l<=i;l++)t.push({row:s,col:l});u(t)}},handleMouseUp:function(){d.current=!1,f.current=null},isSelected:v,getBorderClass:function(e,n){var r=[];return v(e-1,n)||r.push("st-selected-top-border"),v(e+1,n)||r.push("st-selected-bottom-border"),v(e,n-1)||r.push("st-selected-left-border"),v(e,n+1)||r.push("st-selected-right-border"),r.join(" ")},isTopLeftCell:function(e,n){return e===Math.min.apply(Math,l.map((function(e){return e.row})))&&n===Math.min.apply(Math,l.map((function(e){return e.col})))},setSelectedCells:u}}({selectableCells:Y,headers:te.current,rows:he}),me=ge.handleMouseDown,pe=ge.handleMouseOver,we=ge.handleMouseUp,be=ge.isSelected,Ce=ge.getBorderClass,ye=ge.isTopLeftCell,xe=ge.setSelectedCells,De=te.current.filter((function(e){return!e.hide})),Re=g((function(){return!!$.current&&De.reduce((function(e,n){return e+n.width}),0)<$.current.clientWidth}),[De]),Ee=Q?he.slice((de-1)*X,de*X):he;i((function(){var e=function(e){e.target.closest(".st-cell")||xe([])};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[xe]);var Ie=g((function(){return"".concat(De.filter((function(e){return!0!==se[e.accessor]})).map((function(e){return"".concat(e.width,"px")})).join(" ")," 1fr")}),[De,se]);return i((function(){process.env.NODE_ENV;require("../../styles/simple-table.css")}),[N]),n(L.Provider,p({value:{rows:j,tableRows:Z}},{children:e("div",p({className:"st-wrapper",style:x?{height:x}:{}},{children:[e("div",p({className:"st-table-wrapper"},{children:[e("div",p({className:"st-table",onMouseUp:we,onMouseLeave:we,ref:$,style:{gridTemplateColumns:Ie}},{children:[n(I,{columnResizing:f,draggable:b,forceUpdate:ve,headersRef:te,hiddenColumns:se,isWidthDragging:ne,onSort:function(e,n){ce((function(r){return(null==r?void 0:r.key.accessor)!==n?{key:te.current[e],direction:"ascending"}:"ascending"===(null==r?void 0:r.direction)?{key:te.current[e],direction:"descending"}:null}))},onTableHeaderDragEnd:function(e){te.current=e,ve()},setIsWidthDragging:re,shouldDisplayLastColumnCell:Re,sort:ae,sortDownIcon:K,sortUpIcon:_,tableRef:$}),n(S,{getBorderClass:Ce,handleMouseDown:me,handleMouseOver:pe,headers:te.current,hiddenColumns:se,isSelected:be,isTopLeftCell:ye,isWidthDragging:ne,onCellChange:A,shouldDisplayLastColumnCell:Re,shouldPaginate:Q,sortedRows:Ee,tableRef:$})]})),n(W,{headers:te.current,columnEditorText:u,editColumns:y,position:s,setHiddenColumns:le,hiddenColumns:se})]})),n(O,{currentPage:de,hideFooter:R,nextIcon:k,onPageChange:fe,prevIcon:z,rowsPerPage:X,shouldPaginate:Q,totalRows:he.length})]}))}))};export{F as SimpleTable};
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
/* Import Nunito font from Google Fonts */
|
|
2
|
+
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;700&display=swap");
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
/* Slate Colors */
|
|
6
|
+
--slate-50: #f8fafc;
|
|
7
|
+
--slate-100: #f1f5f9;
|
|
8
|
+
--slate-200: #e2e8f0;
|
|
9
|
+
--slate-300: #cbd5e1;
|
|
10
|
+
--slate-400: #94a3b8;
|
|
11
|
+
--slate-500: #64748b;
|
|
12
|
+
--slate-600: #475569;
|
|
13
|
+
--slate-700: #334155;
|
|
14
|
+
--slate-800: #1e293b;
|
|
15
|
+
--slate-900: #0f172a;
|
|
16
|
+
|
|
17
|
+
/* Blue Colors */
|
|
18
|
+
--blue-50: #eff6ff;
|
|
19
|
+
--blue-100: #dbeafe;
|
|
20
|
+
--blue-200: #bfdbfe;
|
|
21
|
+
--blue-300: #93c5fd;
|
|
22
|
+
--blue-400: #60a5fa;
|
|
23
|
+
--blue-500: #3b82f6;
|
|
24
|
+
--blue-600: #2563eb;
|
|
25
|
+
--blue-700: #1d4ed8;
|
|
26
|
+
--blue-800: #1e40af;
|
|
27
|
+
--blue-900: #1e3a8a;
|
|
28
|
+
|
|
29
|
+
/* Orange Colors */
|
|
30
|
+
--orange-50: #fff7ed;
|
|
31
|
+
--orange-100: #ffedd5;
|
|
32
|
+
--orange-200: #fed7aa;
|
|
33
|
+
--orange-300: #fdba74;
|
|
34
|
+
--orange-400: #fb923c;
|
|
35
|
+
--orange-500: #f97316;
|
|
36
|
+
--orange-600: #ea580c;
|
|
37
|
+
--orange-700: #c2410c;
|
|
38
|
+
--orange-800: #9a3412;
|
|
39
|
+
--orange-900: #7c2d12;
|
|
40
|
+
|
|
41
|
+
/* Amber Colors */
|
|
42
|
+
--amber-50: #fffbeb;
|
|
43
|
+
--amber-100: #fef3c7;
|
|
44
|
+
--amber-200: #fde68a;
|
|
45
|
+
--amber-300: #fcd34d;
|
|
46
|
+
--amber-400: #fbbf24;
|
|
47
|
+
--amber-500: #f59e0b;
|
|
48
|
+
--amber-600: #d97706;
|
|
49
|
+
--amber-700: #b45309;
|
|
50
|
+
--amber-800: #92400e;
|
|
51
|
+
--amber-900: #78350f;
|
|
52
|
+
|
|
53
|
+
/* Customizable Variables */
|
|
54
|
+
--st-border-radius: 4px;
|
|
55
|
+
--st-border-color: var(--slate-300);
|
|
56
|
+
--st-border-width: 1px;
|
|
57
|
+
--st-resize-handle-color: var(--slate-300);
|
|
58
|
+
--st-separator-border-color: var(--slate-300);
|
|
59
|
+
--st-odd-row-background-color: var(--slate-100);
|
|
60
|
+
--st-dragging-background-color: var(--blue-100);
|
|
61
|
+
--st-selected-cell-background-color: var(--blue-200);
|
|
62
|
+
--st-selected-first-cell-background-color: var(--amber-100);
|
|
63
|
+
--st-border-top-color: var(--blue-500);
|
|
64
|
+
--st-border-bottom-color: var(--blue-500);
|
|
65
|
+
--st-border-left-color: var(--blue-500);
|
|
66
|
+
--st-border-right-color: var(--blue-500);
|
|
67
|
+
--st-border-top-white-color: white;
|
|
68
|
+
--st-footer-background-color: white;
|
|
69
|
+
--st-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
|
70
|
+
--st-cell-padding: 8px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Global styles */
|
|
74
|
+
* {
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Apply Nunito as the default font */
|
|
81
|
+
body {
|
|
82
|
+
font-family: "Nunito";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Wrapper for the table */
|
|
86
|
+
.st-wrapper {
|
|
87
|
+
position: relative;
|
|
88
|
+
border: var(--st-border-width) solid var(--st-border-color);
|
|
89
|
+
border-radius: var(--st-border-radius);
|
|
90
|
+
max-height: 100dvh;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.st-table-wrapper {
|
|
95
|
+
position: relative;
|
|
96
|
+
display: flex;
|
|
97
|
+
width: max-content;
|
|
98
|
+
overflow: visible;
|
|
99
|
+
height: 100%;
|
|
100
|
+
width: 100%;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Main table styling */
|
|
104
|
+
.st-table {
|
|
105
|
+
position: relative;
|
|
106
|
+
display: grid;
|
|
107
|
+
border-collapse: collapse;
|
|
108
|
+
table-layout: auto;
|
|
109
|
+
white-space: nowrap;
|
|
110
|
+
width: 100%;
|
|
111
|
+
height: 100%;
|
|
112
|
+
overflow: auto;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* Styles for table header cells */
|
|
116
|
+
.st-header-cell {
|
|
117
|
+
position: sticky;
|
|
118
|
+
top: 0;
|
|
119
|
+
background-color: white;
|
|
120
|
+
z-index: 1;
|
|
121
|
+
font-weight: 600;
|
|
122
|
+
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
gap: 4px;
|
|
126
|
+
border-top: var(--st-border-width) solid transparent;
|
|
127
|
+
border-bottom: var(--st-border-width) solid var(--st-border-color);
|
|
128
|
+
}
|
|
129
|
+
.st-header-cell.clickable {
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
}
|
|
132
|
+
.st-header-cell.draggable {
|
|
133
|
+
cursor: grab;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Common styles for table header and cells */
|
|
137
|
+
.st-header-cell,
|
|
138
|
+
.st-cell {
|
|
139
|
+
color: var(--slate-800);
|
|
140
|
+
overflow: hidden;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.st-cell.clickable {
|
|
144
|
+
cursor: pointer;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.st-header-cell,
|
|
148
|
+
.st-cell,
|
|
149
|
+
.st-cell-editing {
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: 40px;
|
|
152
|
+
font-family: "Nunito";
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.st-cell-editing {
|
|
156
|
+
position: relative;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.st-header-label {
|
|
160
|
+
flex: 1;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.st-header-label,
|
|
164
|
+
.st-cell {
|
|
165
|
+
user-select: none;
|
|
166
|
+
padding: var(--st-cell-padding);
|
|
167
|
+
text-align: left;
|
|
168
|
+
white-space: nowrap;
|
|
169
|
+
text-overflow: ellipsis;
|
|
170
|
+
overflow: hidden;
|
|
171
|
+
width: 100%;
|
|
172
|
+
}
|
|
173
|
+
.st-cell {
|
|
174
|
+
position: relative;
|
|
175
|
+
border: var(--st-border-width) solid transparent;
|
|
176
|
+
}
|
|
177
|
+
.st-sort-icon-container {
|
|
178
|
+
display: flex;
|
|
179
|
+
flex-direction: column;
|
|
180
|
+
align-items: center;
|
|
181
|
+
justify-content: center;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.st-sort-icon {
|
|
185
|
+
fill: var(--slate-500);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.st-header-resize-handle {
|
|
189
|
+
top: 0;
|
|
190
|
+
right: 0;
|
|
191
|
+
width: 5px;
|
|
192
|
+
height: 20px;
|
|
193
|
+
cursor: col-resize;
|
|
194
|
+
background-color: var(--st-resize-handle-color);
|
|
195
|
+
border-radius: 0.25rem;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.st-row-separator {
|
|
199
|
+
height: 1px;
|
|
200
|
+
background-color: var(--st-separator-border-color);
|
|
201
|
+
grid-column: 1 / -1;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.st-cell-odd-row {
|
|
205
|
+
background-color: var(--st-odd-row-background-color);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* Style for a cell when it is being dragged */
|
|
209
|
+
.st-dragging {
|
|
210
|
+
background-color: var(--st-dragging-background-color);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* Style for selected table cells */
|
|
214
|
+
.st-cell-selected {
|
|
215
|
+
background-color: var(--st-selected-cell-background-color);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Style for the first selected table cell */
|
|
219
|
+
.st-cell-selected-first {
|
|
220
|
+
background-color: var(--st-selected-first-cell-background-color);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/* Blue top border for cells */
|
|
224
|
+
.st-selected-top-border {
|
|
225
|
+
border-top: var(--st-border-width) solid var(--st-border-top-color);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* Blue bottom border for cells */
|
|
229
|
+
.st-selected-bottom-border {
|
|
230
|
+
border-bottom: var(--st-border-width) solid var(--st-border-bottom-color);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* Blue left border for cells */
|
|
234
|
+
.st-selected-left-border {
|
|
235
|
+
border-left: var(--st-border-width) solid var(--st-border-left-color);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Blue right border for cells */
|
|
239
|
+
.st-selected-right-border {
|
|
240
|
+
border-right: var(--st-border-width) solid var(--st-border-right-color);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* White top border for cells */
|
|
244
|
+
.st-selected-top-border-white {
|
|
245
|
+
border-top: var(--st-border-width) solid var(--st-border-top-white-color);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.st-footer {
|
|
249
|
+
display: flex;
|
|
250
|
+
align-items: center;
|
|
251
|
+
background-color: var(--st-footer-background-color);
|
|
252
|
+
|
|
253
|
+
padding: 8px;
|
|
254
|
+
|
|
255
|
+
border-top: var(--st-border-width) solid var(--st-border-color);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.st-next-prev-btn {
|
|
259
|
+
display: flex;
|
|
260
|
+
align-items: center;
|
|
261
|
+
justify-content: center;
|
|
262
|
+
padding: 4px;
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
background-color: transparent;
|
|
265
|
+
border: none;
|
|
266
|
+
border-radius: 4px;
|
|
267
|
+
transition: background-color 0.3s ease;
|
|
268
|
+
}
|
|
269
|
+
.st-next-prev-btn {
|
|
270
|
+
fill: var(--slate-600);
|
|
271
|
+
}
|
|
272
|
+
.disabled > .st-next-prev-icon {
|
|
273
|
+
cursor: not-allowed;
|
|
274
|
+
fill: var(--slate-400);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.st-next-prev-btn:not(.disabled):hover {
|
|
278
|
+
background-color: var(--slate-100);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.st-page-btn {
|
|
282
|
+
margin-left: 4px;
|
|
283
|
+
padding: 4px;
|
|
284
|
+
cursor: pointer;
|
|
285
|
+
background-color: transparent;
|
|
286
|
+
color: var(--slate-600);
|
|
287
|
+
border: none;
|
|
288
|
+
border-radius: var(--st-border-radius);
|
|
289
|
+
transition: background-color 0.3s ease;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.st-page-btn:hover {
|
|
293
|
+
background-color: var(--slate-100);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.st-page-btn.active {
|
|
297
|
+
background-color: var(--blue-500);
|
|
298
|
+
color: white;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.editable-cell-input {
|
|
302
|
+
position: absolute;
|
|
303
|
+
top: 0;
|
|
304
|
+
left: 0;
|
|
305
|
+
border-radius: var(--st-border-radius);
|
|
306
|
+
border: var(--st-border-width) solid var(--st-border-color);
|
|
307
|
+
box-shadow: var(--st-shadow);
|
|
308
|
+
z-index: 1;
|
|
309
|
+
outline: none;
|
|
310
|
+
height: 100%;
|
|
311
|
+
width: 100%;
|
|
312
|
+
padding: var(--st-cell-padding);
|
|
313
|
+
font-size: 1rem;
|
|
314
|
+
font-family: "Nunito";
|
|
315
|
+
}
|
|
316
|
+
.editable-cell-input:focus {
|
|
317
|
+
border: var(--st-border-width) solid var(--blue-500);
|
|
318
|
+
}
|
|
319
|
+
.st-column-editor {
|
|
320
|
+
position: relative;
|
|
321
|
+
user-select: none;
|
|
322
|
+
|
|
323
|
+
background: var(--st-footer-background-color);
|
|
324
|
+
border-left: var(--st-border-width) solid var(--st-border-color);
|
|
325
|
+
cursor: pointer;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.st-column-editor-text {
|
|
329
|
+
padding: 8px 4px;
|
|
330
|
+
|
|
331
|
+
writing-mode: vertical-rl;
|
|
332
|
+
color: var(--slate-500);
|
|
333
|
+
background-color: white;
|
|
334
|
+
z-index: 2;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.st-column-editor.open,
|
|
338
|
+
.st-column-editor.open .st-column-editor-text {
|
|
339
|
+
background-color: var(--slate-100);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.st-column-editor-popout {
|
|
343
|
+
position: absolute;
|
|
344
|
+
top: 0;
|
|
345
|
+
right: calc(100% + 1px);
|
|
346
|
+
z-index: 1;
|
|
347
|
+
|
|
348
|
+
height: 100%;
|
|
349
|
+
background-color: var(--slate-100);
|
|
350
|
+
|
|
351
|
+
transition: width 0.2s ease;
|
|
352
|
+
overflow: hidden;
|
|
353
|
+
width: 0;
|
|
354
|
+
}
|
|
355
|
+
.st-column-editor-popout-content {
|
|
356
|
+
display: flex;
|
|
357
|
+
flex-direction: column;
|
|
358
|
+
overflow: auto;
|
|
359
|
+
gap: 4px;
|
|
360
|
+
padding: 8px 4px;
|
|
361
|
+
border-left: var(--st-border-width) solid var(--st-border-color);
|
|
362
|
+
height: 100%;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.st-column-editor-popout.open {
|
|
366
|
+
width: 200px;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.st-column-editor-popout.left {
|
|
370
|
+
transform: translateX(-100%);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.st-column-editor-popout.open.left {
|
|
374
|
+
transform: translateX(0);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/* Checkbox styles */
|
|
378
|
+
.st-checkbox-label {
|
|
379
|
+
display: flex;
|
|
380
|
+
align-items: center;
|
|
381
|
+
cursor: pointer;
|
|
382
|
+
gap: 8px;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.st-checkbox-input {
|
|
386
|
+
display: none; /* Hide the default checkbox */
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.st-checkbox-custom {
|
|
390
|
+
display: flex;
|
|
391
|
+
align-items: center;
|
|
392
|
+
justify-content: center;
|
|
393
|
+
|
|
394
|
+
width: 24px;
|
|
395
|
+
height: 24px;
|
|
396
|
+
|
|
397
|
+
border: var(--st-border-width) solid var(--slate-300);
|
|
398
|
+
border-radius: var(--st-border-radius);
|
|
399
|
+
|
|
400
|
+
background-color: white;
|
|
401
|
+
transition: background-color 0.3s ease, border-color 0.3s ease;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.st-checkbox-custom.st-checked {
|
|
405
|
+
background-color: var(--blue-500);
|
|
406
|
+
border-color: var(--blue-500);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.st-checkbox-checkmark {
|
|
410
|
+
width: 6px;
|
|
411
|
+
height: 11px;
|
|
412
|
+
border: solid white;
|
|
413
|
+
border-width: 0 2px 2px 0;
|
|
414
|
+
transform: rotate(45deg);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
@keyframes slide-in-left {
|
|
418
|
+
from {
|
|
419
|
+
transform: translateX(-100%);
|
|
420
|
+
}
|
|
421
|
+
to {
|
|
422
|
+
transform: translateX(0);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
@keyframes slide-in-right {
|
|
427
|
+
from {
|
|
428
|
+
transform: translateX(100%);
|
|
429
|
+
}
|
|
430
|
+
to {
|
|
431
|
+
transform: translateX(0);
|
|
432
|
+
}
|
|
433
|
+
}
|