@zydon/common 2.2.6 → 2.2.7

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.
@@ -12,6 +12,6 @@ import Z from '@mui/material/Popper';
12
12
  import { styled } from '@mui/material/styles';
13
13
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
14
 
15
- var H=styled(Z)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}}),D=styled(v)(({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(v)(({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(v)(({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 te=({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(v,{direction:"row",gap:2,margin:2,children:[jsx(R,{children:i}),jsxs(D,{children:[jsxs(T,{children:[jsx(v,{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(ee,{className:"border",sx:{borderStyle:"dashed",position:"absolute",bottom:0,width:1}})]})},x=te;var N=8,le=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 ae=e=>{let t=O.useRef(null);return useEffect(()=>{t.current!=null&&t.current.resetAfterIndex(0,!0);},[e]),t},se=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,u=a=>Object.prototype.hasOwnProperty.call(a,"group")?48:h,S=()=>d>8?8*h:p.map(u).reduce((a,L)=>a+L,0),C=ae(d);return jsx("div",{ref:i,children:jsx(X.Provider,{value:s,children:jsx(VariableSizeList,{itemData:p,height:S()+2*N,width:"100%",ref:C,outerElementType:B,innerElementType:"ul",itemSize:a=>u(p[a]),overscanCount:5,itemCount:d,children:le})})})}),J=se;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:u,groupBy:S,disabled:C,multiple:a,required:L,renderOption:G,tabIndex:U,onSearch:P,onInputChange:w,..._},F)=>{let V=b("down","md"),q=r=>r&&typeof r=="object"?r.value.toString():r.toString(),I=useMemo(()=>a?(Array.isArray(t)?t:[]).reduce((o,A)=>{let E=i.find(Q=>Q.value.toString()===A.toString());return E?[...o,E]:[...o]},[]):i.find(n=>n.value.toString()===t?.toString())||null,[i,t,a]),K=V&&i[0]?Object.keys(i[0]).length*24:void 0;return jsx(de,{ref:F,value:I,onInputChange:(r,n,o)=>{!l&&!I&&o!=="input"&&u(a?[]:null),w&&w(r,n,o),P&&r&&(r.type==="change"||r.type==="blur")&&P(n);},options:i,loading:l,noOptionsText:m,loadingText:s,disabled:l||C,disableListWrap:!0,PopperComponent:H,ListboxProps:{"data-item-height":K},ListboxComponent:G?void 0:J,filterOptions:(r,n)=>r.filter(o=>`${o.field1?.value} ${o.field1?.label} ${o.field2?.label} ${o.field2?.value} ${o.field3?.label} ${o.field3?.value} ${o.field4?.label} ${o.field4?.value} ${o.field5?.label} ${o.field5?.value} ${o.label}${o.value}`.toLocaleUpperCase().includes(n.inputValue.toLocaleUpperCase())),onChange:(r,n)=>{if(!n){u(a?[]:null);return}if(Array.isArray(n)){u(n.map(q));return}u(typeof n=="string"?n.toString():n.value.toString());},renderOption:({key:r,...n},o)=>jsx("li",{...n,style:{display:"block"},children:jsx(x,{option:o})},r),renderGroup:r=>r,groupBy:S,multiple:a,renderInput:r=>jsx(ce,{...r,placeholder:h,fullWidth:!0,error:!!p,helperText:d,label:e,required:L,InputProps:{...r.InputProps,endAdornment:jsxs(Fragment,{children:[l?jsx(ue,{color:"primary",size:20}):null,r.InputProps.endAdornment]})},inputProps:{...r.inputProps,tabIndex:U}}),..._})});j.displayName="Autocomplete";var _e=j;
15
+ var H=styled(Z)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}}),D=styled(v)(({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(v)(({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(v)(({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 te=({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(v,{direction:"row",gap:2,margin:2,children:[jsx(R,{children:i}),jsxs(D,{children:[jsxs(T,{children:[jsx(v,{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(ee,{className:"border",sx:{borderStyle:"dashed",position:"absolute",bottom:0,width:1}})]})},x=te;var N=8,le=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 ae=e=>{let t=O.useRef(null);return useEffect(()=>{t.current!=null&&t.current.resetAfterIndex(0,!0);},[e]),t},se=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,u=a=>Object.prototype.hasOwnProperty.call(a,"group")?48:h,S=()=>d>8?8*h:p.map(u).reduce((a,L)=>a+L,0),C=ae(d);return jsx("div",{ref:i,children:jsx(X.Provider,{value:s,children:jsx(VariableSizeList,{itemData:p,height:S()+2*N,width:"100%",ref:C,outerElementType:B,innerElementType:"ul",itemSize:a=>u(p[a]),overscanCount:5,itemCount:d,children:le})})})}),J=se;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:u,groupBy:S,disabled:C,multiple:a,required:L,renderOption:G,tabIndex:U,onSearch:P,onInputChange:w,..._},F)=>{let V=b("down","md"),q=r=>r&&typeof r=="object"?r.value.toString():r.toString(),I=useMemo(()=>a?(Array.isArray(t)?t:[]).reduce((o,A)=>{let E=i.find(Q=>Q.value.toString()===A.toString());return E?[...o,E]:[...o]},[]):i.find(n=>n.value.toString()===t?.toString())||null,[i,t,a]),K=V&&i[0]?Object.keys(i[0]).length*24:void 0;return jsx(de,{ref:F,value:I,onInputChange:(r,n,o)=>{!l&&!I&&u(a?[]:null),w&&w(r,n,o),P&&r&&(r.type==="change"||r.type==="blur")&&P(n);},options:i,loading:l,noOptionsText:m,loadingText:s,disabled:l||C,disableListWrap:!0,PopperComponent:H,ListboxProps:{"data-item-height":K},ListboxComponent:G?void 0:J,filterOptions:(r,n)=>r.filter(o=>`${o.field1?.value} ${o.field1?.label} ${o.field2?.label} ${o.field2?.value} ${o.field3?.label} ${o.field3?.value} ${o.field4?.label} ${o.field4?.value} ${o.field5?.label} ${o.field5?.value} ${o.label}${o.value}`.toLocaleUpperCase().includes(n.inputValue.toLocaleUpperCase())),onChange:(r,n)=>{if(!n){u(a?[]:null);return}if(Array.isArray(n)){u(n.map(q));return}u(typeof n=="string"?n.toString():n.value.toString());},renderOption:({key:r,...n},o)=>jsx("li",{...n,style:{display:"block"},children:jsx(x,{option:o})},r),renderGroup:r=>r,groupBy:S,multiple:a,renderInput:r=>jsx(ce,{...r,placeholder:h,fullWidth:!0,error:!!p,helperText:d,label:e,required:L,InputProps:{...r.InputProps,endAdornment:jsxs(Fragment,{children:[l?jsx(ue,{color:"primary",size:20}):null,r.InputProps.endAdornment]})},inputProps:{...r.inputProps,tabIndex:U}}),..._})});j.displayName="Autocomplete";var _e=j;
16
16
 
17
17
  export { _e as a };
@@ -1,4 +1,4 @@
1
- import { a } from './chunk-4EQYE64E.js';
1
+ import { a } from './chunk-MSH7OPW3.js';
2
2
  import { useFormContext, Controller } from 'react-hook-form';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -12,6 +12,6 @@ import F from '@mui/material/useMediaQuery';
12
12
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
13
  import ee from '@mui/material/Popper';
14
14
 
15
- var I=8,Q=m=>{let{data:o,index:i,style:u}=m,n=o[i],{showValueInLabel:s,...f}=n[0],c={...u,top:u.top+I,paddingTop:8};return Object.prototype.hasOwnProperty.call(n,"group")?jsx(G,{component:"div",style:c,children:n.group},n.key):jsx(v,{component:"li",...f,noWrap:!0,style:c,children:jsxs(_,{component:"div",direction:"row",flex:1,gap:1,justifyContent:"start",children:[n[1].icon&&jsx(a,{icon:n[1].icon}),n[1].label,s&&jsxs(v,{variant:"inherit",color:"grey.400",children:["(",n[1].value,")"]})]})})},R=createContext({}),z=forwardRef((m,o)=>{let i=useContext(R);return jsx("div",{ref:o,...m,...i})});z.displayName="OuterElementType";var K=m=>{let o=useRef(null);return useEffect(()=>{o.current!=null&&o.current.resetAfterIndex(0,!0);},[m]),o},Y=forwardRef(function(o,i){let{children:u,...n}=o,s=[];u.forEach(r=>{s.push(r),s.push(...r.children||[]);});let f=useTheme(),c=F(f.breakpoints.up("sm")),y=s.length,l=c?36:48,h=r=>Object.prototype.hasOwnProperty.call(r,"group")?48:l,C=()=>y>8?8*l:s.map(h).reduce((r,P)=>r+P,0),L=K(y);return jsx("div",{ref:i,children:jsx(R.Provider,{value:n,children:jsx(VariableSizeList,{itemData:s,height:C()+2*I,width:"100%",ref:L,outerElementType:z,innerElementType:"ul",itemSize:r=>h(s[r]),overscanCount:5,itemCount:y,children:Q})})})}),M=Y;var k=styled(ee)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var N=forwardRef(({label:m,value:o,options:i=[],loading:u,noOptionsText:n="Nenhum resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:f,helperText:c,placeholder:y,onChange:l,groupBy:h,showValueInLabel:C,disabled:L,multiple:r,required:P,renderOption:x,tabIndex:D,onInputChange:T,onSearch:A,...H},X)=>{let J=e=>e&&typeof e=="object"?e.value.toString():e.toString(),d=useMemo(()=>r?(Array.isArray(o)?o:[]).reduce((p,g)=>{let E=i.find(V=>V.value.toString()===g.toString());return E?[...p,E]:[...p]},[]):i.find(t=>t.value.toString()===o?.toString())||null,[i,o,r]);return jsx(ne,{ref:X,value:d,onInputChange:(e,t,p)=>{!u&&!d&&p!=="input"&&l(r?[]:null),T&&T(e,t,p),A&&e&&(e.type==="change"||e.type==="blur")&&A(t);},options:i,loading:u,noOptionsText:n,loadingText:s,disabled:u||L,disableListWrap:!0,PopperComponent:k,ListboxComponent:x?void 0:M,filterOptions:(e,t)=>e.filter(p=>`${p.value} ${p.label}`.toLocaleUpperCase().includes(t.inputValue.toLocaleUpperCase())),onChange:(e,t)=>{if(!t){l(r?[]:null);return}if(Array.isArray(t)){l(t.map(J));return}l(typeof t=="string"?t.toString():t.value.toString());},renderOption:(e,t,p,g)=>x?x(e,t,p,g):[{...e,showValueInLabel:C},t],renderGroup:e=>e,groupBy:h,multiple:r,renderInput:e=>jsx(se,{...e,placeholder:y,fullWidth:!0,error:!!f,helperText:c,label:m,required:P,InputProps:{...e.InputProps,...!r&&{startAdornment:d&&!Array.isArray(d)&&d.icon?jsx(a,{icon:d.icon}):void 0},endAdornment:jsxs(Fragment,{children:[u?jsx(ie,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,tabIndex:D}}),...H})});N.displayName="Autocomplete";var Me=N;
15
+ var I=8,Q=m=>{let{data:o,index:i,style:p}=m,n=o[i],{showValueInLabel:s,...f}=n[0],c={...p,top:p.top+I,paddingTop:8};return Object.prototype.hasOwnProperty.call(n,"group")?jsx(G,{component:"div",style:c,children:n.group},n.key):jsx(v,{component:"li",...f,noWrap:!0,style:c,children:jsxs(_,{component:"div",direction:"row",flex:1,gap:1,justifyContent:"start",children:[n[1].icon&&jsx(a,{icon:n[1].icon}),n[1].label,s&&jsxs(v,{variant:"inherit",color:"grey.400",children:["(",n[1].value,")"]})]})})},R=createContext({}),z=forwardRef((m,o)=>{let i=useContext(R);return jsx("div",{ref:o,...m,...i})});z.displayName="OuterElementType";var K=m=>{let o=useRef(null);return useEffect(()=>{o.current!=null&&o.current.resetAfterIndex(0,!0);},[m]),o},Y=forwardRef(function(o,i){let{children:p,...n}=o,s=[];p.forEach(r=>{s.push(r),s.push(...r.children||[]);});let f=useTheme(),c=F(f.breakpoints.up("sm")),y=s.length,l=c?36:48,h=r=>Object.prototype.hasOwnProperty.call(r,"group")?48:l,C=()=>y>8?8*l:s.map(h).reduce((r,P)=>r+P,0),L=K(y);return jsx("div",{ref:i,children:jsx(R.Provider,{value:n,children:jsx(VariableSizeList,{itemData:s,height:C()+2*I,width:"100%",ref:L,outerElementType:z,innerElementType:"ul",itemSize:r=>h(s[r]),overscanCount:5,itemCount:y,children:Q})})})}),M=Y;var k=styled(ee)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var N=forwardRef(({label:m,value:o,options:i=[],loading:p,noOptionsText:n="Nenhum resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:f,helperText:c,placeholder:y,onChange:l,groupBy:h,showValueInLabel:C,disabled:L,multiple:r,required:P,renderOption:x,tabIndex:D,onInputChange:T,onSearch:A,...H},X)=>{let J=e=>e&&typeof e=="object"?e.value.toString():e.toString(),d=useMemo(()=>r?(Array.isArray(o)?o:[]).reduce((u,g)=>{let E=i.find(V=>V.value.toString()===g.toString());return E?[...u,E]:[...u]},[]):i.find(t=>t.value.toString()===o?.toString())||null,[i,o,r]);return jsx(ne,{ref:X,value:d,onInputChange:(e,t,u)=>{!p&&!d&&l(r?[]:null),T&&T(e,t,u),A&&e&&(e.type==="change"||e.type==="blur")&&A(t);},options:i,loading:p,noOptionsText:n,loadingText:s,disabled:p||L,disableListWrap:!0,PopperComponent:k,ListboxComponent:x?void 0:M,filterOptions:(e,t)=>e.filter(u=>`${u.value} ${u.label}`.toLocaleUpperCase().includes(t.inputValue.toLocaleUpperCase())),onChange:(e,t)=>{if(!t){l(r?[]:null);return}if(Array.isArray(t)){l(t.map(J));return}l(typeof t=="string"?t.toString():t.value.toString());},renderOption:(e,t,u,g)=>x?x(e,t,u,g):[{...e,showValueInLabel:C},t],renderGroup:e=>e,groupBy:h,multiple:r,renderInput:e=>jsx(se,{...e,placeholder:y,fullWidth:!0,error:!!f,helperText:c,label:m,required:P,InputProps:{...e.InputProps,...!r&&{startAdornment:d&&!Array.isArray(d)&&d.icon?jsx(a,{icon:d.icon}):void 0},endAdornment:jsxs(Fragment,{children:[p?jsx(ie,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,tabIndex:D}}),...H})});N.displayName="Autocomplete";var Me=N;
16
16
 
17
17
  export { Me as a };
@@ -1,3 +1,3 @@
1
- export { a as default } from '../../chunk-4EQYE64E.js';
1
+ export { a as default } from '../../chunk-MSH7OPW3.js';
2
2
  import '../../chunk-4Z2JJGWA.js';
3
3
  import '../../chunk-QDDGXWNG.js';
@@ -1,3 +1,3 @@
1
- export { a as default } from '../../chunk-OD56T2BA.js';
1
+ export { a as default } from '../../chunk-HIX5OGEA.js';
2
2
  import '../../chunk-NF42ENKE.js';
3
3
  import '../../chunk-ILHUUK4X.js';
@@ -1,8 +1,8 @@
1
1
  import { a as a$2 } from '../../../chunk-P46BBUKR.js';
2
2
  import { a as a$1 } from '../../../chunk-U7BKKRLD.js';
3
- import { a as a$3 } from '../../../chunk-MOCOUFQO.js';
3
+ import { a as a$3 } from '../../../chunk-LJGKMBLJ.js';
4
4
  import '../../../chunk-QNAXGE5H.js';
5
- import '../../../chunk-4EQYE64E.js';
5
+ import '../../../chunk-MSH7OPW3.js';
6
6
  import '../../../chunk-4Z2JJGWA.js';
7
7
  import '../../../chunk-QDDGXWNG.js';
8
8
  import E from '@mui/material/CircularProgress';
@@ -1,4 +1,4 @@
1
- export { a as default } from '../../../chunk-MOCOUFQO.js';
2
- import '../../../chunk-4EQYE64E.js';
1
+ export { a as default } from '../../../chunk-LJGKMBLJ.js';
2
+ import '../../../chunk-MSH7OPW3.js';
3
3
  import '../../../chunk-4Z2JJGWA.js';
4
4
  import '../../../chunk-QDDGXWNG.js';
@@ -1,4 +1,4 @@
1
- import { a } from '../../../chunk-OD56T2BA.js';
1
+ import { a } from '../../../chunk-HIX5OGEA.js';
2
2
  import '../../../chunk-NF42ENKE.js';
3
3
  import '../../../chunk-ILHUUK4X.js';
4
4
  import { useFormContext, Controller } from 'react-hook-form';
@@ -1,7 +1,7 @@
1
1
  import { a } from '../../../chunk-P46BBUKR.js';
2
- import { a as a$2 } from '../../../chunk-MOCOUFQO.js';
2
+ import { a as a$2 } from '../../../chunk-LJGKMBLJ.js';
3
3
  import { a as a$3 } from '../../../chunk-AKR4HFCK.js';
4
- import '../../../chunk-4EQYE64E.js';
4
+ import '../../../chunk-MSH7OPW3.js';
5
5
  import { a as a$1 } from '../../../chunk-4Z2JJGWA.js';
6
6
  import '../../../chunk-QDDGXWNG.js';
7
7
  import { useFormContext, useFieldArray } from 'react-hook-form';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.2.6",
3
+ "version": "2.2.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",