@zydon/common 2.1.92 → 2.1.94

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-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,4 +1,4 @@
1
- import { a } from './chunk-TAOXEQBE.js';
1
+ import { a } from './chunk-FMUKZOVG.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-TAOXEQBE.js';
1
+ export { a as default } from '../../chunk-FMUKZOVG.js';
2
2
  import '../../chunk-4Z2JJGWA.js';
3
3
  import '../../chunk-QDDGXWNG.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-M2RUXGRI.js';
3
+ import { a as a$3 } from '../../../chunk-H3BSTE4Q.js';
4
4
  import '../../../chunk-QNAXGE5H.js';
5
- import '../../../chunk-TAOXEQBE.js';
5
+ import '../../../chunk-FMUKZOVG.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-M2RUXGRI.js';
2
- import '../../../chunk-TAOXEQBE.js';
1
+ export { a as default } from '../../../chunk-H3BSTE4Q.js';
2
+ import '../../../chunk-FMUKZOVG.js';
3
3
  import '../../../chunk-4Z2JJGWA.js';
4
4
  import '../../../chunk-QDDGXWNG.js';
@@ -1,14 +1,16 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { BaseAutoComplete } from '../../../types/autoComplete.js';
3
3
  import { BaseField } from '../../../types/baseField.js';
4
+ import { Option } from '../../../types/option.js';
4
5
  import 'react';
5
6
  import '@mui/material/Autocomplete';
6
- import '../../../types/option.js';
7
7
  import '../../../types/icon.js';
8
8
  import 'react-hook-form';
9
9
 
10
- type AutocompleteDetailedProps = BaseField<BaseAutoComplete>;
10
+ type AutocompleteDetailedProps = BaseField<BaseAutoComplete> & {
11
+ onSelectOption?(newValue: NonNullable<string | Option> | (string | Option)[] | null | undefined, oldValue?: NonNullable<string | Option> | (string | Option)[] | null | undefined): void;
12
+ };
11
13
 
12
- declare const AutocompleteDetailed: ({ name, rules, helperText, ...other }: AutocompleteDetailedProps) => react_jsx_runtime.JSX.Element;
14
+ declare const AutocompleteDetailed: ({ name, rules, helperText, onSelectOption, ...other }: AutocompleteDetailedProps) => react_jsx_runtime.JSX.Element;
13
15
 
14
16
  export { AutocompleteDetailed as default };
@@ -4,6 +4,6 @@ import '../../../chunk-ILHUUK4X.js';
4
4
  import { useFormContext, Controller } from 'react-hook-form';
5
5
  import { jsx } from 'react/jsx-runtime';
6
6
 
7
- var d=({name:l,rules:n,helperText:m,...p})=>{let{control:a$1}=useFormContext();return jsx(Controller,{name:l,control:a$1,rules:n,render:({field:e,fieldState:{error:o}})=>jsx(a,{...e,...p,onChange:u=>{e.onChange(u);},error:!!o,helperText:o?.message||m})})},f=d;
7
+ var d=({name:m,rules:p,helperText:a$1,onSelectOption:o,...s})=>{let{control:u}=useFormContext();return jsx(Controller,{name:m,control:u,rules:p,render:({field:e,fieldState:{error:t}})=>jsx(a,{...e,...s,onChange:r=>{o&&o(r,e.value),e.onChange(r);},error:!!t,helperText:t?.message||a$1})})},g=d;
8
8
 
9
- export { f as default };
9
+ export { g as default };
@@ -1,7 +1,7 @@
1
1
  import { a } from '../../../chunk-P46BBUKR.js';
2
- import { a as a$2 } from '../../../chunk-M2RUXGRI.js';
2
+ import { a as a$2 } from '../../../chunk-H3BSTE4Q.js';
3
3
  import { a as a$3 } from '../../../chunk-AKR4HFCK.js';
4
- import '../../../chunk-TAOXEQBE.js';
4
+ import '../../../chunk-FMUKZOVG.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';
@@ -11,7 +11,6 @@ type AutocompleteProps = BaseAutoComplete & {
11
11
  error?: boolean;
12
12
  helperText?: string;
13
13
  showValueInLabel?: boolean;
14
- disabledIfLoading?: boolean;
15
14
  };
16
15
 
