@zydon/common 2.2.37 → 2.2.38
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.
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { GridRowParams, MuiEvent } from '@mui/x-data-grid-premium';
|
|
2
|
+
import { GridRowParams, MuiEvent, GridValidRowModel } from '@mui/x-data-grid-premium';
|
|
3
3
|
import { DatagridRow, Columns } from '../../types/datagrid.js';
|
|
4
4
|
|
|
5
|
+
interface MappedRow extends GridValidRowModel {
|
|
6
|
+
label: string;
|
|
7
|
+
value: unknown;
|
|
8
|
+
order: number;
|
|
9
|
+
type: string | undefined;
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
5
12
|
interface DataCardsProps {
|
|
6
13
|
title: string;
|
|
7
14
|
rows: DatagridRow[];
|
|
@@ -17,7 +24,17 @@ interface DataCardsProps {
|
|
|
17
24
|
getRowId: (row: DatagridRow) => string;
|
|
18
25
|
onClick?: (params: GridRowParams<object>, event: MuiEvent<React.MouseEvent<HTMLElement, MouseEvent>>, details: unknown) => void;
|
|
19
26
|
}
|
|
27
|
+
interface DataCardProps {
|
|
28
|
+
fields: MappedRow[];
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
onClick?: (params: GridRowParams<object>, event: MuiEvent<React.MouseEvent<HTMLElement, MouseEvent>>, details: unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare const DataCard: ({ fields, id, title, onClick }: DataCardProps) => react_jsx_runtime.JSX.Element;
|
|
35
|
+
|
|
36
|
+
declare const DataCardsSkeleton: () => react_jsx_runtime.JSX.Element;
|
|
20
37
|
|
|
21
38
|
declare const DataCards: ({ title, rows, columns, getRowId, onClick, loading, fetching, pagination, }: DataCardsProps) => react_jsx_runtime.JSX.Element;
|
|
22
39
|
|
|
23
|
-
export { DataCards };
|
|
40
|
+
export { DataCard, DataCardsSkeleton, DataCards as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c } from '../../chunk-QQB3DGHT.js';
|
|
2
|
-
import { a
|
|
3
|
-
import { a } from '../../chunk-YWEB6IAI.js';
|
|
4
|
-
import { a as a$
|
|
2
|
+
import { a } from '../../chunk-3SFA4YEZ.js';
|
|
3
|
+
import { a as a$1 } from '../../chunk-YWEB6IAI.js';
|
|
4
|
+
import { a as a$2 } from '../../chunk-ZODC2MGF.js';
|
|
5
5
|
import '../../chunk-ZDHXW74M.js';
|
|
6
6
|
import '../../chunk-D27ND54J.js';
|
|
7
7
|
import H from '@mui/material/Pagination';
|
|
@@ -9,12 +9,12 @@ import d from '@mui/material/Stack';
|
|
|
9
9
|
import { useMemo } from 'react';
|
|
10
10
|
import P from '@mui/material/Card';
|
|
11
11
|
import N from '@mui/material/CardContent';
|
|
12
|
-
import
|
|
12
|
+
import u from '@mui/material/Typography';
|
|
13
13
|
import G from '@mui/material/CardActionArea';
|
|
14
14
|
import { styled } from '@mui/material/styles';
|
|
15
|
-
import {
|
|
15
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
16
16
|
import l from '@mui/material/Skeleton';
|
|
17
17
|
|
|
18
|
-
var M=styled(G)(({disableRipple:r})=>({".MuiCardActionArea-focusHighlight":{background:"transparent"},...r&&{"&:hover":{cursor:"default"}}}));var T=r=>{r.stopPropagation();},j=({fields:r,id:o,title:s,onClick:n})=>{let e=r.find(t=>t.label.toLowerCase()==="status"||t.type==="status"||t.field==="status"),v=useMemo(()=>e?.renderCell?.({value:e.value,field:o,row:{[o]:e.value}})||e?.value,[e,o]),g=r.find(t=>t.type==="actions"||t.id==="actions"),p=useMemo(()=>g?.getActions({id:o})||null,[g,o]),y=useMemo(()=>r.filter(t=>t.label.toLowerCase()!=="status"&&t.value?.toString()!==o&&t.type!=="actions"),[r,o]),c$1=t=>{n?.({id:o},t,r);},C=jsxs(N,{sx:{padding:"0!important"},children:[jsxs(d,{flexDirection:"row",justifyContent:"space-between",p:2,children:[jsxs(d,{flexDirection:"row",alignItems:"center",gap:1,children:[jsx(
|
|
18
|
+
var M=styled(G)(({disableRipple:r})=>({".MuiCardActionArea-focusHighlight":{background:"transparent"},...r&&{"&:hover":{cursor:"default"}}}));var T=r=>{r.stopPropagation();},j=({fields:r,id:o,title:s,onClick:n})=>{let e=r.find(t=>t.label.toLowerCase()==="status"||t.type==="status"||t.field==="status"),v=useMemo(()=>e?.renderCell?.({value:e.value,field:o,row:{[o]:e.value}})||e?.value,[e,o]),g=r.find(t=>t.type==="actions"||t.id==="actions"),p=useMemo(()=>g?.getActions({id:o})||null,[g,o]),y=useMemo(()=>r.filter(t=>t.label.toLowerCase()!=="status"&&t.value?.toString()!==o&&t.type!=="actions"),[r,o]),c$1=t=>{n?.({id:o},t,r);},C=jsxs(N,{sx:{padding:"0!important"},children:[jsxs(d,{flexDirection:"row",justifyContent:"space-between",p:2,children:[jsxs(d,{flexDirection:"row",alignItems:"center",gap:1,children:[jsx(u,{variant:"body1",fontWeight:600,color:"text.secondary",children:s}),jsxs(u,{variant:"body1",fontWeight:600,children:[c(o)?"#":"",o]})]}),jsxs(d,{className:"actions",flexDirection:"row",alignItems:"center",gap:1,children:[jsx(u,{variant:"body2",color:"text.secondary",textTransform:"uppercase",fontSize:14,fontWeight:600,children:v}),jsx(d,{onClick:T,onMouseDown:T,children:p})]})]}),jsx(a,{}),jsx(d,{flexWrap:"wrap",direction:"row",justifyContent:"space-between",p:2,pb:0,children:y.map(t=>t.value!=o&&jsxs(d,{flexBasis:"50%",pb:2,order:t.order,children:[jsx(u,{variant:"body2",color:"text.secondary",children:t.label}),jsx(u,{variant:"body1",children:t.valueGetter?t.valueFormatter(t.valueGetter(t.value)):t.value})]},`data-card-field-${o}-${t.label}`))})]});return n?jsx(P,{onClick:c$1,children:jsx(M,{component:"div",children:C})}):jsx(P,{children:C})},E=j;var w=()=>jsxs(P,{children:[jsxs(d,{justifyContent:"space-between",direction:"row",spacing:2,p:2,children:[jsx(l,{height:24,width:200}),jsx(l,{height:24,width:100})]}),jsxs(d,{justifyContent:"space-between",flexWrap:"wrap",direction:"row",p:2,children:[jsxs(d,{width:"50%",spacing:1,children:[jsx(l,{height:24,width:100}),jsx(l,{sx:{maxWidth:"95%"},height:24,width:230})]}),jsxs(d,{width:"50%",spacing:1,children:[jsx(l,{height:24,width:80}),jsx(l,{sx:{maxWidth:"100%"},height:27,width:250})]})]})]});var R=(r,o)=>{let s=[];r.forEach(e=>{e.field&&e.field!=="actions"&&s.push({...e,label:e.headerName||e.field,value:o[e.field],type:e.type,order:e?.order||0,id:e.field});});let n=r.find(e=>e.field==="actions");return n&&s.push({...n,label:"Actions",value:null,order:0,type:"actions",id:"actions"}),s};var $=({title:r,rows:o,columns:s,getRowId:n,onClick:e,loading:v,fetching:g,pagination:p})=>{let y=g&&jsx(a$1,{sx:{zIndex:1}});return v?jsxs(Fragment,{children:[y,jsx(w,{}),jsx(w,{}),jsx(w,{})]}):jsxs(d,{spacing:2,children:[y,o.length===0&&jsx(a$2,{sx:{mb:3},title:"Nenhum registro encontrado"}),o.map(c=>jsx(E,{title:r,id:n(c),fields:R(s,c),onClick:e},`data-card-${n(c)}`)),p&&o.length>0&&jsx(d,{direction:"row",justifyContent:"center",children:jsx(H,{page:p?.page,onChange:(c,C)=>{p?.onPageChange(C);},count:p?.total})})]})},ut=$;
|
|
19
19
|
|
|
20
|
-
export {
|
|
20
|
+
export { E as DataCard, w as DataCardsSkeleton, ut as default };
|