@zydon/common 2.3.3 → 2.3.5

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.
@@ -16,6 +16,6 @@ import { styled, alpha } from '@mui/material/styles';
16
16
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
17
17
  import y from '@mui/material/Skeleton';
18
18
 
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;
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)=>{if(e.renderCell){let a=e.renderCell({value:e.value,field:t,row:{[t]:e.value}});if(a)return a}return e.valueFormatter&&e.valueGetter?e.valueFormatter(e.valueGetter(e.value)):e.value},G=e=>{e.stopPropagation();},ot=({fields:e,id:t,row:a$1,title:p,onClick:o,checkboxSelection:h,selectedRows:s=[],onSelectionRow:i})=>{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]),f=e.find(r=>r.type==="actions"||r.id==="actions"),u=useMemo(()=>f?.getActions({id:t,row:a$1})||null,[f,t,a$1]),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=>{i?.(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:[h&&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 a=[];e.forEach(o=>{o.field&&o.field!=="actions"&&a.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&&a.push({...p,label:"Actions",value:null,order:0,type:"actions",id:"actions"}),a};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:a,onSelectionRow:p,selectedRows:o,totalItems:h})=>{let s=c=>{p?.(c?a.map(l=>l["@id"]):[]);},i=o?.length||0;return jsxs(j,{children:[jsxs(z,{children:[jsx(et,{onChange:(c,l)=>s(l),checked:i===h,indeterminate:i>0&&i<h}),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:a,getRowId:p,onClick:o,loading:h,fetching:s,pagination:i,checkboxSelection:c,onSelectionRow:l,selectedRows:d})=>{let v=s&&jsx(a$1,{sx:{zIndex:1}});return h?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:i?.total||t.length},children:[v,t.length===0&&jsx(a$2,{sx:{mb:3},title:"Nenhum registro encontrado"}),t.map(f=>{let u=p(f);return jsx(L,{title:e,id:u,row:f,fields:N(a,f),onClick:o,checkboxSelection:c,selectedRows:d,onSelectionRow:l},`data-card-${u}`)}),i&&t.length>0&&jsx(g,{direction:"row",justifyContent:"center",children:jsx(dt,{page:i?.page,onChange:(f,u)=>{i?.onPageChange(u);},count:i?.total})})]})},Xt=mt;
20
20
 
21
21
  export { L as DataCard, D as DataCardSkeleton, Xt as default, N as getFieldData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",