mantine-datatable 1.7.3 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import*as i from"react";import{Box as la,createStyles as sa,packSx as da,Table as ua}from"@mantine/core";import{useElementSize as me}from"@mantine/hooks";import{useEffect as pa}from"react";import{createStyles as Ir}from"@mantine/core";import{jsx as Ye}from"react/jsx-runtime";var Vr=Ir({root:{"&&":{background:"transparent"}}});function be(){let{classes:e}=Vr();return Ye("tr",{className:e.root,children:Ye("td",{})})}import{Center as $r,createStyles as Xr,Text as Kr}from"@mantine/core";function P(){return P=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e},P.apply(this,arguments)}function Gr(e,r){if(e==null)return{};var o={},a=Object.keys(e),t,f;for(f=0;f<a.length;f++)t=a[f],!(r.indexOf(t)>=0)&&(o[t]=e[t]);return o}function F(e,r){if(e==null)return{};var o=Gr(e,r),a,t;if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(e);for(t=0;t<f.length;t++)a=f[t],!(r.indexOf(a)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,a)||(o[a]=e[a]))}return o}import $ from"react";var Ur=["size","color"];function Be(e){var r=e.size,o=r===void 0?24:r,a=e.color,t=a===void 0?"currentColor":a,f=F(e,Ur);return $.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-arrow-down",width:o,height:o,viewBox:"0 0 24 24",stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),$.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$.createElement("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),$.createElement("line",{x1:"18",y1:"13",x2:"12",y2:"19"}),$.createElement("line",{x1:"6",y1:"13",x2:"12",y2:"19"}))}import X from"react";var qr=["size","color"];function Oe(e){var r=e.size,o=r===void 0?24:r,a=e.color,t=a===void 0?"currentColor":a,f=F(e,qr);return X.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-arrows-vertical",width:o,height:o,viewBox:"0 0 24 24",stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),X.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),X.createElement("polyline",{points:"8 7 12 3 16 7"}),X.createElement("polyline",{points:"8 17 12 21 16 17"}),X.createElement("line",{x1:"12",y1:"3",x2:"12",y2:"21"}))}import E from"react";var Zr=["size","color"];function we(e){var r=e.size,o=r===void 0?24:r,a=e.color,t=a===void 0?"currentColor":a,f=F(e,Zr);return E.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-off",width:o,height:o,viewBox:"0 0 24 24",stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),E.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),E.createElement("path",{d:"M12.983 8.978c3.955 -.182 7.017 -1.446 7.017 -2.978c0 -1.657 -3.582 -3 -8 -3c-1.661 0 -3.204 .19 -4.483 .515m-2.783 1.228c-.471 .382 -.734 .808 -.734 1.257c0 1.22 1.944 2.271 4.734 2.74"}),E.createElement("path",{d:"M4 6v6c0 1.657 3.582 3 8 3c.986 0 1.93 -.067 2.802 -.19m3.187 -.82c1.251 -.53 2.011 -1.228 2.011 -1.99v-6"}),E.createElement("path",{d:"M4 12v6c0 1.657 3.582 3 8 3c3.217 0 5.991 -.712 7.261 -1.74m.739 -3.26v-4"}),E.createElement("line",{x1:"3",y1:"3",x2:"21",y2:"21"}))}import{Fragment as Qr,jsx as re,jsxs as _r}from"react/jsx-runtime";var Yr=Xr(e=>({root:{position:"absolute",top:0,right:0,bottom:0,left:0,flexDirection:"column",pointerEvents:"none",color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[6],opacity:0,transition:"opacity .15s ease"},active:{opacity:1},standardIcon:{fontSize:0,borderRadius:"50%",padding:e.spacing.xs,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[2]}}));function Te({icon:e,text:r,pt:o,pb:a,active:t,children:f}){let{classes:d,cx:l}=Yr();return re($r,{pt:o,pb:a,className:l(d.root,{[d.active]:t}),children:f||_r(Qr,{children:[e||re("div",{className:d.standardIcon,children:re(we,{})}),re(Kr,{size:"sm",color:"dimmed",children:r})]})})}import{Box as jr,createStyles as Jr,Pagination as eo,Text as ro}from"@mantine/core";import{forwardRef as oo}from"react";import{jsx as Qe,jsxs as to}from"react/jsx-runtime";var ao=Jr((e,{topBorderColor:r})=>({root:{borderTop:`1px solid ${typeof r=="function"?r(e):r}`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"space-between",gap:e.spacing.xs,[e.fn.largerThan("xs")]:{flexDirection:"row"}},pagination:{opacity:1,transition:"opacity .15s ease"},paginationFetching:{opacity:0}})),_e=oo(function({className:r,style:o,topBorderColor:a,fetching:t,page:f,onPageChange:d,paginationSize:l,paginationText:x,totalRecords:u,recordsPerPage:s,recordsLength:S,horizontalSpacing:m},g){let n;if(t||!u)n="...";else{let w=(f-1)*s+1,y=w+S-1;n=x({from:w,to:y,totalRecords:u})}let{classes:h,cx:B}=ao({topBorderColor:a});return to(jr,{ref:g,px:m??"xs",py:"xs",className:B(h.root,r),style:o,children:[Qe(ro,{size:l,children:n}),Qe(eo,{className:B(h.pagination,{[h.paginationFetching]:t||!S}),page:f,onChange:d,size:l,total:Math.ceil(u/s)})]})});import{Checkbox as no,createStyles as io}from"@mantine/core";import{forwardRef as co}from"react";import{Box as ye,Center as so,createStyles as uo,Group as po}from"@mantine/core";import{useMantineTheme as fo}from"@mantine/core";import{useMediaQuery as lo}from"@mantine/hooks";function oe(e){let r=fo(),o=typeof e=="function"?e(r):e;return lo(o||"",!0)}function ae(e){let r=e.replace(/([a-z\d])([A-Z]+)/g,"$1 $2").replace(/\W|_/g," ").trim().toLowerCase();return`${r.charAt(0).toUpperCase()}${r.slice(1)}`}function je(e,r,o){if(typeof o=="string"){let a=o;o=t=>t[a]}return e.filter(a=>!r.map(o).includes(o(a)))}function te(e,r){if(typeof r=="string"){let o=r;r=a=>a[o]}return e.filter((o,a,t)=>a===t.findIndex(f=>r(o)===r(f)))}function c(e,r){return r?r.match(/([^[.\]])+/g).reduce((a,t)=>a&&a[t],e):void 0}import{jsx as N,jsxs as xo}from"react/jsx-runtime";var mo=uo(e=>({sortableColumnHeader:{cursor:"pointer",transition:"background .15s ease","&:hover":{background:e.colorScheme==="dark"?e.colors.dark[6]:e.colors.gray[0]}},columnHeaderText:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},sortableColumnHeaderText:{minWidth:0,flexGrow:1},sortableColumnHeaderIcon:{transition:"transform .15s ease"},sortableColumnHeaderIconRotated:{transform:"rotate3d(0, 0, 1, 180deg)"},sortableColumnHeaderNeutralIcon:{color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5],transition:"color .15s ease","th:hover &":{color:e.colorScheme==="dark"?e.colors.dark[2]:e.colors.gray[6]}}}));function De({accessor:e,visibleMediaQuery:r,title:o,sortable:a,textAlignment:t,width:f,sortStatus:d,onSortStatusChange:l}){let{cx:x,classes:u}=mo();if(!oe(r))return null;let s=o??ae(e);return N(ye,{component:"th",className:x({[u.sortableColumnHeader]:a}),sx:{"&&":{textAlign:t},width:f,minWidth:f,maxWidth:f},role:a?"button":void 0,onClick:a&&l?()=>{l({columnAccessor:e,direction:d?.direction==="asc"?"desc":"asc"})}:void 0,children:a||d?.columnAccessor===e?xo(po,{position:"apart",noWrap:!0,spacing:"xs",children:[N(ye,{className:x(u.columnHeaderText,u.sortableColumnHeaderText),children:s}),N(so,{children:d?.columnAccessor===e?N(Be,{className:x(u.sortableColumnHeaderIcon,{[u.sortableColumnHeaderIconRotated]:d.direction==="desc"}),size:14}):N(Oe,{className:u.sortableColumnHeaderNeutralIcon,size:14})})]}):N(ye,{className:u.columnHeaderText,children:s})})}import{jsx as fe,jsxs as ho}from"react/jsx-runtime";var go=io(e=>{let r=e.colorScheme==="dark"?.5:.05;return{root:{zIndex:2,position:"sticky",top:0,background:e.colorScheme==="dark"?e.colors.dark[7]:e.white},textSelectionDisabled:{userSelect:"none"},selectorColumnHeader:{position:"sticky",width:0,left:0,background:"inherit","&::after":{content:'""',position:"absolute",top:0,right:-e.spacing.sm,bottom:0,borderLeft:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,width:e.spacing.sm,background:`linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`,pointerEvents:"none",opacity:0,transition:"opacity .15s ease"}},selectorColumnHeaderWithRightShadow:{"&::after":{opacity:1}},selectionCheckboxInput:{cursor:"pointer"}}}),Je=co(function({className:r,style:o,sortStatus:a,onSortStatusChange:t,columns:f,selectionVisible:d,selectionChecked:l,selectionIndeterminate:x,onSelectionChange:u,leftShadowVisible:s},S){let{classes:m,cx:g}=go();return fe("thead",{className:g(m.root,r),style:o,ref:S,children:ho("tr",{children:[d&&fe("th",{className:g(m.selectorColumnHeader,{[m.selectorColumnHeaderWithRightShadow]:s}),children:fe(no,{classNames:{input:m.selectionCheckboxInput},checked:l,indeterminate:x,disabled:!u,onChange:u})}),f.map(({accessor:n,hidden:h,visibleMediaQuery:B,textAlignment:w,width:y,title:D,sortable:A})=>h?null:fe(De,{accessor:n,visibleMediaQuery:B,textAlignment:w,width:y,title:D,sortable:A,sortStatus:a,onSortStatusChange:t},n))]})})});import{Center as Co,createStyles as So,Loader as bo}from"@mantine/core";import{jsx as er}from"react/jsx-runtime";var Bo=So(e=>({root:{zIndex:3,position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",background:e.fn.rgba(e.colorScheme==="dark"?e.colors.dark[8]:e.white,.75),opacity:0,transition:"opacity .15s ease"},fetching:{pointerEvents:"all",opacity:1}}));function ke({pt:e,pb:r,fetching:o,loaderBackgroundBlur:a,loaderSize:t,loaderVariant:f}){let{classes:d,cx:l}=Bo();return er(Co,{pt:e,pb:r,className:l(d.root,{[d.fetching]:o}),sx:a?{backdropFilter:`blur(${a}px)`}:void 0,children:o&&er(bo,{size:t,variant:f})})}import{createStyles as Ho}from"@mantine/core";import{Box as Oo,createStyles as wo}from"@mantine/core";import{jsx as yo}from"react/jsx-runtime";var To=wo({ellipsis:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}});function Re({className:e,sx:r,style:o,visibleMediaQuery:a,record:t,ellipsis:f,textAlignment:d,width:l,accessor:x,render:u}){let{cx:s,classes:S}=To();return oe(a)?yo(Oo,{component:"td",className:s({[S.ellipsis]:f},e),sx:[{width:l,minWidth:l,maxWidth:l,textAlign:d},r],style:o,children:u?u(t):c(t,x)}):null}import{Collapse as Do,createStyles as ko}from"@mantine/core";import{useDebouncedState as le,useTimeout as rr}from"@mantine/hooks";import{useEffect as Pe,useState as K}from"react";var se=200,de={leading:!0};function or(){let[e,r]=le(!0,se,de),[o,a]=le(!0,se,de),[t,f]=le(!0,se,de),[d,l]=le(!0,se,de);return{scrolledToTop:e,setScrolledToTop:r,scrolledToBottom:o,setScrolledToBottom:a,scrolledToLeft:t,setScrolledToLeft:f,scrolledToRight:d,setScrolledToRight:l}}function ar(e){let[r,o]=K(null),a=e?.join(":")||"";return Pe(()=>{o(null)},[a]),{lastSelectionChangeIndex:r,setLastSelectionChangeIndex:o}}function tr(e){let[r,o]=K(null);return Pe(()=>{e&&o(null)},[e]),{rowContextMenuInfo:r,setRowContextMenuInfo:o}}function fr({rowExpansion:e,records:r,idAccessor:o}){let a=[];if(e&&r){let{trigger:d,allowMultiple:l,initiallyExpanded:x}=e;r&&d==="always"?a=r.map(u=>c(u,o)):x&&(a=r.filter(x).map(u=>c(u,o)),l||(a=[a[0]]))}let[t,f]=K(a);if(typeof e<"u"){let d=l=>f(t.filter(x=>x!==c(l,o)));return{expandOnClick:e.trigger!=="always",isRowExpanded:l=>e.trigger==="always"?!0:t.includes(c(l,o)),expandRow:l=>{let x=c(l,o);f(e.allowMultiple?[...t,x]:[x])},collapseRow:d,collapseProps:e.collapseProps,content:l=>()=>e.content({record:l,collapse:()=>d(l)})}}}function lr(e,r){let[o,a]=K(e),[t,f]=K(e),d=rr(()=>a(!0),0),l=rr(()=>f(!1),r||200);return Pe(()=>{e?(l.clear(),f(!0),d.start()):(d.clear(),a(!1),l.start())},[d,l,e]),{expanded:o,visible:t}}import{Fragment as Po,jsx as ue,jsxs as Ao}from"react/jsx-runtime";var Ro=ko({cell:{"&&":{borderBottomWidth:0,padding:0}},expandedCell:{"&&":{borderBottomWidth:1}}});function Ae({open:e,colSpan:r,content:o,collapseProps:a}){let{expanded:t,visible:f}=lr(e,a?.transitionDuration),{cx:d,classes:l}=Ro();return f?Ao(Po,{children:[ue("tr",{}),ue("tr",{children:ue("td",{className:d(l.cell,{[l.expandedCell]:t}),colSpan:r,children:ue(Do,{in:t,...a,children:o()})})})]}):null}import{Checkbox as Mo,createStyles as Lo}from"@mantine/core";import{jsx as sr}from"react/jsx-runtime";var vo=Lo(e=>{let r=e.colorScheme==="dark"?.5:.05;return{root:{position:"sticky",zIndex:1,left:0,background:"inherit","&::after":{content:'""',position:"absolute",top:0,right:-e.spacing.sm,bottom:0,borderLeft:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,width:e.spacing.sm,background:`linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`,pointerEvents:"none",opacity:0,transition:"opacity .15s ease"}},withRightShadow:{"&::after":{opacity:1}},checkbox:{cursor:"pointer"}}});function Me({withRightShadow:e,...r}){let{cx:o,classes:a}=vo();return sr("td",{className:o(a.root,{[a.withRightShadow]:e}),children:sr(Mo,{classNames:{input:a.checkbox},...r,onClick:t=>t.stopPropagation()})})}import{Fragment as Eo,jsx as Le,jsxs as dr}from"react/jsx-runtime";var Fo=Ho(e=>{let r=e.colors[e.primaryColor][6];return{withPointerCursor:{cursor:"pointer"},selected:{"&&":{"tr&":{background:e.colorScheme==="dark"?e.fn.darken(r,.6):e.fn.lighten(r,.9)},"table[data-striped] tbody &:nth-of-type(odd)":{background:e.colorScheme==="dark"?e.fn.darken(r,.55):e.fn.lighten(r,.85)}}},contextMenuVisible:{"&&":{"tr&":{background:e.colorScheme==="dark"?e.fn.darken(r,.5):e.fn.lighten(r,.7)},"table[data-striped] tbody &:nth-of-type(odd)":{background:e.colorScheme==="dark"?e.fn.darken(r,.45):e.fn.lighten(r,.65)}}}}});function ve({record:e,columns:r,selectionVisible:o,selectionChecked:a,onSelectionChange:t,onClick:f,onContextMenu:d,expansion:l,contextMenuVisible:x,leftShadowVisible:u}){let{cx:s,classes:S}=Fo();return dr(Eo,{children:[dr("tr",{className:s({[S.withPointerCursor]:f||l?.expandOnClick,[S.selected]:a,[S.contextMenuVisible]:x}),onClick:m=>{if(l){let{isRowExpanded:g,expandOnClick:n,expandRow:h,collapseRow:B}=l;n&&(g(e)?B(e):h(e))}f?.(m)},onContextMenu:d,children:[o&&Le(Me,{withRightShadow:u,checked:a,disabled:!t,onChange:t}),r.map(({accessor:m,hidden:g,visibleMediaQuery:n,textAlignment:h,ellipsis:B,width:w,render:y,cellsClassName:D,cellsStyle:A,cellsSx:xe})=>g?null:Le(Re,{className:typeof D=="function"?D(e):D,style:typeof A=="function"?A(e):A,sx:xe,visibleMediaQuery:n,record:e,accessor:m,textAlignment:h,ellipsis:B,width:w,render:y},m))]}),l&&Le(Ae,{colSpan:r.filter(m=>!m.hidden).length+(o?1:0),open:l.isRowExpanded(e),content:l.content(e),collapseProps:l.collapseProps})]})}import{createStyles as No,Paper as Wo,useMantineTheme as zo}from"@mantine/core";import{useClickOutside as Io,useElementSize as Vo,useMergedRef as Go,useWindowEvent as ur}from"@mantine/hooks";import{jsx as qo}from"react/jsx-runtime";var Uo=No(e=>({root:{position:"fixed",border:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,overflow:"hidden",transition:"all .15s ease"}}));function He({borderRadius:e="xs",shadow:r="sm",zIndex:o=3,top:a,left:t,onDestroy:f,children:d}){ur("resize",f),ur("scroll",f);let l=Io(f),{ref:x,width:u,height:s}=Vo(),S=Go(l,x),{spacing:{xs:m}}=zo(),{innerWidth:g,innerHeight:n}=window,h=a+s+m>n?n-s-m:a,B=t+u+m>g?g-u-m:t,{classes:w}=Uo();return qo(Wo,{ref:S,shadow:r,radius:e,className:w.root,sx:{top:h,left:B,zIndex:o},children:d})}import{createStyles as Zo}from"@mantine/core";import{jsx as Xo}from"react/jsx-runtime";var $o=Zo(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function Fe(){let{classes:e}=$o();return Xo("div",{className:e.root})}import{Box as Ko,createStyles as Yo,Text as Qo,UnstyledButton as _o}from"@mantine/core";import{jsx as pr,jsxs as Jo}from"react/jsx-runtime";var jo=Yo((e,{color:r})=>{let o=e.spacing.sm/2;return{root:{width:"100%",display:"flex",alignItems:"center",paddingTop:o,paddingBottom:o,paddingLeft:e.spacing.sm,paddingRight:e.spacing.sm,color:r&&e.colors[r][6],transition:"background .15s ease","&[disabled]":{cursor:"not-allowed",color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5]},"&:hover:not([disabled])":{background:e.fn.rgba(r?e.colors[r][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],r?e.colorScheme==="dark"?.15:.08:.25)},"&:active:not([disabled])":{background:e.fn.rgba(r?e.colors[r][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],r?e.colorScheme==="dark"?.3:.2:.5)}},icon:{fontSize:0,marginRight:e.spacing.xs},title:{whiteSpace:"nowrap"}}});function Ee({icon:e,title:r,color:o,disabled:a,onClick:t}){let{classes:f}=jo({color:o});return Jo(_o,{className:f.root,disabled:a,onClick:t,children:[e&&pr(Ko,{className:f.icon,children:e}),pr(Qo,{className:f.title,size:"sm",children:r})]})}import{Box as ea,createStyles as ra,ScrollArea as oa}from"@mantine/core";import{forwardRef as aa}from"react";import{jsx as pe,jsxs as fa}from"react/jsx-runtime";var ta=ra(e=>{let r=e.colorScheme==="dark"?.5:.05;return{root:{flex:"1 1 100%"},scrollbar:{'&[data-state="visible"]':{background:"transparent"},"div::before":{pointerEvents:"none"}},corner:{background:"transparent"},thumb:{zIndex:3},shadow:{position:"absolute",pointerEvents:"none",opacity:0,transition:"opacity .15s ease"},topShadow:{zIndex:2,top:0,left:0,right:0,height:e.spacing.sm,background:`linear-gradient(${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`},leftShadow:{zIndex:3,top:0,left:0,bottom:0,width:e.spacing.sm,background:`linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`},rightShadow:{zIndex:2,top:0,bottom:0,right:0,width:e.spacing.sm,background:`linear-gradient(to left, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(to left, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`},bottomShadow:{zIndex:2,left:0,right:0,bottom:0,height:e.spacing.sm,background:`linear-gradient(${e.fn.rgba(e.black,0)}, ${e.fn.rgba(e.black,r)}), linear-gradient(${e.fn.rgba(e.black,0)} 30%, ${e.fn.rgba(e.black,r)})`},shadowVisible:{opacity:1}}}),mr=aa(function({topShadowVisible:r,leftShadowVisible:o,rightShadowVisible:a,bottomShadowVisible:t,headerHeight:f,onScrollPositionChange:d,children:l},x){let{cx:u,classes:s}=ta();return fa(oa,{viewportRef:x,classNames:{root:s.root,scrollbar:s.scrollbar,thumb:s.thumb,corner:s.corner},styles:{scrollbar:{marginTop:f}},onScrollPositionChange:d,children:[l,pe(ea,{className:u(s.shadow,s.topShadow,{[s.shadowVisible]:r}),sx:{top:f}}),pe("div",{className:u(s.shadow,s.leftShadow,{[s.shadowVisible]:o})}),pe("div",{className:u(s.shadow,s.rightShadow,{[s.shadowVisible]:a})}),pe("div",{className:u(s.shadow,s.bottomShadow,{[s.shadowVisible]:t})})]})});import{jsx as O,jsxs as xr}from"react/jsx-runtime";var ma={},xa=sa((e,{borderColor:r,rowBorderColor:o})=>{let a=typeof r=="function"?r(e):r,t=typeof o=="function"?o(e):o;return{root:{position:"relative",display:"flex",flexDirection:"column",overflow:"hidden",tr:{backgroundColor:e.colorScheme==="dark"?e.colors.dark[7]:e.white},"&&":{"thead tr th":{borderBottomColor:a},"tbody tr td":{borderBottomColor:t}}},lastRowBorderBottomVisible:{"tbody tr:last-of-type td":{borderBottom:`1px solid ${t}`}},textSelectionDisabled:{userSelect:"none"},table:{borderCollapse:"separate",borderSpacing:0},tableWithBorder:{border:`1px solid ${a}`},tableWithColumnBorders:{"th, td":{":not(:first-of-type)":{borderLeft:`1px solid ${t}`}}},verticalAlignmentTop:{td:{verticalAlign:"top"}},verticalAlignmentBottom:{td:{verticalAlign:"bottom"}}}});function nr({withBorder:e,borderRadius:r,borderColor:o=C=>C.colorScheme==="dark"?C.colors.dark[4]:C.colors.gray[3],rowBorderColor:a=C=>C.fn.rgba(C.colorScheme==="dark"?C.colors.dark[4]:C.colors.gray[3],.65),withColumnBorders:t,textSelectionDisabled:f,height:d="100%",minHeight:l,shadow:x,verticalAlignment:u="center",fetching:s,columns:S,idAccessor:m="id",records:g,selectedRecords:n,onSelectedRecordsChange:h,sortStatus:B,onSortStatusChange:w,horizontalSpacing:y,page:D,onPageChange:A,totalRecords:xe,recordsPerPage:ir,paginationSize:cr="sm",paginationText:gr=({from:C,to:W,totalRecords:M})=>`${C} - ${W} / ${M}`,loaderSize:hr,loaderVariant:Cr,loaderBackgroundBlur:Sr,emptyState:br,noRecordsText:Br="No records",noRecordsIcon:Or,striped:wr,onRowClick:ne,rowContextMenu:T,rowExpansion:Tr,sx:yr,className:Dr,classNames:ie,style:kr,styles:ce,...Rr}){let{ref:C,width:W,height:M}=me(),{ref:Pr,height:ge}=me(),{ref:Ar,width:he,height:Y}=me(),{ref:Mr,height:Ne}=me(),{scrolledToTop:Lr,setScrolledToTop:We,scrolledToBottom:vr,setScrolledToBottom:ze,scrolledToLeft:Ie,setScrolledToLeft:Ve,scrolledToRight:Hr,setScrolledToRight:Ge}=or(),{rowContextMenuInfo:L,setRowContextMenuInfo:z}=tr(s),Fr=fr({rowExpansion:Tr,records:g,idAccessor:m}),Ue=()=>{if(!s&&T&&z(null),s||Y<=M)We(!0),ze(!0);else{let p=C.current.scrollTop;We(p===0),ze(Math.round(Y-p)===Math.round(M))}if(s||he===W)Ve(!0),Ge(!0);else{let p=C.current.scrollLeft;Ve(p===0),Ge(Math.round(he-p)===Math.round(W))}};pa(Ue,[s,M,C,W,Y,he]);let Er=p=>{C.current.scrollTo({top:0,left:0}),A(p)},Q=g?.length,I=g?.map(p=>c(p,m)),V=n?.map(p=>c(p,m)),qe=I!==void 0&&V!==void 0&&V.length>0,Ce=qe&&I.every(p=>V.includes(p)),Nr=qe&&I.some(p=>V.includes(p)),Ze;h&&(Ze=()=>{h(Ce?n.filter(p=>!I.includes(c(p,m))):te([...n,...g],p=>c(p,m)))});let{lastSelectionChangeIndex:_,setLastSelectionChangeIndex:Wr}=ar(I),$e=!!n&&!Ie,{cx:Xe,classes:k,theme:zr}=xa({borderColor:o,rowBorderColor:a}),Se=typeof ce=="function"?ce(zr,ma):ce;return xr(la,{className:Xe(k.root,{[k.tableWithBorder]:e},Dr,ie?.root),sx:[p=>({borderRadius:p.radius[r]||r,boxShadow:p.shadows[x]||x,height:d,minHeight:l}),...da(yr)],style:{...Se?.root,...kr},children:[O(mr,{ref:C,topShadowVisible:!Lr,leftShadowVisible:!(n||Ie),rightShadowVisible:!Hr,bottomShadowVisible:!vr,headerHeight:ge,onScrollPositionChange:Ue,children:xr(ua,{ref:Ar,horizontalSpacing:y,className:Xe(k.table,{[k.tableWithColumnBorders]:t,[k.lastRowBorderBottomVisible]:Y<M,[k.textSelectionDisabled]:f,[k.verticalAlignmentTop]:u==="top",[k.verticalAlignmentBottom]:u==="bottom"}),striped:Q?wr:!1,...Rr,children:[O(Je,{ref:Pr,className:ie?.header,style:Se?.header,columns:S,sortStatus:B,onSortStatusChange:w,selectionVisible:!!n,selectionChecked:Ce,selectionIndeterminate:Nr&&!Ce,onSelectionChange:Ze,leftShadowVisible:$e}),O("tbody",{children:Q?g.map((p,R)=>{let v=c(p,m),G=V?.includes(v)||!1,j=!1,J=!1;if(T){let{hidden:b}=T;(!b||!(typeof b=="function"?b(p):b))&&(T.trigger==="click"?j=!0:J=!0)}let ee;h&&(ee=b=>{if(b.nativeEvent.shiftKey&&_!==null){let H=g.filter(R>_?(q,Z)=>Z>=_&&Z<=R:(q,Z)=>Z>=R&&Z<=_);h(G?je(n,H,q=>c(q,m)):te([...n,...H],q=>c(q,m)))}else h(G?n.filter(H=>c(H,m)!==v):te([...n,p],H=>c(H,m)));Wr(R)});let U;j?U=b=>{z({top:b.clientY,left:b.clientX,record:p}),ne?.(p)}:ne&&(U=()=>{ne(p)});let Ke;return J&&(Ke=b=>{b.preventDefault(),z({top:b.clientY,left:b.clientX,record:p})}),O(ve,{record:p,columns:S,selectionVisible:!!n,selectionChecked:G,onSelectionChange:ee,onClick:U,onContextMenu:Ke,contextMenuVisible:L?c(L.record,m)===v:!1,expansion:Fr,leftShadowVisible:$e},v)}):O(be,{})})]})}),D&&O(_e,{ref:Mr,className:ie?.pagination,style:Se?.pagination,topBorderColor:o,horizontalSpacing:y,fetching:s,page:D,onPageChange:Er,totalRecords:xe,recordsPerPage:ir,paginationSize:cr,paginationText:gr,recordsLength:Q}),O(ke,{pt:ge,pb:Ne,fetching:s,loaderBackgroundBlur:Sr,loaderSize:hr,loaderVariant:Cr}),O(Te,{pt:ge,pb:Ne,icon:Or,text:Br,active:!s&&!Q,children:br}),T&&L&&O(He,{zIndex:T.zIndex,borderRadius:T.borderRadius,shadow:T.shadow,top:L.top,left:L.left,onDestroy:()=>z(null),children:T.items(L.record).map(({divider:p,key:R,title:v,icon:G,color:j,hidden:J,disabled:ee,onClick:U})=>p?O(Fe,{},R):J?null:O(Ee,{title:v??ae(R),icon:G,color:j,disabled:ee,onClick:()=>{z(null),U()}},R))})]})}export{nr as DataTable};
1
+ import*as i from"react";import{Box as la,createStyles as sa,packSx as da,Table as ua}from"@mantine/core";import{useElementSize as me}from"@mantine/hooks";import{useEffect as pa}from"react";import{createStyles as Ir}from"@mantine/core";import{jsx as Ye}from"react/jsx-runtime";var Vr=Ir({root:{"&&":{background:"transparent"}}});function be(){let{classes:e}=Vr();return Ye("tr",{className:e.root,children:Ye("td",{})})}import{Center as $r,createStyles as Xr,Text as Kr}from"@mantine/core";function P(){return P=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o])}return e},P.apply(this,arguments)}function Gr(e,r){if(e==null)return{};var a={},o=Object.keys(e),t,f;for(f=0;f<o.length;f++)t=o[f],!(r.indexOf(t)>=0)&&(a[t]=e[t]);return a}function F(e,r){if(e==null)return{};var a=Gr(e,r),o,t;if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(e);for(t=0;t<f.length;t++)o=f[t],!(r.indexOf(o)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,o)||(a[o]=e[o]))}return a}import $ from"react";var Ur=["size","color"];function Be(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=F(e,Ur);return $.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-arrow-down",width:a,height:a,viewBox:"0 0 24 24",stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),$.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$.createElement("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),$.createElement("line",{x1:"18",y1:"13",x2:"12",y2:"19"}),$.createElement("line",{x1:"6",y1:"13",x2:"12",y2:"19"}))}import X from"react";var qr=["size","color"];function Oe(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=F(e,qr);return X.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-arrows-vertical",width:a,height:a,viewBox:"0 0 24 24",stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),X.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),X.createElement("polyline",{points:"8 7 12 3 16 7"}),X.createElement("polyline",{points:"8 17 12 21 16 17"}),X.createElement("line",{x1:"12",y1:"3",x2:"12",y2:"21"}))}import E from"react";var Zr=["size","color"];function we(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=F(e,Zr);return E.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-off",width:a,height:a,viewBox:"0 0 24 24",stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),E.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),E.createElement("path",{d:"M12.983 8.978c3.955 -.182 7.017 -1.446 7.017 -2.978c0 -1.657 -3.582 -3 -8 -3c-1.661 0 -3.204 .19 -4.483 .515m-2.783 1.228c-.471 .382 -.734 .808 -.734 1.257c0 1.22 1.944 2.271 4.734 2.74"}),E.createElement("path",{d:"M4 6v6c0 1.657 3.582 3 8 3c.986 0 1.93 -.067 2.802 -.19m3.187 -.82c1.251 -.53 2.011 -1.228 2.011 -1.99v-6"}),E.createElement("path",{d:"M4 12v6c0 1.657 3.582 3 8 3c3.217 0 5.991 -.712 7.261 -1.74m.739 -3.26v-4"}),E.createElement("line",{x1:"3",y1:"3",x2:"21",y2:"21"}))}import{Fragment as Qr,jsx as re,jsxs as _r}from"react/jsx-runtime";var Yr=Xr(e=>({root:{position:"absolute",top:0,right:0,bottom:0,left:0,flexDirection:"column",pointerEvents:"none",color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[6],opacity:0,transition:"opacity .15s ease"},active:{opacity:1},standardIcon:{fontSize:0,borderRadius:"50%",padding:e.spacing.xs,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[2]}}));function Te({icon:e,text:r,pt:a,pb:o,active:t,children:f}){let{classes:d,cx:l}=Yr();return re($r,{pt:a,pb:o,className:l(d.root,{[d.active]:t}),children:f||_r(Qr,{children:[e||re("div",{className:d.standardIcon,children:re(we,{})}),re(Kr,{size:"sm",color:"dimmed",children:r})]})})}import{Box as jr,createStyles as Jr,Pagination as eo,Text as ro}from"@mantine/core";import{forwardRef as oo}from"react";import{jsx as Qe,jsxs as to}from"react/jsx-runtime";var ao=Jr((e,{topBorderColor:r})=>({root:{borderTop:`1px solid ${typeof r=="function"?r(e):r}`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"space-between",gap:e.spacing.xs,[e.fn.largerThan("xs")]:{flexDirection:"row"}},pagination:{opacity:1,transition:"opacity .15s ease"},paginationFetching:{opacity:0}})),_e=oo(function({className:r,style:a,topBorderColor:o,fetching:t,page:f,onPageChange:d,paginationSize:l,paginationText:x,totalRecords:u,recordsPerPage:s,recordsLength:S,horizontalSpacing:m},g){let n;if(t||!u)n="...";else{let w=(f-1)*s+1,y=w+S-1;n=x({from:w,to:y,totalRecords:u})}let{classes:h,cx:B}=ao({topBorderColor:o});return to(jr,{ref:g,px:m??"xs",py:"xs",className:B(h.root,r),style:a,children:[Qe(ro,{size:l,children:n}),Qe(eo,{className:B(h.pagination,{[h.paginationFetching]:t||!S}),page:f,onChange:d,size:l,total:Math.ceil(u/s)})]})});import{Checkbox as no,createStyles as io}from"@mantine/core";import{forwardRef as co}from"react";import{Box as ye,Center as so,createStyles as uo,Group as po}from"@mantine/core";import{useMantineTheme as fo}from"@mantine/core";import{useMediaQuery as lo}from"@mantine/hooks";function oe(e){let r=fo(),a=typeof e=="function"?e(r):e;return lo(a||"",!0)}function ae(e){let r=e.replace(/([a-z\d])([A-Z]+)/g,"$1 $2").replace(/\W|_/g," ").trim().toLowerCase();return`${r.charAt(0).toUpperCase()}${r.slice(1)}`}function je(e,r,a){return e.filter(o=>!r.map(a).includes(a(o)))}function te(e,r){return e.filter((a,o,t)=>o===t.findIndex(f=>r(a)===r(f)))}function c(e,r){return r?r.match(/([^[.\]])+/g).reduce((o,t)=>o&&o[t],e):void 0}import{jsx as N,jsxs as xo}from"react/jsx-runtime";var mo=uo(e=>({sortableColumnHeader:{cursor:"pointer",transition:"background .15s ease","&:hover":{background:e.colorScheme==="dark"?e.colors.dark[6]:e.colors.gray[0]}},columnHeaderText:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},sortableColumnHeaderText:{minWidth:0,flexGrow:1},sortableColumnHeaderIcon:{transition:"transform .15s ease"},sortableColumnHeaderIconRotated:{transform:"rotate3d(0, 0, 1, 180deg)"},sortableColumnHeaderNeutralIcon:{color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5],transition:"color .15s ease","th:hover &":{color:e.colorScheme==="dark"?e.colors.dark[2]:e.colors.gray[6]}}}));function De({accessor:e,visibleMediaQuery:r,title:a,sortable:o,textAlignment:t,width:f,sortStatus:d,onSortStatusChange:l}){let{cx:x,classes:u}=mo();if(!oe(r))return null;let s=a??ae(e);return N(ye,{component:"th",className:x({[u.sortableColumnHeader]:o}),sx:{"&&":{textAlign:t},width:f,minWidth:f,maxWidth:f},role:o?"button":void 0,onClick:o&&l?()=>{l({columnAccessor:e,direction:d?.direction==="asc"?"desc":"asc"})}:void 0,children:o||d?.columnAccessor===e?xo(po,{position:"apart",noWrap:!0,spacing:"xs",children:[N(ye,{className:x(u.columnHeaderText,u.sortableColumnHeaderText),children:s}),N(so,{children:d?.columnAccessor===e?N(Be,{className:x(u.sortableColumnHeaderIcon,{[u.sortableColumnHeaderIconRotated]:d.direction==="desc"}),size:14}):N(Oe,{className:u.sortableColumnHeaderNeutralIcon,size:14})})]}):N(ye,{className:u.columnHeaderText,children:s})})}import{jsx as fe,jsxs as ho}from"react/jsx-runtime";var go=io(e=>{let r=e.colorScheme==="dark"?.5:.05;return{root:{zIndex:2,position:"sticky",top:0,background:e.colorScheme==="dark"?e.colors.dark[7]:e.white},textSelectionDisabled:{userSelect:"none"},selectorColumnHeader:{position:"sticky",width:0,left:0,background:"inherit","&::after":{content:'""',position:"absolute",top:0,right:-e.spacing.sm,bottom:0,borderLeft:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,width:e.spacing.sm,background:`linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`,pointerEvents:"none",opacity:0,transition:"opacity .15s ease"}},selectorColumnHeaderWithRightShadow:{"&::after":{opacity:1}},selectionCheckboxInput:{cursor:"pointer"}}}),Je=co(function({className:r,style:a,sortStatus:o,onSortStatusChange:t,columns:f,selectionVisible:d,selectionChecked:l,selectionIndeterminate:x,onSelectionChange:u,leftShadowVisible:s},S){let{classes:m,cx:g}=go();return fe("thead",{className:g(m.root,r),style:a,ref:S,children:ho("tr",{children:[d&&fe("th",{className:g(m.selectorColumnHeader,{[m.selectorColumnHeaderWithRightShadow]:s}),children:fe(no,{classNames:{input:m.selectionCheckboxInput},checked:l,indeterminate:x,disabled:!u,onChange:u})}),f.map(({accessor:n,hidden:h,visibleMediaQuery:B,textAlignment:w,width:y,title:D,sortable:A})=>h?null:fe(De,{accessor:n,visibleMediaQuery:B,textAlignment:w,width:y,title:D,sortable:A,sortStatus:o,onSortStatusChange:t},n))]})})});import{Center as Co,createStyles as So,Loader as bo}from"@mantine/core";import{jsx as er}from"react/jsx-runtime";var Bo=So(e=>({root:{zIndex:3,position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",background:e.fn.rgba(e.colorScheme==="dark"?e.colors.dark[8]:e.white,.75),opacity:0,transition:"opacity .15s ease"},fetching:{pointerEvents:"all",opacity:1}}));function ke({pt:e,pb:r,fetching:a,loaderBackgroundBlur:o,loaderSize:t,loaderVariant:f}){let{classes:d,cx:l}=Bo();return er(Co,{pt:e,pb:r,className:l(d.root,{[d.fetching]:a}),sx:o?{backdropFilter:`blur(${o}px)`}:void 0,children:a&&er(bo,{size:t,variant:f})})}import{createStyles as Ho}from"@mantine/core";import{Box as Oo,createStyles as wo}from"@mantine/core";import{jsx as yo}from"react/jsx-runtime";var To=wo({ellipsis:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}});function Re({className:e,sx:r,style:a,visibleMediaQuery:o,record:t,ellipsis:f,textAlignment:d,width:l,accessor:x,render:u}){let{cx:s,classes:S}=To();return oe(o)?yo(Oo,{component:"td",className:s({[S.ellipsis]:f},e),sx:[{width:l,minWidth:l,maxWidth:l,textAlign:d},r],style:a,children:u?u(t):c(t,x)}):null}import{Collapse as Do,createStyles as ko}from"@mantine/core";import{useDebouncedState as le,useTimeout as rr}from"@mantine/hooks";import{useEffect as Pe,useState as K}from"react";var se=200,de={leading:!0};function or(){let[e,r]=le(!0,se,de),[a,o]=le(!0,se,de),[t,f]=le(!0,se,de),[d,l]=le(!0,se,de);return{scrolledToTop:e,setScrolledToTop:r,scrolledToBottom:a,setScrolledToBottom:o,scrolledToLeft:t,setScrolledToLeft:f,scrolledToRight:d,setScrolledToRight:l}}function ar(e){let[r,a]=K(null),o=e?.join(":")||"";return Pe(()=>{a(null)},[o]),{lastSelectionChangeIndex:r,setLastSelectionChangeIndex:a}}function tr(e){let[r,a]=K(null);return Pe(()=>{e&&a(null)},[e]),{rowContextMenuInfo:r,setRowContextMenuInfo:a}}function fr({rowExpansion:e,records:r,idAccessor:a}){let o=[];if(e&&r){let{trigger:d,allowMultiple:l,initiallyExpanded:x}=e;r&&d==="always"?o=r.map(u=>c(u,a)):x&&(o=r.filter(x).map(u=>c(u,a)),l||(o=[o[0]]))}let[t,f]=K(o);if(typeof e<"u"){let d=l=>f(t.filter(x=>x!==c(l,a)));return{expandOnClick:e.trigger!=="always",isRowExpanded:l=>e.trigger==="always"?!0:t.includes(c(l,a)),expandRow:l=>{let x=c(l,a);f(e.allowMultiple?[...t,x]:[x])},collapseRow:d,collapseProps:e.collapseProps,content:l=>()=>e.content({record:l,collapse:()=>d(l)})}}}function lr(e,r){let[a,o]=K(e),[t,f]=K(e),d=rr(()=>o(!0),0),l=rr(()=>f(!1),r||200);return Pe(()=>{e?(l.clear(),f(!0),d.start()):(d.clear(),o(!1),l.start())},[d,l,e]),{expanded:a,visible:t}}import{Fragment as Po,jsx as ue,jsxs as Ao}from"react/jsx-runtime";var Ro=ko({cell:{"&&":{borderBottomWidth:0,padding:0}},expandedCell:{"&&":{borderBottomWidth:1}}});function Ae({open:e,colSpan:r,content:a,collapseProps:o}){let{expanded:t,visible:f}=lr(e,o?.transitionDuration),{cx:d,classes:l}=Ro();return f?Ao(Po,{children:[ue("tr",{}),ue("tr",{children:ue("td",{className:d(l.cell,{[l.expandedCell]:t}),colSpan:r,children:ue(Do,{in:t,...o,children:a()})})})]}):null}import{Checkbox as Mo,createStyles as Lo}from"@mantine/core";import{jsx as sr}from"react/jsx-runtime";var vo=Lo(e=>{let r=e.colorScheme==="dark"?.5:.05;return{root:{position:"sticky",zIndex:1,left:0,background:"inherit","&::after":{content:'""',position:"absolute",top:0,right:-e.spacing.sm,bottom:0,borderLeft:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,width:e.spacing.sm,background:`linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`,pointerEvents:"none",opacity:0,transition:"opacity .15s ease"}},withRightShadow:{"&::after":{opacity:1}},checkbox:{cursor:"pointer"}}});function Me({withRightShadow:e,...r}){let{cx:a,classes:o}=vo();return sr("td",{className:a(o.root,{[o.withRightShadow]:e}),children:sr(Mo,{classNames:{input:o.checkbox},...r,onClick:t=>t.stopPropagation()})})}import{Fragment as Eo,jsx as Le,jsxs as dr}from"react/jsx-runtime";var Fo=Ho(e=>{let r=e.colors[e.primaryColor][6];return{withPointerCursor:{cursor:"pointer"},selected:{"&&":{"tr&":{background:e.colorScheme==="dark"?e.fn.darken(r,.6):e.fn.lighten(r,.9)},"table[data-striped] tbody &:nth-of-type(odd)":{background:e.colorScheme==="dark"?e.fn.darken(r,.55):e.fn.lighten(r,.85)}}},contextMenuVisible:{"&&":{"tr&":{background:e.colorScheme==="dark"?e.fn.darken(r,.5):e.fn.lighten(r,.7)},"table[data-striped] tbody &:nth-of-type(odd)":{background:e.colorScheme==="dark"?e.fn.darken(r,.45):e.fn.lighten(r,.65)}}}}});function ve({record:e,columns:r,selectionVisible:a,selectionChecked:o,onSelectionChange:t,onClick:f,onContextMenu:d,expansion:l,contextMenuVisible:x,leftShadowVisible:u}){let{cx:s,classes:S}=Fo();return dr(Eo,{children:[dr("tr",{className:s({[S.withPointerCursor]:f||l?.expandOnClick,[S.selected]:o,[S.contextMenuVisible]:x}),onClick:m=>{if(l){let{isRowExpanded:g,expandOnClick:n,expandRow:h,collapseRow:B}=l;n&&(g(e)?B(e):h(e))}f?.(m)},onContextMenu:d,children:[a&&Le(Me,{withRightShadow:u,checked:o,disabled:!t,onChange:t}),r.map(({accessor:m,hidden:g,visibleMediaQuery:n,textAlignment:h,ellipsis:B,width:w,render:y,cellsClassName:D,cellsStyle:A,cellsSx:xe})=>g?null:Le(Re,{className:typeof D=="function"?D(e):D,style:typeof A=="function"?A(e):A,sx:xe,visibleMediaQuery:n,record:e,accessor:m,textAlignment:h,ellipsis:B,width:w,render:y},m))]}),l&&Le(Ae,{colSpan:r.filter(m=>!m.hidden).length+(a?1:0),open:l.isRowExpanded(e),content:l.content(e),collapseProps:l.collapseProps})]})}import{createStyles as No,Paper as Wo,useMantineTheme as zo}from"@mantine/core";import{useClickOutside as Io,useElementSize as Vo,useMergedRef as Go,useWindowEvent as ur}from"@mantine/hooks";import{jsx as qo}from"react/jsx-runtime";var Uo=No(e=>({root:{position:"fixed",border:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3]}`,overflow:"hidden",transition:"all .15s ease"}}));function He({borderRadius:e="xs",shadow:r="sm",zIndex:a=3,top:o,left:t,onDestroy:f,children:d}){ur("resize",f),ur("scroll",f);let l=Io(f),{ref:x,width:u,height:s}=Vo(),S=Go(l,x),{spacing:{xs:m}}=zo(),{innerWidth:g,innerHeight:n}=window,h=o+s+m>n?n-s-m:o,B=t+u+m>g?g-u-m:t,{classes:w}=Uo();return qo(Wo,{ref:S,shadow:r,radius:e,className:w.root,sx:{top:h,left:B,zIndex:a},children:d})}import{createStyles as Zo}from"@mantine/core";import{jsx as Xo}from"react/jsx-runtime";var $o=Zo(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function Fe(){let{classes:e}=$o();return Xo("div",{className:e.root})}import{Box as Ko,createStyles as Yo,Text as Qo,UnstyledButton as _o}from"@mantine/core";import{jsx as pr,jsxs as Jo}from"react/jsx-runtime";var jo=Yo((e,{color:r})=>{let a=e.spacing.sm/2;return{root:{width:"100%",display:"flex",alignItems:"center",paddingTop:a,paddingBottom:a,paddingLeft:e.spacing.sm,paddingRight:e.spacing.sm,color:r&&e.colors[r][6],transition:"background .15s ease","&[disabled]":{cursor:"not-allowed",color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5]},"&:hover:not([disabled])":{background:e.fn.rgba(r?e.colors[r][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],r?e.colorScheme==="dark"?.15:.08:.25)},"&:active:not([disabled])":{background:e.fn.rgba(r?e.colors[r][6]:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[4],r?e.colorScheme==="dark"?.3:.2:.5)}},icon:{fontSize:0,marginRight:e.spacing.xs},title:{whiteSpace:"nowrap"}}});function Ee({icon:e,title:r,color:a,disabled:o,onClick:t}){let{classes:f}=jo({color:a});return Jo(_o,{className:f.root,disabled:o,onClick:t,children:[e&&pr(Ko,{className:f.icon,children:e}),pr(Qo,{className:f.title,size:"sm",children:r})]})}import{Box as ea,createStyles as ra,ScrollArea as oa}from"@mantine/core";import{forwardRef as aa}from"react";import{jsx as pe,jsxs as fa}from"react/jsx-runtime";var ta=ra(e=>{let r=e.colorScheme==="dark"?.5:.05;return{root:{flex:"1 1 100%"},scrollbar:{'&[data-state="visible"]':{background:"transparent"},"div::before":{pointerEvents:"none"}},corner:{background:"transparent"},thumb:{zIndex:3},shadow:{position:"absolute",pointerEvents:"none",opacity:0,transition:"opacity .15s ease"},topShadow:{zIndex:2,top:0,left:0,right:0,height:e.spacing.sm,background:`linear-gradient(${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`},leftShadow:{zIndex:3,top:0,left:0,bottom:0,width:e.spacing.sm,background:`linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(to right, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`},rightShadow:{zIndex:2,top:0,bottom:0,right:0,width:e.spacing.sm,background:`linear-gradient(to left, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)}), linear-gradient(to left, ${e.fn.rgba(e.black,r)}, ${e.fn.rgba(e.black,0)} 30%)`},bottomShadow:{zIndex:2,left:0,right:0,bottom:0,height:e.spacing.sm,background:`linear-gradient(${e.fn.rgba(e.black,0)}, ${e.fn.rgba(e.black,r)}), linear-gradient(${e.fn.rgba(e.black,0)} 30%, ${e.fn.rgba(e.black,r)})`},shadowVisible:{opacity:1}}}),mr=aa(function({topShadowVisible:r,leftShadowVisible:a,rightShadowVisible:o,bottomShadowVisible:t,headerHeight:f,onScrollPositionChange:d,children:l},x){let{cx:u,classes:s}=ta();return fa(oa,{viewportRef:x,classNames:{root:s.root,scrollbar:s.scrollbar,thumb:s.thumb,corner:s.corner},styles:{scrollbar:{marginTop:f}},onScrollPositionChange:d,children:[l,pe(ea,{className:u(s.shadow,s.topShadow,{[s.shadowVisible]:r}),sx:{top:f}}),pe("div",{className:u(s.shadow,s.leftShadow,{[s.shadowVisible]:a})}),pe("div",{className:u(s.shadow,s.rightShadow,{[s.shadowVisible]:o})}),pe("div",{className:u(s.shadow,s.bottomShadow,{[s.shadowVisible]:t})})]})});import{jsx as O,jsxs as xr}from"react/jsx-runtime";var ma={},xa=sa((e,{borderColor:r,rowBorderColor:a})=>{let o=typeof r=="function"?r(e):r,t=typeof a=="function"?a(e):a;return{root:{position:"relative",display:"flex",flexDirection:"column",overflow:"hidden",tr:{backgroundColor:e.colorScheme==="dark"?e.colors.dark[7]:e.white},"&&":{"thead tr th":{borderBottomColor:o},"tbody tr td":{borderBottomColor:t}}},lastRowBorderBottomVisible:{"tbody tr:last-of-type td":{borderBottom:`1px solid ${t}`}},textSelectionDisabled:{userSelect:"none"},table:{borderCollapse:"separate",borderSpacing:0},tableWithBorder:{border:`1px solid ${o}`},tableWithColumnBorders:{"th, td":{":not(:first-of-type)":{borderLeft:`1px solid ${t}`}}},verticalAlignmentTop:{td:{verticalAlign:"top"}},verticalAlignmentBottom:{td:{verticalAlign:"bottom"}}}});function nr({withBorder:e,borderRadius:r,borderColor:a=C=>C.colorScheme==="dark"?C.colors.dark[4]:C.colors.gray[3],rowBorderColor:o=C=>C.fn.rgba(C.colorScheme==="dark"?C.colors.dark[4]:C.colors.gray[3],.65),withColumnBorders:t,textSelectionDisabled:f,height:d="100%",minHeight:l,shadow:x,verticalAlignment:u="center",fetching:s,columns:S,idAccessor:m="id",records:g,selectedRecords:n,onSelectedRecordsChange:h,sortStatus:B,onSortStatusChange:w,horizontalSpacing:y,page:D,onPageChange:A,totalRecords:xe,recordsPerPage:ir,paginationSize:cr="sm",paginationText:gr=({from:C,to:W,totalRecords:M})=>`${C} - ${W} / ${M}`,loaderSize:hr,loaderVariant:Cr,loaderBackgroundBlur:Sr,emptyState:br,noRecordsText:Br="No records",noRecordsIcon:Or,striped:wr,onRowClick:ne,rowContextMenu:T,rowExpansion:Tr,sx:yr,className:Dr,classNames:ie,style:kr,styles:ce,...Rr}){let{ref:C,width:W,height:M}=me(),{ref:Pr,height:ge}=me(),{ref:Ar,width:he,height:Y}=me(),{ref:Mr,height:Ne}=me(),{scrolledToTop:Lr,setScrolledToTop:We,scrolledToBottom:vr,setScrolledToBottom:ze,scrolledToLeft:Ie,setScrolledToLeft:Ve,scrolledToRight:Hr,setScrolledToRight:Ge}=or(),{rowContextMenuInfo:L,setRowContextMenuInfo:z}=tr(s),Fr=fr({rowExpansion:Tr,records:g,idAccessor:m}),Ue=()=>{if(!s&&T&&z(null),s||Y<=M)We(!0),ze(!0);else{let p=C.current.scrollTop;We(p===0),ze(Math.round(Y-p)===Math.round(M))}if(s||he===W)Ve(!0),Ge(!0);else{let p=C.current.scrollLeft;Ve(p===0),Ge(Math.round(he-p)===Math.round(W))}};pa(Ue,[s,M,C,W,Y,he]);let Er=p=>{C.current.scrollTo({top:0,left:0}),A(p)},Q=g?.length,I=g?.map(p=>c(p,m)),V=n?.map(p=>c(p,m)),qe=I!==void 0&&V!==void 0&&V.length>0,Ce=qe&&I.every(p=>V.includes(p)),Nr=qe&&I.some(p=>V.includes(p)),Ze;h&&(Ze=()=>{h(Ce?n.filter(p=>!I.includes(c(p,m))):te([...n,...g],p=>c(p,m)))});let{lastSelectionChangeIndex:_,setLastSelectionChangeIndex:Wr}=ar(I),$e=!!n&&!Ie,{cx:Xe,classes:k,theme:zr}=xa({borderColor:a,rowBorderColor:o}),Se=typeof ce=="function"?ce(zr,ma):ce;return xr(la,{className:Xe(k.root,{[k.tableWithBorder]:e},Dr,ie?.root),sx:[p=>({borderRadius:p.radius[r]||r,boxShadow:p.shadows[x]||x,height:d,minHeight:l}),...da(yr)],style:{...Se?.root,...kr},children:[O(mr,{ref:C,topShadowVisible:!Lr,leftShadowVisible:!(n||Ie),rightShadowVisible:!Hr,bottomShadowVisible:!vr,headerHeight:ge,onScrollPositionChange:Ue,children:xr(ua,{ref:Ar,horizontalSpacing:y,className:Xe(k.table,{[k.tableWithColumnBorders]:t,[k.lastRowBorderBottomVisible]:Y<M,[k.textSelectionDisabled]:f,[k.verticalAlignmentTop]:u==="top",[k.verticalAlignmentBottom]:u==="bottom"}),striped:Q?wr:!1,...Rr,children:[O(Je,{ref:Pr,className:ie?.header,style:Se?.header,columns:S,sortStatus:B,onSortStatusChange:w,selectionVisible:!!n,selectionChecked:Ce,selectionIndeterminate:Nr&&!Ce,onSelectionChange:Ze,leftShadowVisible:$e}),O("tbody",{children:Q?g.map((p,R)=>{let v=c(p,m),G=V?.includes(v)||!1,j=!1,J=!1;if(T){let{hidden:b}=T;(!b||!(typeof b=="function"?b(p):b))&&(T.trigger==="click"?j=!0:J=!0)}let ee;h&&(ee=b=>{if(b.nativeEvent.shiftKey&&_!==null){let H=g.filter(R>_?(q,Z)=>Z>=_&&Z<=R:(q,Z)=>Z>=R&&Z<=_);h(G?je(n,H,q=>c(q,m)):te([...n,...H],q=>c(q,m)))}else h(G?n.filter(H=>c(H,m)!==v):te([...n,p],H=>c(H,m)));Wr(R)});let U;j?U=b=>{z({top:b.clientY,left:b.clientX,record:p}),ne?.(p)}:ne&&(U=()=>{ne(p)});let Ke;return J&&(Ke=b=>{b.preventDefault(),z({top:b.clientY,left:b.clientX,record:p})}),O(ve,{record:p,columns:S,selectionVisible:!!n,selectionChecked:G,onSelectionChange:ee,onClick:U,onContextMenu:Ke,contextMenuVisible:L?c(L.record,m)===v:!1,expansion:Fr,leftShadowVisible:$e},v)}):O(be,{})})]})}),D&&O(_e,{ref:Mr,className:ie?.pagination,style:Se?.pagination,topBorderColor:a,horizontalSpacing:y,fetching:s,page:D,onPageChange:Er,totalRecords:xe,recordsPerPage:ir,paginationSize:cr,paginationText:gr,recordsLength:Q}),O(ke,{pt:ge,pb:Ne,fetching:s,loaderBackgroundBlur:Sr,loaderSize:hr,loaderVariant:Cr}),O(Te,{pt:ge,pb:Ne,icon:Or,text:Br,active:!s&&!Q,children:br}),T&&L&&O(He,{zIndex:T.zIndex,borderRadius:T.borderRadius,shadow:T.shadow,top:L.top,left:L.left,onDestroy:()=>z(null),children:T.items(L.record).map(({divider:p,key:R,title:v,icon:G,color:j,hidden:J,disabled:ee,onClick:U})=>p?O(Fe,{},R):J?null:O(Ee,{title:v??ae(R),icon:G,color:j,disabled:ee,onClick:()=>{z(null),U()}},R))})]})}export{nr as DataTable};
2
2
  //# sourceMappingURL=index.mjs.map