@zydon/common-csr 2.0.86 → 2.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,24 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useState } from 'react';
2
2
  import { useFormContext } from 'react-hook-form';
3
- import _ from '@mui/material/Accordion';
4
- import N from '@mui/material/AccordionDetails';
5
- import $ from '@mui/material/AccordionSummary';
6
- import L from '@mui/material/Button';
7
- import w from '@mui/material/Checkbox';
8
- import A from '@mui/material/FormControlLabel';
9
- import j from '@mui/material/List';
10
- import x from '@mui/material/ListItem';
11
- import T from '@mui/material/Radio';
12
- import z from '@mui/material/Stack';
3
+ import H from '@mui/material/Accordion';
4
+ import _ from '@mui/material/AccordionDetails';
5
+ import N from '@mui/material/AccordionSummary';
6
+ import k from '@mui/material/Button';
7
+ import L from '@mui/material/Checkbox';
8
+ import w from '@mui/material/FormControlLabel';
9
+ import $ from '@mui/material/List';
10
+ import A from '@mui/material/ListItem';
11
+ import x from '@mui/material/Radio';
12
+ import T from '@mui/material/Stack';
13
13
  import { styled, alpha } from '@mui/material/styles';
14
- import u from '@mui/material/Typography';
15
- import G from '@zydon/common/components/EmptyView';
16
- import U from '@zydon/common/components/Icon';
17
- import W from '@zydon/common/components/Label';
18
- import J from '@zydon/common/components/SearchInput';
14
+ import p from '@mui/material/Typography';
15
+ import q from '@zydon/common/components/EmptyView';
16
+ import G from '@zydon/common/components/Icon';
17
+ import U from '@zydon/common/components/Label';
18
+ import W from '@zydon/common/components/SearchInput';
19
19
  import M from '@zydon/common/components/Scrollbar';
20
20
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
21
21
 
