mantine-datatable 1.7.21 → 1.7.22

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