mantine-datatable 1.7.30 → 1.7.32

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