mantine-datatable 1.7.4 → 1.7.6

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 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};
1
+ import*as i from"react";import{Box as sa,createStyles as da,packSx as ua,Table as pa}from"@mantine/core";import{useElementSize as me}from"@mantine/hooks";import{useEffect as ma}from"react";import{createStyles as Vr}from"@mantine/core";import{jsx as Ye}from"react/jsx-runtime";var Gr=Vr({root:{"&&":{background:"transparent"}}});function be(){let{classes:e}=Gr();return Ye("tr",{className:e.root,children:Ye("td",{})})}import{Center as Xr,createStyles as Kr,Text as Yr}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 Ur(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=Ur(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 qr=["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,qr);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 Zr=["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,Zr);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 $r=["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,$r);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 _r,jsx as re,jsxs as jr}from"react/jsx-runtime";var Qr=Kr(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}=Qr();return re(Xr,{pt:a,pb:o,className:l(d.root,{[d.active]:t}),children:f||jr(_r,{children:[e||re("div",{className:d.standardIcon,children:re(we,{})}),re(Yr,{size:"sm",color:"dimmed",children:r})]})})}import{Box as Jr,createStyles as eo,Pagination as ro,Text as oo}from"@mantine/core";import{forwardRef as ao}from"react";import{jsx as Qe,jsxs as fo}from"react/jsx-runtime";var to=eo((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=ao(function({className:r,style:a,topBorderColor:o,fetching:t,page:f,onPageChange:d,paginationColor:l,paginationSize:x,paginationText:p,totalRecords:s,recordsPerPage:S,recordsLength:m,horizontalSpacing:g},n){let h;if(t||!s)h="...";else{let y=(f-1)*S+1,T=y+m-1;h=p({from:y,to:T,totalRecords:s})}let{classes:b,cx:w}=to({topBorderColor:o});return fo(Jr,{ref:n,px:g??"xs",py:"xs",className:w(b.root,r),style:a,children:[Qe(oo,{size:x,children:h}),Qe(ro,{color:l,className:w(b.pagination,{[b.paginationFetching]:t||!m}),page:f,onChange:d,size:x,total:Math.ceil(s/S)})]})});import{Checkbox as io,createStyles as co}from"@mantine/core";import{forwardRef as go}from"react";import{Box as ye,Center as uo,createStyles as po,Group as mo}from"@mantine/core";import{useMantineTheme as lo}from"@mantine/core";import{useMediaQuery as so}from"@mantine/hooks";function oe(e){let r=lo(),a=typeof e=="function"?e(r):e;return so(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 no}from"react/jsx-runtime";var xo=po(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:p}=xo();if(!oe(r))return null;let s=a??ae(e);return N(ye,{component:"th",className:x({[p.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?no(mo,{position:"apart",noWrap:!0,spacing:"xs",children:[N(ye,{className:x(p.columnHeaderText,p.sortableColumnHeaderText),children:s}),N(uo,{children:d?.columnAccessor===e?N(Be,{className:x(p.sortableColumnHeaderIcon,{[p.sortableColumnHeaderIconRotated]:d.direction==="desc"}),size:14}):N(Oe,{className:p.sortableColumnHeaderNeutralIcon,size:14})})]}):N(ye,{className:p.columnHeaderText,children:s})})}import{jsx as fe,jsxs as Co}from"react/jsx-runtime";var ho=co(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=go(function({className:r,style:a,sortStatus:o,onSortStatusChange:t,columns:f,selectionVisible:d,selectionChecked:l,selectionIndeterminate:x,onSelectionChange:p,leftShadowVisible:s},S){let{classes:m,cx:g}=ho();return fe("thead",{className:g(m.root,r),style:a,ref:S,children:Co("tr",{children:[d&&fe("th",{className:g(m.selectorColumnHeader,{[m.selectorColumnHeaderWithRightShadow]:s}),children:fe(io,{classNames:{input:m.selectionCheckboxInput},checked:l,indeterminate:x,disabled:!p,onChange:p})}),f.map(({accessor:n,hidden:h,visibleMediaQuery:b,textAlignment:w,width:y,title:T,sortable:A})=>h?null:fe(De,{accessor:n,visibleMediaQuery:b,textAlignment:w,width:y,title:T,sortable:A,sortStatus:o,onSortStatusChange:t},n))]})})});import{Center as So,createStyles as bo,Loader as Bo}from"@mantine/core";import{jsx as er}from"react/jsx-runtime";var Oo=bo(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}=Oo();return er(So,{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 Fo}from"@mantine/core";import{Box as wo,createStyles as To}from"@mantine/core";import{jsx as Do}from"react/jsx-runtime";var yo=To({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:p}){let{cx:s,classes:S}=yo();return oe(o)?Do(wo,{component:"td",className:s({[S.ellipsis]:f},e),sx:[{width:l,minWidth:l,maxWidth:l,textAlign:d},r],style:a,children:p?p(t):c(t,x)}):null}import{Collapse as ko,createStyles as Ro}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(p=>c(p,a)):x&&(o=r.filter(x).map(p=>c(p,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 Ao,jsx as ue,jsxs as Mo}from"react/jsx-runtime";var Po=Ro({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}=Po();return f?Mo(Ao,{children:[ue("tr",{}),ue("tr",{children:ue("td",{className:d(l.cell,{[l.expandedCell]:t}),colSpan:r,children:ue(ko,{in:t,...o,children:a()})})})]}):null}import{Checkbox as Lo,createStyles as vo}from"@mantine/core";import{jsx as sr}from"react/jsx-runtime";var Ho=vo(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}=Ho();return sr("td",{className:a(o.root,{[o.withRightShadow]:e}),children:sr(Lo,{classNames:{input:o.checkbox},...r,onClick:t=>t.stopPropagation()})})}import{Fragment as No,jsx as Le,jsxs as dr}from"react/jsx-runtime";var Eo=Fo(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:p}){let{cx:s,classes:S}=Eo();return dr(No,{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:p,checked:o,disabled:!t,onChange:t}),r.map(({accessor:m,hidden:g,visibleMediaQuery:n,textAlignment:h,ellipsis:b,width:w,render:y,cellsClassName:T,cellsStyle:A,cellsSx:xe})=>g?null:Le(Re,{className:typeof T=="function"?T(e):T,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 Wo,Paper as zo,useMantineTheme as Io}from"@mantine/core";import{useClickOutside as Vo,useElementSize as Go,useMergedRef as Uo,useWindowEvent as ur}from"@mantine/hooks";import{jsx as Zo}from"react/jsx-runtime";var qo=Wo(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=Vo(f),{ref:x,width:p,height:s}=Go(),S=Uo(l,x),{spacing:{xs:m}}=Io(),{innerWidth:g,innerHeight:n}=window,h=o+s+m>n?n-s-m:o,b=t+p+m>g?g-p-m:t,{classes:w}=qo();return Zo(zo,{ref:S,shadow:r,radius:e,className:w.root,sx:{top:h,left:b,zIndex:a},children:d})}import{createStyles as $o}from"@mantine/core";import{jsx as Ko}from"react/jsx-runtime";var Xo=$o(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function Fe(){let{classes:e}=Xo();return Ko("div",{className:e.root})}import{Box as Yo,createStyles as Qo,Text as _o,UnstyledButton as jo}from"@mantine/core";import{jsx as pr,jsxs as ea}from"react/jsx-runtime";var Jo=Qo((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 ea(jo,{className:f.root,disabled:o,onClick:t,children:[e&&pr(Yo,{className:f.icon,children:e}),pr(_o,{className:f.title,size:"sm",children:r})]})}import{Box as ra,createStyles as oa,ScrollArea as aa}from"@mantine/core";import{forwardRef as ta}from"react";import{jsx as pe,jsxs as la}from"react/jsx-runtime";var fa=oa(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=ta(function({topShadowVisible:r,leftShadowVisible:a,rightShadowVisible:o,bottomShadowVisible:t,headerHeight:f,onScrollPositionChange:d,children:l},x){let{cx:p,classes:s}=fa();return la(aa,{viewportRef:x,classNames:{root:s.root,scrollbar:s.scrollbar,thumb:s.thumb,corner:s.corner},styles:{scrollbar:{marginTop:f}},onScrollPositionChange:d,children:[l,pe(ra,{className:p(s.shadow,s.topShadow,{[s.shadowVisible]:r}),sx:{top:f}}),pe("div",{className:p(s.shadow,s.leftShadow,{[s.shadowVisible]:a})}),pe("div",{className:p(s.shadow,s.rightShadow,{[s.shadowVisible]:o})}),pe("div",{className:p(s.shadow,s.bottomShadow,{[s.shadowVisible]:t})})]})});import{jsx as O,jsxs as xr}from"react/jsx-runtime";var xa={},na=da((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:p="center",fetching:s,columns:S,idAccessor:m="id",records:g,selectedRecords:n,onSelectedRecordsChange:h,sortStatus:b,onSortStatusChange:w,horizontalSpacing:y,page:T,onPageChange:A,totalRecords:xe,recordsPerPage:ir,paginationColor:cr,paginationSize:gr="sm",paginationText:hr=({from:C,to:W,totalRecords:M})=>`${C} - ${W} / ${M}`,loaderSize:Cr,loaderVariant:Sr,loaderBackgroundBlur:br,emptyState:Br,noRecordsText:Or="No records",noRecordsIcon:wr,striped:Tr,onRowClick:ne,rowContextMenu:D,rowExpansion:yr,sx:Dr,className:kr,classNames:ie,style:Rr,styles:ce,...Pr}){let{ref:C,width:W,height:M}=me(),{ref:Ar,height:ge}=me(),{ref:Mr,width:he,height:Y}=me(),{ref:Lr,height:Ne}=me(),{scrolledToTop:vr,setScrolledToTop:We,scrolledToBottom:Hr,setScrolledToBottom:ze,scrolledToLeft:Ie,setScrolledToLeft:Ve,scrolledToRight:Fr,setScrolledToRight:Ge}=or(),{rowContextMenuInfo:L,setRowContextMenuInfo:z}=tr(s),Er=fr({rowExpansion:yr,records:g,idAccessor:m}),Ue=()=>{if(!s&&D&&z(null),s||Y<=M)We(!0),ze(!0);else{let u=C.current.scrollTop;We(u===0),ze(Math.round(Y-u)===Math.round(M))}if(s||he===W)Ve(!0),Ge(!0);else{let u=C.current.scrollLeft;Ve(u===0),Ge(Math.round(he-u)===Math.round(W))}};ma(Ue,[s,M,C,W,Y,he]);let Nr=u=>{C.current.scrollTo({top:0,left:0}),A(u)},Q=g?.length,I=g?.map(u=>c(u,m)),V=n?.map(u=>c(u,m)),qe=I!==void 0&&V!==void 0&&V.length>0,Ce=qe&&I.every(u=>V.includes(u)),Wr=qe&&I.some(u=>V.includes(u)),Ze;h&&(Ze=()=>{h(Ce?n.filter(u=>!I.includes(c(u,m))):te([...n,...g],u=>c(u,m)))});let{lastSelectionChangeIndex:_,setLastSelectionChangeIndex:zr}=ar(I),$e=!!n&&!Ie,{cx:Xe,classes:k,theme:Ir}=na({borderColor:a,rowBorderColor:o}),Se=typeof ce=="function"?ce(Ir,xa):ce;return xr(sa,{className:Xe(k.root,{[k.tableWithBorder]:e},kr,ie?.root),sx:[u=>({borderRadius:u.radius[r]||r,boxShadow:u.shadows[x]||x,height:d,minHeight:l}),...ua(Dr)],style:{...Se?.root,...Rr},children:[O(mr,{ref:C,topShadowVisible:!vr,leftShadowVisible:!(n||Ie),rightShadowVisible:!Fr,bottomShadowVisible:!Hr,headerHeight:ge,onScrollPositionChange:Ue,children:xr(pa,{ref:Mr,horizontalSpacing:y,className:Xe(k.table,{[k.tableWithColumnBorders]:t,[k.lastRowBorderBottomVisible]:Y<M,[k.textSelectionDisabled]:f,[k.verticalAlignmentTop]:p==="top",[k.verticalAlignmentBottom]:p==="bottom"}),striped:Q?Tr:!1,...Pr,children:[O(Je,{ref:Ar,className:ie?.header,style:Se?.header,columns:S,sortStatus:b,onSortStatusChange:w,selectionVisible:!!n,selectionChecked:Ce,selectionIndeterminate:Wr&&!Ce,onSelectionChange:Ze,leftShadowVisible:$e}),O("tbody",{children:Q?g.map((u,R)=>{let v=c(u,m),G=V?.includes(v)||!1,j=!1,J=!1;if(D){let{hidden:B}=D;(!B||!(typeof B=="function"?B(u):B))&&(D.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,u],H=>c(H,m)));zr(R)});let U;j?U=B=>{z({top:B.clientY,left:B.clientX,record:u}),ne?.(u)}:ne&&(U=()=>{ne(u)});let Ke;return J&&(Ke=B=>{B.preventDefault(),z({top:B.clientY,left:B.clientX,record:u})}),O(ve,{record:u,columns:S,selectionVisible:!!n,selectionChecked:G,onSelectionChange:ee,onClick:U,onContextMenu:Ke,contextMenuVisible:L?c(L.record,m)===v:!1,expansion:Er,leftShadowVisible:$e},v)}):O(be,{})})]})}),T&&O(_e,{ref:Lr,className:ie?.pagination,style:Se?.pagination,topBorderColor:a,horizontalSpacing:y,fetching:s,page:T,onPageChange:Nr,totalRecords:xe,recordsPerPage:ir,paginationColor:cr,paginationSize:gr,paginationText:hr,recordsLength:Q}),O(ke,{pt:ge,pb:Ne,fetching:s,loaderBackgroundBlur:br,loaderSize:Cr,loaderVariant:Sr}),O(Te,{pt:ge,pb:Ne,icon:wr,text:Or,active:!s&&!Q,children:Br}),D&&L&&O(He,{zIndex:D.zIndex,borderRadius:D.borderRadius,shadow:D.shadow,top:L.top,left:L.left,onDestroy:()=>z(null),children:D.items(L.record).map(({divider:u,key:R,title:v,icon:G,color:j,hidden:J,disabled:ee,onClick:U})=>u?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