@zydon/common 2.9.50 → 2.9.52
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.
- package/README.md +1 -1
- package/dist/{chunk-NENWDNKY.js → chunk-2TSB3SAD.js} +2 -2
- package/dist/{chunk-EUU7QQT7.js → chunk-GI7NSBVO.js} +2 -2
- package/dist/{chunk-TY762RFI.js → chunk-OAETEHZS.js} +2 -2
- package/dist/{chunk-XDHRQPZ7.js → chunk-OTCYO765.js} +2 -2
- package/dist/chunk-SUOJNPZZ.js +18 -0
- package/dist/chunk-SUOJNPZZ.js.map +1 -0
- package/dist/{chunk-I4HDCXVI.js → chunk-XADW5XM2.js} +2 -2
- package/dist/chunk-ZA4ABS3L.js +11 -0
- package/dist/chunk-ZA4ABS3L.js.map +1 -0
- package/dist/components/Analytics/Carts/index.js +4 -4
- package/dist/components/Analytics/OrderProjection/index.js +2 -2
- package/dist/components/Analytics/OverviewAnalytics/index.js +2 -2
- package/dist/components/Analytics/PartnerAnalysis/index.js +2 -2
- package/dist/components/Analytics/index.js +1 -1
- package/dist/components/Autocomplete/index.js +1 -1
- package/dist/components/BulkEditModal/index.js +2 -2
- package/dist/components/DataView/index.js +2 -2
- package/dist/components/DynamicDataView/index.js +3 -3
- package/dist/components/Filters/index.js +1 -1
- package/dist/components/SearchInput/index.d.ts +2 -1
- package/dist/components/SearchInput/index.js +1 -1
- package/dist/components/SelectList/index.js +2 -2
- package/dist/components/SelectableCards/index.js +2 -2
- package/dist/components/SwapList/index.js +1 -1
- package/dist/components/form/Address/index.js +2 -2
- package/dist/components/form/Autocomplete/index.js +2 -2
- package/dist/components/form/SelectList/index.js +2 -2
- package/dist/components/form/SelectableCards/index.js +2 -2
- package/dist/components/form/Webhook/index.js +2 -2
- package/dist/types/searchInputProps.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunk-PXC4AAOB.js +0 -11
- package/dist/chunk-PXC4AAOB.js.map +0 -1
- package/dist/chunk-QNKHAGBG.js +0 -18
- package/dist/chunk-QNKHAGBG.js.map +0 -1
- /package/dist/{chunk-NENWDNKY.js.map → chunk-2TSB3SAD.js.map} +0 -0
- /package/dist/{chunk-EUU7QQT7.js.map → chunk-GI7NSBVO.js.map} +0 -0
- /package/dist/{chunk-TY762RFI.js.map → chunk-OAETEHZS.js.map} +0 -0
- /package/dist/{chunk-XDHRQPZ7.js.map → chunk-OTCYO765.js.map} +0 -0
- /package/dist/{chunk-I4HDCXVI.js.map → chunk-XADW5XM2.js.map} +0 -0
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
|
59
59
|
- **NumberInput:** input que aceita somente números
|
|
60
60
|
- **Portal:** componente que renderiza o `children` em outro local desejado [React Portals](https://react.dev/reference/react-dom/createPortal)
|
|
61
61
|
- **Scrollbar:** Scrollbar `bonitinha` construido em cima do [simplebar-react](https://www.npmjs.com/package/simplebar-react)
|
|
62
|
-
- **SearchInput:** componente para busca/filtros. Funciona com `onChange` e como click na tecla `enter`
|
|
62
|
+
- **SearchInput:** componente para busca/filtros. Funciona com `onChange` e como click na tecla `enter`; `iconButtonProps` repassa props ao botão da lupa (por exemplo, uma `className`)
|
|
63
63
|
- **snackbar:** componente para mostrar mensagens `[sucesso | alerta | informação | erro]` para o usuário
|
|
64
64
|
```
|
|
65
65
|
const { enqueueSnackbar } = useSnackbar();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a } from './chunk-RUABKHIV.js';
|
|
2
|
-
import { a as a$1 } from './chunk-
|
|
2
|
+
import { a as a$1 } from './chunk-ZA4ABS3L.js';
|
|
3
3
|
import { a as a$3 } from './chunk-4F2NKGF6.js';
|
|
4
4
|
import { a as a$4 } from './chunk-6U5LS7MP.js';
|
|
5
5
|
import { a as a$2 } from './chunk-RYAZSEY4.js';
|
|
@@ -17,4 +17,4 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
17
17
|
var A=styled(i)(({theme:r})=>({flexDirection:"row",minHeight:48,alignItems:"flex-start",justifyContent:"flex-start",padding:r.spacing(1.5,0),borderBottom:`1px dashed ${r.palette.divider}`,"& label":{marginInline:0,userSelect:"none",alignItems:"flex-start","& .MuiFormControlLabel-label":{minHeight:36,display:"flex",alignItems:"center"}}}));var $=Array.from({length:12},(r,p)=>jsx(a,{height:48},p)),q=({value:r,multiple:p,options:l,onChange:c,pagination:n,onSearch:f,onAdd:g,total:m=0,label:h,loading:b,loadingView:O,fetching:S,fetchingView:v,emptyView:M,error:N,helperText:k})=>{let s=p&&Array.isArray(r),C=useMemo(()=>Math.ceil(m/(n?.perPage||1)),[m,n?.perPage]),_=useMemo(()=>l.map(e=>e.value),[l]),j=s&&m>0&&_.every(e=>r.includes(e)),z=useCallback(()=>{if(!s)return;let e=l.filter(o=>!o.disabled).map(o=>o.value),a=e.every(o=>r.includes(o));c(a?r.filter(o=>!e.includes(o)):[...r,...e.filter(o=>!r.includes(o))]);},[s,r,c,l]),y=useCallback((e,a)=>{if(!s){c(e);return}c(a?[...r,e]:r.filter(o=>o!==e));},[s,r,c]),E=useCallback(e=>s?jsx(B,{checked:r.includes(e.value),onChange:(a,o)=>y(e.value,o),disabled:e.disabled}):jsx(K,{checked:r===e.value,onChange:()=>y(e.value,!0),disabled:e.disabled}),[s,r,y]);return jsxs(i,{gap:2,width:1,children:[h&&jsx(u,{variant:"overline",color:"text.secondary",children:h}),s&&jsxs(i,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",gap:1,children:[jsx(H,{label:"Selecionar todos",control:jsx(B,{checked:j,onChange:z}),componentsProps:{typography:{color:"text.secondary",ml:.5,sx:{fontSize:"12px !important"}}}}),m>0&&jsxs(u,{variant:"caption",color:"text.secondary",children:[jsx("strong",{children:r.length})," de ",jsx("strong",{children:m})," ","selecionados"]})]}),(f||g)&&jsxs(i,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",gap:1,children:[jsx(i,{maxWidth:280,flex:1,children:f&&jsx(a$1,{onSearch:f,trigger:"click",size:"small",fullWidth:!0,placeholder:"Buscar",iconPosition:"start"})}),g&&jsx(a$2,{actionType:"NEW",onClick:g,size:"small",variant:"text",children:"Adicionar"})]}),jsx(i,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:jsx(a$3,{isFetching:S,fetching:v||jsx(a$4,{}),isLoading:b,loading:O||$,children:l.map(e=>jsxs(A,{minHeight:48,justifyContent:"center",p:1.5,children:[e.startContent&&jsx(i,{children:e.startContent}),jsx(H,{label:e.label,control:E(e),componentsProps:{typography:{ml:.5}}})]},e.value))})}),k&&jsx(D,{error:N,children:k}),!b&&!S&&l.length===0&&(M||jsx(u,{variant:"body1",color:"text.secondary",align:"center",my:3,children:"Nenhum resultado encontrado"})),n&&C>1&&jsx(G,{page:n.page+1,count:C,onChange:(e,a)=>n.onChange(a-1,n.perPage),variant:"soft",sx:{mx:"auto"}})]})},me=q;
|
|
18
18
|
|
|
19
19
|
export { me as a };
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
20
|
+
//# sourceMappingURL=chunk-2TSB3SAD.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as a$4 } from './chunk-6ZSTKYGL.js';
|
|
2
|
-
import { a as a$1 } from './chunk-
|
|
2
|
+
import { a as a$1 } from './chunk-ZA4ABS3L.js';
|
|
3
3
|
import { a as a$3 } from './chunk-4F2NKGF6.js';
|
|
4
4
|
import { a } from './chunk-STWQUEEE.js';
|
|
5
5
|
import { a as a$2 } from './chunk-F65ZXAGV.js';
|
|
@@ -16,4 +16,4 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
16
16
|
var T=styled(H,{shouldForwardProp:t=>t!=="active"&&t!=="disabled"})(({theme:t,active:a,disabled:i})=>({boxShadow:"none",borderRadius:8,borderStyle:"solid",borderWidth:1.5,borderColor:a?t.palette.primary.main:t.palette.grey[300],color:t.palette.primary.main,backgroundColor:a?alpha(t.palette.primary.main,.04):"white","&:hover":{borderColor:t.palette.primary.main},...i?{opacity:.6,cursor:"default"}:{opacity:1,cursor:"pointer"}}));var D=memo(({item:t,isSelected:a$1,disabled:i,onSelectItem:n})=>{let o=useCallback(()=>{n(t);},[t,n]);return jsx(q,{item:!0,xs:4,children:jsx(T,{active:a$1,onClick:o,disabled:i,children:jsxs(d,{padding:1.5,width:"100%",children:[jsxs(d,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[jsx(h,{color:a$1?"primary.main":"text.primary",variant:"subtitle2",textAlign:"left",noWrap:!0,children:t.title}),a$1&&jsx(a,{icon:"CHECK_CIRCLE",width:24})]}),t.options.map(l=>jsx(h,{mt:1,variant:"body2",color:"text.disabled",fontSize:12,textAlign:"left",noWrap:!0,children:`${l.label}: ${l.value}`},l.label))]})})},t.title)});D.displayName="CardItem";var O=D;var Y=new Intl.PluralRules("pt-BR"),Z=new Map([["one","selecionado"],["other","selecionados"]]),tt=t=>{let a=Y.select(t),i=Z.get(a);return `${t} ${i}`},rt=({title:t,action:a,loading:i,items:n,values:o,onChange:l,onSearch:C,disabled:s=!1})=>{let[p,$]=useState(),b=useMemo(()=>new Set(o),[o]),y=useCallback(r=>b.has(r),[b]),A=useMemo(()=>{if(!p)return n;let r=p.toLowerCase();return n.filter(g=>g.title.toLowerCase().includes(r))},[n,p]),B=useCallback(r=>{if(s)return;let g=y(r.value),u;g?u=o.filter(N=>N!==r.value):u=[...o,r.value],l(u);},[s,y,l,o]),w=useMemo(()=>n.map(r=>r.value),[n]),G=useCallback(()=>{s||(o.length===n.length?l([]):l(w));},[s,n.length,l,o.length,w]),K=useCallback(r=>{$(r),C?.(r);},[C]),W=r=>{r.key==="Enter"&&r.preventDefault();},z=useMemo(()=>o.length===0?"nenhum selecionado":tt(o.length),[o.length]),M=useMemo(()=>typeof t=="string"?jsx(h,{variant:"overline",color:"text.disabled",children:t}):t,[t]);return jsxs(d,{gap:1.5,height:450,children:[jsxs(d,{direction:"row",justifyContent:"space-between",children:[M,jsx(h,{variant:"overline",color:"text.disabled",children:z})]}),jsxs(d,{direction:"row",alignItems:"center",spacing:1.5,children:[jsx(a$1,{fullWidth:!0,size:"small",iconPosition:"start",placeholder:"Buscar",trigger:"change",onSearch:K,onKeyDown:W}),a?jsx(Fragment,{children:a}):jsx(Q,{onClick:G,size:"small",disabled:s,children:jsx(h,{variant:"overline",children:"TODOS"})})]}),jsx(a$2,{children:jsx(d,{flex:1,mb:2,children:jsx(a$3,{isLoading:i,loading:jsx(d,{alignItems:"center",mt:3,children:jsx(U,{})}),isEmpty:n.length===0,empty:jsx(a$4,{sx:{svg:{height:140}},text:p?`N\xE3o foi possivel encontrar o item "${p}"`:"Nenhum item dispon\xEDvel"}),children:jsx(q,{container:!0,spacing:1.5,children:A.map(r=>jsx(O,{item:r,isSelected:y(r.value),disabled:s,onSelectItem:B},r.value))})})})})]})},xt=rt;
|
|
17
17
|
|
|
18
18
|
export { xt as a };
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-GI7NSBVO.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as a$2, b, c } from './chunk-6X3GKY7E.js';
|
|
2
2
|
import { a as a$4 } from './chunk-DRGARBKB.js';
|
|
3
3
|
import { a as a$5 } from './chunk-4F2NKGF6.js';
|
|
4
|
-
import { a as a$3 } from './chunk-
|
|
4
|
+
import { a as a$3 } from './chunk-SUOJNPZZ.js';
|
|
5
5
|
import { a } from './chunk-E3R7W7GK.js';
|
|
6
6
|
import { a as a$1 } from './chunk-GGJJ3II3.js';
|
|
7
7
|
import { useState, useMemo, useCallback } from 'react';
|
|
@@ -13,4 +13,4 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
13
13
|
var K=({name:v,title:s,placeholder:C,emptyText:I,testIdPrefix:V,defaultExpanded:w,selected:n,onChange:i,useOptions:D})=>{let[m,E]=a(w),[L,c$1]=useState(""),{buildOptions:u,finishSearch:P,onSearch:W,onSelectValue:d,search:R,searching:l}=a$1(),{items:g,isFetching:r,isLoading:$}=D({search:R,skip:!m}),a$6=useMemo(()=>l||r?[]:u(g.map(({id:o,name:t})=>({value:o,label:t})),r),[u,r,g,l]),q=n.length>0,z=useCallback(o=>{d(a$6,o);let t=typeof o=="string"?o:String(o?.value||""),H=a$6.find(p=>String(p.value)===t)?.label||(typeof o=="string"?o:String(o?.label||""));t&&!n.some(p=>p.id===t)&&i([...n,{id:t,name:H}]),c$1("");},[i,d,a$6,n]),B=useCallback(o=>{i(n.filter(t=>t.id!==o.id));},[i,n]);return jsxs(a$2,{expanded:m,onChange:E,children:[jsx(b,{children:jsx(F,{variant:"body2",fontWeight:"bold",color:"text.primary",children:s})}),jsx(c,{children:jsxs(J,{gap:1,children:[jsx(a$3,{name:v,label:s,placeholder:C,size:"small",options:a$6,isOptionEqualToValue:(o,t)=>o.value===t.value,loading:$,inputValue:L,onInputChange:(o,t)=>c$1(t),onSearch:W,onBlur:P,onChange:z,filterOptions:o=>o,noOptionsText:l||r?"Carregando...":void 0,InputLabelProps:{shrink:!0},fullWidth:!0}),jsx(a$4,{direction:"row",alignItems:"center",flexWrap:"wrap",overflow:"auto",maxHeight:148,p:1.5,sx:{bgcolor:"grey.50"},children:jsx(a$5,{isEmpty:!q,empty:jsx(F,{variant:"body2",color:"text.secondary",children:I}),children:n.map((o,t)=>jsx(G,{variant:"outlined",label:o.name,color:"default",onDelete:()=>B(o),"data-testid":`${V}-${t}`},t))})})]})})]})},io=K;
|
|
14
14
|
|
|
15
15
|
export { io as a };
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-OAETEHZS.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a } from './chunk-
|
|
1
|
+
import { a } from './chunk-SUOJNPZZ.js';
|
|
2
2
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
var A=({name:t,helperText:u,rules:m,onSelectOption:r,InputLabelProps:p,onBlur:n,...c})=>{let{control:i}=useFormContext(),C=o=>e=>{r&&r(e,o.value),o.onChange(e);};return jsx(Controller,{name:t,control:i,rules:m,render:({field:{ref:o,...e},fieldState:{error:l}})=>{let g=d=>{e.onBlur(),n&&n(d);};return jsx(a,{"data-intercom-target":t,...e,...c,inputRef:o,onChange:C(e),onBlur:g,error:!!l,helperText:l?.message||u,InputLabelProps:p})}})},B=A;
|
|
6
6
|
|
|
7
7
|
export { B as a };
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-OTCYO765.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { a } from './chunk-STWQUEEE.js';
|
|
2
|
+
import { memo, createContext, forwardRef, useContext, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
3
|
+
import $t, { autocompleteClasses } from '@mui/material/Autocomplete';
|
|
4
|
+
import gt from '@mui/material/CircularProgress';
|
|
5
|
+
import Pt from '@mui/material/TextField';
|
|
6
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
+
import { VariableSizeList } from 'react-window';
|
|
8
|
+
import { useTheme, styled } from '@mui/material/styles';
|
|
9
|
+
import wt from '@mui/material/useMediaQuery';
|
|
10
|
+
import ht from '@mui/material/ListSubheader';
|
|
11
|
+
import St from '@mui/material/Stack';
|
|
12
|
+
import q from '@mui/material/Typography';
|
|
13
|
+
import Nt from '@mui/material/Popper';
|
|
14
|
+
|
|
15
|
+
var It=t=>{if(!(!t||Array.isArray(t))){if(t.startAdornment)return t.startAdornment;if(t.icon)return jsx(a,{icon:t.icon})}},$=memo(({params:t,name:e,placeholder:i,error:s,helperText:u,label:l,required:A,multiple:a,formattedValue:p,loading:c,tabIndex:m,InputLabelProps:y,inputRef:g})=>jsx(Pt,{...t,name:e,placeholder:i,fullWidth:!0,error:!!s,helperText:u,label:l,required:A,inputRef:g,InputProps:{...t.InputProps,...!a&&{startAdornment:It(p)},endAdornment:jsxs(Fragment,{children:[c?jsx(gt,{color:"primary",size:20}):null,t.InputProps.endAdornment]})},inputProps:{...t.inputProps,name:e,tabIndex:m},InputLabelProps:y}));$.displayName="AutocompleteInput";var F=$;var w=8,U=memo(t=>{let{data:e,index:i,style:s}=t,u=e[i],l={...s,top:s.top+w,paddingTop:8};if(Object.prototype.hasOwnProperty.call(u,"group")){let y=u;return jsx(ht,{component:"div",style:l,children:y.group},`list-box-item-group-${y.group}`)}let[A,a$1]=u,{showValueInLabel:p,key:c,...m}=A;return jsx(q,{component:"li",...m,noWrap:!0,style:l,children:jsxs(St,{component:"div",direction:"row",flex:1,gap:1,justifyContent:"start",children:[a$1.icon&&jsx(a,{icon:a$1.icon}),a$1.label,p&&jsxs(q,{variant:"inherit",color:"grey.400",children:["(",a$1.value,")"]})]})},`list-box-item-${c}`)});U.displayName="ListboxRow";var W=U;var Tt=createContext(void 0),h=Tt;var Y=createContext({}),Z=forwardRef((t,e)=>{let i=useContext(Y);return jsx("div",{ref:e,...t,...i})});Z.displayName="OuterElementType";var Ht=t=>{let e=useRef(null);return useEffect(()=>{e.current!=null&&e.current.resetAfterIndex(0,!0);},[t]),e},kt=forwardRef(function(e,i){let{children:s,...u}=e,l=useMemo(()=>{let r=[];return s.forEach(b=>{r.push(b),Object.prototype.hasOwnProperty.call(b,"children")&&Array.isArray(b.children)&&r.push(...b.children);}),r},[s]),A=useTheme(),a=wt(A.breakpoints.up("sm")),p=l.length,c=a?36:48,m=useCallback(r=>Object.prototype.hasOwnProperty.call(r,"group")?48:c,[c]),y=useMemo(()=>p>8?8*c:l.map(m).reduce((r,b)=>r+b,0),[p,c,l,m]),g=Ht(p),P=useContext(h),d=useRef(!1);useEffect(()=>{d.current=!1;},[p]);let R=useCallback(({visibleStopIndex:r})=>{P&&!d.current&&r>=p-3&&(d.current=!0,P());},[P,p]);return jsx("div",{ref:i,children:jsx(Y.Provider,{value:u,children:jsx(VariableSizeList,{itemData:l,height:y+2*w,width:"100%",ref:g,outerElementType:Z,innerElementType:"ul",itemSize:r=>m(l[r]),overscanCount:5,itemCount:p,onItemsRendered:R,children:W})})})}),tt=kt;var et=styled(Nt)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var k=t=>t&&typeof t=="object"?t.value.toString():t.toString(),Ft=t=>t,qt=(t,e)=>k(t)===k(e),Bt=(t,e)=>{let i=e.inputValue.toLocaleUpperCase();return t.filter(s=>`${s.value} ${s.label}`.toLocaleUpperCase().includes(i))},nt=memo(forwardRef(({name:t,label:e,value:i,options:s=[],loading:u,noOptionsText:l="Nenhum resultado encontrado.",loadingText:A="Carregando op\xE7\xF5es...",error:a,helperText:p,placeholder:c,onChange:m,groupBy:y,showValueInLabel:g,disabled:P,multiple:d,required:R,renderOption:r,tabIndex:b,onInputChange:C,onSearch:L,onBlur:T,onScrollEnd:it,InputLabelProps:G,inputRef:N,filterOptions:st,...pt},ut)=>{let z=useRef(null),D=useRef(null),v=useMemo(()=>{if(d)return (Array.isArray(i)?i:[]).reduce((x,yt)=>{let V=s.find(At=>At.value.toString()===yt.toString());return V?[...x,V]:[...x]},[]);let n=s.find(f=>f.value.toString()===i?.toString())||null,o=D.current;return !n&&o?.value.toString()===i?.toString()||o&&n&&o.value===n.value&&o.label===n.label?o:(D.current=n,n)},[s,i,d]),lt=st??(z.current==="reset"?void 0:Bt),mt=useCallback((n,o,f)=>{if(z.current=f,C&&C(n,o,f),f==="input"){L&&L(o);return}f==="reset"&&L&&L(void 0),f==="clear"&&L&&L("");},[C,L]),at=useCallback((n,o)=>{if(!o){m(d?[]:null);return}if(Array.isArray(o)){m(o.map(k));return}m(typeof o=="string"?o.toString():o.value.toString());},[m,d]),ct=useCallback(n=>{T&&T(n);},[T]),dt=useCallback((n,o,f,x)=>r?r(n,o,f,x):[{...n,showValueInLabel:g},o],[r,g]),ft=useMemo(()=>r?void 0:tt,[r]),bt=useCallback(n=>jsx(F,{params:n,name:t,placeholder:c,error:a,helperText:p,label:e,required:R,multiple:d,formattedValue:v,loading:u,tabIndex:b,InputLabelProps:G,inputRef:N}),[t,c,a,p,e,R,d,v,u,b,G,N]);return jsx(h.Provider,{value:it,children:jsx($t,{ref:ut,value:v,onInputChange:mt,options:s,loading:u,noOptionsText:l,loadingText:A,disabled:P,disableListWrap:!0,PopperComponent:et,ListboxComponent:ft,filterOptions:lt,isOptionEqualToValue:qt,onChange:at,onBlur:ct,renderOption:dt,renderGroup:Ft,groupBy:y,multiple:d,renderInput:bt,...pt})})}));nt.displayName="Autocomplete";var Me=nt;
|
|
16
|
+
|
|
17
|
+
export { Me as a };
|
|
18
|
+
//# sourceMappingURL=chunk-SUOJNPZZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Autocomplete/index.tsx","../src/components/Autocomplete/AutocompleteInput.tsx","../src/components/Autocomplete/Listbox.tsx","../src/components/Autocomplete/ListboxRow.tsx","../src/components/Autocomplete/ScrollEndContext.ts","../src/components/Autocomplete/styles.ts"],"names":["forwardRef","memo","useCallback","useMemo","useRef","MuiAutocomplete","CircularProgress","TextField","Fragment","jsx","jsxs","inputStartAdornment","formattedValue","Icon_default","AutocompleteInput","params","name","placeholder","error","helperText","label","required","multiple","loading","tabIndex","InputLabelProps","inputRef","AutocompleteInput_default","createContext","useContext","useEffect","VariableSizeList","useTheme","useMediaQuery","ListSubheader","Stack","Typography","LISTBOX_PADDING","ListboxRow","props","data","index","style","dataSet","inlineStyle","groupItem","itemProps","option","showValueInLabel","key","otherItemProps","ListboxRow_default","ScrollEndContext","ScrollEndContext_default","OuterElementContext","OuterElementType","ref","outerProps","useResetCache","ListboxComponent","children","other","itemData","item","theme","smUp","itemCount","itemSize","getChildSize","child","itemsHeight","a","gridRef","onScrollEnd","firedRef","handleItemsRendered","visibleStopIndex","Listbox_default","autocompleteClasses","Popper","styled","StyledPopper","getOptionValue","optionValue","renderGroup","defaultIsOptionEqualToValue","selected","defaultFilterOptions","optionsFilter","state","searchValue","opt","Autocomplete","value","options","noOptionsText","loadingText","onChange","groupBy","disabled","renderOption","onInputChange","onSearch","onBlur","filterOptionsProp","inputReasonRef","lastSingleValueRef","acc","curr","previous","resolvedFilterOptions","handleInputChange","event","eventValue","reason","handleChange","_","handleBlur","memoizedRenderOption","ownerState","renderListbox","memoizedRenderInput","Autocomplete_default"],"mappings":"wCAAA,OACE,cAAAA,GACA,QAAAC,GAEA,eAAAC,EACA,WAAAC,GACA,UAAAC,OACK,QACP,OAAOC,OAKA,6BCbP,OAAS,QAAAJ,OAAY,QACrB,OAAOK,OAAsB,iCAC7B,OAAOC,OAAe,0BAaY,OAqCxB,YAAAC,GArCwB,OAAAC,EAqCxB,QAAAC,OArCwB,oBAPlC,IAAMC,GACJC,GACG,CACH,GAAI,GAACA,GAAkB,MAAM,QAAQA,CAAc,GAEnD,IAAIA,EAAe,eAAgB,OAAOA,EAAe,eAEzD,GAAIA,EAAe,KAAM,OAAOH,EAACI,EAAA,CAAK,KAAMD,EAAe,KAAM,EAGnE,EAEME,EAAoBb,GACxB,CAAC,CACC,OAAAc,EACA,KAAAC,EACA,YAAAC,EACA,MAAAC,EACA,WAAAC,EACA,MAAAC,EACA,SAAAC,EACA,SAAAC,EACA,eAAAV,EACA,QAAAW,EACA,SAAAC,EACA,gBAAAC,EACA,SAAAC,CACF,IACEjB,EAACF,GAAA,CACE,GAAGQ,EACJ,KAAMC,EACN,YAAaC,EACb,UAAS,GACT,MAAO,CAAC,CAACC,EACT,WAAYC,EACZ,MAAOC,EACP,SAAUC,EACV,SAAUK,EACV,WAAY,CACV,GAAGX,EAAO,WACV,GAAI,CAACO,GAAY,CACf,eAAgBX,GAAoBC,CAAc,CACpD,EACA,aACEF,GAAAF,GAAA,CACG,UAAAe,EAAUd,EAACH,GAAA,CAAiB,MAAM,UAAU,KAAM,GAAI,EAAK,KAC3DS,EAAO,WAAW,cACrB,CA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ACuB,CAAY,CACf,EAEMqB,GAAsBvH,EACzBa,GACCN,EAACkB,EAAA,CACC,OAAQZ,EACR,KAAMC,EACN,YAAaC,EACb,MAAOC,EACP,WAAYC,EACZ,MAAOC,EACP,SAAUC,EACV,SAAUC,EACV,eAAgBV,EAChB,QAASW,EACT,SAAUC,EACV,gBAAiBC,EACjB,SAAUC,EACZ,EAEF,CACEV,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAV,EACAW,EACAC,EACAC,EACAC,CACF,CACF,EAEA,OACEjB,EAAC4C,EAAiB,SAAjB,CAA0B,MAAOoB,GAChC,SAAAhE,EAACJ,GAAA,CACC,IAAKmD,GACL,MAAO5C,EACP,cAAemG,GACf,QAASjB,EACT,QAASvE,EACT,cAAewE,EACf,YAAaC,EACb,SAAUG,EACV,gBAAe,GACf,gBAAiBlB,GACjB,iBAAkBuC,GAClB,cAAeV,GACf,qBAAsBzB,GACtB,SAAU8B,GACV,OAAQE,GACR,aAAcC,GACd,YAAalC,GACb,QAASc,EACT,SAAU5E,EACV,YAAamG,GACZ,GAAG5D,GACN,EACF,CAEJ,CACF,CACF,EAEA+B,GAAa,YAAc,eAE3B,IAAO8B,GAAQ9B","sourcesContent":["import {\n forwardRef,\n memo,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport MuiAutocomplete, {\n AutocompleteOwnerState,\n AutocompleteRenderGroupParams,\n AutocompleteRenderInputParams,\n AutocompleteRenderOptionState,\n} from '@mui/material/Autocomplete';\n\nimport { AutocompleteProps } from 'types/autoCompleteProps';\nimport { Option } from 'types/option';\n\nimport AutocompleteInput from './AutocompleteInput';\nimport ListboxComponent from './Listbox';\nimport ScrollEndContext from './ScrollEndContext';\nimport { StyledPopper } from './styles';\n\nconst getOptionValue = (optionValue: Option | string | number): string =>\n optionValue && typeof optionValue === 'object'\n ? optionValue.value.toString()\n : optionValue.toString();\n\nconst renderGroup = (params: AutocompleteRenderGroupParams) =>\n params as unknown as ReactNode;\n\nconst defaultIsOptionEqualToValue = (option: Option, selected: Option) =>\n getOptionValue(option) === getOptionValue(selected);\n\nconst defaultFilterOptions = (\n optionsFilter: Option[],\n state: { inputValue: string },\n) => {\n const searchValue = state.inputValue.toLocaleUpperCase();\n return optionsFilter.filter(opt => {\n const search = `${opt.value} ${opt.label}`;\n\n return search.toLocaleUpperCase().includes(searchValue);\n });\n};\n\nconst Autocomplete = memo(\n forwardRef<unknown, AutocompleteProps>(\n (\n {\n name,\n label,\n value,\n options = [],\n loading,\n noOptionsText = 'Nenhum resultado encontrado.',\n loadingText = 'Carregando opções...',\n error,\n helperText,\n placeholder,\n onChange,\n groupBy,\n showValueInLabel,\n disabled,\n multiple,\n required,\n renderOption,\n tabIndex,\n onInputChange,\n onSearch,\n onBlur,\n onScrollEnd,\n InputLabelProps,\n inputRef,\n filterOptions: filterOptionsProp,\n ...other\n },\n ref,\n ) => {\n const inputReasonRef = useRef<'input' | 'reset' | 'clear' | null>(null);\n\n const lastSingleValueRef = useRef<Option | null>(null);\n\n const formattedValue = useMemo(() => {\n if (multiple) {\n const values = Array.isArray(value) ? value : [];\n\n return values.reduce<Option[]>((acc, curr) => {\n const item = options.find(\n opt => opt.value.toString() === curr.toString(),\n );\n\n if (item) return [...acc, item];\n\n return [...acc];\n }, []);\n }\n\n const item =\n options.find(opt => opt.value.toString() === value?.toString()) ||\n null;\n\n const previous = lastSingleValueRef.current;\n\n if (!item && previous?.value.toString() === value?.toString()) {\n return previous;\n }\n\n if (\n previous &&\n item &&\n previous.value === item.value &&\n previous.label === item.label\n ) {\n return previous;\n }\n\n lastSingleValueRef.current = item;\n return item;\n }, [options, value, multiple]);\n\n const resolvedFilterOptions =\n filterOptionsProp ??\n (inputReasonRef.current === 'reset' ? undefined : defaultFilterOptions);\n\n const handleInputChange = useCallback(\n (\n event: React.SyntheticEvent,\n eventValue: string,\n reason: 'input' | 'reset' | 'clear',\n ) => {\n inputReasonRef.current = reason;\n if (onInputChange) onInputChange(event, eventValue, reason);\n\n if (reason === 'input') {\n if (onSearch) onSearch(eventValue);\n return;\n }\n\n if (reason === 'reset') {\n if (onSearch) onSearch(undefined);\n }\n\n if (reason === 'clear') {\n if (onSearch) onSearch('');\n }\n },\n [onInputChange, onSearch],\n );\n\n const handleChange = useCallback(\n (\n _: React.SyntheticEvent,\n option: Option | (string | Option)[] | string | null,\n ) => {\n if (!option) {\n onChange(multiple ? [] : null);\n return;\n }\n\n if (Array.isArray(option)) {\n onChange(option.map(getOptionValue));\n return;\n }\n\n onChange(\n typeof option === 'string'\n ? option.toString()\n : option.value.toString(),\n );\n },\n [onChange, multiple],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (onBlur) onBlur(event);\n },\n [onBlur],\n );\n\n const memoizedRenderOption = useCallback(\n (\n props: React.HTMLAttributes<HTMLLIElement> & { key: string },\n option: Option,\n state: AutocompleteRenderOptionState,\n ownerState: AutocompleteOwnerState<Option, boolean, boolean, boolean>,\n ) =>\n renderOption\n ? renderOption(props, option, state, ownerState)\n : ([{ ...props, showValueInLabel }, option] as ReactNode),\n [renderOption, showValueInLabel],\n );\n\n const renderListbox = useMemo(\n () => (renderOption ? undefined : ListboxComponent),\n [renderOption],\n );\n\n const memoizedRenderInput = useCallback(\n (params: AutocompleteRenderInputParams) => (\n <AutocompleteInput\n params={params}\n name={name}\n placeholder={placeholder}\n error={error}\n helperText={helperText}\n label={label}\n required={required}\n multiple={multiple}\n formattedValue={formattedValue}\n loading={loading}\n tabIndex={tabIndex}\n InputLabelProps={InputLabelProps}\n inputRef={inputRef}\n />\n ),\n [\n name,\n placeholder,\n error,\n helperText,\n label,\n required,\n multiple,\n formattedValue,\n loading,\n tabIndex,\n InputLabelProps,\n inputRef,\n ],\n );\n\n return (\n <ScrollEndContext.Provider value={onScrollEnd}>\n <MuiAutocomplete\n ref={ref}\n value={formattedValue}\n onInputChange={handleInputChange}\n options={options}\n loading={loading}\n noOptionsText={noOptionsText}\n loadingText={loadingText}\n disabled={disabled}\n disableListWrap\n PopperComponent={StyledPopper}\n ListboxComponent={renderListbox}\n filterOptions={resolvedFilterOptions}\n isOptionEqualToValue={defaultIsOptionEqualToValue}\n onChange={handleChange}\n onBlur={handleBlur}\n renderOption={memoizedRenderOption}\n renderGroup={renderGroup}\n groupBy={groupBy}\n multiple={multiple}\n renderInput={memoizedRenderInput}\n {...other}\n />\n </ScrollEndContext.Provider>\n );\n },\n ),\n);\n\nAutocomplete.displayName = 'Autocomplete';\n\nexport default Autocomplete;\n","import { memo } from 'react';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport TextField from '@mui/material/TextField';\n\nimport Icon from '../Icon';\n\nimport { AutocompleteInputProps } from './props';\n\nconst inputStartAdornment = (\n formattedValue: AutocompleteInputProps['formattedValue'],\n) => {\n if (!formattedValue || Array.isArray(formattedValue)) return undefined;\n\n if (formattedValue.startAdornment) return formattedValue.startAdornment;\n\n if (formattedValue.icon) return <Icon icon={formattedValue.icon} />;\n\n return undefined;\n};\n\nconst AutocompleteInput = memo(\n ({\n params,\n name,\n placeholder,\n error,\n helperText,\n label,\n required,\n multiple,\n formattedValue,\n loading,\n tabIndex,\n InputLabelProps,\n inputRef,\n }: AutocompleteInputProps) => (\n <TextField\n {...params}\n name={name}\n placeholder={placeholder}\n fullWidth\n error={!!error}\n helperText={helperText}\n label={label}\n required={required}\n inputRef={inputRef}\n InputProps={{\n ...params.InputProps,\n ...(!multiple && {\n startAdornment: inputStartAdornment(formattedValue),\n }),\n endAdornment: (\n <>\n {loading ? <CircularProgress color=\"primary\" size={20} /> : null}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n inputProps={{\n ...params.inputProps,\n name,\n tabIndex,\n }}\n InputLabelProps={InputLabelProps}\n />\n ),\n);\n\nAutocompleteInput.displayName = 'AutocompleteInput';\n\nexport default AutocompleteInput;\n","import {\n createContext,\n forwardRef,\n HTMLAttributes,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport { ListOnItemsRenderedProps, VariableSizeList } from 'react-window';\nimport { AutocompleteRenderGroupParams } from '@mui/material/Autocomplete';\nimport { useTheme } from '@mui/material/styles';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport ListboxRow, { LISTBOX_PADDING } from './ListboxRow';\nimport type { ListboxItem } from './props';\nimport ScrollEndContext from './ScrollEndContext';\n\nconst OuterElementContext = createContext({});\n\nconst OuterElementType = forwardRef<HTMLDivElement>((props, ref) => {\n const outerProps = useContext(OuterElementContext);\n return <div ref={ref} {...props} {...outerProps} />;\n});\n\nOuterElementType.displayName = 'OuterElementType';\n\nconst useResetCache = (data: number) => {\n const ref = useRef<VariableSizeList>(null);\n\n useEffect(() => {\n if (ref.current != null) {\n ref.current.resetAfterIndex(0, true);\n }\n }, [data]);\n\n return ref;\n};\n\nconst ListboxComponent = forwardRef<\n HTMLDivElement,\n HTMLAttributes<HTMLElement>\n>(function ListboxComponent(props, ref) {\n const { children, ...other } = props;\n\n const itemData: ListboxItem[] = useMemo(() => {\n const data: ListboxItem[] = [];\n (children as ListboxItem[]).forEach(item => {\n data.push(item);\n if (\n Object.prototype.hasOwnProperty.call(item, 'children') &&\n Array.isArray((item as AutocompleteRenderGroupParams).children)\n ) {\n data.push(\n ...((item as AutocompleteRenderGroupParams)\n .children as ListboxItem[]),\n );\n }\n });\n return data;\n }, [children]);\n\n const theme = useTheme();\n const smUp = useMediaQuery(theme.breakpoints.up('sm'));\n const itemCount = itemData.length;\n const itemSize = smUp ? 36 : 48;\n\n const getChildSize = useCallback(\n (child: ListboxItem) => {\n if (Object.prototype.hasOwnProperty.call(child, 'group')) {\n return 48;\n }\n\n return itemSize;\n },\n [itemSize],\n );\n\n const itemsHeight = useMemo(() => {\n if (itemCount > 8) {\n return 8 * itemSize;\n }\n return itemData.map(getChildSize).reduce((a, b) => a + b, 0);\n }, [itemCount, itemSize, itemData, getChildSize]);\n\n const gridRef = useResetCache(itemCount);\n const onScrollEnd = useContext(ScrollEndContext);\n const firedRef = useRef(false);\n\n useEffect(() => {\n firedRef.current = false;\n }, [itemCount]);\n\n const handleItemsRendered = useCallback(\n ({ visibleStopIndex }: ListOnItemsRenderedProps) => {\n if (\n onScrollEnd &&\n !firedRef.current &&\n visibleStopIndex >= itemCount - 3\n ) {\n firedRef.current = true;\n onScrollEnd();\n }\n },\n [onScrollEnd, itemCount],\n );\n\n return (\n <div ref={ref}>\n <OuterElementContext.Provider value={other}>\n <VariableSizeList\n itemData={itemData}\n height={itemsHeight + 2 * LISTBOX_PADDING}\n width=\"100%\"\n ref={gridRef}\n outerElementType={OuterElementType}\n innerElementType=\"ul\"\n itemSize={index => getChildSize(itemData[index])}\n overscanCount={5}\n itemCount={itemCount}\n onItemsRendered={handleItemsRendered}\n >\n {ListboxRow}\n </VariableSizeList>\n </OuterElementContext.Provider>\n </div>\n );\n});\n\nexport default ListboxComponent;\n","import { HTMLAttributes, memo } from 'react';\nimport { ListChildComponentProps } from 'react-window';\nimport { AutocompleteRenderGroupParams } from '@mui/material/Autocomplete';\nimport ListSubheader from '@mui/material/ListSubheader';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport { Option } from 'types/option';\n\nimport Icon from '../Icon';\n\nimport type { IconName } from './props';\n\nconst LISTBOX_PADDING = 8;\n\nconst ListboxRow = memo((props: ListChildComponentProps) => {\n const { data, index, style } = props;\n const dataSet = data[index] as\n | AutocompleteRenderGroupParams\n | [HTMLAttributes<HTMLLIElement> & { showValueInLabel?: boolean }, Option];\n\n const inlineStyle = {\n ...style,\n top: (style.top as number) + LISTBOX_PADDING,\n paddingTop: 8,\n };\n\n if (Object.prototype.hasOwnProperty.call(dataSet, 'group')) {\n const groupItem = dataSet as AutocompleteRenderGroupParams;\n return (\n <ListSubheader\n key={`list-box-item-group-${groupItem.group}`}\n component=\"div\"\n style={inlineStyle}\n >\n {groupItem.group}\n </ListSubheader>\n );\n }\n\n const [itemProps, option] = dataSet as [\n HTMLAttributes<HTMLLIElement> & {\n showValueInLabel?: boolean;\n key: string;\n },\n Option,\n ];\n const { showValueInLabel, key, ...otherItemProps } = itemProps;\n\n return (\n <Typography\n component=\"li\"\n key={`list-box-item-${key}`}\n {...otherItemProps}\n noWrap\n style={inlineStyle}\n >\n <Stack\n component=\"div\"\n direction=\"row\"\n flex={1}\n gap={1}\n justifyContent=\"start\"\n >\n {option.icon && <Icon icon={option.icon as IconName} />}\n {option.label}\n\n {showValueInLabel && (\n <Typography variant=\"inherit\" color=\"grey.400\">\n ({option.value})\n </Typography>\n )}\n </Stack>\n </Typography>\n );\n});\n\nListboxRow.displayName = 'ListboxRow';\n\nexport { LISTBOX_PADDING };\nexport default ListboxRow;\n","import { createContext } from 'react';\n\nconst ScrollEndContext = createContext<(() => void) | undefined>(undefined);\n\nexport default ScrollEndContext;\n","import { autocompleteClasses } from '@mui/material/Autocomplete';\nimport Popper from '@mui/material/Popper';\nimport { styled } from '@mui/material/styles';\n\nexport const StyledPopper = styled(Popper)({\n [`& .${autocompleteClasses.listbox}`]: {\n boxSizing: 'border-box',\n '& ul': {\n padding: 0,\n margin: 0,\n },\n },\n});\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as a$9 } from './chunk-
|
|
1
|
+
import { a as a$9 } from './chunk-ZA4ABS3L.js';
|
|
2
2
|
import { a as a$6 } from './chunk-4F2NKGF6.js';
|
|
3
3
|
import { a as a$5 } from './chunk-PRWQQJDL.js';
|
|
4
4
|
import { a as a$3 } from './chunk-SB7J43ND.js';
|
|
@@ -24,4 +24,4 @@ import { GridToolbarColumnsButton } from '@mui/x-data-grid-premium';
|
|
|
24
24
|
var Fo=(o,e)=>typeof o=="function"?o(e):!!o,Ae=(o,e)=>{if(o)return o===!0?{}:typeof o=="function"?o(e):o},ke=({actions:o,context:e})=>{let[t,r]=useState(null),[a$1,i]=useState(null),l=useMemo(()=>o.filter(n=>!Fo(n.hidden,e)),[o,e]),s=useCallback(async n=>{i(n.actionId);try{await n.handler(e);}finally{i(null);}},[e]),d=useCallback(n=>{if(n.confirmation){r(n);return}s(n).catch(()=>{});},[s]),m$1=useCallback(async()=>{t&&(await s(t),r(null));},[t,s]),f=useCallback(()=>{a$1||r(null);},[a$1]),c=Ae(t?.confirmation,e);return jsxs(Fragment,{children:[jsx(m,{children:l.map(n=>{let h=!!a$1||Fo(n.disabled,e),k=a$1===n.actionId;return jsx(Ce,{size:"small",variant:"text",onClick:()=>d(n),loading:k,disabled:h,sx:{color:"text.primary"},startIcon:typeof n.icon=="string"?jsx(a,{icon:n.icon}):n.icon,children:n.label},n.actionId)})}),t&&jsx(a$5,{open:!0,onClose:f,onConfirm:()=>{m$1().catch(()=>{});},confirming:a$1===t.actionId,modalTitle:c?.title??`${t.action??"Excluir"} ${e.selectedCount} ${t.entityName??"registro"}${e.selectedCount!==1?"s":""}?`,message:c?.message??"Esta a\xE7\xE3o n\xE3o poder\xE1 ser desfeita.",cancelButtonText:c?.cancelButtonText??"Cancelar",confirmButtonText:c?.confirmButtonText??"Sim, excluir"})]})},zo=ke;var Re=({title:o,breakpoint:e,actions:t,showActions:r,showAdd:a$1,showHeaderMoreActions:i,showActionsContainer:l,onAdd:s,onOpenMoreActions:d$1})=>jsxs(b$1,{breakpoint:e,children:[jsx(Xo,{variant:"overline",color:"text.secondary",noWrap:!0,children:o}),l&&jsxs(c,{breakpoint:e,children:[r&&t,a$1&&jsxs(Fragment,{children:[r&&jsx(d,{orientation:"vertical",flexItem:!0}),jsx(_o,{startIcon:jsx(a,{icon:"SIMPLE_ADD"}),variant:"contained",onClick:s,children:"Adicionar"})]}),i&&jsxs(Fragment,{children:[(r||a$1)&&jsx(d,{orientation:"vertical",flexItem:!0}),jsx(_o,{color:"inherit",startIcon:jsx(a,{icon:"MORE_BOLD"}),size:"small",onClick:d$1,children:"Mais"})]})]})]}),$o=Re;var De=({fetching:o,loading:e,rows:t,mobileSlots:r$1,mobileSlotsProps:a,slots:i,scrollableNodeRef:l,mobileRender:s,hideFooter:d,onPaginationChange:m,rowCount:f,paginationModel:c})=>jsxs(a$6,{isFetching:o,fetching:jsx(a$7,{}),isLoading:e,loading:jsx(q,{}),isEmpty:t.length===0,empty:jsxs(to,{flex:1,direction:"column",...a,children:[r$1&&r$1,jsx(to,{flex:1,alignItems:"center",justifyContent:"center",children:i?.noRowsOverlay?jsx(i.noRowsOverlay,{}):jsx(Xo,{variant:"body2",color:"text.secondary",children:"Nenhum registro encontrado"})})]}),children:[jsxs(to,{direction:"column",flex:1,minHeight:0,...a,children:[r$1&&r$1,jsx(a$8,{fillContent:!0,ref:l,children:t.map(n=>jsx(Fragment$1,{children:s(n)},n.id))})]}),!d&&m&&jsx(h,{children:jsx(r,{count:f,page:c.page,rowsPerPage:c.pageSize,onPageChange:n=>m?.(n,c.pageSize),onRowsPerPageChange:n=>m?.(0,n)})})]}),qo=De;var z="datagrid-actions";var Ko=(o,e)=>Children.map(o,t=>{if(!isValidElement(t))return t;let r=t.props.onClick,a={};a.onClick=(...l)=>{e(),r&&r(...l);};let i=t.props;return i?.children&&(a.children=Ko(i.children,e)),cloneElement(t,a)}),ve=({children:o,onClose:e})=>o?Ko(o,e):null,ro=memo(ve);var Ve=({breakpoint:o$1,isMobile:e$1,showSearch:t,showMoreActions:r,showTopbarMoreActions:a$1,showHeaderMoreActions:i,filterButton:l,searchValue:s,onSearch:d,onSearchChange:m,moreActions:f$1,popover:c})=>jsxs(f,{breakpoint:o$1,children:[jsxs(to,{flex:1,direction:"row",alignItems:"center",id:z,gap:.5,children:[r&&jsxs(Fragment,{children:[a$1&&jsxs(Fragment,{children:[jsx(_o,{color:"inherit",startIcon:jsx(a,{icon:"MORE_BOLD"}),size:"small",onClick:c.onOpen,children:"Mais"}),!e$1&&jsx(e,{orientation:"vertical",flexItem:!0})]}),(a$1||i)&&jsx(o,{open:c.open,anchorEl:c.open,onClose:c.onClose,disabledArrow:!0,children:jsx(ro,{onClose:c.onClose,children:f$1})})]}),!e$1&&l&&jsxs(Fragment,{children:[l,a$1&&jsx(e,{orientation:"vertical",flexItem:!0})]})]}),t&&jsxs(g,{breakpoint:o$1,children:[jsx(a$9,{value:s,placeholder:"Buscar",onSearch:n=>d(n??""),onChange:n=>m?.(n.target.value),size:"small",fullWidth:!0,iconPosition:"start"}),e$1&&l&&jsx(to,{ml:1,children:l})]})]}),Jo=Ve;var Oe=({rowCount:o,page:e,rowsPerPage:t,onPaginationChange:r$1})=>jsxs(i,{children:[jsxs(to,{direction:"row",alignItems:"center",gap:.5,children:[jsx(Xo,{variant:"body2",color:"text.disabled",children:"Total de itens:"}),jsx(Xo,{variant:"body2",children:o})]}),jsx(r,{count:o,page:e,rowsPerPage:t,onPageChange:a=>r$1(a,t),onRowsPerPageChange:a=>r$1(0,a)})]}),lo=memo(Oe);var ze=forwardRef(({children:o,...e},t)=>jsx(_o,{...e,ref:t,color:"inherit",startIcon:jsx(a,{icon:"COLUMNS"}),children:o??"Colunas"}));ze.displayName="ColumnsButton";var _e=({setFilterButtonEl:o})=>{let e=useCallback(t=>{o(t);},[o]);return jsx(a$4,{container:z,children:jsx(GridToolbarColumnsButton,{ref:e,slotProps:{button:{color:"inherit",startIcon:jsx(a,{icon:"COLUMNS"}),children:"Colunas"}}})})},so=_e;var qe=({slots:o,showColumnButton:e,rowCount:t,paginationModel:r,onPaginationChange:a})=>{let i=useCallback(()=>a?jsx(lo,{rowCount:t,page:r.page,rowsPerPage:r.pageSize,onPaginationChange:a}):null,[t,r,a]);return {dataGridSlots:useMemo(()=>({...o,footer:i,...e&&!o?.toolbar&&{toolbar:so}}),[o,i,e])}},Zo=qe;var Qe=({rows:o,rowSelectionModel:e,onRowSelectionModelChange:t,getRowId:r,bulkActions:a})=>{let i=useMemo(()=>Array.isArray(e)?e:[],[e]),l=i.length,s=useMemo(()=>o.map(S=>r(S)),[o,r]),d=useMemo(()=>new Set(s),[s]),m=useMemo(()=>i.reduce((S,C)=>S+(d.has(C)?1:0),0),[i,d]),f=s.length>0&&m===s.length,c=m>0&&!f,n=useCallback(S=>{t&&t(S);},[t]),h=useCallback(()=>{n([]);},[n]),k=useMemo(()=>new Set(i),[i]),I=useMemo(()=>o.filter(S=>k.has(r(S))),[o,k,r]),_=useMemo(()=>({selectedIds:i,selectedRowsInPage:I,selectedCount:l,clearSelection:h}),[i,I,l,h]),W=!!a?.length,v=useCallback((S,C)=>{if(!t)return;if(C){let M=new Set(i),V=[...i];s.forEach(x=>{M.has(x)||V.push(x);}),n(V);return}let G=i.filter(M=>!d.has(M));n(G);},[t,i,s,d,n]);return {selectionModel:i,numSelected:l,allSelected:f,someSelected:c,hasBulkActions:W,bulkActionContext:_,clearSelection:h,handleSelectAllToggle:v}},jo=Qe;var nt=({title:o,header:e,headerProps:t,breakpoint:r="md",columns:a$4,rows:i=[],mobileSlots:l$1,mobileSlotsProps:s,mobileRender:d,rowCount:m=0,paginationModel:f={page:0,pageSize:25},onPaginationChange:c,actions:n$1,moreActions:h,onAdd:k$1,onSearch:I,searchValue:_,onSearchChange:W,slots:v,slotProps:S,loading:C,fetching:G,fetchingNextPage:M,containerProps:V={height:562,maxHeight:562},hideFooter:x,showColumnButton:mo=!1,filterButton:po,activeFilters:uo,bulkActions:fo,onRowsScrollEnd:E,scrollEndThreshold:$=200,...R})=>{let So=a$1(),T=b("down",r),[te,ne]=useState(null),go=useRef(null);useEffect(()=>{let P=go.current;if(!P||!T||!E)return;let wo=()=>{let{scrollTop:fe,scrollHeight:Se,clientHeight:ge}=P;Se-fe-ge<=$&&E();};return P.addEventListener("scroll",wo,{passive:!0}),()=>{P.removeEventListener("scroll",wo);}},[T,E,$,i.length]);let re=useMemo(()=>R.getRowId??(P=>P.id),[R.getRowId]),{numSelected:q,allSelected:ie,someSelected:ae,hasBulkActions:le,bulkActionContext:se,clearSelection:ce,handleSelectAllToggle:de}=jo({rows:i,rowSelectionModel:Array.isArray(R.rowSelectionModel)?R.rowSelectionModel:void 0,onRowSelectionModelChange:R.onRowSelectionModelChange,getRowId:re,bulkActions:fo}),{dataGridSlots:me}=Zo({slots:v,showColumnButton:mo,rowCount:m,paginationModel:f,onPaginationChange:c}),ho=!!I,Co=!!k$1,Ao=!!n$1,K=!!h,Q=T&&K,ko=!T&&K,pe=Ao||Co||Q,To=ko||ho||mo||!!po||!T,ue=le&&q>0&&jsxs(k,{children:[jsxs(to,{flexDirection:"row",alignItems:"center",gap:1,flex:1,children:[jsx(ee,{title:"Selecione todos nessa pagina",children:jsx(n,{size:"small",checked:ie,indeterminate:ae,onChange:de})}),jsxs(l,{variant:"body2",children:[q," selecionado",q>1?"s":""]}),jsx(ee,{title:"Desselecionar tudo",children:jsx(et,{size:"small",onClick:ce,"aria-label":"Desselecionar tudo",sx:{color:"primary.main"},children:jsx(a,{icon:"CLOSE_MARK_BUTTON",width:18,height:18})})})]}),jsx(zo,{actions:fo??[],context:se})]});return jsxs(a$2,{breakpoint:r,...V,flex:C?1:void 0,minHeight:C||i.length===0?562:void 0,children:[e?jsx(to,{p:3,...t,children:e}):jsxs(Fragment,{children:[jsx($o,{title:o,breakpoint:r,actions:n$1,showActions:Ao,showAdd:Co,showHeaderMoreActions:Q,showActionsContainer:pe,onAdd:k$1,onOpenMoreActions:So.onOpen}),To&&jsx(Jo,{breakpoint:r,isMobile:T,showSearch:ho,showMoreActions:K,showTopbarMoreActions:ko,showHeaderMoreActions:Q,filterButton:po,searchValue:_,onSearch:I,onSearchChange:W,moreActions:h,popover:So}),uo&&uo,!To&&jsx(p,{})]}),T?jsx(qo,{fetching:G,loading:C,rows:i,mobileSlots:l$1,mobileSlotsProps:s,slots:v,scrollableNodeRef:go,mobileRender:d,hideFooter:x,onPaginationChange:c,rowCount:m,paginationModel:f}):jsxs(j,{children:[ue,jsx(a$3,{columns:a$4,rows:i,slots:me,slotProps:{panel:{anchorEl:te},toolbar:{setFilterButtonEl:ne,showQuickFilter:!0},...S},columnHeaderHeight:48,getRowHeight:()=>68,loading:C,fetching:G,hideFooter:x,onRowsScrollEnd:E,scrollEndThreshold:$,...R})]}),M&&jsx(tt,{})]})},yn=memo(nt,ot);
|
|
25
25
|
|
|
26
26
|
export { ro as a, lo as b, so as c, yn as d };
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-XADW5XM2.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a } from './chunk-STWQUEEE.js';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import g from '@mui/material/IconButton';
|
|
4
|
+
import c from '@mui/material/InputAdornment';
|
|
5
|
+
import h from '@mui/material/TextField';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var k=({onSearch:n,onChange:a$1,trigger:d="click",iconPosition:r="end",tabIndex:f,InputProps:e,iconButtonAriaLabel:s="Buscar",iconButtonProps:I,...o})=>{let u=useRef(null),i=jsx(g,{color:"inherit",...I,onClick:()=>{n(u.current?.value);},"aria-label":s,children:jsx(a,{icon:"SEARCH_MAGNIFYING_GLASS",width:20,height:20,color:"text.secondary"})});return jsx(h,{inputRef:u,sx:{"& .MuiOutlinedInput-root":{backgroundColor:"background.paper","& input::placeholder":{color:"text.disabled",opacity:.7}}},InputProps:{...e,onKeyDown:t=>{t.key==="Enter"&&(n(u.current?.value),t.preventDefault());},...r==="start"?{startAdornment:jsxs(c,{position:r,children:[i,e?.startAdornment]})}:{endAdornment:jsxs(c,{position:r,children:[i,e?.endAdornment]})}},inputProps:{tabIndex:f,name:o.name,...o.inputProps},onChange:t=>{if(d==="change"){n(t.target.value);return}t.target.value===""&&n(""),a$1&&a$1(t);},...o})},B=k;
|
|
9
|
+
|
|
10
|
+
export { B as a };
|
|
11
|
+
//# sourceMappingURL=chunk-ZA4ABS3L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/SearchInput/index.tsx"],"names":["useRef","IconButton","InputAdornment","TextField","jsx","jsxs","SearchInput","onSearch","onChange","trigger","iconPosition","tabIndex","InputProps","iconButtonAriaLabel","iconButtonProps","other","inputRef","seachIcon","Icon_default","e","SearchInput_default"],"mappings":"wCAAA,OAAS,UAAAA,MAAc,QACvB,OAAOC,MAAgB,2BACvB,OAAOC,MAAoB,+BAC3B,OAAOC,MAAe,0BA4BhB,cAAAC,EAgCU,QAAAC,MAhCV,oBAtBN,IAAMC,EAAc,CAAC,CACnB,SAAAC,EACA,SAAAC,EACA,QAAAC,EAAU,QACV,aAAAC,EAAe,MACf,SAAAC,EACA,WAAAC,EACA,oBAAAC,EAAsB,SACtB,gBAAAC,EACA,GAAGC,CACL,IAAwB,CACtB,IAAMC,EAAWhB,EAAyB,IAAI,EAExCiB,EACJb,EAACH,EAAA,CACC,MAAM,UACL,GAAGa,EACJ,QAAS,IAAM,CACbP,EAASS,EAAS,SAAS,KAAK,CAClC,EACA,aAAYH,EAEZ,SAAAT,EAACc,EAAA,CACC,KAAK,0BACL,MAAO,GACP,OAAQ,GACR,MAAM,iBACR,EACF,EAGF,OACEd,EAACD,EAAA,CACC,SAAUa,EACV,GAAI,CACF,2BAA4B,CAC1B,gBAAiB,mBACjB,uBAAwB,CACtB,MAAO,gBACP,QAAS,EACX,CACF,CACF,EACA,WAAY,CACV,GAAGJ,EACH,UAAWO,GAAK,CACVA,EAAE,MAAQ,UACZZ,EAASS,EAAS,SAAS,KAAK,EAChCG,EAAE,eAAe,EAErB,EACA,GAAIT,IAAiB,QACjB,CACE,eACEL,EAACH,EAAA,CAAe,SAAUQ,EACvB,UAAAO,EACAL,GAAY,gBACf,CAEJ,EACA,CACE,aACEP,EAACH,EAAA,CAAe,SAAUQ,EACvB,UAAAO,EACAL,GAAY,cACf,CAEJ,CACN,EACA,WAAY,CACV,SAAAD,EACA,KAAMI,EAAM,KACZ,GAAGA,EAAM,UACX,EACA,SAAUI,GAAK,CACb,GAAIV,IAAY,SAAU,CACxBF,EAASY,EAAE,OAAO,KAAK,EACvB,OAGEA,EAAE,OAAO,QAAU,IAAIZ,EAAS,EAAE,EAElCC,GAAUA,EAASW,CAAC,CAC1B,EACC,GAAGJ,EACN,CAEJ,EAEOK,EAAQd","sourcesContent":["import { useRef } from 'react';\nimport IconButton from '@mui/material/IconButton';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport TextField from '@mui/material/TextField';\n\nimport { SearchInputProps } from 'types/searchInputProps';\n\nimport Icon from '../Icon';\n\nconst SearchInput = ({\n onSearch,\n onChange,\n trigger = 'click',\n iconPosition = 'end',\n tabIndex,\n InputProps,\n iconButtonAriaLabel = 'Buscar',\n iconButtonProps,\n ...other\n}: SearchInputProps) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const seachIcon = (\n <IconButton\n color=\"inherit\"\n {...iconButtonProps}\n onClick={() => {\n onSearch(inputRef.current?.value);\n }}\n aria-label={iconButtonAriaLabel}\n >\n <Icon\n icon=\"SEARCH_MAGNIFYING_GLASS\"\n width={20}\n height={20}\n color=\"text.secondary\"\n />\n </IconButton>\n );\n\n return (\n <TextField\n inputRef={inputRef}\n sx={{\n '& .MuiOutlinedInput-root': {\n backgroundColor: 'background.paper',\n '& input::placeholder': {\n color: 'text.disabled',\n opacity: 0.7,\n },\n },\n }}\n InputProps={{\n ...InputProps,\n onKeyDown: e => {\n if (e.key === 'Enter') {\n onSearch(inputRef.current?.value);\n e.preventDefault();\n }\n },\n ...(iconPosition === 'start'\n ? {\n startAdornment: (\n <InputAdornment position={iconPosition}>\n {seachIcon}\n {InputProps?.startAdornment}\n </InputAdornment>\n ),\n }\n : {\n endAdornment: (\n <InputAdornment position={iconPosition}>\n {seachIcon}\n {InputProps?.endAdornment}\n </InputAdornment>\n ),\n }),\n }}\n inputProps={{\n tabIndex,\n name: other.name,\n ...other.inputProps,\n }}\n onChange={e => {\n if (trigger === 'change') {\n onSearch(e.target.value);\n return;\n }\n\n if (e.target.value === '') onSearch('');\n\n if (onChange) onChange(e);\n }}\n {...other}\n />\n );\n};\n\nexport default SearchInput;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { e, c as c$1, f, a as a$d, d as d$3 } from '../../../chunk-Z3HTIXB2.js';
|
|
2
|
-
import { a as a$b } from '../../../chunk-
|
|
2
|
+
import { a as a$b } from '../../../chunk-OAETEHZS.js';
|
|
3
3
|
import { i, h as h$2 } from '../../../chunk-BBVOF2BY.js';
|
|
4
4
|
import { a as a$c, b as b$1, c as c$3 } from '../../../chunk-6X3GKY7E.js';
|
|
5
5
|
import { a as a$2 } from '../../../chunk-Q2R3X4EB.js';
|
|
@@ -12,8 +12,8 @@ import { a as a$a } from '../../../chunk-P4AHHSI7.js';
|
|
|
12
12
|
import { d as d$2, h as h$1, m } from '../../../chunk-2W5FGLTC.js';
|
|
13
13
|
import { h, c as c$2 } from '../../../chunk-OF6623HG.js';
|
|
14
14
|
import { a as a$7 } from '../../../chunk-MTJT2RGA.js';
|
|
15
|
-
import { d as d$1 } from '../../../chunk-
|
|
16
|
-
import '../../../chunk-
|
|
15
|
+
import { d as d$1 } from '../../../chunk-XADW5XM2.js';
|
|
16
|
+
import '../../../chunk-ZA4ABS3L.js';
|
|
17
17
|
import '../../../chunk-4F2NKGF6.js';
|
|
18
18
|
import '../../../chunk-PRWQQJDL.js';
|
|
19
19
|
import '../../../chunk-SB7J43ND.js';
|
|
@@ -23,7 +23,7 @@ import '../../../chunk-NIQW2J3M.js';
|
|
|
23
23
|
import '../../../chunk-XUDTPZHF.js';
|
|
24
24
|
import '../../../chunk-UVPQR2Q2.js';
|
|
25
25
|
import '../../../chunk-RBTYTONM.js';
|
|
26
|
-
import '../../../chunk-
|
|
26
|
+
import '../../../chunk-SUOJNPZZ.js';
|
|
27
27
|
import { a } from '../../../chunk-CO2KQFUN.js';
|
|
28
28
|
import { a as a$3 } from '../../../chunk-STWQUEEE.js';
|
|
29
29
|
import '../../../chunk-Z6YXPKWP.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d, e as e$1 } from '../../../chunk-K2PWIYEM.js';
|
|
2
2
|
import { a as a$d } from '../../../chunk-K34AZXX4.js';
|
|
3
|
-
import { a as a$h } from '../../../chunk-
|
|
3
|
+
import { a as a$h } from '../../../chunk-OAETEHZS.js';
|
|
4
4
|
import { i as i$1, h as h$1 } from '../../../chunk-BBVOF2BY.js';
|
|
5
5
|
import { a as a$g, b as b$1, c as c$1 } from '../../../chunk-6X3GKY7E.js';
|
|
6
6
|
import { a as a$5 } from '../../../chunk-DRGARBKB.js';
|
|
@@ -14,7 +14,7 @@ import { a as a$3 } from '../../../chunk-HE2LUROB.js';
|
|
|
14
14
|
import { a as a$f } from '../../../chunk-5J35UAV6.js';
|
|
15
15
|
import { a as a$e } from '../../../chunk-4F2NKGF6.js';
|
|
16
16
|
import { a } from '../../../chunk-AZJ3VCNL.js';
|
|
17
|
-
import '../../../chunk-
|
|
17
|
+
import '../../../chunk-SUOJNPZZ.js';
|
|
18
18
|
import { a as a$a } from '../../../chunk-CO2KQFUN.js';
|
|
19
19
|
import { a as a$1 } from '../../../chunk-STWQUEEE.js';
|
|
20
20
|
import '../../../chunk-Z6YXPKWP.js';
|
|
@@ -8,8 +8,8 @@ import { a as a$4 } from '../../../chunk-P4AHHSI7.js';
|
|
|
8
8
|
import { d as d$2 } from '../../../chunk-2W5FGLTC.js';
|
|
9
9
|
import { h, d as d$1, c as c$2 } from '../../../chunk-OF6623HG.js';
|
|
10
10
|
import '../../../chunk-5J35UAV6.js';
|
|
11
|
-
import { d } from '../../../chunk-
|
|
12
|
-
import { a as a$3 } from '../../../chunk-
|
|
11
|
+
import { d } from '../../../chunk-XADW5XM2.js';
|
|
12
|
+
import { a as a$3 } from '../../../chunk-ZA4ABS3L.js';
|
|
13
13
|
import { a as a$1 } from '../../../chunk-4F2NKGF6.js';
|
|
14
14
|
import '../../../chunk-PRWQQJDL.js';
|
|
15
15
|
import '../../../chunk-SB7J43ND.js';
|
|
@@ -7,8 +7,8 @@ import { a as a$5 } from '../../../chunk-LJCSQMGX.js';
|
|
|
7
7
|
import { a as a$4 } from '../../../chunk-P4AHHSI7.js';
|
|
8
8
|
import { d as d$2 } from '../../../chunk-2W5FGLTC.js';
|
|
9
9
|
import { h, d, a as a$7, c as c$1 } from '../../../chunk-OF6623HG.js';
|
|
10
|
-
import { d as d$1 } from '../../../chunk-
|
|
11
|
-
import { a as a$3 } from '../../../chunk-
|
|
10
|
+
import { d as d$1 } from '../../../chunk-XADW5XM2.js';
|
|
11
|
+
import { a as a$3 } from '../../../chunk-ZA4ABS3L.js';
|
|
12
12
|
import { a as a$1 } from '../../../chunk-4F2NKGF6.js';
|
|
13
13
|
import '../../../chunk-PRWQQJDL.js';
|
|
14
14
|
import '../../../chunk-SB7J43ND.js';
|
|
@@ -8,7 +8,7 @@ import { a as a$1 } from '../../chunk-LJCSQMGX.js';
|
|
|
8
8
|
import { a } from '../../chunk-P4AHHSI7.js';
|
|
9
9
|
import { c } from '../../chunk-VGTQYKAC.js';
|
|
10
10
|
import { a as a$3 } from '../../chunk-4F2NKGF6.js';
|
|
11
|
-
import { a as a$a } from '../../chunk-
|
|
11
|
+
import { a as a$a } from '../../chunk-SUOJNPZZ.js';
|
|
12
12
|
import { a as a$6 } from '../../chunk-CO2KQFUN.js';
|
|
13
13
|
import { a as a$4 } from '../../chunk-STWQUEEE.js';
|
|
14
14
|
import '../../chunk-Z6YXPKWP.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a } from '../../chunk-
|
|
1
|
+
import { a } from '../../chunk-OTCYO765.js';
|
|
2
2
|
import { r } from '../../chunk-XUDTPZHF.js';
|
|
3
3
|
import '../../chunk-UVPQR2Q2.js';
|
|
4
4
|
import { a as a$1 } from '../../chunk-RBTYTONM.js';
|
|
5
|
-
import '../../chunk-
|
|
5
|
+
import '../../chunk-SUOJNPZZ.js';
|
|
6
6
|
import '../../chunk-CO2KQFUN.js';
|
|
7
7
|
import { a as a$2 } from '../../chunk-STWQUEEE.js';
|
|
8
8
|
import '../../chunk-Z6YXPKWP.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { b as DesktopFooter, a as EnhancedMoreActions, c as Toolbar, d as default } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { b as DesktopFooter, a as EnhancedMoreActions, c as Toolbar, d as default } from '../../chunk-XADW5XM2.js';
|
|
2
|
+
import '../../chunk-ZA4ABS3L.js';
|
|
3
3
|
import '../../chunk-4F2NKGF6.js';
|
|
4
4
|
import '../../chunk-PRWQQJDL.js';
|
|
5
5
|
import '../../chunk-SB7J43ND.js';
|
|
@@ -6,8 +6,8 @@ import { d, c } from '../../chunk-2W5FGLTC.js';
|
|
|
6
6
|
import { h, a as a$6 } from '../../chunk-OF6623HG.js';
|
|
7
7
|
import { a as a$5 } from '../../chunk-RHQILFII.js';
|
|
8
8
|
import '../../chunk-5J35UAV6.js';
|
|
9
|
-
import { d as d$1 } from '../../chunk-
|
|
10
|
-
import '../../chunk-
|
|
9
|
+
import { d as d$1 } from '../../chunk-XADW5XM2.js';
|
|
10
|
+
import '../../chunk-ZA4ABS3L.js';
|
|
11
11
|
import '../../chunk-4F2NKGF6.js';
|
|
12
12
|
import '../../chunk-PRWQQJDL.js';
|
|
13
13
|
import '../../chunk-SB7J43ND.js';
|
|
@@ -17,7 +17,7 @@ import '../../chunk-NIQW2J3M.js';
|
|
|
17
17
|
import { e } from '../../chunk-XUDTPZHF.js';
|
|
18
18
|
import '../../chunk-UVPQR2Q2.js';
|
|
19
19
|
import '../../chunk-RBTYTONM.js';
|
|
20
|
-
import { a as a$3 } from '../../chunk-
|
|
20
|
+
import { a as a$3 } from '../../chunk-SUOJNPZZ.js';
|
|
21
21
|
import '../../chunk-CO2KQFUN.js';
|
|
22
22
|
import { a } from '../../chunk-STWQUEEE.js';
|
|
23
23
|
import '../../chunk-Z6YXPKWP.js';
|
|
@@ -2,7 +2,7 @@ import { a as a$3 } from '../../chunk-J7RPKCIN.js';
|
|
|
2
2
|
import { a as a$2 } from '../../chunk-XAPSXJZO.js';
|
|
3
3
|
import { c } from '../../chunk-VGTQYKAC.js';
|
|
4
4
|
import { a as a$7 } from '../../chunk-RYAZSEY4.js';
|
|
5
|
-
import { a as a$4 } from '../../chunk-
|
|
5
|
+
import { a as a$4 } from '../../chunk-SUOJNPZZ.js';
|
|
6
6
|
import { a } from '../../chunk-CO2KQFUN.js';
|
|
7
7
|
import { a as a$6 } from '../../chunk-STWQUEEE.js';
|
|
8
8
|
import '../../chunk-Z6YXPKWP.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { SearchInputProps } from '../../types/searchInputProps.js';
|
|
3
|
+
import '@mui/material/IconButton';
|
|
3
4
|
import '@mui/material/TextField';
|
|
4
5
|
|
|
5
|
-
declare const SearchInput: ({ onSearch, onChange, trigger, iconPosition, tabIndex, InputProps, iconButtonAriaLabel, ...other }: SearchInputProps) => react_jsx_runtime.JSX.Element;
|
|
6
|
+
declare const SearchInput: ({ onSearch, onChange, trigger, iconPosition, tabIndex, InputProps, iconButtonAriaLabel, iconButtonProps, ...other }: SearchInputProps) => react_jsx_runtime.JSX.Element;
|
|
6
7
|
|
|
7
8
|
export { SearchInput as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { a as default } from '../../chunk-
|
|
1
|
+
export { a as default } from '../../chunk-2TSB3SAD.js';
|
|
2
2
|
import '../../chunk-RUABKHIV.js';
|
|
3
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-ZA4ABS3L.js';
|
|
4
4
|
import '../../chunk-4F2NKGF6.js';
|
|
5
5
|
import '../../chunk-6U5LS7MP.js';
|
|
6
6
|
import '../../chunk-RYAZSEY4.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { a as default } from '../../chunk-
|
|
1
|
+
export { a as default } from '../../chunk-GI7NSBVO.js';
|
|
2
2
|
import '../../chunk-6ZSTKYGL.js';
|
|
3
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-ZA4ABS3L.js';
|
|
4
4
|
import '../../chunk-4F2NKGF6.js';
|
|
5
5
|
import '../../chunk-NIQW2J3M.js';
|
|
6
6
|
import '../../chunk-STWQUEEE.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as a$2 } from '../../chunk-6ZSTKYGL.js';
|
|
2
|
-
import { a } from '../../chunk-
|
|
2
|
+
import { a } from '../../chunk-ZA4ABS3L.js';
|
|
3
3
|
import { a as a$1 } from '../../chunk-4F2NKGF6.js';
|
|
4
4
|
import '../../chunk-NIQW2J3M.js';
|
|
5
5
|
import { a as a$4 } from '../../chunk-STWQUEEE.js';
|
|
@@ -2,8 +2,8 @@ import { a as a$3 } from '../../../chunk-MSCOIJQ5.js';
|
|
|
2
2
|
import { a } from '../../../chunk-X64QHBVQ.js';
|
|
3
3
|
import { a as a$1 } from '../../../chunk-P2QZJ57W.js';
|
|
4
4
|
import '../../../chunk-RTC7H5E5.js';
|
|
5
|
-
import { a as a$2 } from '../../../chunk-
|
|
6
|
-
import '../../../chunk-
|
|
5
|
+
import { a as a$2 } from '../../../chunk-OTCYO765.js';
|
|
6
|
+
import '../../../chunk-SUOJNPZZ.js';
|
|
7
7
|
import '../../../chunk-STWQUEEE.js';
|
|
8
8
|
import '../../../chunk-Z6YXPKWP.js';
|
|
9
9
|
import L from '@mui/material/CircularProgress';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as default } from '../../../chunk-
|
|
2
|
-
import '../../../chunk-
|
|
1
|
+
export { a as default } from '../../../chunk-OTCYO765.js';
|
|
2
|
+
import '../../../chunk-SUOJNPZZ.js';
|
|
3
3
|
import '../../../chunk-STWQUEEE.js';
|
|
4
4
|
import '../../../chunk-Z6YXPKWP.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a } from '../../../chunk-
|
|
1
|
+
import { a } from '../../../chunk-2TSB3SAD.js';
|
|
2
2
|
import '../../../chunk-RUABKHIV.js';
|
|
3
|
-
import '../../../chunk-
|
|
3
|
+
import '../../../chunk-ZA4ABS3L.js';
|
|
4
4
|
import '../../../chunk-4F2NKGF6.js';
|
|
5
5
|
import '../../../chunk-6U5LS7MP.js';
|
|
6
6
|
import '../../../chunk-RYAZSEY4.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a } from '../../../chunk-
|
|
1
|
+
import { a } from '../../../chunk-GI7NSBVO.js';
|
|
2
2
|
import '../../../chunk-6ZSTKYGL.js';
|
|
3
|
-
import '../../../chunk-
|
|
3
|
+
import '../../../chunk-ZA4ABS3L.js';
|
|
4
4
|
import '../../../chunk-4F2NKGF6.js';
|
|
5
5
|
import '../../../chunk-NIQW2J3M.js';
|
|
6
6
|
import '../../../chunk-STWQUEEE.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as a$1 } from '../../../chunk-P2QZJ57W.js';
|
|
2
2
|
import { a as a$3 } from '../../../chunk-RYAZSEY4.js';
|
|
3
|
-
import { a as a$2 } from '../../../chunk-
|
|
4
|
-
import '../../../chunk-
|
|
3
|
+
import { a as a$2 } from '../../../chunk-OTCYO765.js';
|
|
4
|
+
import '../../../chunk-SUOJNPZZ.js';
|
|
5
5
|
import { a } from '../../../chunk-STWQUEEE.js';
|
|
6
6
|
import '../../../chunk-Z6YXPKWP.js';
|
|
7
7
|
import { useCallback, useMemo } from 'react';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IconButtonProps } from '@mui/material/IconButton';
|
|
1
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
2
3
|
|
|
3
4
|
type SearchInputProps = TextFieldProps & {
|
|
@@ -5,6 +6,7 @@ type SearchInputProps = TextFieldProps & {
|
|
|
5
6
|
trigger?: 'change' | 'click';
|
|
6
7
|
iconPosition?: 'start' | 'end';
|
|
7
8
|
iconButtonAriaLabel?: string;
|
|
9
|
+
iconButtonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label'>;
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
export { SearchInputProps };
|
package/package.json
CHANGED
package/dist/chunk-PXC4AAOB.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-STWQUEEE.js';
|
|
2
|
-
import { useRef } from 'react';
|
|
3
|
-
import A from '@mui/material/IconButton';
|
|
4
|
-
import c from '@mui/material/InputAdornment';
|
|
5
|
-
import g from '@mui/material/TextField';
|
|
6
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
-
|
|
8
|
-
var h=({onSearch:n,onChange:a$1,trigger:d="click",iconPosition:r="end",tabIndex:f,InputProps:e,iconButtonAriaLabel:s="Buscar",...o})=>{let u=useRef(null),i=jsx(A,{color:"inherit",onClick:()=>{n(u.current?.value);},"aria-label":s,children:jsx(a,{icon:"SEARCH_MAGNIFYING_GLASS",width:20,height:20,color:"text.secondary"})});return jsx(g,{inputRef:u,sx:{"& .MuiOutlinedInput-root":{backgroundColor:"background.paper","& input::placeholder":{color:"text.disabled",opacity:.7}}},InputProps:{...e,onKeyDown:t=>{t.key==="Enter"&&(n(u.current?.value),t.preventDefault());},...r==="start"?{startAdornment:jsxs(c,{position:r,children:[i,e?.startAdornment]})}:{endAdornment:jsxs(c,{position:r,children:[i,e?.endAdornment]})}},inputProps:{tabIndex:f,name:o.name,...o.inputProps},onChange:t=>{if(d==="change"){n(t.target.value);return}t.target.value===""&&n(""),a$1&&a$1(t);},...o})},R=h;
|
|
9
|
-
|
|
10
|
-
export { R as a };
|
|
11
|
-
//# sourceMappingURL=chunk-PXC4AAOB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/SearchInput/index.tsx"],"names":["useRef","IconButton","InputAdornment","TextField","jsx","jsxs","SearchInput","onSearch","onChange","trigger","iconPosition","tabIndex","InputProps","iconButtonAriaLabel","other","inputRef","seachIcon","Icon_default","e","SearchInput_default"],"mappings":"wCAAA,OAAS,UAAAA,MAAc,QACvB,OAAOC,MAAgB,2BACvB,OAAOC,MAAoB,+BAC3B,OAAOC,MAAe,0BA0BhB,cAAAC,EAgCU,QAAAC,MAhCV,oBApBN,IAAMC,EAAc,CAAC,CACnB,SAAAC,EACA,SAAAC,EACA,QAAAC,EAAU,QACV,aAAAC,EAAe,MACf,SAAAC,EACA,WAAAC,EACA,oBAAAC,EAAsB,SACtB,GAAGC,CACL,IAAwB,CACtB,IAAMC,EAAWf,EAAyB,IAAI,EAExCgB,EACJZ,EAACH,EAAA,CACC,MAAM,UACN,QAAS,IAAM,CACbM,EAASQ,EAAS,SAAS,KAAK,CAClC,EACA,aAAYF,EAEZ,SAAAT,EAACa,EAAA,CACC,KAAK,0BACL,MAAO,GACP,OAAQ,GACR,MAAM,iBACR,EACF,EAGF,OACEb,EAACD,EAAA,CACC,SAAUY,EACV,GAAI,CACF,2BAA4B,CAC1B,gBAAiB,mBACjB,uBAAwB,CACtB,MAAO,gBACP,QAAS,EACX,CACF,CACF,EACA,WAAY,CACV,GAAGH,EACH,UAAWM,GAAK,CACVA,EAAE,MAAQ,UACZX,EAASQ,EAAS,SAAS,KAAK,EAChCG,EAAE,eAAe,EAErB,EACA,GAAIR,IAAiB,QACjB,CACE,eACEL,EAACH,EAAA,CAAe,SAAUQ,EACvB,UAAAM,EACAJ,GAAY,gBACf,CAEJ,EACA,CACE,aACEP,EAACH,EAAA,CAAe,SAAUQ,EACvB,UAAAM,EACAJ,GAAY,cACf,CAEJ,CACN,EACA,WAAY,CACV,SAAAD,EACA,KAAMG,EAAM,KACZ,GAAGA,EAAM,UACX,EACA,SAAUI,GAAK,CACb,GAAIT,IAAY,SAAU,CACxBF,EAASW,EAAE,OAAO,KAAK,EACvB,OAGEA,EAAE,OAAO,QAAU,IAAIX,EAAS,EAAE,EAElCC,GAAUA,EAASU,CAAC,CAC1B,EACC,GAAGJ,EACN,CAEJ,EAEOK,EAAQb","sourcesContent":["import { useRef } from 'react';\nimport IconButton from '@mui/material/IconButton';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport TextField from '@mui/material/TextField';\n\nimport { SearchInputProps } from 'types/searchInputProps';\n\nimport Icon from '../Icon';\n\nconst SearchInput = ({\n onSearch,\n onChange,\n trigger = 'click',\n iconPosition = 'end',\n tabIndex,\n InputProps,\n iconButtonAriaLabel = 'Buscar',\n ...other\n}: SearchInputProps) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const seachIcon = (\n <IconButton\n color=\"inherit\"\n onClick={() => {\n onSearch(inputRef.current?.value);\n }}\n aria-label={iconButtonAriaLabel}\n >\n <Icon\n icon=\"SEARCH_MAGNIFYING_GLASS\"\n width={20}\n height={20}\n color=\"text.secondary\"\n />\n </IconButton>\n );\n\n return (\n <TextField\n inputRef={inputRef}\n sx={{\n '& .MuiOutlinedInput-root': {\n backgroundColor: 'background.paper',\n '& input::placeholder': {\n color: 'text.disabled',\n opacity: 0.7,\n },\n },\n }}\n InputProps={{\n ...InputProps,\n onKeyDown: e => {\n if (e.key === 'Enter') {\n onSearch(inputRef.current?.value);\n e.preventDefault();\n }\n },\n ...(iconPosition === 'start'\n ? {\n startAdornment: (\n <InputAdornment position={iconPosition}>\n {seachIcon}\n {InputProps?.startAdornment}\n </InputAdornment>\n ),\n }\n : {\n endAdornment: (\n <InputAdornment position={iconPosition}>\n {seachIcon}\n {InputProps?.endAdornment}\n </InputAdornment>\n ),\n }),\n }}\n inputProps={{\n tabIndex,\n name: other.name,\n ...other.inputProps,\n }}\n onChange={e => {\n if (trigger === 'change') {\n onSearch(e.target.value);\n return;\n }\n\n if (e.target.value === '') onSearch('');\n\n if (onChange) onChange(e);\n }}\n {...other}\n />\n );\n};\n\nexport default SearchInput;\n"]}
|
package/dist/chunk-QNKHAGBG.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-STWQUEEE.js';
|
|
2
|
-
import { memo, createContext, forwardRef, useContext, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
3
|
-
import $e, { autocompleteClasses } from '@mui/material/Autocomplete';
|
|
4
|
-
import ge from '@mui/material/CircularProgress';
|
|
5
|
-
import Pe from '@mui/material/TextField';
|
|
6
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import { VariableSizeList } from 'react-window';
|
|
8
|
-
import { useTheme, styled } from '@mui/material/styles';
|
|
9
|
-
import we from '@mui/material/useMediaQuery';
|
|
10
|
-
import he from '@mui/material/ListSubheader';
|
|
11
|
-
import Se from '@mui/material/Stack';
|
|
12
|
-
import q from '@mui/material/Typography';
|
|
13
|
-
import Ne from '@mui/material/Popper';
|
|
14
|
-
|
|
15
|
-
var Ie=e=>{if(!(!e||Array.isArray(e))){if(e.startAdornment)return e.startAdornment;if(e.icon)return jsx(a,{icon:e.icon})}},$=memo(({params:e,name:t,placeholder:s,error:n,helperText:u,label:l,required:A,multiple:a,formattedValue:p,loading:c,tabIndex:m,InputLabelProps:y,inputRef:g})=>jsx(Pe,{...e,name:t,placeholder:s,fullWidth:!0,error:!!n,helperText:u,label:l,required:A,inputRef:g,InputProps:{...e.InputProps,...!a&&{startAdornment:Ie(p)},endAdornment:jsxs(Fragment,{children:[c?jsx(ge,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,name:t,tabIndex:m},InputLabelProps:y}));$.displayName="AutocompleteInput";var F=$;var w=8,U=memo(e=>{let{data:t,index:s,style:n}=e,u=t[s],l={...n,top:n.top+w,paddingTop:8};if(Object.prototype.hasOwnProperty.call(u,"group")){let y=u;return jsx(he,{component:"div",style:l,children:y.group},`list-box-item-group-${y.group}`)}let[A,a$1]=u,{showValueInLabel:p,key:c,...m}=A;return jsx(q,{component:"li",...m,noWrap:!0,style:l,children:jsxs(Se,{component:"div",direction:"row",flex:1,gap:1,justifyContent:"start",children:[a$1.icon&&jsx(a,{icon:a$1.icon}),a$1.label,p&&jsxs(q,{variant:"inherit",color:"grey.400",children:["(",a$1.value,")"]})]})},`list-box-item-${c}`)});U.displayName="ListboxRow";var W=U;var Te=createContext(void 0),h=Te;var Y=createContext({}),Z=forwardRef((e,t)=>{let s=useContext(Y);return jsx("div",{ref:t,...e,...s})});Z.displayName="OuterElementType";var He=e=>{let t=useRef(null);return useEffect(()=>{t.current!=null&&t.current.resetAfterIndex(0,!0);},[e]),t},ke=forwardRef(function(t,s){let{children:n,...u}=t,l=useMemo(()=>{let o=[];return n.forEach(b=>{o.push(b),Object.prototype.hasOwnProperty.call(b,"children")&&Array.isArray(b.children)&&o.push(...b.children);}),o},[n]),A=useTheme(),a=we(A.breakpoints.up("sm")),p=l.length,c=a?36:48,m=useCallback(o=>Object.prototype.hasOwnProperty.call(o,"group")?48:c,[c]),y=useMemo(()=>p>8?8*c:l.map(m).reduce((o,b)=>o+b,0),[p,c,l,m]),g=He(p),P=useContext(h),d=useRef(!1);useEffect(()=>{d.current=!1;},[p]);let R=useCallback(({visibleStopIndex:o})=>{P&&!d.current&&o>=p-3&&(d.current=!0,P());},[P,p]);return jsx("div",{ref:s,children:jsx(Y.Provider,{value:u,children:jsx(VariableSizeList,{itemData:l,height:y+2*w,width:"100%",ref:g,outerElementType:Z,innerElementType:"ul",itemSize:o=>m(l[o]),overscanCount:5,itemCount:p,onItemsRendered:R,children:W})})})}),ee=ke;var te=styled(Ne)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var k=e=>e&&typeof e=="object"?e.value.toString():e.toString(),Fe=e=>e,qe=(e,t)=>k(e)===k(t),Be=(e,t)=>{let s=t.inputValue.toLocaleUpperCase();return e.filter(n=>`${n.value} ${n.label}`.toLocaleUpperCase().includes(s))},ne=memo(forwardRef(({name:e,label:t,value:s,options:n=[],loading:u,noOptionsText:l="Nenhum resultado encontrado.",loadingText:A="Carregando op\xE7\xF5es...",error:a,helperText:p,placeholder:c,onChange:m,groupBy:y,showValueInLabel:g,disabled:P,multiple:d,required:R,renderOption:o,tabIndex:b,onInputChange:C,onSearch:L,onBlur:T,onScrollEnd:ie,InputLabelProps:G,inputRef:N,filterOptions:se,...pe},ue)=>{let z=useRef(null),D=useRef(null),v=useMemo(()=>{if(d)return (Array.isArray(s)?s:[]).reduce((x,ye)=>{let V=n.find(Ae=>Ae.value.toString()===ye.toString());return V?[...x,V]:[...x]},[]);let i=n.find(f=>f.value.toString()===s?.toString())||null,r=D.current;return r&&i&&r.value===i.value&&r.label===i.label?r:(D.current=i,i)},[n,s,d]),le=se??(z.current==="reset"?void 0:Be),me=useCallback((i,r,f)=>{if(z.current=f,C&&C(i,r,f),f==="input"){L&&L(r);return}f==="reset"&&L&&L(void 0),f==="clear"&&L&&L("");},[C,L]),ae=useCallback((i,r)=>{if(!r){m(d?[]:null);return}if(Array.isArray(r)){m(r.map(k));return}m(typeof r=="string"?r.toString():r.value.toString());},[m,d]),ce=useCallback(i=>{T&&T(i);},[T]),de=useCallback((i,r,f,x)=>o?o(i,r,f,x):[{...i,showValueInLabel:g},r],[o,g]),fe=useMemo(()=>o?void 0:ee,[o]),be=useCallback(i=>jsx(F,{params:i,name:e,placeholder:c,error:a,helperText:p,label:t,required:R,multiple:d,formattedValue:v,loading:u,tabIndex:b,InputLabelProps:G,inputRef:N}),[e,c,a,p,t,R,d,v,u,b,G,N]);return jsx(h.Provider,{value:ie,children:jsx($e,{ref:ue,value:v,onInputChange:me,options:n,loading:u,noOptionsText:l,loadingText:A,disabled:P,disableListWrap:!0,PopperComponent:te,ListboxComponent:fe,filterOptions:le,isOptionEqualToValue:qe,onChange:ae,onBlur:ce,renderOption:de,renderGroup:Fe,groupBy:y,multiple:d,renderInput:be,...pe})})}));ne.displayName="Autocomplete";var Mt=ne;
|
|
16
|
-
|
|
17
|
-
export { Mt as a };
|
|
18
|
-
//# sourceMappingURL=chunk-QNKHAGBG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Autocomplete/index.tsx","../src/components/Autocomplete/AutocompleteInput.tsx","../src/components/Autocomplete/Listbox.tsx","../src/components/Autocomplete/ListboxRow.tsx","../src/components/Autocomplete/ScrollEndContext.ts","../src/components/Autocomplete/styles.ts"],"names":["forwardRef","memo","useCallback","useMemo","useRef","MuiAutocomplete","CircularProgress","TextField","Fragment","jsx","jsxs","inputStartAdornment","formattedValue","Icon_default","AutocompleteInput","params","name","placeholder","error","helperText","label","required","multiple","loading","tabIndex","InputLabelProps","inputRef","AutocompleteInput_default","createContext","useContext","useEffect","VariableSizeList","useTheme","useMediaQuery","ListSubheader","Stack","Typography","LISTBOX_PADDING","ListboxRow","props","data","index","style","dataSet","inlineStyle","groupItem","itemProps","option","showValueInLabel","key","otherItemProps","ListboxRow_default","ScrollEndContext","ScrollEndContext_default","OuterElementContext","OuterElementType","ref","outerProps","useResetCache","ListboxComponent","children","other","itemData","item","theme","smUp","itemCount","itemSize","getChildSize","child","itemsHeight","a","gridRef","onScrollEnd","firedRef","handleItemsRendered","visibleStopIndex","Listbox_default","autocompleteClasses","Popper","styled","StyledPopper","getOptionValue","optionValue","renderGroup","defaultIsOptionEqualToValue","selected","defaultFilterOptions","optionsFilter","state","searchValue","opt","Autocomplete","value","options","noOptionsText","loadingText","onChange","groupBy","disabled","renderOption","onInputChange","onSearch","onBlur","filterOptionsProp","inputReasonRef","lastSingleValueRef","acc","curr","previous","resolvedFilterOptions","handleInputChange","event","eventValue","reason","handleChange","_","handleBlur","memoizedRenderOption","ownerState","renderListbox","memoizedRenderInput","Autocomplete_default"],"mappings":"wCAAA,OACE,cAAAA,GACA,QAAAC,GAEA,eAAAC,EACA,WAAAC,GACA,UAAAC,OACK,QACP,OAAOC,OAKA,6BCbP,OAAS,QAAAJ,OAAY,QACrB,OAAOK,OAAsB,iCAC7B,OAAOC,OAAe,0BAaY,OAqCxB,YAAAC,GArCwB,OAAAC,EAqCxB,QAAAC,OArCwB,oBAPlC,IAAMC,GACJC,GACG,CACH,GAAI,GAACA,GAAkB,MAAM,QAAQA,CAAc,GAEnD,IAAIA,EAAe,eAAgB,OAAOA,EAAe,eAEzD,GAAIA,EAAe,KAAM,OAAOH,EAACI,EAAA,CAAK,KAAMD,EAAe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ent":["import {\n forwardRef,\n memo,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport MuiAutocomplete, {\n AutocompleteOwnerState,\n AutocompleteRenderGroupParams,\n AutocompleteRenderInputParams,\n AutocompleteRenderOptionState,\n} from '@mui/material/Autocomplete';\n\nimport { AutocompleteProps } from 'types/autoCompleteProps';\nimport { Option } from 'types/option';\n\nimport AutocompleteInput from './AutocompleteInput';\nimport ListboxComponent from './Listbox';\nimport ScrollEndContext from './ScrollEndContext';\nimport { StyledPopper } from './styles';\n\nconst getOptionValue = (optionValue: Option | string | number): string =>\n optionValue && typeof optionValue === 'object'\n ? optionValue.value.toString()\n : optionValue.toString();\n\nconst renderGroup = (params: AutocompleteRenderGroupParams) =>\n params as unknown as ReactNode;\n\nconst defaultIsOptionEqualToValue = (option: Option, selected: Option) =>\n getOptionValue(option) === getOptionValue(selected);\n\nconst defaultFilterOptions = (\n optionsFilter: Option[],\n state: { inputValue: string },\n) => {\n const searchValue = state.inputValue.toLocaleUpperCase();\n return optionsFilter.filter(opt => {\n const search = `${opt.value} ${opt.label}`;\n\n return search.toLocaleUpperCase().includes(searchValue);\n });\n};\n\nconst Autocomplete = memo(\n forwardRef<unknown, AutocompleteProps>(\n (\n {\n name,\n label,\n value,\n options = [],\n loading,\n noOptionsText = 'Nenhum resultado encontrado.',\n loadingText = 'Carregando opções...',\n error,\n helperText,\n placeholder,\n onChange,\n groupBy,\n showValueInLabel,\n disabled,\n multiple,\n required,\n renderOption,\n tabIndex,\n onInputChange,\n onSearch,\n onBlur,\n onScrollEnd,\n InputLabelProps,\n inputRef,\n filterOptions: filterOptionsProp,\n ...other\n },\n ref,\n ) => {\n const inputReasonRef = useRef<'input' | 'reset' | 'clear' | null>(null);\n\n const lastSingleValueRef = useRef<Option | null>(null);\n\n const formattedValue = useMemo(() => {\n if (multiple) {\n const values = Array.isArray(value) ? value : [];\n\n return values.reduce<Option[]>((acc, curr) => {\n const item = options.find(\n opt => opt.value.toString() === curr.toString(),\n );\n\n if (item) return [...acc, item];\n\n return [...acc];\n }, []);\n }\n\n const item =\n options.find(opt => opt.value.toString() === value?.toString()) ||\n null;\n\n const previous = lastSingleValueRef.current;\n if (\n previous &&\n item &&\n previous.value === item.value &&\n previous.label === item.label\n ) {\n return previous;\n }\n\n lastSingleValueRef.current = item;\n return item;\n }, [options, value, multiple]);\n\n const resolvedFilterOptions =\n filterOptionsProp ??\n (inputReasonRef.current === 'reset' ? undefined : defaultFilterOptions);\n\n const handleInputChange = useCallback(\n (\n event: React.SyntheticEvent,\n eventValue: string,\n reason: 'input' | 'reset' | 'clear',\n ) => {\n inputReasonRef.current = reason;\n if (onInputChange) onInputChange(event, eventValue, reason);\n\n if (reason === 'input') {\n if (onSearch) onSearch(eventValue);\n return;\n }\n\n if (reason === 'reset') {\n if (onSearch) onSearch(undefined);\n }\n\n if (reason === 'clear') {\n if (onSearch) onSearch('');\n }\n },\n [onInputChange, onSearch],\n );\n\n const handleChange = useCallback(\n (\n _: React.SyntheticEvent,\n option: Option | (string | Option)[] | string | null,\n ) => {\n if (!option) {\n onChange(multiple ? [] : null);\n return;\n }\n\n if (Array.isArray(option)) {\n onChange(option.map(getOptionValue));\n return;\n }\n\n onChange(\n typeof option === 'string'\n ? option.toString()\n : option.value.toString(),\n );\n },\n [onChange, multiple],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (onBlur) onBlur(event);\n },\n [onBlur],\n );\n\n const memoizedRenderOption = useCallback(\n (\n props: React.HTMLAttributes<HTMLLIElement> & { key: string },\n option: Option,\n state: AutocompleteRenderOptionState,\n ownerState: AutocompleteOwnerState<Option, boolean, boolean, boolean>,\n ) =>\n renderOption\n ? renderOption(props, option, state, ownerState)\n : ([{ ...props, showValueInLabel }, option] as ReactNode),\n [renderOption, showValueInLabel],\n );\n\n const renderListbox = useMemo(\n () => (renderOption ? undefined : ListboxComponent),\n [renderOption],\n );\n\n const memoizedRenderInput = useCallback(\n (params: AutocompleteRenderInputParams) => (\n <AutocompleteInput\n params={params}\n name={name}\n placeholder={placeholder}\n error={error}\n helperText={helperText}\n label={label}\n required={required}\n multiple={multiple}\n formattedValue={formattedValue}\n loading={loading}\n tabIndex={tabIndex}\n InputLabelProps={InputLabelProps}\n inputRef={inputRef}\n />\n ),\n [\n name,\n placeholder,\n error,\n helperText,\n label,\n required,\n multiple,\n formattedValue,\n loading,\n tabIndex,\n InputLabelProps,\n inputRef,\n ],\n );\n\n return (\n <ScrollEndContext.Provider value={onScrollEnd}>\n <MuiAutocomplete\n ref={ref}\n value={formattedValue}\n onInputChange={handleInputChange}\n options={options}\n loading={loading}\n noOptionsText={noOptionsText}\n loadingText={loadingText}\n disabled={disabled}\n disableListWrap\n PopperComponent={StyledPopper}\n ListboxComponent={renderListbox}\n filterOptions={resolvedFilterOptions}\n isOptionEqualToValue={defaultIsOptionEqualToValue}\n onChange={handleChange}\n onBlur={handleBlur}\n renderOption={memoizedRenderOption}\n renderGroup={renderGroup}\n groupBy={groupBy}\n multiple={multiple}\n renderInput={memoizedRenderInput}\n {...other}\n />\n </ScrollEndContext.Provider>\n );\n },\n ),\n);\n\nAutocomplete.displayName = 'Autocomplete';\n\nexport default Autocomplete;\n","import { memo } from 'react';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport TextField from '@mui/material/TextField';\n\nimport Icon from '../Icon';\n\nimport { AutocompleteInputProps } from './props';\n\nconst inputStartAdornment = (\n formattedValue: AutocompleteInputProps['formattedValue'],\n) => {\n if (!formattedValue || Array.isArray(formattedValue)) return undefined;\n\n if (formattedValue.startAdornment) return formattedValue.startAdornment;\n\n if (formattedValue.icon) return <Icon icon={formattedValue.icon} />;\n\n return undefined;\n};\n\nconst AutocompleteInput = memo(\n ({\n params,\n name,\n placeholder,\n error,\n helperText,\n label,\n required,\n multiple,\n formattedValue,\n loading,\n tabIndex,\n InputLabelProps,\n inputRef,\n }: AutocompleteInputProps) => (\n <TextField\n {...params}\n name={name}\n placeholder={placeholder}\n fullWidth\n error={!!error}\n helperText={helperText}\n label={label}\n required={required}\n inputRef={inputRef}\n InputProps={{\n ...params.InputProps,\n ...(!multiple && {\n startAdornment: inputStartAdornment(formattedValue),\n }),\n endAdornment: (\n <>\n {loading ? <CircularProgress color=\"primary\" size={20} /> : null}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n inputProps={{\n ...params.inputProps,\n name,\n tabIndex,\n }}\n InputLabelProps={InputLabelProps}\n />\n ),\n);\n\nAutocompleteInput.displayName = 'AutocompleteInput';\n\nexport default AutocompleteInput;\n","import {\n createContext,\n forwardRef,\n HTMLAttributes,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport { ListOnItemsRenderedProps, VariableSizeList } from 'react-window';\nimport { AutocompleteRenderGroupParams } from '@mui/material/Autocomplete';\nimport { useTheme } from '@mui/material/styles';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport ListboxRow, { LISTBOX_PADDING } from './ListboxRow';\nimport type { ListboxItem } from './props';\nimport ScrollEndContext from './ScrollEndContext';\n\nconst OuterElementContext = createContext({});\n\nconst OuterElementType = forwardRef<HTMLDivElement>((props, ref) => {\n const outerProps = useContext(OuterElementContext);\n return <div ref={ref} {...props} {...outerProps} />;\n});\n\nOuterElementType.displayName = 'OuterElementType';\n\nconst useResetCache = (data: number) => {\n const ref = useRef<VariableSizeList>(null);\n\n useEffect(() => {\n if (ref.current != null) {\n ref.current.resetAfterIndex(0, true);\n }\n }, [data]);\n\n return ref;\n};\n\nconst ListboxComponent = forwardRef<\n HTMLDivElement,\n HTMLAttributes<HTMLElement>\n>(function ListboxComponent(props, ref) {\n const { children, ...other } = props;\n\n const itemData: ListboxItem[] = useMemo(() => {\n const data: ListboxItem[] = [];\n (children as ListboxItem[]).forEach(item => {\n data.push(item);\n if (\n Object.prototype.hasOwnProperty.call(item, 'children') &&\n Array.isArray((item as AutocompleteRenderGroupParams).children)\n ) {\n data.push(\n ...((item as AutocompleteRenderGroupParams)\n .children as ListboxItem[]),\n );\n }\n });\n return data;\n }, [children]);\n\n const theme = useTheme();\n const smUp = useMediaQuery(theme.breakpoints.up('sm'));\n const itemCount = itemData.length;\n const itemSize = smUp ? 36 : 48;\n\n const getChildSize = useCallback(\n (child: ListboxItem) => {\n if (Object.prototype.hasOwnProperty.call(child, 'group')) {\n return 48;\n }\n\n return itemSize;\n },\n [itemSize],\n );\n\n const itemsHeight = useMemo(() => {\n if (itemCount > 8) {\n return 8 * itemSize;\n }\n return itemData.map(getChildSize).reduce((a, b) => a + b, 0);\n }, [itemCount, itemSize, itemData, getChildSize]);\n\n const gridRef = useResetCache(itemCount);\n const onScrollEnd = useContext(ScrollEndContext);\n const firedRef = useRef(false);\n\n useEffect(() => {\n firedRef.current = false;\n }, [itemCount]);\n\n const handleItemsRendered = useCallback(\n ({ visibleStopIndex }: ListOnItemsRenderedProps) => {\n if (\n onScrollEnd &&\n !firedRef.current &&\n visibleStopIndex >= itemCount - 3\n ) {\n firedRef.current = true;\n onScrollEnd();\n }\n },\n [onScrollEnd, itemCount],\n );\n\n return (\n <div ref={ref}>\n <OuterElementContext.Provider value={other}>\n <VariableSizeList\n itemData={itemData}\n height={itemsHeight + 2 * LISTBOX_PADDING}\n width=\"100%\"\n ref={gridRef}\n outerElementType={OuterElementType}\n innerElementType=\"ul\"\n itemSize={index => getChildSize(itemData[index])}\n overscanCount={5}\n itemCount={itemCount}\n onItemsRendered={handleItemsRendered}\n >\n {ListboxRow}\n </VariableSizeList>\n </OuterElementContext.Provider>\n </div>\n );\n});\n\nexport default ListboxComponent;\n","import { HTMLAttributes, memo } from 'react';\nimport { ListChildComponentProps } from 'react-window';\nimport { AutocompleteRenderGroupParams } from '@mui/material/Autocomplete';\nimport ListSubheader from '@mui/material/ListSubheader';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport { Option } from 'types/option';\n\nimport Icon from '../Icon';\n\nimport type { IconName } from './props';\n\nconst LISTBOX_PADDING = 8;\n\nconst ListboxRow = memo((props: ListChildComponentProps) => {\n const { data, index, style } = props;\n const dataSet = data[index] as\n | AutocompleteRenderGroupParams\n | [HTMLAttributes<HTMLLIElement> & { showValueInLabel?: boolean }, Option];\n\n const inlineStyle = {\n ...style,\n top: (style.top as number) + LISTBOX_PADDING,\n paddingTop: 8,\n };\n\n if (Object.prototype.hasOwnProperty.call(dataSet, 'group')) {\n const groupItem = dataSet as AutocompleteRenderGroupParams;\n return (\n <ListSubheader\n key={`list-box-item-group-${groupItem.group}`}\n component=\"div\"\n style={inlineStyle}\n >\n {groupItem.group}\n </ListSubheader>\n );\n }\n\n const [itemProps, option] = dataSet as [\n HTMLAttributes<HTMLLIElement> & {\n showValueInLabel?: boolean;\n key: string;\n },\n Option,\n ];\n const { showValueInLabel, key, ...otherItemProps } = itemProps;\n\n return (\n <Typography\n component=\"li\"\n key={`list-box-item-${key}`}\n {...otherItemProps}\n noWrap\n style={inlineStyle}\n >\n <Stack\n component=\"div\"\n direction=\"row\"\n flex={1}\n gap={1}\n justifyContent=\"start\"\n >\n {option.icon && <Icon icon={option.icon as IconName} />}\n {option.label}\n\n {showValueInLabel && (\n <Typography variant=\"inherit\" color=\"grey.400\">\n ({option.value})\n </Typography>\n )}\n </Stack>\n </Typography>\n );\n});\n\nListboxRow.displayName = 'ListboxRow';\n\nexport { LISTBOX_PADDING };\nexport default ListboxRow;\n","import { createContext } from 'react';\n\nconst ScrollEndContext = createContext<(() => void) | undefined>(undefined);\n\nexport default ScrollEndContext;\n","import { autocompleteClasses } from '@mui/material/Autocomplete';\nimport Popper from '@mui/material/Popper';\nimport { styled } from '@mui/material/styles';\n\nexport const StyledPopper = styled(Popper)({\n [`& .${autocompleteClasses.listbox}`]: {\n boxSizing: 'border-box',\n '& ul': {\n padding: 0,\n margin: 0,\n },\n },\n});\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|