@zydon/common 2.2.37 → 2.2.39
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/chunk-DTHBD5B6.js +17 -0
- package/dist/components/AutocompleteDetailed/index.js +1 -1
- package/dist/components/DataCards/index.d.ts +19 -2
- package/dist/components/DataCards/index.js +7 -7
- package/dist/components/form/AutocompleteDetailed/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-KPB2CGXZ.js +0 -17
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { a } from './chunk-NF42ENKE.js';
|
|
2
|
+
import { b } from './chunk-ILHUUK4X.js';
|
|
3
|
+
import O, { forwardRef, useState, useMemo, useEffect } from 'react';
|
|
4
|
+
import fe, { autocompleteClasses } from '@mui/material/Autocomplete';
|
|
5
|
+
import be from '@mui/material/CircularProgress';
|
|
6
|
+
import ge from '@mui/material/TextField';
|
|
7
|
+
import { VariableSizeList } from 'react-window';
|
|
8
|
+
import W from '@mui/material/Typography';
|
|
9
|
+
import re from '@mui/material/Divider';
|
|
10
|
+
import L from '@mui/material/Stack';
|
|
11
|
+
import te from '@mui/material/Popper';
|
|
12
|
+
import { styled } from '@mui/material/styles';
|
|
13
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
|
+
|
|
15
|
+
var H=styled(te)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}}),D=styled(L)(({theme:e})=>({flex:1,width:"100%",[e.breakpoints.down("md")]:{flexDirection:"column",gap:0,width:"100%"},[e.breakpoints.up("sm")]:{width:"calc(100% - 75px)"},[e.breakpoints.up("md")]:{flexDirection:"row",gap:8}})),T=styled(L)(({theme:e})=>({flex:1,maxWidth:"100%",[e.breakpoints.up("md")]:{flex:"1 1 calc(50% - 8px)",width:"calc(50% - 8px)",minWidth:"calc(50% - 8px)",maxWidth:"calc(50% - 8px)"}})),R=styled(L)(({theme:e})=>({position:"relative",alignItems:"center",justifyContent:"center",width:68,height:68,borderRadius:8,overflow:"hidden",img:{position:"absolute",width:"100%",height:"100%",objectFit:"cover"},[e.breakpoints.down("sm")]:{display:"none"}}));var oe=({option:e})=>{let t=Object.keys(e).filter(l=>l.startsWith("field")).map((l,m)=>{let s=e[l];if(s&&typeof s=="object"){let p="label"in s?s.label:null,u="value"in s?s.value:null;return jsxs(W,{component:"span",variant:"body2",color:"textPrimary",noWrap:!0,children:[p,": ",u]},`${l}:${m}`)}}),i=e.image?jsx("img",{alt:"Imagem",src:e.image}):jsx(a,{alt:e.label||e.value.toString(),name:e.label||e.value.toString(),sx:{width:68,height:68,borderRadius:1}});return jsxs(Fragment,{children:[jsxs(L,{direction:"row",gap:2,margin:2,children:[jsx(R,{children:i}),jsxs(L,{children:[jsxs(W,{variant:"subtitle2",color:"textPrimary",noWrap:!0,flex:1,children:[e.value," - ",e.label]}),t.length>0&&jsxs(D,{children:[jsxs(T,{children:[t[0]?t[0]:void 0,t[1]?t[1]:void 0]}),(t[2]||t[3])&&jsxs(T,{children:[t[2]?t[2]:void 0,t[3]?t[3]:void 0]})]})]})]}),jsx(re,{className:"border",sx:{borderStyle:"dashed",position:"absolute",bottom:0,width:1}})]})},x=oe;var N=8,se=e=>{let{data:t,index:i,style:l}=e,m=t[i],s={...l,top:l.top+N,paddingTop:8,display:"block"};return jsx(W,{component:"li",...m.props,noWrap:!0,style:s,children:jsx(x,{...m?.props?.children?.props})})},X=O.createContext({}),B=forwardRef((e,t)=>{let i=O.useContext(X);return jsx("div",{ref:t,...e,...i})});B.displayName="OuterElementType";var pe=e=>{let t=O.useRef(null);return useEffect(()=>{t.current!=null&&t.current.resetAfterIndex(0,!0);},[e]),t},me=forwardRef(function(t,i){let{children:l,"data-item-height":m,...s}=t,p=[];l.forEach(a=>{p.push(a),p.push(...a.children||[]);});let u=p.length,g=m>112?m:112,c=a=>Object.prototype.hasOwnProperty.call(a,"group")?48:g,S=()=>u>8?8*g:p.map(c).reduce((a,C)=>a+C,0),v=pe(u);return jsx("div",{ref:i,children:jsx(X.Provider,{value:s,children:jsx(VariableSizeList,{itemData:p,height:S()+2*N,width:"100%",ref:v,outerElementType:B,innerElementType:"ul",itemSize:a=>c(p[a]),overscanCount:5,itemCount:u,children:se})})})}),J=me;var j=forwardRef(({label:e,value:t,options:i=[],loading:l,noOptionsText:m="Nenhum resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:p,helperText:u,placeholder:g,onChange:c,groupBy:S,disabled:v,multiple:a,required:C,renderOption:G,tabIndex:U,onSearch:P,onInputChange:w,...V},_)=>{let[F,I]=useState(),q=b("down","md"),K=o=>o&&typeof o=="object"?o.value.toString():o.toString(),Q=useMemo(()=>a?(Array.isArray(t)?t:[]).reduce((r,A)=>{let E=i.find(Z=>Z.value.toString()===A.toString());return E?[...r,E]:[...r]},[]):i.find(n=>n.value.toString()===t?.toString())||null,[i,t,a]),Y=q&&i[0]?Object.keys(i[0]).length*24:void 0;return jsx(fe,{ref:_,value:F||Q,onInputChange:(o,n,r)=>{if(w&&w(o,n,r),r==="input"){P&&P(n),I(n);return}I(void 0);},options:i,loading:l,noOptionsText:m,loadingText:s,disabled:l||v,disableListWrap:!0,PopperComponent:H,ListboxProps:{"data-item-height":Y},ListboxComponent:G?void 0:J,filterOptions:(o,n)=>o.filter(r=>`${r.field1?.value} ${r.field1?.label} ${r.field2?.label} ${r.field2?.value} ${r.field3?.label} ${r.field3?.value} ${r.field4?.label} ${r.field4?.value} ${r.field5?.label} ${r.field5?.value} ${r.label}${r.value}`.toLocaleUpperCase().includes(n.inputValue.toLocaleUpperCase())),onChange:(o,n)=>{if(!n){c(a?[]:null);return}if(Array.isArray(n)){c(n.map(K));return}c(typeof n=="string"?n.toString():n.value.toString());},renderOption:({key:o,...n},r)=>jsx("li",{...n,style:{display:"block"},children:jsx(x,{option:r})},o),renderGroup:o=>o,groupBy:S,multiple:a,renderInput:o=>jsx(ge,{...o,placeholder:g,fullWidth:!0,error:!!p,helperText:u,label:e,required:C,InputProps:{...o.InputProps,endAdornment:jsxs(Fragment,{children:[l?jsx(be,{color:"primary",size:20}):null,o.InputProps.endAdornment]})},inputProps:{...o.inputProps,tabIndex:U}}),...V})});j.displayName="Autocomplete";var qe=j;
|
|
16
|
+
|
|
17
|
+
export { qe as a };
|
|
@@ -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 };
|
package/package.json
CHANGED
package/dist/chunk-KPB2CGXZ.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-NF42ENKE.js';
|
|
2
|
-
import { b } from './chunk-ILHUUK4X.js';
|
|
3
|
-
import O, { forwardRef, useState, useMemo, useEffect } from 'react';
|
|
4
|
-
import fe, { autocompleteClasses } from '@mui/material/Autocomplete';
|
|
5
|
-
import be from '@mui/material/CircularProgress';
|
|
6
|
-
import ge from '@mui/material/TextField';
|
|
7
|
-
import { VariableSizeList } from 'react-window';
|
|
8
|
-
import W from '@mui/material/Typography';
|
|
9
|
-
import re from '@mui/material/Divider';
|
|
10
|
-
import L from '@mui/material/Stack';
|
|
11
|
-
import te from '@mui/material/Popper';
|
|
12
|
-
import { styled } from '@mui/material/styles';
|
|
13
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
|
-
|
|
15
|
-
var H=styled(te)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}}),D=styled(L)(({theme:e})=>({flex:1,width:"100%",[e.breakpoints.down("md")]:{flexDirection:"column",gap:0,width:"100%"},[e.breakpoints.up("sm")]:{width:"calc(100% - 75px)"},[e.breakpoints.up("md")]:{flexDirection:"row",gap:8}})),T=styled(L)(({theme:e})=>({flex:1,maxWidth:"100%",[e.breakpoints.up("md")]:{flex:"1 1 calc(50% - 8px)",width:"calc(50% - 8px)",minWidth:"calc(50% - 8px)",maxWidth:"calc(50% - 8px)"}})),R=styled(L)(({theme:e})=>({position:"relative",alignItems:"center",justifyContent:"center",width:68,height:68,borderRadius:8,overflow:"hidden",img:{position:"absolute",width:"100%",height:"100%",objectFit:"cover"},[e.breakpoints.down("sm")]:{display:"none"}}));var oe=({option:e})=>{let t=Object.keys(e).filter(l=>l.startsWith("field")).map((l,m)=>{let s=e[l];if(s&&typeof s=="object"){let p="label"in s?s.label:null,d="value"in s?s.value:null;return jsxs(W,{component:"span",variant:"body2",color:"textPrimary",noWrap:!0,children:[p,": ",d]},`${l}:${m}`)}}),i=e.image?jsx("img",{alt:"Imagem",src:e.image}):jsx(a,{alt:e.label||e.value.toString(),name:e.label||e.value.toString(),sx:{width:68,height:68,borderRadius:1}});return jsxs(Fragment,{children:[jsxs(L,{direction:"row",gap:2,margin:2,children:[jsx(R,{children:i}),jsxs(D,{children:[jsxs(T,{children:[jsx(L,{children:jsxs(W,{variant:"subtitle2",color:"textPrimary",noWrap:!0,children:[e.value," - ",e.label]})}),t[0]?t[0]:void 0,t[1]?t[1]:void 0]}),t.length>2&&jsxs(T,{children:[t[2]?t[2]:void 0,t[3]?t[3]:void 0,t[4]?t[4]:void 0]})]})]}),jsx(re,{className:"border",sx:{borderStyle:"dashed",position:"absolute",bottom:0,width:1}})]})},x=oe;var N=8,se=e=>{let{data:t,index:i,style:l}=e,m=t[i],s={...l,top:l.top+N,paddingTop:8,display:"block"};return jsx(W,{component:"li",...m.props,noWrap:!0,style:s,children:jsx(x,{...m?.props?.children?.props})})},X=O.createContext({}),B=forwardRef((e,t)=>{let i=O.useContext(X);return jsx("div",{ref:t,...e,...i})});B.displayName="OuterElementType";var pe=e=>{let t=O.useRef(null);return useEffect(()=>{t.current!=null&&t.current.resetAfterIndex(0,!0);},[e]),t},me=forwardRef(function(t,i){let{children:l,"data-item-height":m,...s}=t,p=[];l.forEach(a=>{p.push(a),p.push(...a.children||[]);});let d=p.length,h=m>112?m:112,c=a=>Object.prototype.hasOwnProperty.call(a,"group")?48:h,S=()=>d>8?8*h:p.map(c).reduce((a,C)=>a+C,0),v=pe(d);return jsx("div",{ref:i,children:jsx(X.Provider,{value:s,children:jsx(VariableSizeList,{itemData:p,height:S()+2*N,width:"100%",ref:v,outerElementType:B,innerElementType:"ul",itemSize:a=>c(p[a]),overscanCount:5,itemCount:d,children:se})})})}),J=me;var j=forwardRef(({label:e,value:t,options:i=[],loading:l,noOptionsText:m="Nenhum resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:p,helperText:d,placeholder:h,onChange:c,groupBy:S,disabled:v,multiple:a,required:C,renderOption:G,tabIndex:U,onSearch:P,onInputChange:w,...V},_)=>{let[F,I]=useState(),q=b("down","md"),K=o=>o&&typeof o=="object"?o.value.toString():o.toString(),Q=useMemo(()=>a?(Array.isArray(t)?t:[]).reduce((r,A)=>{let E=i.find(Z=>Z.value.toString()===A.toString());return E?[...r,E]:[...r]},[]):i.find(n=>n.value.toString()===t?.toString())||null,[i,t,a]),Y=q&&i[0]?Object.keys(i[0]).length*24:void 0;return jsx(fe,{ref:_,value:F||Q,onInputChange:(o,n,r)=>{if(w&&w(o,n,r),r==="input"){P&&P(n),I(n);return}I(void 0);},options:i,loading:l,noOptionsText:m,loadingText:s,disabled:l||v,disableListWrap:!0,PopperComponent:H,ListboxProps:{"data-item-height":Y},ListboxComponent:G?void 0:J,filterOptions:(o,n)=>o.filter(r=>`${r.field1?.value} ${r.field1?.label} ${r.field2?.label} ${r.field2?.value} ${r.field3?.label} ${r.field3?.value} ${r.field4?.label} ${r.field4?.value} ${r.field5?.label} ${r.field5?.value} ${r.label}${r.value}`.toLocaleUpperCase().includes(n.inputValue.toLocaleUpperCase())),onChange:(o,n)=>{if(!n){c(a?[]:null);return}if(Array.isArray(n)){c(n.map(K));return}c(typeof n=="string"?n.toString():n.value.toString());},renderOption:({key:o,...n},r)=>jsx("li",{...n,style:{display:"block"},children:jsx(x,{option:r})},o),renderGroup:o=>o,groupBy:S,multiple:a,renderInput:o=>jsx(ge,{...o,placeholder:h,fullWidth:!0,error:!!p,helperText:d,label:e,required:C,InputProps:{...o.InputProps,endAdornment:jsxs(Fragment,{children:[l?jsx(be,{color:"primary",size:20}):null,o.InputProps.endAdornment]})},inputProps:{...o.inputProps,tabIndex:U}}),...V})});j.displayName="Autocomplete";var qe=j;
|
|
16
|
-
|
|
17
|
-
export { qe as a };
|