mantine-datatable 1.7.11 → 1.7.12

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