@zydon/common-csr 2.0.63 → 2.0.65

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,11 +1,11 @@
1
1
  import { useState, useEffect } from 'react';
2
2
  import { useFormContext } from 'react-hook-form';
3
- import B from '@mui/material/Accordion';
4
- import H from '@mui/material/AccordionDetails';
5
- import M from '@mui/material/AccordionSummary';
3
+ import P from '@mui/material/Accordion';
4
+ import B from '@mui/material/AccordionDetails';
5
+ import H from '@mui/material/AccordionSummary';
6
6
  import _ from '@mui/material/Button';
7
- import L from '@mui/material/Checkbox';
8
- import w from '@mui/material/FormControlLabel';
7
+ import w from '@mui/material/Checkbox';
8
+ import h from '@mui/material/FormControlLabel';
9
9
  import N from '@mui/material/List';
10
10
  import x from '@mui/material/ListItem';
11
11
  import $ from '@mui/material/Radio';
@@ -16,9 +16,9 @@ import q from '@zydon/common/components/EmptyView';
16
16
  import G from '@zydon/common/components/Icon';
17
17
  import U from '@zydon/common/components/Label';
18
18
  import W from '@zydon/common/components/SearchInput';
19
- import D from '@zydon/common/components/Scrollbar';
19
+ import I from '@zydon/common/components/Scrollbar';
20
20
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
21
21
 
