@zydon/common 2.0.74 → 2.0.76

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,4 +1,4 @@
1
- import { a } from './chunk-7GKMDF23.js';
1
+ import { a } from './chunk-QSVO7OEW.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: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="Nenhuma 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"&&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;
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="Nenhuma 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-7GKMDF23.js';
1
+ export { a as default } from '../../chunk-QSVO7OEW.js';
2
2
  import '../../chunk-QACPD766.js';
3
3
  import '../../chunk-S3U3CT7C.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-EYCOMLAK.js';
3
+ import { a as a$3 } from '../../../chunk-FWL7MHHN.js';
4
4
  import '../../../chunk-QNAXGE5H.js';
5
- import '../../../chunk-7GKMDF23.js';
5
+ import '../../../chunk-QSVO7OEW.js';
6
6
  import '../../../chunk-QACPD766.js';
7
7
  import '../../../chunk-S3U3CT7C.js';
8
8
  import E from '@mui/material/CircularProgress';
@@ -1,4 +1,4 @@
1
- export { a as default } from '../../../chunk-EYCOMLAK.js';
2
- import '../../../chunk-7GKMDF23.js';
1
+ export { a as default } from '../../../chunk-FWL7MHHN.js';
2
+ import '../../../chunk-QSVO7OEW.js';
3
3
  import '../../../chunk-QACPD766.js';
4
4
  import '../../../chunk-S3U3CT7C.js';
@@ -1,6 +1,6 @@
1
1
  import { a } from '../../../chunk-P46BBUKR.js';
2
- import { a as a$2 } from '../../../chunk-EYCOMLAK.js';
3
- import '../../../chunk-7GKMDF23.js';
2
+ import { a as a$2 } from '../../../chunk-FWL7MHHN.js';
3
+ import '../../../chunk-QSVO7OEW.js';
4
4
  import { a as a$3 } from '../../../chunk-EXDRISPF.js';
5
5
  import { a as a$1 } from '../../../chunk-QACPD766.js';
6
6
  import '../../../chunk-S3U3CT7C.js';
@@ -1,5 +1,6 @@
1
1
  import { useState } from 'react';
2
+ import { debounce } from '@mui/material/utils';
2
3
 
3
- var p=(n=[],s)=>{let[a,u]=useState(),[c,o]=useState(),f=t=>u(t),l=t=>{(!t||t.length===0)&&o(void 0),o(typeof t=="string"?n.find(r=>r.value===t):n.filter(r=>t.includes(r.value)));},e=c||s;return {options:e?[...Array.isArray(e)?[...e]:[e],...n]:n,search:a,onSearch:f,onSelectValue:l}},m=p;
4
+ var d=(e=[],s)=>{let[a,c]=useState(),[u,o]=useState(),f=debounce(t=>{c(t);},500),p=t=>{f(t);},l=t=>{(!t||t.length===0)&&o(void 0),o(typeof t=="string"?e.find(r=>r.value===t):e.filter(r=>t.includes(r.value)));},n=u||s;return {options:n?[...Array.isArray(n)?[...n]:[n],...e]:e,search:a,onSearch:p,onSelectValue:l}},h=d;
4
5
 
5
- export { m as default };
6
+ export { h as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.0.74",
3
+ "version": "2.0.76",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",