@zydon/common-csr 2.0.95 → 2.0.96
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
1
|
import { useState } from 'react';
|
|
2
2
|
import { useFormContext } from 'react-hook-form';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
3
|
+
import N from '@mui/material/Accordion';
|
|
4
|
+
import $ from '@mui/material/AccordionDetails';
|
|
5
|
+
import j 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 q 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';
|
|
13
13
|
import { styled, alpha } from '@mui/material/styles';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
14
|
+
import u from '@mui/material/Typography';
|
|
15
|
+
import U from '@zydon/common/components/EmptyView';
|
|
16
|
+
import W from '@zydon/common/components/Icon';
|
|
17
|
+
import J from '@zydon/common/components/Label';
|
|
18
|
+
import K from '@zydon/common/components/SearchInput';
|
|
19
|
+
import H from '@zydon/common/components/Scrollbar';
|
|
20
20
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var k=styled(H)(()=>({maxHeight:"260px"}));var Q=({items:s,initialValues:F,onChange:S})=>{let{setValue:R,getValues:E}=useFormContext(),[t,I]=useState(-1),[g,b]=useState(""),V=Object.fromEntries(s.map((a,o)=>[o,[]])),[c,h]=useState(F||V),B=(a,o)=>{I(o?a:-1),o&&P();},P=()=>{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);h({...c,[t]:i}),f(a,i);},y=a=>{b(a);},D=()=>{let o=s[t].list.every(n=>c[t].includes(n.value))?[]:[...s[t].list.map(n=>n.value)];h({...c,[t]:o}),f(s[t].name,o);},M=()=>{h({...c,[t]:[]}),f(s[t].name,[]);},f=(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},R("config",{...e,...n}),S&&S({...e,...n});}},C=a=>[...a].sort((o,n)=>{let e=c[t].includes(o.value),l=c[t].includes(n.value);return e&&!l?-1:!e&&l?1:0});return jsx(Fragment,{children:s.map(({type:a="multi",...o},n)=>jsxs(N,{expanded:t===n,onChange:(e,l)=>B(n,l),children:[jsx(j,{expandIcon:jsx(W,{icon:"CHEVRON_UP"}),id:`${n}`,children:jsxs(z,{alignItems:"center",direction:"row",children:[jsx(u,{variant:"subtitle2",color:"grey.600",children:o.label}),jsxs(J,{variant:"soft",color:"primary",marginLeft:1,sx:e=>({backgroundColor:`${alpha(e.palette.grey[400],.2)}`,cursor:"pointer"}),children:[c[n].length," selecionados"]})]})}),jsxs($,{children:[jsxs(z,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[jsx(K,{onSearch:y,onChange:e=>y(e.target.value),iconPosition:"start",size:"small",placeholder:"Buscar",value:g,fullWidth:!0}),a==="multi"?jsx(L,{onClick:D,size:"small",children:jsx(u,{variant:"overline",children:"TODOS"})}):jsx(L,{onClick:M,size:"small",color:"error",children:jsx(u,{variant:"overline",children:"LIMPAR"})})]}),jsx(k,{children:jsx(q,{children:t>-1&&C(o.list.filter(e=>e.label?.toLowerCase().includes(g.toLowerCase()))).map((e,l)=>jsx(x,{children:jsx(A,{control:a==="multi"?jsx(w,{size:"small",checked:c[t].includes(e.value),onChange:i=>d(o.name,e.value,i,a),name:e.label}):jsx(T,{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(U,{sx:{svg:{height:100}},text:"Nenhum registro para ser apresentado"}):C(o.list.filter(e=>e.label?.toLowerCase().includes(g.toLowerCase()))).map((e,l)=>jsx(x,{children:jsx(A,{control:a==="multi"?jsx(w,{size:"small",checked:c[t].includes(e.value),onChange:i=>d(o.name,e.value,i,a),name:e.label}):jsx(T,{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))})},Ce=Q;
|
|
23
23
|
|
|
24
|
-
export {
|
|
24
|
+
export { Ce as default };
|
package/package.json
CHANGED