22
- var k=styled(D)(()=>({maxHeight:"260px"}));var J=({items:s,onChange:h})=>{let{setValue:y,getValues:E}=useFormContext(),[t,F]=useState(-1),[g,b]=useState(""),T=Object.fromEntries(s.map((a,o)=>[o,[]])),[c,v]=useState(T);useEffect(()=>()=>{y("config",{});},[]);let R=(a,o)=>{F(o?a:-1),o&&V();},V=()=>{b("");},d=(a,o,n,e)=>{let l=e==="unique"?[o]:[...c[t],o],i=n.target.checked?l:c[t].filter(m=>m!==o);v({...c,[t]:i}),C(a,i);},S=a=>{b(a);},z=()=>{let o=s[t].list.every(n=>c[t].includes(n.value))?[]:[...s[t].list.map(n=>n.value)];v({...c,[t]:o}),C(s[t].name,o);},C=(a,o)=>{let n={},e=E("config"),l=s[t];if(l){let i=l.list.filter(m=>c[t].includes(m.value)).map(m=>m.value);n[l.name]={type:"FIELD",values:l.name===a?o:i},y("config",{...e,...n}),h&&h({...e,...n});}};return jsx(Fragment,{children:s.map(({type:a="multi",...o},n)=>jsxs(B,{expanded:t===n,onChange:(e,l)=>R(n,l),children:[jsx(M,{expandIcon:jsx(G,{icon:"CHEVRON_UP"}),id:`${n}`,children:jsxs(A,{alignItems:"center",direction:"row",children:[jsx(u,{variant:"subtitle2",color:"grey.600",children:o.label}),jsxs(U,{variant:"soft",color:"primary",marginLeft:1,sx:e=>({backgroundColor:`${alpha(e.palette.grey[400],.2)}`,cursor:"pointer"}),children:[c[n].length," selecionados"]})]})}),jsxs(H,{children:[jsxs(A,{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:g,fullWidth:!0}),a==="multi"&&jsx(_,{onClick:()=>z(),size:"small",children:jsx(u,{variant:"overline",children:"TODOS"})})]}),jsx(k,{children:jsx(N,{children:t>-1&&(o.list.filter(e=>e.label?.toLowerCase().includes(g.toLowerCase())).map((e,l)=>jsx(x,{children:jsx(w,{control:a==="multi"?jsx(L,{size:"small",checked:c[t].includes(e.value),onChange:i=>d(o.name,e.value,i,a),name:e.label}):jsx($,{size:"small",checked:c[t].includes(e.value),onChange:i=>d(o.name,e.value,i,a),name:e.label,value:e.value}),label:jsx(u,{variant:"caption",color:"grey.600",children:e.label})})},l)).length===0?jsx(q,{sx:{svg:{height:100}},text:"Nenhum registro para ser apresentado"}):o.list.filter(e=>e.label?.toLowerCase().includes(g.toLowerCase())).map((e,l)=>jsx(x,{children:jsx(w,{control:jsx(L,{size:"small",checked:c[t].includes(e.value),onChange:i=>d(o.name,e.value,i,a),name:e.label}),label:jsx(u,{variant:"caption",color:"grey.600",children:e.label})})},l)))})})]})]},n))})},ve=J;
22
+ var L=styled(I)(()=>({maxHeight:"260px"}));var J=({items:i,onChange:y})=>{let{setValue:v,getValues:T}=useFormContext(),[a,E]=useState(-1),[g,b]=useState(""),F=Object.fromEntries(i.map((t,o)=>[o,[]])),[c,S]=useState(F);useEffect(()=>()=>{v("config",{});},[]);let R=(t,o)=>{E(o?t:-1),o&&V();},V=()=>{b("");},d=(t,o,n,e)=>{let l=e==="unique"?[o]:[...c[a],o],s=n.target.checked?l:c[a].filter(p=>p!==o);S({...c,[a]:s}),k(t,s);},C=t=>{b(t);},z=()=>{let o=i[a].list.every(n=>c[a].includes(n.value))?[]:[...i[a].list.map(n=>n.value)];S({...c,[a]:o}),k(i[a].name,o);},k=(t,o)=>{let n={},e=T("config"),l=i[a];if(l){let s=l.list.filter(p=>c[a].includes(p.value)).map(p=>p.value);n[l.name]={type:"FIELD",values:l.name===t?o:s},v("config",{...e,...n}),y&&y({...e,...n});}};return jsx(Fragment,{children:i.map(({type:t="multi",...o},n)=>jsxs(P,{expanded:a===n,onChange:(e,l)=>R(n,l),children:[jsx(H,{expandIcon:jsx(G,{icon:"CHEVRON_UP"}),id:`${n}`,children:jsxs(A,{alignItems:"center",direction:"row",children:[jsx(u,{variant:"subtitle2",color:"grey.600",children:o.label}),jsxs(U,{variant:"soft",color:"primary",marginLeft:1,sx:e=>({backgroundColor:`${alpha(e.palette.grey[400],.2)}`,cursor:"pointer"}),children:[c[n].length," selecionados"]})]})}),jsxs(B,{children:[jsxs(A,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[jsx(W,{onSearch:C,onChange:e=>C(e.target.value),iconPosition:"start",size:"small",placeholder:"Buscar",value:g,fullWidth:!0}),t==="multi"&&jsx(_,{onClick:()=>z(),size:"small",children:jsx(u,{variant:"overline",children:"TODOS"})})]}),jsx(L,{children:jsx(N,{children:a>-1&&(o.list.filter(e=>e.label?.toLowerCase().includes(g.toLowerCase())).map(e=>jsx(x,{children:t==="multi"?jsx(h,{control:jsx(w,{size:"small",checked:c[a].includes(e.value),onChange:l=>d(o.name,e.value,l,t),name:e.label}),label:jsx(u,{variant:"caption",color:"grey.600",children:e.label})}):jsx(h,{checked:c[a].includes(e.value),control:jsx($,{size:"small",onChange:l=>d(o.name,e.value,l,t)}),value:e.value,label:jsxs(u,{variant:"caption",color:"grey.600",children:["MuiRadio: ",e.label]})})},t+e.value)).length===0?jsx(q,{sx:{svg:{height:100}},text:"Nenhum registro para ser apresentado"}):o.list.filter(e=>e.label?.toLowerCase().includes(g.toLowerCase())).map((e,l)=>jsx(x,{children:jsx(h,{control:jsx(w,{size:"small",checked:c[a].includes(e.value),onChange:s=>d(o.name,e.value,s,t),name:e.label}),label:jsx(u,{variant:"caption",color:"grey.600",children:e.label})})},l)))})})]})]},n))})},be=J;
23
23
 
24
- export { ve as default };
24
+ export { be as default };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.63",
2
+ "version": "2.0.65",
3
3
  "name": "@zydon/common-csr",
4
4
  "description": "Zydon common resources for React projects (only Client-Side Rendering (CSR))",
5
5
  "license": "MIT",