@zydon/common 2.6.91 → 2.6.93

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,5 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ function u(){let e=typeof document<"u",[n,i]=useState(()=>e?!document.hidden:!0);return useEffect(()=>{if(!e)return;let t=()=>{i(!document.hidden);};return document.addEventListener("visibilitychange",t),()=>{document.removeEventListener("visibilitychange",t);}},[e]),n}var c=u;
4
+
5
+ export { c as a };
@@ -1,4 +1,4 @@
1
- import { a as a$1 } from '../../chunk-F3N2UJTK.js';
1
+ import { a as a$1 } from '../../chunk-UBRDWK4B.js';
2
2
  import { a } from '../../chunk-HXTQLRC7.js';
3
3
  import '../../chunk-W3NEQX4G.js';
4
4
  import '../../chunk-FO7JCJ76.js';
@@ -23,10 +23,9 @@ import { LocalizationProvider } from '@mui/x-date-pickers-pro/LocalizationProvid
23
23
  import { jsx, jsxs } from 'react/jsx-runtime';
24
24
  import { LazyMotion, domMax } from 'framer-motion';
25
25
  import z from '@mui/material/Portal';
26
- import { styled } from '@mui/material/styles';
26
+ import { styled, useColorScheme } from '@mui/material/styles';
27
27
  import { Toaster } from 'sonner';
28
28
  import { useCallback, useEffect } from 'react';
29
- import { useColorScheme } from '@mui/material';
30
29
 
