@zydon/common 2.2.25 → 2.2.26

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-CWR7MWFN.js';
1
+ import { a } from './chunk-UUVFDAMW.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-A3HKJM7C.js';
2
+ import { createContext, forwardRef, useContext, useState, useMemo, useRef, useEffect } from 'react';
3
+ import ue, { autocompleteClasses } from '@mui/material/Autocomplete';
4
+ import me from '@mui/material/CircularProgress';
5
+ import le from '@mui/material/TextField';
6
+ import { VariableSizeList } from 'react-window';
7
+ import F from '@mui/material/ListSubheader';
8
+ import Q from '@mui/material/Stack';
9
+ import { useTheme, styled } from '@mui/material/styles';
10
+ import I from '@mui/material/Typography';
11
+ import Y from '@mui/material/useMediaQuery';
12
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
+ import oe from '@mui/material/Popper';
14
+
15
+ var k=8,Z=u=>{let{data:r,index:i,style:m}=u,n=r[i],{showValueInLabel:s,key:c,...f}=n[0],l={...m,top:m.top+k,paddingTop:8};return Object.prototype.hasOwnProperty.call(n,"group")?jsx(F,{component:"div",style:l,children:n.group},`list-box-item-group-${c}`):jsx(I,{component:"li",...f,noWrap:!0,style:l,children:jsxs(Q,{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(I,{variant:"inherit",color:"grey.400",children:["(",n[1].value,")"]})]})},`list-box-item-${c}`)},z=createContext({}),M=forwardRef((u,r)=>{let i=useContext(z);return jsx("div",{ref:r,...u,...i})});M.displayName="OuterElementType";var ee=u=>{let r=useRef(null);return useEffect(()=>{r.current!=null&&r.current.resetAfterIndex(0,!0);},[u]),r},te=forwardRef(function(r,i){let{children:m,...n}=r,s=[];m.forEach(o=>{s.push(o),s.push(...o.children||[]);});let c=useTheme(),f=Y(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=ee(l);return jsx("div",{ref:i,children:jsx(z.Provider,{value:n,children:jsx(VariableSizeList,{itemData:s,height:C()+2*k,width:"100%",ref:x,outerElementType:M,innerElementType:"ul",itemSize:o=>g(s[o]),overscanCount:5,itemCount:l,children:Z})})})}),N=te;var D=styled(oe)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var H=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:X,onInputChange:A,onSearch:v,onBlur:E,...J},$)=>{let[V,T]=useState(),U=e=>e&&typeof e=="object"?e.value.toString():e.toString(),y=useMemo(()=>o?(Array.isArray(r)?r:[]).reduce((p,h)=>{let O=i.find(W=>W.value.toString()===h.toString());return O?[...p,O]:[...p]},[]):i.find(t=>t.value.toString()===r?.toString())||null,[i,r,o]);return jsx(ue,{ref:$,value:V||y,onInputChange:(e,t,p)=>{if(A&&A(e,t,p),p==="input"){v&&(v(t),T(t));return}T(void 0);},options:i,loading:m,noOptionsText:n,loadingText:s,disabled:m||x,disableListWrap:!0,PopperComponent:D,ListboxComponent:P?void 0:N,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(U));return}d(typeof t=="string"?t.toString():t.value.toString());},onBlur:e=>{E&&E(e),T(void 0);},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(le,{...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(me,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,tabIndex:X}}),...J})});H.displayName="Autocomplete";var He=H;
16
+
17
+ export { He as a };
@@ -1,3 +1,3 @@
1
- export { a as default } from '../../chunk-CWR7MWFN.js';
1
+ export { a as default } from '../../chunk-UUVFDAMW.js';
2
2
  import '../../chunk-A3HKJM7C.js';
3
3
  import '../../chunk-HR73D35E.js';
@@ -1,8 +1,8 @@
1
1
  import { a as a$2 } from '../../../chunk-JAIK5CGA.js';
2
2
  import { a as a$1 } from '../../../chunk-SEVJABAI.js';
3
- import { a as a$3 } from '../../../chunk-YVYCQ6LJ.js';
3
+ import { a as a$3 } from '../../../chunk-AIE3DQLQ.js';
4
4
  import '../../../chunk-QNAXGE5H.js';
5
- import '../../../chunk-CWR7MWFN.js';
5
+ import '../../../chunk-UUVFDAMW.js';
6
6
  import '../../../chunk-A3HKJM7C.js';
7
7
  import '../../../chunk-HR73D35E.js';
8
8
  import E from '@mui/material/CircularProgress';
@@ -1,4 +1,4 @@
1
- export { a as default } from '../../../chunk-YVYCQ6LJ.js';
2
- import '../../../chunk-CWR7MWFN.js';
1
+ export { a as default } from '../../../chunk-AIE3DQLQ.js';
2
+ import '../../../chunk-UUVFDAMW.js';
3
3
  import '../../../chunk-A3HKJM7C.js';
4
4
  import '../../../chunk-HR73D35E.js';
@@ -1,7 +1,7 @@
1
1
  import { a } from '../../../chunk-JAIK5CGA.js';
