@zydon/common 2.1.94 → 2.1.96

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.
@@ -0,0 +1,17 @@
1
+ import { a } from './chunk-NF42ENKE.js';
2
+ import { b } from './chunk-ILHUUK4X.js';
3
+ import O, { forwardRef, useMemo, useEffect } from 'react';
4
+ import de, { autocompleteClasses } from '@mui/material/Autocomplete';
5
+ import ue from '@mui/material/CircularProgress';
6
+ import ce from '@mui/material/TextField';
7
+ import { VariableSizeList } from 'react-window';
8
+ import W from '@mui/material/Typography';
9
+ import ee from '@mui/material/Divider';
10
+ import v from '@mui/material/Stack';
11
+ import Z 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(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
+
17
+ export { _e as a };
@@ -1,3 +1,3 @@
1
- export { a as default } from '../../chunk-ORBDUMXB.js';
1
+ export { a as default } from '../../chunk-HIX5OGEA.js';
2
2
  import '../../chunk-NF42ENKE.js';
3
3
  import '../../chunk-ILHUUK4X.js';
@@ -1,4 +1,4 @@
1
- import { a } from '../../../chunk-ORBDUMXB.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.1.94",
3
+ "version": "2.1.96",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,17 +0,0 @@
1
- import { a } from './chunk-NF42ENKE.js';
2
- import { b } from './chunk-ILHUUK4X.js';
3
- import O, { forwardRef, useMemo, useEffect } from 'react';
4
- import pe, { autocompleteClasses } from '@mui/material/Autocomplete';
5
- import me from '@mui/material/CircularProgress';
6
- import de from '@mui/material/TextField';
7
- import { VariableSizeList } from 'react-window';
8
- import R from '@mui/material/Typography';
9
- import Y from '@mui/material/Divider';
10
- import L from '@mui/material/Stack';
11
- import Q from '@mui/material/Popper';
12
- import { styled } from '@mui/material/styles';
13
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
-
15
- var k=styled(Q)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}}),$=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)"}})),H=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 Z=({option:e})=>{let t=Object.keys(e).filter(i=>i.startsWith("field")).map((i,m)=>{let s=e[i];if(s&&typeof s=="object"){let p="label"in s?s.label:null,d="value"in s?s.value:null;return jsxs(R,{component:"span",variant:"body2",color:"textPrimary",noWrap:!0,children:[p,": ",d]},`${i}:${m}`)}}),n=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(H,{children:n}),jsxs($,{children:[jsxs(T,{children:[jsx(L,{children:jsxs(R,{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(Y,{className:"border",sx:{borderStyle:"dashed",position:"absolute",bottom:0,width:1}})]})},x=Z;var W=8,ne=e=>{let{data:t,index:n,style:i}=e,m=t[n],s={...i,top:i.top+W,paddingTop:8,display:"block"};return jsx(R,{component:"li",...m.props,noWrap:!0,style:s,children:jsx(x,{...m?.props?.children?.props})})},z=O.createContext({}),N=forwardRef((e,t)=>{let n=O.useContext(z);return jsx("div",{ref:t,...e,...n})});N.displayName="OuterElementType";var ie=e=>{let t=O.useRef(null);return useEffect(()=>{t.current!=null&&t.current.resetAfterIndex(0,!0);},[e]),t},le=forwardRef(function(t,n){let{children:i,"data-item-height":m,...s}=t,p=[];i.forEach(l=>{p.push(l),p.push(...l.children||[]);});let d=p.length,h=m>112?m:112,u=l=>Object.prototype.hasOwnProperty.call(l,"group")?48:h,v=()=>d>8?8*h:p.map(u).reduce((l,C)=>l+C,0),S=ie(d);return jsx("div",{ref:n,children:jsx(z.Provider,{value:s,children:jsx(VariableSizeList,{itemData:p,height:v()+2*W,width:"100%",ref:S,outerElementType:N,innerElementType:"ul",itemSize:l=>u(p[l]),overscanCount:5,itemCount:d,children:ne})})})}),X=le;var B=forwardRef(({label:e,value:t,options:n=[],loading:i,noOptionsText:m="Nenhuma resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:p,helperText:d,placeholder:h,onChange:u,groupBy:v,disabled:S,multiple:l,required:C,renderOption:J,tabIndex:j,...G},U)=>{let V=b("down","md"),_=r=>r&&typeof r=="object"?r.value.toString():r.toString(),P=useMemo(()=>l?(Array.isArray(t)?t:[]).reduce((o,w)=>{let I=n.find(q=>q.value.toString()===w.toString());return I?[...o,I]:[...o]},[]):n.find(a=>a.value.toString()===t?.toString())||null,[n,t,l]),F=V&&n[0]?Object.keys(n[0]).length*24:void 0;return jsx(pe,{ref:U,value:P,onInputChange:()=>{!i&&!P&&u(l?[]:null);},options:n,loading:i,noOptionsText:m,loadingText:s,disabled:i||S,disableListWrap:!0,PopperComponent:k,ListboxProps:{"data-item-height":F},ListboxComponent:J?void 0:X,filterOptions:(r,a)=>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(a.inputValue.toLocaleUpperCase())),onChange:(r,a)=>{if(!a){u(l?[]:null);return}if(Array.isArray(a)){u(a.map(_));return}u(typeof a=="string"?a.toString():a.value.toString());},renderOption:({key:r,...a},o)=>jsx("li",{...a,style:{display:"block"},children:jsx(x,{option:o})},r),renderGroup:r=>r,groupBy:v,multiple:l,renderInput:r=>jsx(de,{...r,placeholder:h,fullWidth:!0,error:!!p,helperText:d,label:e,required:C,InputProps:{...r.InputProps,endAdornment:jsxs(Fragment,{children:[i?jsx(me,{color:"primary",size:20}):null,r.InputProps.endAdornment]})},inputProps:{...r.inputProps,tabIndex:j}}),...G})});B.displayName="Autocomplete";var Ge=B;
16
-
17
- export { Ge as a };