31
30
  var $=({children:t})=>(h.locale("pt-br"),jsx(LocalizationProvider,{dateAdapter:AdapterDayjs,adapterLocale:"pt-br",children:t})),g=$;var C=({children:t})=>jsx(LazyMotion,{strict:!0,features:domMax,children:t});var o={root:"toaster__root",toast:"toaster__toast",title:"toaster__title",icon:"toaster__icon",iconSvg:"toaster__icon__svg",content:"toaster__content",description:"toaster__description",actionButton:"toaster__action__button",cancelButton:"toaster__cancel__button",closeButton:"toaster__close_button",loadingIcon:"toaster__loading_icon",default:"toaster__default",error:"toaster__error",success:"toaster__success",warning:"toaster__warning",info:"toaster__info",loader:"sonner-loader",loaderVisible:'&[data-visible="true"]',closeBtnVisible:'[data-close-button="true"]'};var b=styled(Toaster)(({theme:t})=>{let r={toastDefault:{padding:t.spacing(1,1,1,1.5),boxShadow:t.customShadows.z8,color:t.vars.palette.background.paper,backgroundColor:t.vars.palette.text.primary},toastColor:{padding:t.spacing(.5,1,.5,.5),boxShadow:t.customShadows.z8,color:t.vars.palette.text.primary,backgroundColor:t.vars.palette.background.paper},toastLoader:{padding:t.spacing(.5,1,.5,.5),boxShadow:t.customShadows.z8,color:t.vars.palette.text.primary,backgroundColor:t.vars.palette.background.paper}},e={top:0,left:0,width:"100%",height:"100%",display:"none",transform:"none",overflow:"hidden",alignItems:"center",position:"relative",borderRadius:"inherit",justifyContent:"center",background:t.vars.palette.background.neutral,[`& .${o.loadingIcon}`]:{zIndex:9,width:24,height:24,borderRadius:"50%",animation:"rotate 3s infinite linear",background:`conic-gradient(${k(t.vars.palette.text.primaryChannel,0)}, ${k(t.vars.palette.text.disabledChannel,.64)})`},[o.loaderVisible]:{display:"flex"}};return {width:300,[`& .${o.toast}`]:{gap:12,width:"100%",minHeight:52,display:"flex",borderRadius:12,alignItems:"center"},[`& .${o.content}`]:{gap:0,flex:"1 1 auto"},[`& .${o.title}`]:{fontSize:t.typography.subtitle2.fontSize},[`& .${o.description}`]:{...t.typography.caption,opacity:.64},[`& .${o.actionButton}`]:{},[`& .${o.cancelButton}`]:{},[`& .${o.closeButton}`]:{top:0,right:0,left:"auto",color:"currentColor",backgroundColor:"transparent",transform:"translate(-6px, 6px)",borderColor:k(t.vars.palette.grey["500Channel"],.16),transition:t.transitions.create(["background-color","border-color"]),"&:hover":{borderColor:k(t.vars.palette.grey["500Channel"],.24),backgroundColor:k(t.vars.palette.grey["500Channel"],.08)}},[`& .${o.icon}`]:{margin:0,width:48,height:48,alignItems:"center",borderRadius:"inherit",justifyContent:"center",alignSelf:"flex-start",[`& .${o.iconSvg}`]:{width:24,height:24,fontSize:0}},"@keyframes rotate":{to:{transform:"rotate(1turn)"}},[`& .${o.default}`]:{...r.toastDefault,[`&:has(${o.closeBtnVisible})`]:{[`& .${o.content}`]:{paddingRight:32}},[`&:has(.${o.loader})`]:r.toastLoader,[`&:has(.${o.loader})`]:r.toastLoader,[`& .${o.loader}`]:e},[`& .${o.error}`]:{...r.toastColor,[`& .${o.icon}`]:{color:t.vars.palette.error.main,backgroundColor:k(t.vars.palette.error.mainChannel,.08)}},[`& .${o.success}`]:{...r.toastColor,[`& .${o.icon}`]:{color:t.vars.palette.success.main,backgroundColor:k(t.vars.palette.success.mainChannel,.08)}},[`& .${o.warning}`]:{...r.toastColor,[`& .${o.icon}`]:{color:t.vars.palette.warning.main,backgroundColor:k(t.vars.palette.warning.mainChannel,.08)}},[`& .${o.info}`]:{...r.toastColor,[`& .${o.icon}`]:{color:t.vars.palette.info.main,backgroundColor:k(t.vars.palette.info.mainChannel,.08)}}}});var _=()=>jsx(z,{container:typeof window<"u"?document.getElementById("snackbar-container-provider"):null,children:jsx(b,{expand:!0,gap:12,closeButton:!0,offset:16,visibleToasts:4,position:"top-right",className:o.root,toastOptions:{unstyled:!0,classNames:{toast:o.toast,icon:o.icon,content:o.content,title:o.title,description:o.description,actionButton:o.actionButton,cancelButton:o.cancelButton,closeButton:o.closeButton,default:o.default,info:o.info,error:o.error,success:o.success,warning:o.warning}},icons:{loading:jsx("span",{className:o.loadingIcon}),info:jsx(a,{className:o.iconSvg,icon:"INFO_CIRCLE"}),success:jsx(a,{className:o.iconSvg,icon:"CHECK_CIRCLE"}),warning:jsx(a,{className:o.iconSvg,icon:"WARNING_TRIANGULE"}),error:jsx(a,{className:o.iconSvg,icon:"ALERT_CIRCLE"})}})});var E=({children:t})=>{let r=a$1(),{setMode:e}=useColorScheme(),{settings:{colorScheme:i,setColorScheme:c}}=b$1(),s=useCallback(()=>{e(i),c(i),b$2(i);},[i,e,c]);return useEffect(()=>{r&&s&&s();},[r,s]),t},v=E;var M=({primaryColor:t,colorScheme:r="light",contrast:e="default",children:i,cssVarPrefix:c$1="app",snackbar:s=!0})=>jsx(g,{children:jsx(c,{primaryColor:t,colorScheme:r,contrast:e,cssVarPrefix:c$1,children:jsx(v,{children:jsxs(C,{children:[i,s&&jsx(_,{})]})})})}),bo=M;
32
31
 
@@ -12,12 +12,12 @@ import T from '@mui/material/CircularProgress';
12
12
  import f from '@mui/material/Divider';
13
13
  import o from '@mui/material/Stack';
14
14
  import S from '@mui/material/Typography';