22
- var k=styled(M)(()=>({maxHeight:"260px"}));var K=({items:s,onChange:b})=>{let{setValue:y,getValues:E}=useFormContext(),[a,F]=useState(-1),[d,S]=useState(""),R=Object.fromEntries(s.map((t,r)=>[r,[]])),[l,h]=useState(R);useEffect(()=>()=>{y("config",{});},[]);let V=(t,r)=>{F(r?t:-1),r&&P();},P=()=>{S("");},g=(t,r,n,e)=>{let c=e==="unique"?[r]:[...l[a],r],i=n.target.checked?c:l[a].filter(m=>m!==r);h({...l,[a]:i}),f(t,i);},C=t=>{S(t);},B=()=>{let r=s[a].list.every(n=>l[a].includes(n.value))?[]:[...s[a].list.map(n=>n.value)];h({...l,[a]:r}),f(s[a].name,r);},D=()=>{h({...l,[a]:[]}),f(s[a].name,[]);},f=(t,r)=>{let n={},e=E("config"),c=s[a];if(c){let i=c.list.filter(m=>l[a].includes(m.value)).map(m=>m.value);n[c.name]={type:"FIELD",values:c.name===t?r:i},y("config",{...e,...n}),b&&b({...e,...n});}};return jsx(Fragment,{children:s.map(({type:t="multi",...r},n)=>jsxs(_,{expanded:a===n,onChange:(e,c)=>V(n,c),children:[jsx($,{expandIcon:jsx(U,{icon:"CHEVRON_UP"}),id:`${n}`,children:jsxs(z,{alignItems:"center",direction:"row",children:[jsx(u,{variant:"subtitle2",color:"grey.600",children:r.label}),jsxs(W,{variant:"soft",color:"primary",marginLeft:1,sx:e=>({backgroundColor:`${alpha(e.palette.grey[400],.2)}`,cursor:"pointer"}),children:[l[n].length," selecionados"]})]})}),jsxs(N,{children:[jsxs(z,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[jsx(J,{onSearch:C,onChange:e=>C(e.target.value),iconPosition:"start",size:"small",placeholder:"Buscar",value:d,fullWidth:!0}),t==="multi"?jsx(L,{onClick:B,size:"small",children:jsx(u,{variant:"overline",children:"TODOS"})}):jsx(L,{onClick:D,size:"small",color:"error",children:jsx(u,{variant:"overline",children:"LIMPAR"})})]}),jsx(k,{children:jsx(j,{children:a>-1&&(r.list.filter(e=>e.label?.toLowerCase().includes(d.toLowerCase())).map((e,c)=>jsx(x,{children:jsx(A,{control:t==="multi"?jsx(w,{size:"small",checked:l[a].includes(e.value),onChange:i=>g(r.name,e.value,i,t),name:e.label}):jsx(T,{size:"small",checked:l[a].includes(e.value),onChange:i=>g(r.name,e.value,i,t),name:e.label}),label:jsx(u,{variant:"caption",color:"grey.600",children:e.label})})},c)).length===0?jsx(G,{sx:{svg:{height:100}},text:"Nenhum registro para ser apresentado"}):r.list.filter(e=>e.label?.toLowerCase().includes(d.toLowerCase())).map((e,c)=>jsx(x,{children:jsx(A,{control:t==="multi"?jsx(w,{size:"small",checked:l[a].includes(e.value),onChange:i=>g(r.name,e.value,i,t),name:e.label}):jsx(T,{size:"small",checked:l[a].includes(e.value),onChange:i=>g(r.name,e.value,i,t),name:e.label}),label:jsx(u,{variant:"caption",color:"grey.600",children:e.label})})},c)))})})]})]},n))})},Se=K;
22
+ var C=styled(M)(()=>({maxHeight:"260px"}));var J=({items:s,onChange:b})=>{let{setValue:z,getValues:F}=useFormContext(),[a,R]=useState(-1),[d,y]=useState(""),E=Object.fromEntries(s.map((t,r)=>[r,[]])),[l,h]=useState(E),V=(t,r)=>{R(r?t:-1),r&&P();},P=()=>{y("");},g=(t,r,n,e)=>{let c=e==="unique"?[r]:[...l[a],r],i=n.target.checked?c:l[a].filter(m=>m!==r);h({...l,[a]:i}),f(t,i);},S=t=>{y(t);},B=()=>{let r=s[a].list.every(n=>l[a].includes(n.value))?[]:[...s[a].list.map(n=>n.value)];h({...l,[a]:r}),f(s[a].name,r);},D=()=>{h({...l,[a]:[]}),f(s[a].name,[]);},f=(t,r)=>{let n={},e=F("config"),c=s[a];if(c){let i=c.list.filter(m=>l[a].includes(m.value)).map(m=>m.value);n[c.name]={type:"FIELD",values:c.name===t?r:i},z("config",{...e,...n}),b&&b({...e,...n});}};return jsx(Fragment,{children:s.map(({type:t="multi",...r},n)=>jsxs(H,{expanded:a===n,onChange:(e,c)=>V(n,c),children:[jsx(N,{expandIcon:jsx(G,{icon:"CHEVRON_UP"}),id:`${n}`,children:jsxs(T,{alignItems:"center",direction:"row",children:[jsx(p,{variant:"subtitle2",color:"grey.600",children:r.label}),jsxs(U,{variant:"soft",color:"primary",marginLeft:1,sx:e=>({backgroundColor:`${alpha(e.palette.grey[400],.2)}`,cursor:"pointer"}),children:[l[n].length," selecionados"]})]})}),jsxs(_,{children:[jsxs(T,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[jsx(W,{onSearch:S,onChange:e=>S(e.target.value),iconPosition:"start",size:"small",placeholder:"Buscar",value:d,fullWidth:!0}),t==="multi"?jsx(k,{onClick:B,size:"small",children:jsx(p,{variant:"overline",children:"TODOS"})}):jsx(k,{onClick:D,size:"small",color:"error",children:jsx(p,{variant:"overline",children:"LIMPAR"})})]}),jsx(C,{children:jsx($,{children:a>-1&&(r.list.filter(e=>e.label?.toLowerCase().includes(d.toLowerCase())).map((e,c)=>jsx(A,{children:jsx(w,{control:t==="multi"?jsx(L,{size:"small",checked:l[a].includes(e.value),onChange:i=>g(r.name,e.value,i,t),name:e.label}):jsx(x,{size:"small",checked:l[a].includes(e.value),onChange:i=>g(r.name,e.value,i,t),name:e.label}),label:jsx(p,{variant:"caption",color:"grey.600",children:e.label})})},c)).length===0?jsx(q,{sx:{svg:{height:100}},text:"Nenhum registro para ser apresentado"}):r.list.filter(e=>e.label?.toLowerCase().includes(d.toLowerCase())).map((e,c)=>jsx(A,{children:jsx(w,{control:t==="multi"?jsx(L,{size:"small",checked:l[a].includes(e.value),onChange:i=>g(r.name,e.value,i,t),name:e.label}):jsx(x,{size:"small",checked:l[a].includes(e.value),onChange:i=>g(r.name,e.value,i,t),name:e.label}),label:jsx(p,{variant:"caption",color:"grey.600",children:e.label})})},c)))})})]})]},n))})},ye=J;
23
23
 
24
- export { Se as default };
24
+ export { ye as default };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.86",
2
+ "version": "2.0.87",
3
3
  "name": "@zydon/common-csr",
4
4
  "description": "Zydon common resources for React projects (only Client-Side Rendering (CSR))",
5
5
  "license": "MIT",