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