15
- import { debounce } from '@mui/material/utils';
15
+ import Y from '@mui/material/utils/debounce';
16
16
  import U from '@mui/material/Box';
17
17
  import X from '@mui/material/Button';
18
18
  import { styled } from '@mui/material/styles';
19
19
  import { jsx, jsxs } from 'react/jsx-runtime';
20
20
 
21
- var R=styled(X)(({theme:a})=>({borderColor:a.palette.grey[300]})),L=styled(U)(({theme:a})=>({display:"flex",border:`1.5px solid ${a.palette.grey[300]}`,height:450,borderRadius:8,flex:1,overflow:"hidden"}));var Z=({selectedItems:a$5,items:B,loading:$,searchText:g,onAdd:D,onRemove:P,search:z,itemsTitle:W,selectedItemsTitle:H,additionalContent:K,enableSearchInSelectedItems:u,selectedItemChild:A,onSearch:N})=>{let[m,_]=useState(""),M=debounce(N,400),d=B.filter(e=>!a$5.some(n=>n.id===e.id)),O=a$5.filter(e=>e.name?.toLowerCase().includes(m.toLowerCase())||e.id?.toLowerCase().includes(m.toLowerCase())),k=u&&m?O:a$5,[i,s]=useState([]),[l,p]=useState([]),j=()=>{D(i),s([]);},G=()=>{P(l),p([]);},V=e=>{p(e?k:[]);},q=e=>{s(e?d:[]);},J=(e,n)=>{p(n?c=>[...c,e]:c=>c.filter(y=>y.id!==e.id));},Q=(e,n)=>{s(n?c=>[...c,e]:c=>c.filter(y=>y.id!==e.id));},E=e=>{e.key==="Enter"&&e.preventDefault();};return jsx(o,{children:jsxs(o,{direction:"row",alignItems:"center",gap:3,children:[jsx(L,{flex:1,children:jsxs(o,{flex:1,overflow:"hidden",children:[jsxs(o,{direction:"row",gap:1,padding:2,children:[jsx(h,{size:"small",indeterminate:i.length>0&&i.length!==d.length,checked:i.length>0&&i.length===d.length,onChange:e=>q(e.target.checked)}),jsxs(o,{children:[jsx(S,{variant:"subtitle2",color:"text.primary",children:`${W} cadastrados(as)`}),jsx(S,{variant:"caption",color:"text.disabled",children:`${i.length}/${d.length} selecionados`})]})]}),jsx(f,{}),jsxs(o,{p:2,flex:1,overflow:"hidden",children:[jsxs(o,{direction:"row",gap:1,children:[jsx(a,{iconPosition:"start",placeholder:"Buscar",onKeyDown:E,size:"small",fullWidth:!0,trigger:"change",onSearch:e=>M(e)}),K]}),jsx(a$1,{isLoading:$,loading:jsx(o,{alignItems:"center",justifyContent:"center",flex:1,children:jsx(T,{})}),isEmpty:d.length===0,empty:jsx(a$2,{text:z?`Nenhum ${g} encontrado`:`Nenhum ${g} dispon\xEDvel`,sx:{svg:{height:140}}}),children:jsx(a$3,{sx:{maxHeight:280},children:d.map(e=>jsxs(o,{gap:1,marginTop:"8px",children:[jsxs(o,{direction:"row",gap:.5,alignItems:"center",marginTop:"8px",children:[jsx(h,{size:"small",checked:i.includes(e),onChange:n=>Q(e,n.target.checked)}),e.label]}),jsx(f,{})]},e.id))})})]})]})}),jsxs(o,{gap:3,children:[jsx(R,{variant:"outlined",onClick:j,"data-testid":"add-button",children:jsx(a$4,{icon:"ARROW_RIGHT_SIMPLE"})}),jsx(R,{variant:"outlined",onClick:G,"data-testid":"remove-button",children:jsx(a$4,{icon:"ARROW_LEFT_SIMPLE"})})]}),jsx(L,{flex:1,children:jsxs(o,{flex:1,overflow:"hidden",children:[jsxs(o,{direction:"row",gap:1,padding:2,children:[jsx(h,{size:"small",indeterminate:l.length>0&&l.length!==a$5.length,checked:l.length>0&&l.length===a$5.length,onChange:e=>V(e.target.checked)}),jsxs(o,{children:[jsx(S,{variant:"subtitle2",color:"text.primary",children:`${H} selecionados(as)`}),jsx(S,{variant:"caption",color:"text.disabled",children:`${l.length}/${a$5.length} selecionados`})]})]}),jsx(f,{}),jsxs(o,{p:2,gap:1,overflow:"hidden",children:[u&&jsx(a,{iconPosition:"start",placeholder:"Buscar",size:"small",fullWidth:!0,trigger:"change",onSearch:e=>_(e??""),onKeyDown:E}),jsx(a$1,{isLoading:$,loading:jsx(o,{alignItems:"center",justifyContent:"center",flex:1,children:jsx(T,{})}),isEmpty:k.length===0,empty:jsx(a$2,{text:m&&u?`Nenhum ${g} encontrado`:`Nenhum ${g} selecionado`,sx:{svg:{height:140},marginTop:"56px",backgroundColor:"transparent"}}),children:jsx(a$3,{sx:{maxHeight:280},children:k.map(e=>jsxs(o,{gap:1,children:[jsxs(o,{direction:"row",gap:.5,alignItems:"center",marginTop:"8px",children:[jsxs(o,{direction:"row",children:[A&&A(e),jsx(h,{size:"small",checked:l.includes(e),onChange:n=>J(e,n.target.checked)})]}),e.label]}),jsx(f,{})]},e.id))})})]})]})})]})})},ke=Z;
21
+ var R=styled(X)(({theme:a})=>({borderColor:a.palette.grey[300]})),L=styled(U)(({theme:a})=>({display:"flex",border:`1.5px solid ${a.palette.grey[300]}`,height:450,borderRadius:8,flex:1,overflow:"hidden"}));var Z=({selectedItems:a$5,items:B,loading:$,searchText:g,onAdd:D,onRemove:P,search:z,itemsTitle:W,selectedItemsTitle:H,additionalContent:K,enableSearchInSelectedItems:u,selectedItemChild:A,onSearch:N})=>{let[m,_]=useState(""),M=Y(N,400),d=B.filter(e=>!a$5.some(n=>n.id===e.id)),O=a$5.filter(e=>e.name?.toLowerCase().includes(m.toLowerCase())||e.id?.toLowerCase().includes(m.toLowerCase())),k=u&&m?O:a$5,[i,s]=useState([]),[l,p]=useState([]),j=()=>{D(i),s([]);},G=()=>{P(l),p([]);},V=e=>{p(e?k:[]);},q=e=>{s(e?d:[]);},J=(e,n)=>{p(n?c=>[...c,e]:c=>c.filter(y=>y.id!==e.id));},Q=(e,n)=>{s(n?c=>[...c,e]:c=>c.filter(y=>y.id!==e.id));},E=e=>{e.key==="Enter"&&e.preventDefault();};return jsx(o,{children:jsxs(o,{direction:"row",alignItems:"center",gap:3,children:[jsx(L,{flex:1,children:jsxs(o,{flex:1,overflow:"hidden",children:[jsxs(o,{direction:"row",gap:1,padding:2,children:[jsx(h,{size:"small",indeterminate:i.length>0&&i.length!==d.length,checked:i.length>0&&i.length===d.length,onChange:e=>q(e.target.checked)}),jsxs(o,{children:[jsx(S,{variant:"subtitle2",color:"text.primary",children:`${W} cadastrados(as)`}),jsx(S,{variant:"caption",color:"text.disabled",children:`${i.length}/${d.length} selecionados`})]})]}),jsx(f,{}),jsxs(o,{p:2,flex:1,overflow:"hidden",children:[jsxs(o,{direction:"row",gap:1,children:[jsx(a,{iconPosition:"start",placeholder:"Buscar",onKeyDown:E,size:"small",fullWidth:!0,trigger:"change",onSearch:e=>M(e)}),K]}),jsx(a$1,{isLoading:$,loading:jsx(o,{alignItems:"center",justifyContent:"center",flex:1,children:jsx(T,{})}),isEmpty:d.length===0,empty:jsx(a$2,{text:z?`Nenhum ${g} encontrado`:`Nenhum ${g} dispon\xEDvel`,sx:{svg:{height:140}}}),children:jsx(a$3,{sx:{maxHeight:280},children:d.map(e=>jsxs(o,{gap:1,marginTop:"8px",children:[jsxs(o,{direction:"row",gap:.5,alignItems:"center",marginTop:"8px",children:[jsx(h,{size:"small",checked:i.includes(e),onChange:n=>Q(e,n.target.checked)}),e.label]}),jsx(f,{})]},e.id))})})]})]})}),jsxs(o,{gap:3,children:[jsx(R,{variant:"outlined",onClick:j,"data-testid":"add-button",children:jsx(a$4,{icon:"ARROW_RIGHT_SIMPLE"})}),jsx(R,{variant:"outlined",onClick:G,"data-testid":"remove-button",children:jsx(a$4,{icon:"ARROW_LEFT_SIMPLE"})})]}),jsx(L,{flex:1,children:jsxs(o,{flex:1,overflow:"hidden",children:[jsxs(o,{direction:"row",gap:1,padding:2,children:[jsx(h,{size:"small",indeterminate:l.length>0&&l.length!==a$5.length,checked:l.length>0&&l.length===a$5.length,onChange:e=>V(e.target.checked)}),jsxs(o,{children:[jsx(S,{variant:"subtitle2",color:"text.primary",children:`${H} selecionados(as)`}),jsx(S,{variant:"caption",color:"text.disabled",children:`${l.length}/${a$5.length} selecionados`})]})]}),jsx(f,{}),jsxs(o,{p:2,gap:1,overflow:"hidden",children:[u&&jsx(a,{iconPosition:"start",placeholder:"Buscar",size:"small",fullWidth:!0,trigger:"change",onSearch:e=>_(e??""),onKeyDown:E}),jsx(a$1,{isLoading:$,loading:jsx(o,{alignItems:"center",justifyContent:"center",flex:1,children:jsx(T,{})}),isEmpty:k.length===0,empty:jsx(a$2,{text:m&&u?`Nenhum ${g} encontrado`:`Nenhum ${g} selecionado`,sx:{svg:{height:140},marginTop:"56px",backgroundColor:"transparent"}}),children:jsx(a$3,{sx:{maxHeight:280},children:k.map(e=>jsxs(o,{gap:1,children:[jsxs(o,{direction:"row",gap:.5,alignItems:"center",marginTop:"8px",children:[jsxs(o,{direction:"row",children:[A&&A(e),jsx(h,{size:"small",checked:l.includes(e),onChange:n=>J(e,n.target.checked)})]}),e.label]}),jsx(f,{})]},e.id))})})]})]})})]})})},ke=Z;
22
22
 
