@zydon/common 2.1.98 → 2.2.0

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,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, useMemo, useCallback } from 'react';
5
+ import P from '@mui/material/IconButton';
6
+ import A from '@mui/material/InputAdornment';
7
+ import { jsx } from 'react/jsx-runtime';
8
+
9
+ var D=forwardRef(({name:k,increment:r=1,updadteForMultiple:b,allowNegative:f$1=!1,value:C=0,onChange:I,minValue:n,maxValue:o,decimalScale:p,disabled:c,tabIndex:M,...B},O)=>{let s=Number(C||0),R=useMemo(()=>{let e=s-r;return typeof n=="number"&&e<n?!0:f$1?c:e<0},[c,s,r,n,f$1]),v=useMemo(()=>{let e=s+r;return typeof o=="number"&&e>o?!0:c},[c,s,r,o]),z=useCallback(()=>{if(!f$1&&s-r<0)return;let e=s-r,t=n!==void 0&&e<n?n:f(e,p);I(t);},[s,r,n,p,I,f$1]),E=useCallback(()=>{let e=s+r,t=o!==void 0&&e>o?o:f(e,p);I(t);},[s,r,o,p,I]),L=useCallback(e=>{let t=Number(e.target.value||0);(r!==1||b)&&(t=t+r/2,t-=t%r),!f$1&&t<0&&(t=0),typeof n=="number"&&t<n&&(t=n),typeof o=="number"&&t>o&&(t=o),I(f(t,p));},[r,n,o,p,I,b,f$1]);return jsx(a,{ref:O,name:k,value:s,minValue:n,maxValue:o,allowNegative:f$1,decimalScale:p,InputProps:{startAdornment:jsx(A,{position:"start",children:jsx(P,{size:"medium",disabled:R,onClick:z,children:jsx(a$1,{icon:"MINUS_SIGN",width:14,height:14,color:"primary.main"})})}),endAdornment:jsx(A,{position:"end",children:jsx(P,{size:"medium",onClick:E,disabled:v,children:jsx(a$1,{icon:"SIMPLE_ADD",width:14,height:14,color:"primary.main"})})}),inputProps:{style:{textAlign:"center"}}},inputProps:{tabIndex:M},onChange:L,disabled:c,...B})});D.displayName="Incrementer";var W=D;
10
+
11
+ export { W as a };
@@ -0,0 +1,17 @@
1
+ import { a } from './chunk-4Z2JJGWA.js';
2
+ import { createContext, forwardRef, useContext, useMemo, useRef, useEffect } from 'react';
3
+ import ne, { autocompleteClasses } from '@mui/material/Autocomplete';
4
+ import ie from '@mui/material/CircularProgress';
5
+ import se from '@mui/material/TextField';
6
+ import { VariableSizeList } from 'react-window';
7
+ import G from '@mui/material/ListSubheader';
8
+ import _ from '@mui/material/Stack';
9
+ import { useTheme, styled } from '@mui/material/styles';
10
+ import O from '@mui/material/Typography';
11
+ import F from '@mui/material/useMediaQuery';
12
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
+ import ee from '@mui/material/Popper';
14
+
15
+ var I=8,Q=u=>{let{data:o,index:p,style:i}=u,n=o[p],{showValueInLabel:s,...f}=n[0],d={...i,top:i.top+I,paddingTop:8};return Object.prototype.hasOwnProperty.call(n,"group")?jsx(G,{component:"div",style:d,children:n.group},n.key):jsx(O,{component:"li",...f,noWrap:!0,style:d,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(O,{variant:"inherit",color:"grey.400",children:["(",n[1].value,")"]})]})})},R=createContext({}),z=forwardRef((u,o)=>{let p=useContext(R);return jsx("div",{ref:o,...u,...p})});z.displayName="OuterElementType";var K=u=>{let o=useRef(null);return useEffect(()=>{o.current!=null&&o.current.resetAfterIndex(0,!0);},[u]),o},Y=forwardRef(function(o,p){let{children:i,...n}=o,s=[];i.forEach(r=>{s.push(r),s.push(...r.children||[]);});let f=useTheme(),d=F(f.breakpoints.up("sm")),y=s.length,m=d?36:48,h=r=>Object.prototype.hasOwnProperty.call(r,"group")?48:m,C=()=>y>8?8*m:s.map(h).reduce((r,P)=>r+P,0),L=K(y);return jsx("div",{ref:p,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:u,value:o,options:p=[],loading:i,noOptionsText:n="Nenhum resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:f,helperText:d,placeholder:y,onChange:m,groupBy:h,showValueInLabel:C,disabled:L,multiple:r,required:P,renderOption:x,tabIndex:D,onInputChange:A,onSearch:T,...H},X)=>{let J=e=>e&&typeof e=="object"?e.value.toString():e.toString(),a$1=useMemo(()=>r?(Array.isArray(o)?o:[]).reduce((l,g)=>{let E=p.find(V=>V.value.toString()===g.toString());return E?[...l,E]:[...l]},[]):p.find(t=>t.value.toString()===o?.toString())||null,[p,o,r]);return jsx(ne,{ref:X,value:a$1,onInputChange:(e,t,l)=>{!i&&!a$1&&(console.log("call: onChange(multiple ? [] : null)",{event:e,value:t,reason:l,loading:i,formattedValue:a$1}),m(r?[]:null)),A&&A(e,t,l),T&&e&&(e.type==="change"||e.type==="blur")&&(console.log("call: onSearch(value)"),T(t));},options:p,loading:i,noOptionsText:i?s:n,loadingText:s,disabled:i||L,disableListWrap:!0,PopperComponent:k,ListboxComponent:x?void 0:M,filterOptions:(e,t)=>e.filter(l=>`${l.value} ${l.label}`.toLocaleUpperCase().includes(t.inputValue.toLocaleUpperCase())),onChange:(e,t)=>{if(!t){m(r?[]:null);return}if(Array.isArray(t)){m(t.map(J));return}m(typeof t=="string"?t.toString():t.value.toString());},renderOption:(e,t,l,g)=>x?x(e,t,l,g):[{...e,showValueInLabel:C},t],renderGroup:e=>e,groupBy:h,multiple:r,renderInput:e=>jsx(se,{...e,placeholder:y,fullWidth:!0,error:!!f,helperText:d,label:u,required:P,InputProps:{...e.InputProps,...!r&&{startAdornment:a$1&&!Array.isArray(a$1)&&a$1.icon?jsx(a,{icon:a$1.icon}):void 0},endAdornment:jsxs(Fragment,{children:[i?jsx(ie,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,tabIndex:D}}),...H})});N.displayName="Autocomplete";var Me=N;
16
+
17
+ export { Me as a };
@@ -1,4 +1,4 @@
1
- import { a } from './chunk-FMUKZOVG.js';
1
+ import { a } from './chunk-MIBY3DAC.js';
2
2
  import { useFormContext, Controller } from 'react-hook-form';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -1,3 +1,3 @@
1
- export { a as default } from '../../chunk-FMUKZOVG.js';
1
+ export { a as default } from '../../chunk-MIBY3DAC.js';
2
2
  import '../../chunk-4Z2JJGWA.js';
3
3
  import '../../chunk-QDDGXWNG.js';
@@ -1,4 +1,4 @@
1
- export { a as default } from '../../chunk-YTC35FJH.js';
1
+ export { a as default } from '../../chunk-JWI64EW5.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-H3BSTE4Q.js';
3
+ import { a as a$3 } from '../../../chunk-ZPMH6RBC.js';
4
4
  import '../../../chunk-QNAXGE5H.js';
5
- import '../../../chunk-FMUKZOVG.js';
5
+ import '../../../chunk-MIBY3DAC.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-H3BSTE4Q.js';
2
- import '../../../chunk-FMUKZOVG.js';
1
+ export { a as default } from '../../../chunk-ZPMH6RBC.js';
2
+ import '../../../chunk-MIBY3DAC.js';
3
3
  import '../../../chunk-4Z2JJGWA.js';
4
4
  import '../../../chunk-QDDGXWNG.js';
@@ -1,4 +1,4 @@
1
- import { a } from '../../../chunk-YTC35FJH.js';
1
+ import { a } from '../../../chunk-JWI64EW5.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-H3BSTE4Q.js';
2
+ import { a as a$2 } from '../../../chunk-ZPMH6RBC.js';
3
3
  import { a as a$3 } from '../../../chunk-AKR4HFCK.js';
4
- import '../../../chunk-FMUKZOVG.js';
4
+ import '../../../chunk-MIBY3DAC.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';
@@ -1,6 +1,7 @@
1
1
  import { useState } from 'react';
2
+ import { useFormContext } from 'react-hook-form';
2
3
  import { debounce } from '@mui/material/utils';
3
4
 
4
- var m=u=>{let[l,s]=useState(),[c,i]=useState(),f=debounce(n=>{s(n);},500);return {buildOptions:(n=[])=>{let e=c||u;if(!e)return n.filter(r=>r.value!==null&&r.value!==void 0);let a=[...Array.isArray(e)?e:[e],...n];return Array.from(new Set(a.map(r=>r.value))).map(r=>a.find(d=>d.value===r)).filter(r=>r.value!==null&&r.value!==void 0)},search:l,onSearch:n=>{f(n);},onSelectValue:(n=[],e)=>{(!e||Array.isArray(e)&&e.length===0)&&i(void 0),Array.isArray(e)?i(n.filter(t=>e.includes(t.value))):i(n.find(t=>t.value===e));}}},h=m;
5
+ var A=u=>{let[l,s]=useState(),[c,o]=useState(),{setValue:d}=useFormContext(),f=debounce(n=>{s(n);},500);return {buildOptions:(n=[])=>{let e=c||u;if(!e)return n.filter(r=>r.value!==null&&r.value!==void 0);let i=[...Array.isArray(e)?e:[e],...n];return Array.from(new Set(i.map(r=>r.value))).map(r=>i.find(p=>p.value===r)).filter(r=>r.value!==null&&r.value!==void 0)},search:l,onSearch:n=>{d("brand_id",void 0),f(n);},onSelectValue:(n=[],e)=>{(!e||Array.isArray(e)&&e.length===0)&&o(void 0),Array.isArray(e)?o(n.filter(t=>e.includes(t.value))):o(n.find(t=>t.value===e));}}},V=A;
5
6
 
6
- export { h as default };
7
+ export { V as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.1.98",
3
+ "version": "2.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,17 +0,0 @@
1
- import { a } from './chunk-4Z2JJGWA.js';
2
- import { createContext, forwardRef, useContext, useMemo, useRef, useEffect } from 'react';
3
- import ne, { autocompleteClasses } from '@mui/material/Autocomplete';
4
- import ie from '@mui/material/CircularProgress';
5
- import se from '@mui/material/TextField';
6
- import { VariableSizeList } from 'react-window';
7
- import G from '@mui/material/ListSubheader';
8
- import _ from '@mui/material/Stack';
9
- import { useTheme, styled } from '@mui/material/styles';
10
- import v from '@mui/material/Typography';
11
- import F from '@mui/material/useMediaQuery';
12
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
- import ee from '@mui/material/Popper';
14
-
15
- var I=8,Q=m=>{let{data:o,index:s,style:p}=m,n=o[s],{showValueInLabel:i,...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,i&&jsxs(v,{variant:"inherit",color:"grey.400",children:["(",n[1].value,")"]})]})})},R=createContext({}),z=forwardRef((m,o)=>{let s=useContext(R);return jsx("div",{ref:o,...m,...s})});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,s){let{children:p,...n}=o,i=[];p.forEach(r=>{i.push(r),i.push(...r.children||[]);});let f=useTheme(),c=F(f.breakpoints.up("sm")),y=i.length,l=c?36:48,h=r=>Object.prototype.hasOwnProperty.call(r,"group")?48:l,C=()=>y>8?8*l:i.map(h).reduce((r,P)=>r+P,0),L=K(y);return jsx("div",{ref:s,children:jsx(R.Provider,{value:n,children:jsx(VariableSizeList,{itemData:i,height:C()+2*I,width:"100%",ref:L,outerElementType:z,innerElementType:"ul",itemSize:r=>h(i[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:s=[],loading:p,noOptionsText:n="Nenhum resultado encontrado.",loadingText:i="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:A,onSearch:T,...H},X)=>{let J=e=>e&&typeof e=="object"?e.value.toString():e.toString(),d=useMemo(()=>r?(Array.isArray(o)?o:[]).reduce((u,b)=>{let E=s.find(V=>V.value.toString()===b.toString());return E?[...u,E]:[...u]},[]):s.find(t=>t.value.toString()===o?.toString())||null,[s,o,r]);return jsx(ne,{ref:X,value:d,onInputChange:(e,t,u)=>{!p&&!d&&l(r?[]:null),A&&A(e,t,u),T&&e&&(e.type==="change"||e.type==="blur")&&T(t);},options:s,loading:p,noOptionsText:p?i:n,loadingText:i,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,b)=>x?x(e,t,u,b):[{...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
-
17
- export { Me as a };
@@ -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, useMemo, useCallback } from 'react';
5
- import P from '@mui/material/IconButton';
6
- import A from '@mui/material/InputAdornment';
7
- import { jsx } from 'react/jsx-runtime';
8
-
9
- var D=forwardRef(({name:k,increment:r=1,updadteForMultiple:b,allowNegative:f$1=!1,value:C=0,onChange:I,minValue:n,maxValue:o,decimalScale:p,disabled:c,tabIndex:M,...B},O)=>{let s=Number(C||0),R=useMemo(()=>{let e=s-r;return typeof n=="number"&&e<n?!0:f$1?c:!e},[c,s,r,n,f$1]),v=useMemo(()=>{let e=s+r;return typeof o=="number"&&e>o?!0:c},[c,s,r,o]),z=useCallback(()=>{if(!f$1&&s-r<0)return;let e=s-r,t=n!==void 0&&e<n?n:f(e,p);I(t);},[s,r,n,p,I,f$1]),E=useCallback(()=>{let e=s+r,t=o!==void 0&&e>o?o:f(e,p);I(t);},[s,r,o,p,I]),L=useCallback(e=>{let t=Number(e.target.value||0);(r!==1||b)&&(t=t+r/2,t-=t%r),!f$1&&t<0&&(t=0),typeof n=="number"&&t<n&&(t=n),typeof o=="number"&&t>o&&(t=o),I(f(t,p));},[r,n,o,p,I,b,f$1]);return jsx(a,{ref:O,name:k,value:s,minValue:n,maxValue:o,allowNegative:f$1,decimalScale:p,InputProps:{startAdornment:jsx(A,{position:"start",children:jsx(P,{size:"medium",disabled:R,onClick:z,children:jsx(a$1,{icon:"MINUS_SIGN",width:14,height:14,color:"primary.main"})})}),endAdornment:jsx(A,{position:"end",children:jsx(P,{size:"medium",onClick:E,disabled:v,children:jsx(a$1,{icon:"SIMPLE_ADD",width:14,height:14,color:"primary.main"})})}),inputProps:{style:{textAlign:"center"}}},inputProps:{tabIndex:M},onChange:L,disabled:c,...B})});D.displayName="Incrementer";var W=D;
10
-
11
- export { W as a };