@zydon/common-csr 2.0.61 → 2.0.62

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