mantine-datatable 1.7.8 → 1.7.9

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