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