2
- import { a as a$2 } from '../../../chunk-YVYCQ6LJ.js';
2
+ import { a as a$2 } from '../../../chunk-AIE3DQLQ.js';
3
3
  import { a as a$3 } from '../../../chunk-CAZ3WGTV.js';
4
- import '../../../chunk-CWR7MWFN.js';
4
+ import '../../../chunk-UUVFDAMW.js';
5
5
  import { a as a$1 } from '../../../chunk-A3HKJM7C.js';
6
6
  import '../../../chunk-HR73D35E.js';
7
7
  import { useFormContext, useFieldArray } from 'react-hook-form';
@@ -443,7 +443,7 @@ declare function paper({ theme, color, dropdown }: PaperProps): {
443
443
  wordWrap?: csstype.Property.WordWrap | readonly NonNullable<csstype.Property.WordWrap | undefined>[] | readonly csstype.Property.WordWrap[] | undefined;
444
444
  writingMode?: csstype.Property.WritingMode | readonly NonNullable<csstype.Property.WritingMode | undefined>[] | readonly csstype.Property.WritingMode[] | undefined;
445
445
  zIndex?: csstype.Property.ZIndex | readonly NonNullable<csstype.Property.ZIndex | undefined>[] | readonly ((string & {}) | csstype.Globals | "auto")[] | undefined;
446
- zoom?: csstype.Property.Zoom | readonly NonNullable<csstype.Property.Zoom | undefined>[] | readonly ((string & {}) | csstype.Globals | "normal" | "reset")[] | undefined;
446
+ zoom?: csstype.Property.Zoom | readonly NonNullable<csstype.Property.Zoom | undefined>[] | readonly ("reset" | (string & {}) | csstype.Globals | "normal")[] | undefined;
447
447
  all?: csstype.Globals | readonly NonNullable<csstype.Globals | undefined>[] | readonly csstype.Globals[] | undefined;
448
448
  animation?: csstype.Property.Animation<string & {}> | readonly NonNullable<csstype.Property.Animation<string & {}> | undefined>[] | readonly ((string & {}) | csstype.Globals | "normal" | "reverse" | "linear" | "none" | "auto" | "both" | "alternate" | "alternate-reverse" | "backwards" | "forwards" | "infinite" | "paused" | "running" | "ease" | "ease-in" | "ease-in-out" | "ease-out" | "step-end" | "step-start")[] | undefined;
449
449
  animationRange?: csstype.Property.AnimationRange<string | number> | readonly NonNullable<csstype.Property.AnimationRange<string | number> | undefined>[] | readonly (string | (string & {}))[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.2.25",
3
+ "version": "2.2.26",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,17 +0,0 @@
1
- import { a } from './chunk-A3HKJM7C.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 le 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:l}=u,n=r[i],{showValueInLabel:s,key:c,...y}=n[0],m={...l,top:l.top+R,paddingTop:8};return Object.prototype.hasOwnProperty.call(n,"group")?jsx(q,{component:"div",style:m,children:n.group},`list-box-item-group-${c}`):jsx(O,{component:"li",...y,noWrap:!0,style:m,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:l,...n}=r,s=[];l.forEach(o=>{s.push(o),s.push(...o.children||[]);});let c=useTheme(),y=K(c.breakpoints.up("sm")),m=s.length,d=y?36:48,h=o=>Object.prototype.hasOwnProperty.call(o,"group")?48:d,C=()=>m>8?8*d:s.map(h).reduce((o,L)=>o+L,0),x=Z(m);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=>h(s[o]),overscanCount:5,itemCount:m,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:l,noOptionsText:n="Nenhum resultado encontrado.",loadingText:s="Carregando op\xE7\xF5es...",error:c,helperText:y,placeholder:m,onChange:d,groupBy:h,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(),g=useMemo(()=>o?(Array.isArray(r)?r:[]).reduce((p,f)=>{let E=i.find(U=>U.value.toString()===f.toString());return E?[...p,E]:[...p]},[]):i.find(t=>t.value.toString()===r?.toString())||null,[i,r,o]);return jsx(pe,{ref:J,value:$||g,onInputChange:(e,t,p)=>{if(T&&T(e,t,p),p==="input"){A&&(A(t),v(t));return}v(void 0);},options:i,loading:l,noOptionsText:n,loadingText:s,disabled:l||x,disableListWrap:!0,PopperComponent:N,ListboxComponent:P?void 0:M,filterOptions:(e,t)=>(console.log({optionsFilter:e,state:t}),e.filter(p=>{let f=`${p.value} ${p.label}`;return console.log("optionsFilter.filter ---> search:",f),f.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,f)=>P?P(e,t,p,f):[{...e,showValueInLabel:C},t],renderGroup:e=>e,groupBy:h,multiple:o,renderInput:e=>jsx(le,{...e,placeholder:m,fullWidth:!0,error:!!c,helperText:y,label:u,required:L,InputProps:{...e.InputProps,...!o&&{startAdornment:g&&!Array.isArray(g)&&g.icon?jsx(a,{icon:g.icon}):void 0},endAdornment:jsxs(Fragment,{children:[l?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 };