@zydon/common 2.3.2 → 2.3.3
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.
|
@@ -4,18 +4,18 @@ import { a as a$2 } from '../../chunk-ZODC2MGF.js';
|
|
|
4
4
|
import '../../chunk-ZDHXW74M.js';
|
|
5
5
|
import { a as a$1 } from '../../chunk-FK7DDO5L.js';
|
|
6
6
|
import '../../chunk-D27ND54J.js';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import dt from '@mui/material/Pagination';
|
|
8
|
+
import g from '@mui/material/Stack';
|
|
9
9
|
import { useMemo } from 'react';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import tt from '@mui/material/CardContent';
|
|
11
|
+
import et from '@mui/material/Checkbox';
|
|
12
12
|
import x from '@mui/material/Typography';
|
|
13
|
-
import
|
|
14
|
-
import
|
|
13
|
+
import X from '@mui/material/Card';
|
|
14
|
+
import Y from '@mui/material/CardActionArea';
|
|
15
15
|
import { styled, alpha } from '@mui/material/styles';
|
|
16
16
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
17
|
-
import
|
|
17
|
+
import y from '@mui/material/Skeleton';
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var P=styled(X)(({theme:e})=>({boxShadow:"none",border:`1px solid ${alpha(e.palette.grey[500],.2)}`})),I=styled(Y)({"&.MuiCardActionArea-focusHighlight":{background:"transparent"}});var rt=(e,t)=>e.renderCell?e.renderCell({value:e.value,field:t,row:{[t]:e.value}}):e.valueFormatter&&e.valueGetter?e.valueFormatter(e.valueGetter(e.value)):e.value,G=e=>{e.stopPropagation();},ot=({fields:e,id:t,row:i,title:p,onClick:o,checkboxSelection:f,selectedRows:s=[],onSelectionRow:n})=>{let c$1=useMemo(()=>`${c(t)?"#":""}${t}`,[t]),l=useMemo(()=>s?.includes(t),[t,s]),d=e.find(r=>r.label.toLowerCase()==="status"||r.type==="status"||r.field==="status"),v=useMemo(()=>d?.renderCell?.({value:d.value,field:t,row:{[t]:d.value}})||d?.value,[d,t]),h=e.find(r=>r.type==="actions"||r.id==="actions"),u=useMemo(()=>h?.getActions({id:t,row:i})||null,[h,t,i]),A=useMemo(()=>e.filter(r=>r.label.toLowerCase()!=="status"&&r.value?.toString()!==t&&r.type!=="actions"),[e,t]),Q=r=>{o?.({id:t},r,e);},U=r=>{n?.(r?[...s,t]:s.filter(M=>M!==t));},V=useMemo(()=>A.map(r=>r.value!=t&&jsxs(g,{flexBasis:"50%",pb:2,order:r.order,children:[jsx(x,{variant:"body2",color:"text.secondary",children:r.label}),jsx(x,{variant:"body1",children:rt(r,t)})]},`data-card-field-${t}-${r.label}`)),[A,t]),R=jsxs(tt,{sx:{padding:"0!important"},children:[jsxs(g,{flexDirection:"row",justifyContent:"space-between",p:2,children:[jsxs(g,{flexDirection:"row",alignItems:"center",gap:1,children:[f&&jsx(et,{checked:l||!1,onChange:(r,M)=>U(M)}),jsx(x,{variant:"body1",fontWeight:600,color:"text.secondary",children:p}),jsx(x,{variant:"body1",fontWeight:600,children:c$1})]}),jsxs(g,{className:"actions",flexDirection:"row",alignItems:"center",gap:1,children:[jsx(x,{variant:"body2",color:"text.secondary",textTransform:"uppercase",fontSize:14,fontWeight:600,children:v}),jsx(g,{onClick:G,onMouseDown:G,children:u})]})]}),jsx(a,{}),jsx(g,{flexWrap:"wrap",direction:"row",justifyContent:"space-between",p:2,pb:0,children:V})]});return o?jsx(P,{onClick:Q,children:jsx(I,{component:"div",children:R})}):jsx(P,{children:R})},L=ot;var nt=()=>jsxs(X,{children:[jsxs(g,{justifyContent:"space-between",direction:"row",spacing:2,p:2,children:[jsx(y,{height:24,width:200}),jsx(y,{height:24,width:100})]}),jsxs(g,{justifyContent:"space-between",flexWrap:"wrap",direction:"row",p:2,children:[jsxs(g,{width:"50%",spacing:1,children:[jsx(y,{height:24,width:100}),jsx(y,{sx:{maxWidth:"95%"},height:24,width:230})]}),jsxs(g,{width:"50%",spacing:1,children:[jsx(y,{height:24,width:80}),jsx(y,{sx:{maxWidth:"100%"},height:27,width:250})]})]})]}),D=nt;var N=(e,t)=>{let i=[];e.forEach(o=>{o.field&&o.field!=="actions"&&i.push({...o,label:o.headerName||o.field,value:t[o.field],type:o.type,order:o?.order||0,id:o.field});});let p=e.find(o=>o.field==="actions");return p&&i.push({...p,label:"Actions",value:null,order:0,type:"actions",id:"actions"}),i};var j=styled(g)(({theme:e})=>({border:`1px solid ${alpha(e.palette.grey[500],.2)}`,borderRadius:16})),z=styled(g)(()=>({padding:"12px 28px",flexDirection:"row",alignItems:"center",backgroundColor:"#F4F4F4",gap:14,borderRadius:"16px 16px 0 0"}));var lt=({children:e,title:t,rows:i,onSelectionRow:p,selectedRows:o,totalItems:f})=>{let s=c=>{p?.(c?i.map(l=>l["@id"]):[]);},n=o?.length||0;return jsxs(j,{children:[jsxs(z,{children:[jsx(et,{onChange:(c,l)=>s(l),checked:n===f,indeterminate:n>0&&n<f}),jsx(x,{variant:"subtitle2",component:"span",color:"grey.600",children:t})]}),jsx(g,{gap:1.5,p:1.5,children:e})]})},J=lt;var mt=({title:e,rows:t,columns:i,getRowId:p,onClick:o,loading:f,fetching:s,pagination:n,checkboxSelection:c,onSelectionRow:l,selectedRows:d})=>{let v=s&&jsx(a$1,{sx:{zIndex:1}});return f?jsxs(Fragment,{children:[v,jsx(D,{}),jsx(D,{}),jsx(D,{})]}):jsxs(g,{gap:2,component:c?J:"div",...c&&{title:e,rows:t,onSelectionRow:l,selectedRows:d,totalItems:n?.total||t.length},children:[v,t.length===0&&jsx(a$2,{sx:{mb:3},title:"Nenhum registro encontrado"}),t.map(h=>{let u=p(h);return jsx(L,{title:e,id:u,row:h,fields:N(i,h),onClick:o,checkboxSelection:c,selectedRows:d,onSelectionRow:l},`data-card-${u}`)}),n&&t.length>0&&jsx(g,{direction:"row",justifyContent:"center",children:jsx(dt,{page:n?.page,onChange:(h,u)=>{n?.onPageChange(u);},count:n?.total})})]})},Xt=mt;
|
|
20
20
|
|
|
21
|
-
export {
|
|
21
|
+
export { L as DataCard, D as DataCardSkeleton, Xt as default, N as getFieldData };
|