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