23
23
  export { ke as default };
@@ -1 +1 @@
1
- export { a as default } from '../chunk-F3N2UJTK.js';
1
+ export { a as default } from '../chunk-UBRDWK4B.js';
@@ -1,3 +1,5 @@
1
+ import * as lodash from 'lodash';
2
+
1
3
  /**
2
4
  * Executa imediatamente uma função e retorna seu resultado.
3
5
  *
@@ -70,51 +72,9 @@ declare const eager: <T>(fn: () => T) => T;
70
72
  * ```
71
73
  */
72
74
  declare const defer: <T>(fn: () => T) => Promise<T>;
73
- /**
74
- * Cria uma versão debounced de uma função que atrasa sua execução até que
75
- * tenha passado um determinado tempo desde a última vez que foi invocada.
76
- *
77
- * Esta função é útil para limitar a frequência de execução de funções caras
78
- * computacionalmente, como chamadas de API, validações ou atualizações de UI
79
- * em resposta a eventos frequentes como digitação ou scroll.
80
- *
81
- * @template T - O tipo dos argumentos da função
82
- * @template R - O tipo do valor retornado pela função
83
- * @param fn - A função a ser debounced
84
- * @param delay - O tempo em milissegundos para aguardar antes da execução
85
- * @returns Uma versão debounced da função original
86
- *
87
- * @example
88
- * ```typescript
89
- * // Debounce para busca em tempo real
90
- * const searchAPI = debounce(async (query: string) => {
91
- * const results = await fetch(`/api/search?q=${query}`);
92
- * return results.json();
93
- * }, 300);
94
- *
95
- * // Uso em input de busca
96
- * const handleSearchInput = (event: ChangeEvent<HTMLInputElement>) => {
97
- * searchAPI(event.target.value);
98
- * };
99
- *
100
- * // Debounce para redimensionamento de janela
101
- * const handleResize = debounce(() => {
102
- * console.log('Janela redimensionada:', window.innerWidth);
103
- * updateLayout();
104
- * }, 250);
105
- *
106
- * window.addEventListener('resize', handleResize);
107
- *
108
- * // Debounce para validação de formulário
109
- * const validateField = debounce((value: string) => {
110
- * if (value.length < 3) {
111
- * setError('Mínimo 3 caracteres');
112
- * } else {
113
- * setError('');
114
- * }
115
- * }, 500);
116
- * ```
117
- */
118
- declare const debounce: <T extends unknown[], R>(fn: (...args: T) => R, delay: number) => (...args: T) => void;
75
+ declare const debounce: {
76
+ <T extends (...args: any) => any>(func: T, wait: number | undefined, options: lodash.DebounceSettingsLeading): lodash.DebouncedFuncLeading<T>;
77
+ <T_1 extends (...args: any) => any>(func: T_1, wait?: number | undefined, options?: lodash.DebounceSettings | undefined): lodash.DebouncedFunc<T_1>;
78
+ };
119
79
 