17
16
  export { AutocompleteProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.1.92",
3
+ "version": "2.1.94",
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 ie, { autocompleteClasses } from '@mui/material/Autocomplete';
4
- import se from '@mui/material/CircularProgress';
5
- import pe from '@mui/material/TextField';
6
- import { VariableSizeList } from 'react-window';
7
- import _ from '@mui/material/ListSubheader';
8
- import q from '@mui/material/Stack';
9
- import { useTheme, styled } from '@mui/material/styles';
10
- import v from '@mui/material/Typography';
11
- import Q from '@mui/material/useMediaQuery';
12
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
- import te from '@mui/material/Popper';
14
-
15
- var I=8,K=m=>{let{data:r,index:i,style:s}=m,o=r[i],{showValueInLabel:n,...y}=o[0],d={...s,top:s.top+I,paddingTop:8};return Object.prototype.hasOwnProperty.call(o,"group")?jsx(_,{component:"div",style:d,children:o.group},o.key):jsx(v,{component:"li",...y,noWrap:!0,style:d,children:jsxs(q,{component:"div",direction:"row",flex:1,gap:1,justifyContent:"start",children:[o[1].icon&&jsx(a,{icon:o[1].icon}),o[1].label,n&&jsxs(v,{variant:"inherit",color:"grey.400",children:["(",o[1].value,")"]})]})})},R=createContext({}),z=forwardRef((m,r)=>{let i=useContext(R);return jsx("div",{ref:r,...m,...i})});z.displayName="OuterElementType";var Y=m=>{let r=useRef(null);return useEffect(()=>{r.current!=null&&r.current.resetAfterIndex(0,!0);},[m]),r},Z=forwardRef(function(r,i){let{children:s,...o}=r,n=[];s.forEach(p=>{n.push(p),n.push(...p.children||[]);});let y=useTheme(),d=Q(y.breakpoints.up("sm")),h=n.length,a=d?36:48,b=p=>Object.prototype.hasOwnProperty.call(p,"group")?48:a,P=()=>h>8?8*a:n.map(b).reduce((p,l)=>p+l,0),g=Y(h);return jsx("div",{ref:i,children:jsx(R.Provider,{value:o,children:jsx(VariableSizeList,{itemData:n,height:P()+2*I,width:"100%",ref:g,outerElementType:z,innerElementType:"ul",itemSize:p=>b(n[p]),overscanCount:5,itemCount:h,children:K})})})}),M=Z;var k=styled(te)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var N=forwardRef(({label:m,value:r,options:i=[],loading:s,noOptionsText:o="Nenhum resultado encontrado.",loadingText:n="Carregando op\xE7\xF5es...",error:y,helperText:d,placeholder:h,onChange:a$1,groupBy:b,showValueInLabel:P,disabled:g,disabledIfLoading:p=!0,multiple:l,required:D,renderOption:x,tabIndex:H,onInputChange:A,onSearch:T,...X},J)=>{let V=e=>e&&typeof e=="object"?e.value.toString():e.toString(),f=useMemo(()=>l?(Array.isArray(r)?r:[]).reduce((u,S)=>{let E=i.find(U=>U.value.toString()===S.toString());return E?[...u,E]:[...u]},[]):i.find(t=>t.value.toString()===r?.toString())||null,[i,r,l]);return jsx(ie,{ref:J,value:f,onInputChange:(e,t,u)=>{!s&&!f&&a$1(l?[]:null),A&&A(e,t,u),T&&e&&(e.type==="change"||e.type==="blur")&&T(t);},options:i,loading:s,noOptionsText:s?n:o,loadingText:n,disabled:p&&s||g,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){a$1(l?[]:null);return}if(Array.isArray(t)){a$1(t.map(V));return}a$1(typeof t=="string"?t.toString():t.value.toString());},renderOption:(e,t,u,S)=>x?x(e,t,u,S):[{...e,showValueInLabel:P},t],renderGroup:e=>e,groupBy:b,multiple:l,renderInput:e=>jsx(pe,{...e,placeholder:h,fullWidth:!0,error:!!y,helperText:d,label:m,required:D,InputProps:{...e.InputProps,...!l&&{startAdornment:f&&!Array.isArray(f)&&f.icon?jsx(a,{icon:f.icon}):void 0},endAdornment:jsxs(Fragment,{children:[s?jsx(se,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,tabIndex:H}}),...X})});N.displayName="Autocomplete";var ke=N;
16
-
17
- export { ke as a };