mantine-datatable 1.7.9 → 1.7.10

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 g from"react";import{Box as ga,createStyles as Ca,packSx as ha,Table as Sa}from"@mantine/core";import{useElementSize as ge}from"@mantine/hooks";import{useEffect as ba}from"react";import{createStyles as Yr}from"@mantine/core";import{jsx as er}from"react/jsx-runtime";var _r=Yr({root:{"&&":{background:"transparent"}}});function ye(){let{classes:e}=_r();return er("tr",{className:e.root,children:er("td",{})})}import{Center as oo,createStyles as ao,Text as to}from"@mantine/core";function R(){return R=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},R.apply(this,arguments)}function jr(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=jr(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 Y from"react";var Jr=["size","color"];function ke(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=F(e,Jr);return Y.createElement("svg",R({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),Y.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Y.createElement("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),Y.createElement("line",{x1:"18",y1:"13",x2:"12",y2:"19"}),Y.createElement("line",{x1:"6",y1:"13",x2:"12",y2:"19"}))}import _ from"react";var eo=["size","color"];function De(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=F(e,eo);return _.createElement("svg",R({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),_.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),_.createElement("polyline",{points:"8 7 12 3 16 7"}),_.createElement("polyline",{points:"8 17 12 21 16 17"}),_.createElement("line",{x1:"12",y1:"3",x2:"12",y2:"21"}))}import E from"react";var ro=["size","color"];function Pe(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=F(e,ro);return E.createElement("svg",R({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 lo,jsx as le,jsxs as so}from"react/jsx-runtime";var fo=ao(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 Re({icon:e,text:r,pt:a,pb:o,active:t,children:f}){let{classes:d,cx:p}=fo();return le(oo,{pt:a,pb:o,className:p(d.root,{[d.active]:t}),children:f||so(lo,{children:[e||le("div",{className:d.standardIcon,children:le(Pe,{})}),le(to,{size:"sm",color:"dimmed",children:r})]})})}import{Box as uo,createStyles as po,Pagination as mo,Text as xo}from"@mantine/core";import{forwardRef as no}from"react";import{jsx as rr,jsxs as co}from"react/jsx-runtime";var io=po((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}})),or=no(function({className:r,style:a,topBorderColor:o,fetching:t,page:f,onPageChange:d,paginationColor:p,paginationSize:i,paginationText:u,totalRecords:l,recordsPerPage:c,recordsLength:s,horizontalSpacing:x},n){let h;if(t||!l)h="...";else{let T=(f-1)*c+1,D=T+s-1;h=u({from:T,to:D,totalRecords:l})}let{classes:b,cx:w}=io({topBorderColor:o});return co(uo,{ref:n,px:x??"xs",py:"xs",className:w(b.root,r),style:a,children:[rr(xo,{size:i,children:h}),rr(mo,{color:p,className:w(b.pagination,{[b.paginationFetching]:t||!s}),page:f,onChange:d,size:i,total:Math.ceil(l/c)})]})});import{Checkbox as wo,createStyles as To}from"@mantine/core";import{forwardRef as yo}from"react";import{Box as Ae,Center as ho,createStyles as So,Group as bo}from"@mantine/core";import{useMantineTheme as go}from"@mantine/core";import{useMediaQuery as Co}from"@mantine/hooks";function se(e){let r=go(),a=typeof e=="function"?e(r):e;return Co(a||"",!0)}function de(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 ar(e,r,a){return e.filter(o=>!r.map(a).includes(a(o)))}function ue(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 Oo}from"react/jsx-runtime";var Bo=So(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 Me({className:e,sx:r,style:a,accessor:o,visibleMediaQuery:t,title:f,sortable:d,textAlignment:p,width:i,sortStatus:u,onSortStatusChange:l}){let{cx:c,classes:s}=Bo();if(!se(t))return null;let x=f??de(o);return N(Ae,{component:"th",className:c({[s.sortableColumnHeader]:d},e),sx:[{"&&":{textAlign:p},width:i,minWidth:i,maxWidth:i},r],style:a,role:d?"button":void 0,onClick:d&&l?()=>{l({columnAccessor:o,direction:u?.direction==="asc"?"desc":"asc"})}:void 0,children:d||u?.columnAccessor===o?Oo(bo,{position:"apart",noWrap:!0,spacing:"xs",children:[N(Ae,{className:c(s.columnHeaderText,s.sortableColumnHeaderText),children:x}),N(ho,{children:u?.columnAccessor===o?N(ke,{className:c(s.sortableColumnHeaderIcon,{[s.sortableColumnHeaderIconRotated]:u.direction==="desc"}),size:14}):N(De,{className:s.sortableColumnHeaderNeutralIcon,size:14})})]}):N(Ae,{className:s.columnHeaderText,children:x})})}import{jsx as pe,jsxs as Do}from"react/jsx-runtime";var ko=To(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"}}}),tr=yo(function({className:r,style:a,sortStatus:o,onSortStatusChange:t,columns:f,selectionVisible:d,selectionChecked:p,selectionIndeterminate:i,onSelectionChange:u,leftShadowVisible:l},c){let{classes:s,cx:x}=ko();return pe("thead",{className:x(s.root,r),style:a,ref:c,children:Do("tr",{children:[d&&pe("th",{className:x(s.selectorColumnHeader,{[s.selectorColumnHeaderWithRightShadow]:l}),children:pe(wo,{classNames:{input:s.selectionCheckboxInput},checked:p,indeterminate:i,disabled:!u,onChange:u})}),f.map(({accessor:n,hidden:h,visibleMediaQuery:b,textAlignment:w,width:T,title:D,sortable:W,titleClassName:I,titleStyle:z,titleSx:A})=>h?null:pe(Me,{className:I,style:z,sx:A,accessor:n,visibleMediaQuery:b,textAlignment:w,width:T,title:D,sortable:W,sortStatus:o,onSortStatusChange:t},n))]})})});import{Center as Po,createStyles as Ro,Loader as Ao}from"@mantine/core";import{jsx as fr}from"react/jsx-runtime";var Mo=Ro(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 Le({pt:e,pb:r,fetching:a,loaderBackgroundBlur:o,loaderSize:t,loaderVariant:f}){let{classes:d,cx:p}=Mo();return fr(Po,{pt:e,pb:r,className:p(d.root,{[d.fetching]:a}),sx:o?{backdropFilter:`blur(${o}px)`}:void 0,children:a&&fr(Ao,{size:t,variant:f})})}import{createStyles as qo}from"@mantine/core";import{Box as Lo,createStyles as vo}from"@mantine/core";import{jsx as Fo}from"react/jsx-runtime";var Ho=vo({withPointerCursor:{cursor:"pointer"},ellipsis:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}});function ve({className:e,sx:r,style:a,visibleMediaQuery:o,record:t,recordIndex:f,onClick:d,ellipsis:p,textAlignment:i,width:u,accessor:l,render:c}){let{cx:s,classes:x}=Ho();return se(o)?Fo(Lo,{component:"td",className:s({[x.ellipsis]:p,[x.withPointerCursor]:d},e),sx:[{width:u,minWidth:u,maxWidth:u,textAlign:i},r],style:a,onClick:d,children:c?c(t,f):C(t,l)}):null}import{Collapse as Eo,createStyles as No}from"@mantine/core";import{useDebouncedState as me,useTimeout as lr}from"@mantine/hooks";import{useEffect as He,useState as j}from"react";var xe=200,ne={leading:!0};function sr(){let[e,r]=me(!0,xe,ne),[a,o]=me(!0,xe,ne),[t,f]=me(!0,xe,ne),[d,p]=me(!0,xe,ne);return{scrolledToTop:e,setScrolledToTop:r,scrolledToBottom:a,setScrolledToBottom:o,scrolledToLeft:t,setScrolledToLeft:f,scrolledToRight:d,setScrolledToRight:p}}function dr(e){let[r,a]=j(null),o=e?.join(":")||"";return He(()=>{a(null)},[o]),{lastSelectionChangeIndex:r,setLastSelectionChangeIndex:a}}function ur(e){let[r,a]=j(null);return He(()=>{e&&a(null)},[e]),{rowContextMenuInfo:r,setRowContextMenuInfo:a}}function pr({rowExpansion:e,records:r,idAccessor:a}){let o=[];if(e&&r){let{trigger:p,allowMultiple:i,initiallyExpanded:u}=e;r&&p==="always"?o=r.map(l=>C(l,a)):u&&(o=r.filter(u).map(l=>C(l,a)),i||(o=[o[0]]))}let t,f,d=j(o);if(e){let{trigger:p,allowMultiple:i,collapseProps:u,content:l}=e;e.expanded?{recordIds:t,onRecordIdsChange:f}=e.expanded:[t,f]=d;let c=s=>f(t.filter(x=>x!==C(s,a)));return{expandOnClick:p!=="always"&&p!=="never",isRowExpanded:s=>p==="always"?!0:t.includes(C(s,a)),expandRow:s=>{let x=C(s,a);f(i?[...t,x]:[x])},collapseRow:c,collapseProps:u,content:(s,x)=>()=>l({record:s,recordIndex:x,collapse:()=>c(s)})}}}function mr(e,r){let[a,o]=j(e),[t,f]=j(e),d=lr(()=>o(!0),0),p=lr(()=>f(!1),r||200);return He(()=>{e?(p.clear(),f(!0),d.start()):(d.clear(),o(!1),p.start())},[d,p,e]),{expanded:a,visible:t}}import{Fragment as Io,jsx as ie,jsxs as zo}from"react/jsx-runtime";var Wo=No({cell:{"&&":{borderBottomWidth:0,padding:0}},expandedCell:{"&&":{borderBottomWidth:1}}});function Fe({open:e,colSpan:r,content:a,collapseProps:o}){let{expanded:t,visible:f}=mr(e,o?.transitionDuration),{cx:d,classes:p}=Wo();return f?zo(Io,{children:[ie("tr",{}),ie("tr",{children:ie("td",{className:d(p.cell,{[p.expandedCell]:t}),colSpan:r,children:ie(Eo,{in:t,...o,children:a()})})})]}):null}import{Checkbox as Vo,createStyles as Go}from"@mantine/core";import{jsx as xr}from"react/jsx-runtime";var Uo=Go(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 Ee({withRightShadow:e,...r}){let{cx:a,classes:o}=Uo();return xr("td",{className:a(o.root,{[o.withRightShadow]:e}),children:xr(Vo,{classNames:{input:o.checkbox},...r,onClick:t=>t.stopPropagation()})})}import{Fragment as $o,jsx as Ne,jsxs as nr}from"react/jsx-runtime";var Zo=qo(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 We({record:e,recordIndex:r,columns:a,selectionVisible:o,selectionChecked:t,onSelectionChange:f,onClick:d,onCellClick:p,onContextMenu:i,expansion:u,contextMenuVisible:l,leftShadowVisible:c}){let{cx:s,classes:x}=Zo();return nr($o,{children:[nr("tr",{className:s({[x.withPointerCursor]:d||u?.expandOnClick,[x.selected]:t,[x.contextMenuVisible]:l}),onClick:n=>{if(u){let{isRowExpanded:h,expandOnClick:b,expandRow:w,collapseRow:T}=u;b&&(h(e)?T(e):w(e))}d?.(n)},onContextMenu:i,children:[o&&Ne(Ee,{withRightShadow:c,checked:t,disabled:!f,onChange:f}),a.map((n,h)=>{let{accessor:b,hidden:w,visibleMediaQuery:T,textAlignment:D,ellipsis:W,width:I,render:z,cellsClassName:A,cellsStyle:V,cellsSx:Ce}=n,J;return p&&(J=()=>p({record:e,recordIndex:r,column:n,columnIndex:h})),w?null:Ne(ve,{className:typeof A=="function"?A(e,r):A,style:typeof V=="function"?V(e,r):V,sx:Ce,visibleMediaQuery:T,record:e,recordIndex:r,onClick:J,accessor:b,textAlignment:D,ellipsis:W,width:I,render:z},b)})]}),u&&Ne(Fe,{colSpan:a.filter(n=>!n.hidden).length+(o?1:0),open:u.isRowExpanded(e),content:u.content(e,r),collapseProps:u.collapseProps})]})}import{createStyles as Xo,Paper as Ko,useMantineTheme as Qo}from"@mantine/core";import{useClickOutside as Yo,useElementSize as _o,useMergedRef as jo,useWindowEvent as ir}from"@mantine/hooks";import{jsx as ea}from"react/jsx-runtime";var Jo=Xo(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 Ie({borderRadius:e="xs",shadow:r="sm",zIndex:a=3,top:o,left:t,onDestroy:f,children:d}){ir("resize",f),ir("scroll",f);let p=Yo(f),{ref:i,width:u,height:l}=_o(),c=jo(p,i),{spacing:{xs:s}}=Qo(),{innerWidth:x,innerHeight:n}=window,h=o+l+s>n?n-l-s:o,b=t+u+s>x?x-u-s:t,{classes:w}=Jo();return ea(Ko,{ref:c,shadow:r,radius:e,className:w.root,sx:{top:h,left:b,zIndex:a},children:d})}import{createStyles as ra}from"@mantine/core";import{jsx as aa}from"react/jsx-runtime";var oa=ra(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function ze(){let{classes:e}=oa();return aa("div",{className:e.root})}import{Box as ta,createStyles as fa,Text as la,UnstyledButton as sa}from"@mantine/core";import{jsx as cr,jsxs as ua}from"react/jsx-runtime";var da=fa((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 Ve({icon:e,title:r,color:a,disabled:o,onClick:t}){let{classes:f}=da({color:a});return ua(sa,{className:f.root,disabled:o,onClick:t,children:[e&&cr(ta,{className:f.icon,children:e}),cr(la,{className:f.title,size:"sm",children:r})]})}import{Box as pa,createStyles as ma,ScrollArea as xa}from"@mantine/core";import{forwardRef as na}from"react";import{jsx as ce,jsxs as ca}from"react/jsx-runtime";var ia=ma(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}}}),gr=na(function({topShadowVisible:r,leftShadowVisible:a,rightShadowVisible:o,bottomShadowVisible:t,headerHeight:f,onScrollPositionChange:d,children:p},i){let{cx:u,classes:l}=ia();return ca(xa,{viewportRef:i,classNames:{root:l.root,scrollbar:l.scrollbar,thumb:l.thumb,corner:l.corner},styles:{scrollbar:{marginTop:f}},onScrollPositionChange:d,children:[p,ce(pa,{className:u(l.shadow,l.topShadow,{[l.shadowVisible]:r}),sx:{top:f}}),ce("div",{className:u(l.shadow,l.leftShadow,{[l.shadowVisible]:a})}),ce("div",{className:u(l.shadow,l.rightShadow,{[l.shadowVisible]:o})}),ce("div",{className:u(l.shadow,l.bottomShadow,{[l.shadowVisible]:t})})]})});import{jsx as y,jsxs as Cr}from"react/jsx-runtime";var Ba={},Oa=Ca((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 hr({withBorder:e,borderRadius:r,borderColor:a=S=>S.colorScheme==="dark"?S.colors.dark[4]:S.colors.gray[3],rowBorderColor:o=S=>S.fn.rgba(S.colorScheme==="dark"?S.colors.dark[4]:S.colors.gray[3],.65),withColumnBorders:t,textSelectionDisabled:f,height:d="100%",minHeight:p,shadow:i,verticalAlignment:u="center",fetching:l,columns:c,idAccessor:s="id",records:x,selectedRecords:n,onSelectedRecordsChange:h,sortStatus:b,onSortStatusChange:w,horizontalSpacing:T,page:D,onPageChange:W,totalRecords:I,recordsPerPage:z,paginationColor:A,paginationSize:V="sm",paginationText:Ce=({from:S,to:G,totalRecords:L})=>`${S} - ${G} / ${L}`,loaderSize:J,loaderVariant:Sr,loaderBackgroundBlur:br,emptyState:Br,noRecordsText:Or="No records",noRecordsIcon:wr,striped:Tr,onRowClick:he,onCellClick:yr,rowContextMenu:k,rowExpansion:kr,m:Dr,my:Pr,mx:Rr,mt:Ar,mb:Mr,ml:Lr,mr:vr,sx:Hr,className:Fr,classNames:Se,style:Er,styles:be,...Nr}){let{ref:S,width:G,height:L}=ge(),{ref:Wr,height:Be}=ge(),{ref:Ir,width:Oe,height:ee}=ge(),{ref:zr,height:Ge}=ge(),{scrolledToTop:Vr,setScrolledToTop:Ue,scrolledToBottom:Gr,setScrolledToBottom:qe,scrolledToLeft:Ze,setScrolledToLeft:$e,scrolledToRight:Ur,setScrolledToRight:Xe}=sr(),{rowContextMenuInfo:M,setRowContextMenuInfo:U}=ur(l),qr=pr({rowExpansion:kr,records:x,idAccessor:s}),Ke=()=>{if(!l&&k&&U(null),l||ee<=L)Ue(!0),qe(!0);else{let m=S.current.scrollTop;Ue(m===0),qe(Math.round(ee-m)===Math.round(L))}if(l||Oe===G)$e(!0),Xe(!0);else{let m=S.current.scrollLeft;$e(m===0),Xe(Math.round(Oe-m)===Math.round(G))}};ba(Ke,[l,L,S,G,ee,Oe]);let Zr=m=>{S.current.scrollTo({top:0,left:0}),W(m)},re=x?.length,q=x?.map(m=>C(m,s)),Z=n?.map(m=>C(m,s)),Qe=q!==void 0&&Z!==void 0&&Z.length>0,we=Qe&&q.every(m=>Z.includes(m)),$r=Qe&&q.some(m=>Z.includes(m)),Ye;h&&(Ye=()=>{h(we?n.filter(m=>!q.includes(C(m,s))):ue([...n,...x],m=>C(m,s)))});let{lastSelectionChangeIndex:oe,setLastSelectionChangeIndex:Xr}=dr(q),_e=!!n&&!Ze,{cx:je,classes:P,theme:Kr}=Oa({borderColor:a,rowBorderColor:o}),Qr={m:Dr,my:Pr,mx:Rr,mt:Ar,mb:Mr,ml:Lr,mr:vr},Te=typeof be=="function"?be(Kr,Ba):be;return Cr(ga,{...Qr,className:je(P.root,{[P.tableWithBorder]:e},Fr,Se?.root),sx:[m=>({borderRadius:m.radius[r]||r,boxShadow:m.shadows[i]||i,height:d,minHeight:p}),...ha(Hr)],style:{...Te?.root,...Er},children:[y(gr,{ref:S,topShadowVisible:!Vr,leftShadowVisible:!(n||Ze),rightShadowVisible:!Ur,bottomShadowVisible:!Gr,headerHeight:Be,onScrollPositionChange:Ke,children:Cr(Sa,{ref:Ir,horizontalSpacing:T,className:je(P.table,{[P.tableWithColumnBorders]:t,[P.lastRowBorderBottomVisible]:ee<L,[P.textSelectionDisabled]:f,[P.verticalAlignmentTop]:u==="top",[P.verticalAlignmentBottom]:u==="bottom"}),striped:re?Tr:!1,...Nr,children:[y(tr,{ref:Wr,className:Se?.header,style:Te?.header,columns:c,sortStatus:b,onSortStatusChange:w,selectionVisible:!!n,selectionChecked:we,selectionIndeterminate:$r&&!we,onSelectionChange:Ye,leftShadowVisible:_e}),y("tbody",{children:re?x.map((m,B)=>{let v=C(m,s),$=Z?.includes(v)||!1,ae=!1,te=!1;if(k){let{hidden:O}=k;(!O||!(typeof O=="function"?O(m,B):O))&&(k.trigger==="click"?ae=!0:te=!0)}let fe;h&&(fe=O=>{if(O.nativeEvent.shiftKey&&oe!==null){let H=x.filter(B>oe?(K,Q)=>Q>=oe&&Q<=B:(K,Q)=>Q>=B&&Q<=oe);h($?ar(n,H,K=>C(K,s)):ue([...n,...H],K=>C(K,s)))}else h($?n.filter(H=>C(H,s)!==v):ue([...n,m],H=>C(H,s)));Xr(B)});let X;ae?X=O=>{U({top:O.clientY,left:O.clientX,record:m,recordIndex:B}),he?.(m,B)}:he&&(X=()=>{he(m,B)});let Je;return te&&(Je=O=>{O.preventDefault(),U({top:O.clientY,left:O.clientX,record:m,recordIndex:B})}),y(We,{record:m,recordIndex:B,columns:c,selectionVisible:!!n,selectionChecked:$,onSelectionChange:fe,onClick:X,onCellClick:yr,onContextMenu:Je,contextMenuVisible:M?C(M.record,s)===v:!1,expansion:qr,leftShadowVisible:_e},v)}):y(ye,{})})]})}),D&&y(or,{ref:zr,className:Se?.pagination,style:Te?.pagination,topBorderColor:a,horizontalSpacing:T,fetching:l,page:D,onPageChange:Zr,totalRecords:I,recordsPerPage:z,paginationColor:A,paginationSize:V,paginationText:Ce,recordsLength:re}),y(Le,{pt:Be,pb:Ge,fetching:l,loaderBackgroundBlur:br,loaderSize:J,loaderVariant:Sr}),y(Re,{pt:Be,pb:Ge,icon:wr,text:Or,active:!l&&!re,children:Br}),k&&M&&y(Ie,{zIndex:k.zIndex,borderRadius:k.borderRadius,shadow:k.shadow,top:M.top,left:M.left,onDestroy:()=>U(null),children:k.items(M.record,M.recordIndex).map(({divider:m,key:B,title:v,icon:$,color:ae,hidden:te,disabled:fe,onClick:X})=>m?y(ze,{},B):te?null:y(Ve,{title:v??de(B),icon:$,color:ae,disabled:fe,onClick:()=>{U(null),X()}},B))})]})}export{hr as DataTable};
1
+ import*as c from"react";import{Box as Ca,createStyles as ha,packSx as Sa,Table as ba}from"@mantine/core";import{useElementSize as ge}from"@mantine/hooks";import{useEffect as Ba}from"react";import{createStyles as _r}from"@mantine/core";import{jsx as rr}from"react/jsx-runtime";var jr=_r({root:{"&&":{background:"transparent"}}});function ye(){let{classes:e}=jr();return rr("tr",{className:e.root,children:rr("td",{})})}import{Center as ao,createStyles as to,Text as fo}from"@mantine/core";function A(){return A=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},A.apply(this,arguments)}function Jr(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 N(e,r){if(e==null)return{};var a=Jr(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 Y from"react";var eo=["size","color"];function ke(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=N(e,eo);return Y.createElement("svg",A({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),Y.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Y.createElement("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),Y.createElement("line",{x1:"18",y1:"13",x2:"12",y2:"19"}),Y.createElement("line",{x1:"6",y1:"13",x2:"12",y2:"19"}))}import _ from"react";var ro=["size","color"];function De(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=N(e,ro);return _.createElement("svg",A({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),_.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),_.createElement("polyline",{points:"8 7 12 3 16 7"}),_.createElement("polyline",{points:"8 17 12 21 16 17"}),_.createElement("line",{x1:"12",y1:"3",x2:"12",y2:"21"}))}import W from"react";var oo=["size","color"];function Pe(e){var r=e.size,a=r===void 0?24:r,o=e.color,t=o===void 0?"currentColor":o,f=N(e,oo);return W.createElement("svg",A({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),W.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),W.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"}),W.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"}),W.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"}),W.createElement("line",{x1:"3",y1:"3",x2:"21",y2:"21"}))}import{Fragment as so,jsx as le,jsxs as uo}from"react/jsx-runtime";var lo=to(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 Re({icon:e,text:r,pt:a,pb:o,active:t,children:f}){let{classes:d,cx:p}=lo();return le(ao,{pt:a,pb:o,className:p(d.root,{[d.active]:t}),children:f||uo(so,{children:[e||le("div",{className:d.standardIcon,children:le(Pe,{})}),le(fo,{size:"sm",color:"dimmed",children:r})]})})}import{Box as po,createStyles as mo,Pagination as xo,Text as no}from"@mantine/core";import{forwardRef as io}from"react";import{jsx as or,jsxs as go}from"react/jsx-runtime";var co=mo((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}})),ar=io(function({className:r,style:a,topBorderColor:o,fetching:t,page:f,onPageChange:d,paginationColor:p,paginationSize:i,loadingText:u,noRecordsText:s,paginationText:g,totalRecords:l,recordsPerPage:x,recordsLength:n,horizontalSpacing:S},w){let b;if(t)b=u;else if(!l)b=s;else{let P=(f-1)*x+1,M=P+n-1;b=g({from:P,to:M,totalRecords:l})}let{classes:T,cx:k}=co({topBorderColor:o});return go(po,{ref:w,px:S??"xs",py:"xs",className:k(T.root,r),style:a,children:[or(no,{size:i,children:b}),or(xo,{color:p,className:k(T.pagination,{[T.paginationFetching]:t||!n}),page:f,onChange:d,size:i,total:Math.ceil(l/x)})]})});import{Checkbox as To,createStyles as yo}from"@mantine/core";import{forwardRef as ko}from"react";import{Box as Ae,Center as So,createStyles as bo,Group as Bo}from"@mantine/core";import{useMantineTheme as Co}from"@mantine/core";import{useMediaQuery as ho}from"@mantine/hooks";function se(e){let r=Co(),a=typeof e=="function"?e(r):e;return ho(a||"",!0)}function de(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 tr(e,r,a){return e.filter(o=>!r.map(a).includes(a(o)))}function ue(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 I,jsxs as wo}from"react/jsx-runtime";var Oo=bo(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 Me({className:e,sx:r,style:a,accessor:o,visibleMediaQuery:t,title:f,sortable:d,textAlignment:p,width:i,sortStatus:u,onSortStatusChange:s}){let{cx:g,classes:l}=Oo();if(!se(t))return null;let x=f??de(o);return I(Ae,{component:"th",className:g({[l.sortableColumnHeader]:d},e),sx:[{"&&":{textAlign:p},width:i,minWidth:i,maxWidth:i},r],style:a,role:d?"button":void 0,onClick:d&&s?()=>{s({columnAccessor:o,direction:u?.direction==="asc"?"desc":"asc"})}:void 0,children:d||u?.columnAccessor===o?wo(Bo,{position:"apart",noWrap:!0,spacing:"xs",children:[I(Ae,{className:g(l.columnHeaderText,l.sortableColumnHeaderText),children:x}),I(So,{children:u?.columnAccessor===o?I(ke,{className:g(l.sortableColumnHeaderIcon,{[l.sortableColumnHeaderIconRotated]:u.direction==="desc"}),size:14}):I(De,{className:l.sortableColumnHeaderNeutralIcon,size:14})})]}):I(Ae,{className:l.columnHeaderText,children:x})})}import{jsx as pe,jsxs as Po}from"react/jsx-runtime";var Do=yo(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"}}}),fr=ko(function({className:r,style:a,sortStatus:o,onSortStatusChange:t,columns:f,selectionVisible:d,selectionChecked:p,selectionIndeterminate:i,onSelectionChange:u,leftShadowVisible:s},g){let{classes:l,cx:x}=Do();return pe("thead",{className:x(l.root,r),style:a,ref:g,children:Po("tr",{children:[d&&pe("th",{className:x(l.selectorColumnHeader,{[l.selectorColumnHeaderWithRightShadow]:s}),children:pe(To,{classNames:{input:l.selectionCheckboxInput},checked:p,indeterminate:i,disabled:!u,onChange:u})}),f.map(({accessor:n,hidden:S,visibleMediaQuery:w,textAlignment:b,width:T,title:k,sortable:P,titleClassName:M,titleStyle:z,titleSx:L})=>S?null:pe(Me,{className:M,style:z,sx:L,accessor:n,visibleMediaQuery:w,textAlignment:b,width:T,title:k,sortable:P,sortStatus:o,onSortStatusChange:t},n))]})})});import{Center as Ro,createStyles as Ao,Loader as Mo}from"@mantine/core";import{jsx as lr}from"react/jsx-runtime";var Lo=Ao(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 Le({pt:e,pb:r,fetching:a,loaderBackgroundBlur:o,loaderSize:t,loaderVariant:f}){let{classes:d,cx:p}=Lo();return lr(Ro,{pt:e,pb:r,className:p(d.root,{[d.fetching]:a}),sx:o?{backdropFilter:`blur(${o}px)`}:void 0,children:a&&lr(Mo,{size:t,variant:f})})}import{createStyles as Zo}from"@mantine/core";import{Box as vo,createStyles as Ho}from"@mantine/core";import{jsx as Eo}from"react/jsx-runtime";var Fo=Ho({withPointerCursor:{cursor:"pointer"},ellipsis:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}});function ve({className:e,sx:r,style:a,visibleMediaQuery:o,record:t,recordIndex:f,onClick:d,ellipsis:p,textAlignment:i,width:u,accessor:s,render:g}){let{cx:l,classes:x}=Fo();return se(o)?Eo(vo,{component:"td",className:l({[x.ellipsis]:p,[x.withPointerCursor]:d},e),sx:[{width:u,minWidth:u,maxWidth:u,textAlign:i},r],style:a,onClick:d,children:g?g(t,f):C(t,s)}):null}import{Collapse as No,createStyles as Wo}from"@mantine/core";import{useDebouncedState as me,useTimeout as sr}from"@mantine/hooks";import{useEffect as He,useState as j}from"react";var xe=200,ne={leading:!0};function dr(){let[e,r]=me(!0,xe,ne),[a,o]=me(!0,xe,ne),[t,f]=me(!0,xe,ne),[d,p]=me(!0,xe,ne);return{scrolledToTop:e,setScrolledToTop:r,scrolledToBottom:a,setScrolledToBottom:o,scrolledToLeft:t,setScrolledToLeft:f,scrolledToRight:d,setScrolledToRight:p}}function ur(e){let[r,a]=j(null),o=e?.join(":")||"";return He(()=>{a(null)},[o]),{lastSelectionChangeIndex:r,setLastSelectionChangeIndex:a}}function pr(e){let[r,a]=j(null);return He(()=>{e&&a(null)},[e]),{rowContextMenuInfo:r,setRowContextMenuInfo:a}}function mr({rowExpansion:e,records:r,idAccessor:a}){let o=[];if(e&&r){let{trigger:p,allowMultiple:i,initiallyExpanded:u}=e;r&&p==="always"?o=r.map(s=>C(s,a)):u&&(o=r.filter(u).map(s=>C(s,a)),i||(o=[o[0]]))}let t,f,d=j(o);if(e){let{trigger:p,allowMultiple:i,collapseProps:u,content:s}=e;e.expanded?{recordIds:t,onRecordIdsChange:f}=e.expanded:[t,f]=d;let g=l=>f(t.filter(x=>x!==C(l,a)));return{expandOnClick:p!=="always"&&p!=="never",isRowExpanded:l=>p==="always"?!0:t.includes(C(l,a)),expandRow:l=>{let x=C(l,a);f(i?[...t,x]:[x])},collapseRow:g,collapseProps:u,content:(l,x)=>()=>s({record:l,recordIndex:x,collapse:()=>g(l)})}}}function xr(e,r){let[a,o]=j(e),[t,f]=j(e),d=sr(()=>o(!0),0),p=sr(()=>f(!1),r||200);return He(()=>{e?(p.clear(),f(!0),d.start()):(d.clear(),o(!1),p.start())},[d,p,e]),{expanded:a,visible:t}}import{Fragment as zo,jsx as ie,jsxs as Vo}from"react/jsx-runtime";var Io=Wo({cell:{"&&":{borderBottomWidth:0,padding:0}},expandedCell:{"&&":{borderBottomWidth:1}}});function Fe({open:e,colSpan:r,content:a,collapseProps:o}){let{expanded:t,visible:f}=xr(e,o?.transitionDuration),{cx:d,classes:p}=Io();return f?Vo(zo,{children:[ie("tr",{}),ie("tr",{children:ie("td",{className:d(p.cell,{[p.expandedCell]:t}),colSpan:r,children:ie(No,{in:t,...o,children:a()})})})]}):null}import{Checkbox as Go,createStyles as Uo}from"@mantine/core";import{jsx as nr}from"react/jsx-runtime";var qo=Uo(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 Ee({withRightShadow:e,...r}){let{cx:a,classes:o}=qo();return nr("td",{className:a(o.root,{[o.withRightShadow]:e}),children:nr(Go,{classNames:{input:o.checkbox},...r,onClick:t=>t.stopPropagation()})})}import{Fragment as Xo,jsx as Ne,jsxs as ir}from"react/jsx-runtime";var $o=Zo(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 We({record:e,recordIndex:r,columns:a,selectionVisible:o,selectionChecked:t,onSelectionChange:f,onClick:d,onCellClick:p,onContextMenu:i,expansion:u,contextMenuVisible:s,leftShadowVisible:g}){let{cx:l,classes:x}=$o();return ir(Xo,{children:[ir("tr",{className:l({[x.withPointerCursor]:d||u?.expandOnClick,[x.selected]:t,[x.contextMenuVisible]:s}),onClick:n=>{if(u){let{isRowExpanded:S,expandOnClick:w,expandRow:b,collapseRow:T}=u;w&&(S(e)?T(e):b(e))}d?.(n)},onContextMenu:i,children:[o&&Ne(Ee,{withRightShadow:g,checked:t,disabled:!f,onChange:f}),a.map((n,S)=>{let{accessor:w,hidden:b,visibleMediaQuery:T,textAlignment:k,ellipsis:P,width:M,render:z,cellsClassName:L,cellsStyle:V,cellsSx:Ce}=n,J;return p&&(J=()=>p({record:e,recordIndex:r,column:n,columnIndex:S})),b?null:Ne(ve,{className:typeof L=="function"?L(e,r):L,style:typeof V=="function"?V(e,r):V,sx:Ce,visibleMediaQuery:T,record:e,recordIndex:r,onClick:J,accessor:w,textAlignment:k,ellipsis:P,width:M,render:z},w)})]}),u&&Ne(Fe,{colSpan:a.filter(n=>!n.hidden).length+(o?1:0),open:u.isRowExpanded(e),content:u.content(e,r),collapseProps:u.collapseProps})]})}import{createStyles as Ko,Paper as Qo,useMantineTheme as Yo}from"@mantine/core";import{useClickOutside as _o,useElementSize as jo,useMergedRef as Jo,useWindowEvent as cr}from"@mantine/hooks";import{jsx as ra}from"react/jsx-runtime";var ea=Ko(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 Ie({borderRadius:e="xs",shadow:r="sm",zIndex:a=3,top:o,left:t,onDestroy:f,children:d}){cr("resize",f),cr("scroll",f);let p=_o(f),{ref:i,width:u,height:s}=jo(),g=Jo(p,i),{spacing:{xs:l}}=Yo(),{innerWidth:x,innerHeight:n}=window,S=o+s+l>n?n-s-l:o,w=t+u+l>x?x-u-l:t,{classes:b}=ea();return ra(Qo,{ref:g,shadow:r,radius:e,className:b.root,sx:{top:S,left:w,zIndex:a},children:d})}import{createStyles as oa}from"@mantine/core";import{jsx as ta}from"react/jsx-runtime";var aa=oa(e=>({root:{height:1,background:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[1]}}));function ze(){let{classes:e}=aa();return ta("div",{className:e.root})}import{Box as fa,createStyles as la,Text as sa,UnstyledButton as da}from"@mantine/core";import{jsx as gr,jsxs as pa}from"react/jsx-runtime";var ua=la((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 Ve({icon:e,title:r,color:a,disabled:o,onClick:t}){let{classes:f}=ua({color:a});return pa(da,{className:f.root,disabled:o,onClick:t,children:[e&&gr(fa,{className:f.icon,children:e}),gr(sa,{className:f.title,size:"sm",children:r})]})}import{Box as ma,createStyles as xa,ScrollArea as na}from"@mantine/core";import{forwardRef as ia}from"react";import{jsx as ce,jsxs as ga}from"react/jsx-runtime";var ca=xa(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}}}),Cr=ia(function({topShadowVisible:r,leftShadowVisible:a,rightShadowVisible:o,bottomShadowVisible:t,headerHeight:f,onScrollPositionChange:d,children:p},i){let{cx:u,classes:s}=ca();return ga(na,{viewportRef:i,classNames:{root:s.root,scrollbar:s.scrollbar,thumb:s.thumb,corner:s.corner},styles:{scrollbar:{marginTop:f}},onScrollPositionChange:d,children:[p,ce(ma,{className:u(s.shadow,s.topShadow,{[s.shadowVisible]:r}),sx:{top:f}}),ce("div",{className:u(s.shadow,s.leftShadow,{[s.shadowVisible]:a})}),ce("div",{className:u(s.shadow,s.rightShadow,{[s.shadowVisible]:o})}),ce("div",{className:u(s.shadow,s.bottomShadow,{[s.shadowVisible]:t})})]})});import{jsx as y,jsxs as hr}from"react/jsx-runtime";var Oa={},wa=ha((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 Sr({withBorder:e,borderRadius:r,borderColor:a=h=>h.colorScheme==="dark"?h.colors.dark[4]:h.colors.gray[3],rowBorderColor:o=h=>h.fn.rgba(h.colorScheme==="dark"?h.colors.dark[4]:h.colors.gray[3],.65),withColumnBorders:t,textSelectionDisabled:f,height:d="100%",minHeight:p,shadow:i,verticalAlignment:u="center",fetching:s,columns:g,idAccessor:l="id",records:x,selectedRecords:n,onSelectedRecordsChange:S,sortStatus:w,onSortStatusChange:b,horizontalSpacing:T,page:k,onPageChange:P,totalRecords:M,recordsPerPage:z,paginationColor:L,paginationSize:V="sm",paginationText:Ce=({from:h,to:G,totalRecords:H})=>`${h} - ${G} / ${H}`,loaderSize:J,loaderVariant:br,loaderBackgroundBlur:Br,loadingText:Or="...",emptyState:wr,noRecordsText:Ge="No records",noRecordsIcon:Tr,striped:yr,onRowClick:he,onCellClick:kr,rowContextMenu:D,rowExpansion:Dr,m:Pr,my:Rr,mx:Ar,mt:Mr,mb:Lr,ml:vr,mr:Hr,sx:Fr,className:Er,classNames:Se,style:Nr,styles:be,...Wr}){let{ref:h,width:G,height:H}=ge(),{ref:Ir,height:Be}=ge(),{ref:zr,width:Oe,height:ee}=ge(),{ref:Vr,height:Ue}=ge(),{scrolledToTop:Gr,setScrolledToTop:qe,scrolledToBottom:Ur,setScrolledToBottom:Ze,scrolledToLeft:$e,setScrolledToLeft:Xe,scrolledToRight:qr,setScrolledToRight:Ke}=dr(),{rowContextMenuInfo:v,setRowContextMenuInfo:U}=pr(s),Zr=mr({rowExpansion:Dr,records:x,idAccessor:l}),Qe=()=>{if(!s&&D&&U(null),s||ee<=H)qe(!0),Ze(!0);else{let m=h.current.scrollTop;qe(m===0),Ze(Math.round(ee-m)===Math.round(H))}if(s||Oe===G)Xe(!0),Ke(!0);else{let m=h.current.scrollLeft;Xe(m===0),Ke(Math.round(Oe-m)===Math.round(G))}};Ba(Qe,[s,H,h,G,ee,Oe]);let $r=m=>{h.current.scrollTo({top:0,left:0}),P(m)},re=x?.length,q=x?.map(m=>C(m,l)),Z=n?.map(m=>C(m,l)),Ye=q!==void 0&&Z!==void 0&&Z.length>0,we=Ye&&q.every(m=>Z.includes(m)),Xr=Ye&&q.some(m=>Z.includes(m)),_e;S&&(_e=()=>{S(we?n.filter(m=>!q.includes(C(m,l))):ue([...n,...x],m=>C(m,l)))});let{lastSelectionChangeIndex:oe,setLastSelectionChangeIndex:Kr}=ur(q),je=!!n&&!$e,{cx:Je,classes:R,theme:Qr}=wa({borderColor:a,rowBorderColor:o}),Yr={m:Pr,my:Rr,mx:Ar,mt:Mr,mb:Lr,ml:vr,mr:Hr},Te=typeof be=="function"?be(Qr,Oa):be;return hr(Ca,{...Yr,className:Je(R.root,{[R.tableWithBorder]:e},Er,Se?.root),sx:[m=>({borderRadius:m.radius[r]||r,boxShadow:m.shadows[i]||i,height:d,minHeight:p}),...Sa(Fr)],style:{...Te?.root,...Nr},children:[y(Cr,{ref:h,topShadowVisible:!Gr,leftShadowVisible:!(n||$e),rightShadowVisible:!qr,bottomShadowVisible:!Ur,headerHeight:Be,onScrollPositionChange:Qe,children:hr(ba,{ref:zr,horizontalSpacing:T,className:Je(R.table,{[R.tableWithColumnBorders]:t,[R.lastRowBorderBottomVisible]:ee<H,[R.textSelectionDisabled]:f,[R.verticalAlignmentTop]:u==="top",[R.verticalAlignmentBottom]:u==="bottom"}),striped:re?yr:!1,...Wr,children:[y(fr,{ref:Ir,className:Se?.header,style:Te?.header,columns:g,sortStatus:w,onSortStatusChange:b,selectionVisible:!!n,selectionChecked:we,selectionIndeterminate:Xr&&!we,onSelectionChange:_e,leftShadowVisible:je}),y("tbody",{children:re?x.map((m,B)=>{let F=C(m,l),$=Z?.includes(F)||!1,ae=!1,te=!1;if(D){let{hidden:O}=D;(!O||!(typeof O=="function"?O(m,B):O))&&(D.trigger==="click"?ae=!0:te=!0)}let fe;S&&(fe=O=>{if(O.nativeEvent.shiftKey&&oe!==null){let E=x.filter(B>oe?(K,Q)=>Q>=oe&&Q<=B:(K,Q)=>Q>=B&&Q<=oe);S($?tr(n,E,K=>C(K,l)):ue([...n,...E],K=>C(K,l)))}else S($?n.filter(E=>C(E,l)!==F):ue([...n,m],E=>C(E,l)));Kr(B)});let X;ae?X=O=>{U({top:O.clientY,left:O.clientX,record:m,recordIndex:B}),he?.(m,B)}:he&&(X=()=>{he(m,B)});let er;return te&&(er=O=>{O.preventDefault(),U({top:O.clientY,left:O.clientX,record:m,recordIndex:B})}),y(We,{record:m,recordIndex:B,columns:g,selectionVisible:!!n,selectionChecked:$,onSelectionChange:fe,onClick:X,onCellClick:kr,onContextMenu:er,contextMenuVisible:v?C(v.record,l)===F:!1,expansion:Zr,leftShadowVisible:je},F)}):y(ye,{})})]})}),k&&y(ar,{ref:Vr,className:Se?.pagination,style:Te?.pagination,topBorderColor:a,horizontalSpacing:T,fetching:s,page:k,onPageChange:$r,totalRecords:M,recordsPerPage:z,paginationColor:L,paginationSize:V,paginationText:Ce,noRecordsText:Ge,loadingText:Or,recordsLength:re}),y(Le,{pt:Be,pb:Ue,fetching:s,loaderBackgroundBlur:Br,loaderSize:J,loaderVariant:br}),y(Re,{pt:Be,pb:Ue,icon:Tr,text:Ge,active:!s&&!re,children:wr}),D&&v&&y(Ie,{zIndex:D.zIndex,borderRadius:D.borderRadius,shadow:D.shadow,top:v.top,left:v.left,onDestroy:()=>U(null),children:D.items(v.record,v.recordIndex).map(({divider:m,key:B,title:F,icon:$,color:ae,hidden:te,disabled:fe,onClick:X})=>m?y(ze,{},B):te?null:y(Ve,{title:F??de(B),icon:$,color:ae,disabled:fe,onClick:()=>{U(null),X()}},B))})]})}export{Sr as DataTable};
2
2
  //# sourceMappingURL=index.mjs.map