120
80
  export { debounce, defer, eager };
@@ -1,3 +1,5 @@
1
- var n=t=>t(),u=t=>new Promise((r,e)=>{setTimeout(()=>{try{r(t());}catch(o){e(o);}},0);}),T=(t,r)=>{let e=null;return (...o)=>{e&&clearTimeout(e),e=setTimeout(()=>{t(...o),e=null;},r);}};
1
+ import c from 'lodash/debounce';
2
2
 
3
- export { T as debounce, u as defer, n as eager };
3
+ var s=e=>e(),T=e=>new Promise((o,r)=>{setTimeout(()=>{try{o(e());}catch(t){r(t);}},0);}),m=c;
4
+
5
+ export { m as debounce, T as defer, s as eager };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.6.91",
3
+ "version": "2.6.93",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -99,6 +99,7 @@
99
99
  "@testing-library/user-event": "14.5.2",
100
100
  "@types/color": "^3.0.6",
101
101
  "@types/jest": "^30.0.0",
102
+ "@types/lodash": "^4.17.20",
102
103
  "@types/node": "^20.0.0",
103
104
  "@types/react": "^18.3.4",
104
105
  "@types/react-color": "^3.0.13",
@@ -143,6 +144,7 @@
143
144
  "embla-carousel-react": "^8.2.0",
144
145
  "framer-motion": "^11.3.30",
145
146
  "hugeicons-react": "^0.3.0",
147
+ "lodash": "^4.17.21",
146
148
  "react-color": "^2.19.3",
147
149
  "react-cropper": "^2.3.3",
148
150
  "react-dropzone": "^14.2.3",
@@ -1,5 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
-
3
- function d(){let[t,n]=useState(()=>!document.hidden);return useEffect(()=>{let e=()=>{n(!document.hidden);};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e);}},[]),t}var u=d;
4
-
5
- export { u as a };