@zydon/common 2.3.2 → 2.3.4

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