@zydon/common 2.2.11 → 2.2.12

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-WTUGAMJ5.js';
1
+ import { a } from './chunk-CNZCR56X.js';
2
2
  import { useFormContext, Controller } from 'react-hook-form';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -0,0 +1,17 @@
1
+ import { a } from './chunk-4Z2JJGWA.js';
2
+ import { createContext, forwardRef, useContext, useState, useMemo, useRef, useEffect } from 'react';
3
+ import pe, { autocompleteClasses } from '@mui/material/Autocomplete';
4
+ import ue from '@mui/material/CircularProgress';
5
+ import me from '@mui/material/TextField';
6
+ import { VariableSizeList } from 'react-window';
7
+ import q from '@mui/material/ListSubheader';
8
+ import F from '@mui/material/Stack';
9
+ import { useTheme, styled } from '@mui/material/styles';
10
+ import O from '@mui/material/Typography';
11
+ import K from '@mui/material/useMediaQuery';
12
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
+ import re from '@mui/material/Popper';
14
+
15
+ var R=8,Y=u=>{let{data:r,index:i,style:m}=u,n=r[i],{showValueInLabel:s,key:c,...f}=n[0],l={...m,top:m.top+R,paddingTop:8};return Object.prototype.hasOwnProperty.call(n,"group")?jsx(q,{component:"div",style:l,children:n.group},`list-box-item-group-${c}`):jsx(O,{component:"li",...f,noWrap:!0,style:l,children:jsxs(F,{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(O,{variant:"inherit",color:"grey.400",children:["(",n[1].value,")"]})]})},`list-box-item-${c}`)},k=createContext({}),z=forwardRef((u,r)=>{let i=useContext(k);return jsx("div",{ref:r,...u,...i})});z.displayName="OuterElementType";var Z=u=>{let r=useRef(null);return useEffect(()=>{r.current!=null&&r.current.resetAfterIndex(0,!0);},[u]),r},ee=forwardRef(function(r,i){let{children:m,...n}=r,s=[];m.forEach(o=>{s.push(o),s.push(...o.children||[]);});let c=useTheme(),f=K(c.breakpoints.up("sm")),l=s.length,d=f?36:48,g=o=>Object.prototype.hasOwnProperty.call(o,"group")?48:d,C=()=>l>8?8*d:s.map(g).reduce((o,L)=>o+L,0),x=Z(l);return jsx("div",{ref:i,children:jsx(k.Provider,{value:n,children:jsx(VariableSizeList,{itemData:s,height:C()+2*R,width:"100%",ref:x,outerElementType:z,innerElementType:"ul",itemSize:o=>g(s[o]),overscanCount:5,itemCount:l,children:Y})})})}),M=ee;var N=styled(re)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var D=forwardRef(({label:u,value:r,options:i=[],loading:m,noOptionsText:n="Nenhum resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:c,helperText:f,placeholder:l,onChange:d,groupBy:g,showValueInLabel:C,disabled:x,multiple:o,required:L,renderOption:P,tabIndex:H,onInputChange:T,onSearch:A,...X},J)=>{let[$,v]=useState(),V=e=>e&&typeof e=="object"?e.value.toString():e.toString(),y=useMemo(()=>o?(Array.isArray(r)?r:[]).reduce((p,h)=>{let E=i.find(U=>U.value.toString()===h.toString());return E?[...p,E]:[...p]},[]):i.find(t=>t.value.toString()===r?.toString())||null,[i,r,o]);return jsx(pe,{ref:J,value:$||y,onInputChange:(e,t,p)=>{if(T&&T(e,t,p),p==="input"){A&&A(t),v(t);return}v(void 0);},options:i,loading:m,noOptionsText:n,loadingText:s,disabled:m||x,disableListWrap:!0,PopperComponent:N,ListboxComponent:P?void 0:M,filterOptions:(e,t)=>e.filter(p=>`${p.value} ${p.label}`.toLocaleUpperCase().includes(t.inputValue.toLocaleUpperCase())),onChange:(e,t)=>{if(!t){d(o?[]:null);return}if(Array.isArray(t)){d(t.map(V));return}d(typeof t=="string"?t.toString():t.value.toString());},renderOption:(e,t,p,h)=>P?P(e,t,p,h):[{...e,showValueInLabel:C},t],renderGroup:e=>e,groupBy:g,multiple:o,renderInput:e=>jsx(me,{...e,placeholder:l,fullWidth:!0,error:!!c,helperText:f,label:u,required:L,InputProps:{...e.InputProps,...!o&&{startAdornment:y&&!Array.isArray(y)&&y.icon?jsx(a,{icon:y.icon}):void 0},endAdornment:jsxs(Fragment,{children:[m?jsx(ue,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,tabIndex:H}}),...X})});D.displayName="Autocomplete";var De=D;
16
+
17
+ export { De as a };
@@ -0,0 +1,11 @@
1
+ import { f } from './chunk-ANAHA3L6.js';
2
+ import { a } from './chunk-PV522B4W.js';
3
+ import { a as a$1 } from './chunk-4Z2JJGWA.js';
4
+ import { forwardRef, useState, useRef, useMemo, useCallback } from 'react';
5
+ import A from '@mui/material/IconButton';
6
+ import C from '@mui/material/InputAdornment';
7
+ import { jsx } from 'react/jsx-runtime';
8
+
9
+ var M=forwardRef(({name:R,increment:r=1,updadteForMultiple:D,allowNegative:s=!1,value:d=0,onChange:c,minValue:n,maxValue:e,decimalScale:p,disabled:i,tabIndex:T,...w},B)=>{let[O,v]=useState(`incrementer-input-${Date.now()}`),I=useRef(null),u=Number(d||0),y=()=>{I.current&&(clearTimeout(I.current),I.current=null);},z=useMemo(()=>{let o=u-r;return typeof n=="number"&&o<n?!0:i||!s&&o<0},[i,u,r,n,s]),E=useMemo(()=>{let o=u+r;return typeof e=="number"&&o>e?!0:i},[i,u,r,e]),L=useCallback(()=>{if(y(),!s&&u-r<0)return;let o=u-r,t=n!==void 0&&o<n?n:f(o,p);c(t);},[u,r,n,p,c,s]),N=useCallback(()=>{y();let o=u+r,t=e!==void 0&&o>e?e:f(o,p);c(t);},[u,r,e,p,c]),_=useCallback(o=>{y();let t=Number(o.target.value||0);(r!==1||D)&&(t=t+r/2,t-=t%r),!s&&t<0&&(t=0),typeof n=="number"&&t<n&&(t=n),typeof e=="number"&&t>e&&(t=e),t=f(t,p),t===d&&(I.current=setTimeout(()=>{v(`incrementer-input-${Date.now()}`);},600)),c(t);},[d,r,n,e,p,c,D,s]);return jsx(a,{ref:B,name:R,value:u,minValue:n,maxValue:e,allowNegative:s,decimalScale:p,InputProps:{startAdornment:jsx(C,{position:"start",children:jsx(A,{size:"medium",onClick:L,disabled:z,children:jsx(a$1,{icon:"MINUS_SIGN",width:14,height:14,color:"primary.main"})})}),endAdornment:jsx(C,{position:"end",children:jsx(A,{size:"medium",onClick:N,disabled:E,children:jsx(a$1,{icon:"SIMPLE_ADD",width:14,height:14,color:"primary.main"})})}),inputProps:{style:{textAlign:"center"}}},inputProps:{tabIndex:T},onChange:_,disabled:i,...w},O)});M.displayName="Incrementer";var X=M;
10
+
11
+ export { X as a };
@@ -1,3 +1,3 @@
1
- export { a as default } from '../../chunk-WTUGAMJ5.js';
1
+ export { a as default } from '../../chunk-CNZCR56X.js';
2
2
  import '../../chunk-4Z2JJGWA.js';
3
3
  import '../../chunk-QDDGXWNG.js';
@@ -1,4 +1,4 @@
1
- export { a as default } from '../../chunk-WRPWZC6G.js';
1
+ export { a as default } from '../../chunk-P72SJ5S3.js';
2
2
  import '../../chunk-ANAHA3L6.js';
3
3
  import '../../chunk-PV522B4W.js';
4
4
  import '../../chunk-4Z2JJGWA.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-VAZ53BM6.js';
3
+ import { a as a$3 } from '../../../chunk-ADVIQ6SV.js';
4
4
  import '../../../chunk-QNAXGE5H.js';
5
- import '../../../chunk-WTUGAMJ5.js';
5
+ import '../../../chunk-CNZCR56X.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-VAZ53BM6.js';
2
- import '../../../chunk-WTUGAMJ5.js';
1
+ export { a as default } from '../../../chunk-ADVIQ6SV.js';
2
+ import '../../../chunk-CNZCR56X.js';
3
3
  import '../../../chunk-4Z2JJGWA.js';
4
4
  import '../../../chunk-QDDGXWNG.js';
@@ -1,4 +1,4 @@
1
- import { a } from '../../../chunk-WRPWZC6G.js';
1
+ import { a } from '../../../chunk-P72SJ5S3.js';
2
2
  import '../../../chunk-ANAHA3L6.js';
3
3
  import '../../../chunk-PV522B4W.js';
4
4
  import '../../../chunk-4Z2JJGWA.js';
@@ -1,7 +1,7 @@
1
1
  import { a } from '../../../chunk-P46BBUKR.js';
2
- import { a as a$2 } from '../../../chunk-VAZ53BM6.js';
2
+ import { a as a$2 } from '../../../chunk-ADVIQ6SV.js';
3
3
  import { a as a$3 } from '../../../chunk-AKR4HFCK.js';
4
- import '../../../chunk-WTUGAMJ5.js';
4
+ import '../../../chunk-CNZCR56X.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.11",
3
+ "version": "2.2.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,11 +0,0 @@
1
- import { f } from './chunk-ANAHA3L6.js';
2
- import { a } from './chunk-PV522B4W.js';
3
- import { a as a$1 } from './chunk-4Z2JJGWA.js';
4
- import { forwardRef, useState, useRef, useMemo, useCallback } from 'react';
5
- import A from '@mui/material/IconButton';
6
- import C from '@mui/material/InputAdornment';
7
- import { jsx } from 'react/jsx-runtime';
8
-
9
- var M=forwardRef(({name:R,increment:r=1,updadteForMultiple:h,allowNegative:s=!1,value:D=0,onChange:c,minValue:n,maxValue:e,decimalScale:p,disabled:i,tabIndex:T,...w},B)=>{let[O,v]=useState(`incrementer-input-${Date.now()}`),I=useRef(null),u=Number(D||0),d=()=>{I.current&&(clearTimeout(I.current),I.current=null);},z=useMemo(()=>{let o=u-r;return typeof n=="number"&&o<n?!0:i||!s&&o<0},[i,u,r,n,s]),E=useMemo(()=>{let o=u+r;return typeof e=="number"&&o>e?!0:i},[i,u,r,e]),L=useCallback(()=>{if(d(),!s&&u-r<0)return;let o=u-r,t=n!==void 0&&o<n?n:f(o,p);c(t);},[u,r,n,p,c,s]),N=useCallback(()=>{d();let o=u+r,t=e!==void 0&&o>e?e:f(o,p);c(t);},[u,r,e,p,c]),_=useCallback(o=>{d();let t=Number(o.target.value||0);(r!==1||h)&&(t=t+r/2,t-=t%r),!s&&t<0&&(t=0),typeof n=="number"&&t<n&&(t=n),typeof e=="number"&&t>e&&(t=e),t=f(t,p),t===D&&(I.current=setTimeout(()=>{v(`incrementer-input-${Date.now()}`);},600)),c(t);},[r,n,e,p,c,h,s]);return jsx(a,{ref:B,name:R,value:u,minValue:n,maxValue:e,allowNegative:s,decimalScale:p,InputProps:{startAdornment:jsx(C,{position:"start",children:jsx(A,{size:"medium",onClick:L,disabled:z,children:jsx(a$1,{icon:"MINUS_SIGN",width:14,height:14,color:"primary.main"})})}),endAdornment:jsx(C,{position:"end",children:jsx(A,{size:"medium",onClick:N,disabled:E,children:jsx(a$1,{icon:"SIMPLE_ADD",width:14,height:14,color:"primary.main"})})}),inputProps:{style:{textAlign:"center"}}},inputProps:{tabIndex:T},onChange:_,disabled:i,...w},O)});M.displayName="Incrementer";var X=M;
10
-
11
- export { X as a };
@@ -1,17 +0,0 @@
1
- import { a } from './chunk-4Z2JJGWA.js';
2
- import { createContext, forwardRef, useContext, useState, useMemo, useRef, useEffect } from 'react';
3
- import pe, { autocompleteClasses } from '@mui/material/Autocomplete';
4
- import ue from '@mui/material/CircularProgress';
5
- import me from '@mui/material/TextField';
6
- import { VariableSizeList } from 'react-window';
7
- import q from '@mui/material/ListSubheader';
8
- import F from '@mui/material/Stack';
9
- import { useTheme, styled } from '@mui/material/styles';
10
- import O from '@mui/material/Typography';
11
- import K from '@mui/material/useMediaQuery';
12
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
- import re from '@mui/material/Popper';
14
-
15
- var R=8,Y=u=>{let{data:r,index:i,style:m}=u,n=r[i],{showValueInLabel:s,...d}=n[0],a$1={...m,top:m.top+R,paddingTop:8};return Object.prototype.hasOwnProperty.call(n,"group")?jsx(q,{component:"div",style:a$1,children:n.group},n.key):jsx(O,{component:"li",...d,noWrap:!0,style:a$1,children:jsxs(F,{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(O,{variant:"inherit",color:"grey.400",children:["(",n[1].value,")"]})]})})},z=createContext({}),M=forwardRef((u,r)=>{let i=useContext(z);return jsx("div",{ref:r,...u,...i})});M.displayName="OuterElementType";var Z=u=>{let r=useRef(null);return useEffect(()=>{r.current!=null&&r.current.resetAfterIndex(0,!0);},[u]),r},ee=forwardRef(function(r,i){let{children:m,...n}=r,s=[];m.forEach(o=>{s.push(o),s.push(...o.children||[]);});let d=useTheme(),a=K(d.breakpoints.up("sm")),f=s.length,c=a?36:48,g=o=>Object.prototype.hasOwnProperty.call(o,"group")?48:c,C=()=>f>8?8*c:s.map(g).reduce((o,P)=>o+P,0),L=Z(f);return jsx("div",{ref:i,children:jsx(z.Provider,{value:n,children:jsx(VariableSizeList,{itemData:s,height:C()+2*R,width:"100%",ref:L,outerElementType:M,innerElementType:"ul",itemSize:o=>g(s[o]),overscanCount:5,itemCount:f,children:Y})})})}),k=ee;var N=styled(re)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var D=forwardRef(({label:u,value:r,options:i=[],loading:m,noOptionsText:n="Nenhum resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:d,helperText:a$1,placeholder:f,onChange:c,groupBy:g,showValueInLabel:C,disabled:L,multiple:o,required:P,renderOption:x,tabIndex:H,onInputChange:T,onSearch:A,...X},J)=>{let[V,v]=useState(),U=e=>e&&typeof e=="object"?e.value.toString():e.toString(),y=useMemo(()=>o?(Array.isArray(r)?r:[]).reduce((p,h)=>{let E=i.find(W=>W.value.toString()===h.toString());return E?[...p,E]:[...p]},[]):i.find(t=>t.value.toString()===r?.toString())||null,[i,r,o]);return jsx(pe,{ref:J,value:V||y,onInputChange:(e,t,p)=>{if(T&&T(e,t,p),p==="input"){A&&A(t),v(t);return}v(void 0);},options:i,loading:m,noOptionsText:n,loadingText:s,disabled:m||L,disableListWrap:!0,PopperComponent:N,ListboxComponent:x?void 0:k,filterOptions:(e,t)=>e.filter(p=>`${p.value} ${p.label}`.toLocaleUpperCase().includes(t.inputValue.toLocaleUpperCase())),onChange:(e,t)=>{if(!t){c(o?[]:null);return}if(Array.isArray(t)){c(t.map(U));return}c(typeof t=="string"?t.toString():t.value.toString());},renderOption:(e,t,p,h)=>x?x(e,t,p,h):[{...e,showValueInLabel:C},t],renderGroup:e=>e,groupBy:g,multiple:o,renderInput:e=>jsx(me,{...e,placeholder:f,fullWidth:!0,error:!!d,helperText:a$1,label:u,required:P,InputProps:{...e.InputProps,...!o&&{startAdornment:y&&!Array.isArray(y)&&y.icon?jsx(a,{icon:y.icon}):void 0},endAdornment:jsxs(Fragment,{children:[m?jsx(ue,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,tabIndex:H}}),...X})});D.displayName="Autocomplete";var De=D;
16
-
17
- export { De as a };