@zydon/common 2.0.58 → 2.0.60
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,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { Item } from '../../types/item.js';
|
|
3
4
|
|
|
4
|
-
interface Item {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
label: ReactNode;
|
|
8
|
-
}
|
|
9
5
|
interface SwapListProps {
|
|
10
6
|
selectedItems: Item[];
|
|
11
7
|
items: Item[];
|
|
@@ -16,11 +12,12 @@ interface SwapListProps {
|
|
|
16
12
|
search: string | undefined;
|
|
17
13
|
onSearch(value: string | undefined): void;
|
|
18
14
|
itemsTitle: ReactNode;
|
|
15
|
+
selectedItemChild(item: Item): ReactNode;
|
|
19
16
|
selectedItemsTitle: ReactNode;
|
|
20
17
|
additionalContent?: ReactNode;
|
|
21
18
|
enableSearchInSelectedItems?: boolean;
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
declare const SwapList: ({ selectedItems, items, loading, searchText, onAdd, onRemove, search, itemsTitle, selectedItemsTitle, additionalContent, enableSearchInSelectedItems, onSearch, }: SwapListProps) => react_jsx_runtime.JSX.Element;
|
|
21
|
+
declare const SwapList: ({ selectedItems, items, loading, searchText, onAdd, onRemove, search, itemsTitle, selectedItemsTitle, additionalContent, enableSearchInSelectedItems, selectedItemChild, onSearch, }: SwapListProps) => react_jsx_runtime.JSX.Element;
|
|
25
22
|
|
|
26
23
|
export { SwapList as default };
|
|
@@ -12,11 +12,11 @@ import f from '@mui/material/Divider';
|
|
|
12
12
|
import o from '@mui/material/Stack';
|
|
13
13
|
import S from '@mui/material/Typography';
|
|
14
14
|
import { debounce } from '@mui/material/utils';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
15
|
+
import U from '@mui/material/Box';
|
|
16
|
+
import X from '@mui/material/Button';
|
|
17
17
|
import { styled } from '@mui/material/styles';
|
|
18
18
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
19
19
|
|
|
20
|
-
var C=styled(
|
|
20
|
+
var C=styled(X)(({theme:n})=>({borderColor:n.palette.grey[300]})),I=styled(U)(({theme:n})=>({display:"flex",border:`1.5px solid ${n.palette.grey[300]}`,height:450,borderRadius:8,flex:1,overflow:"hidden"}));var Z=({selectedItems:n,items:T,loading:L,searchText:g,onAdd:B,onRemove:D,search:P,itemsTitle:z,selectedItemsTitle:W,additionalContent:H,enableSearchInSelectedItems:k,selectedItemChild:K,onSearch:N})=>{let[$,_]=useState(""),M=debounce(N,400),s=T.filter(e=>!n.some(a=>a.id===e.id)),O=n.filter(e=>e.name?.toLowerCase().includes($.toLowerCase())),d=k?O:n,[i,p]=useState([]),[l,m]=useState([]),j=()=>{B(i),p([]);},G=()=>{D(l),m([]);},V=e=>{m(e?d:[]);},q=e=>{p(e?s:[]);},J=(e,a)=>{m(a?c=>[...c,e]:c=>c.filter(u=>u.id!==e.id));},Q=(e,a)=>{p(a?c=>[...c,e]:c=>c.filter(u=>u.id!==e.id));},A=e=>{e.key==="Enter"&&e.preventDefault();};return jsx(o,{children:jsxs(o,{direction:"row",alignItems:"center",gap:3,children:[jsx(I,{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!==s.length,checked:i.length>0&&i.length===s.length,onChange:e=>q(e.target.checked)}),jsxs(o,{children:[jsx(S,{variant:"subtitle2",color:"text.primary",children:`${z} cadastrados(as)`}),jsx(S,{variant:"caption",color:"text.disabled",children:`${i.length}/${s.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:A,size:"small",fullWidth:!0,trigger:"change",onSearch:e=>M(e)}),H]}),jsx(a$1,{isLoading:L,loading:jsx(o,{alignItems:"center",justifyContent:"center",flex:1,children:jsx(F,{})}),isEmpty:s.length===0,empty:jsx(a$2,{text:P?`Nenhum ${g} encontrado`:`Nenhum ${g} dispon\xEDvel`,sx:{svg:{height:140}}}),children:jsx(a$3,{sx:{maxHeight:280},children:s.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:a=>Q(e,a.target.checked)}),e.label]}),jsx(f,{})]},e.id))})})]})]})}),jsxs(o,{gap:3,children:[jsx(C,{variant:"outlined",onClick:j,children:jsx(a$4,{icon:"ARROW_RIGHT_SIMPLE"})}),jsx(C,{variant:"outlined",onClick:G,children:jsx(a$4,{icon:"ARROW_LEFT_SIMPLE"})})]}),jsx(I,{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!==d.length,checked:l.length>0&&l.length===d.length,onChange:e=>V(e.target.checked)}),jsxs(o,{children:[jsx(S,{variant:"subtitle2",color:"text.primary",children:`${W} selecionados(as)`}),jsx(S,{variant:"caption",color:"text.disabled",children:`${l.length}/${d.length} selecionados`})]})]}),jsx(f,{}),jsxs(o,{p:2,gap:1,overflow:"hidden",children:[k&&jsx(a,{iconPosition:"start",placeholder:"Buscar",size:"small",fullWidth:!0,trigger:"change",onSearch:e=>_(e??""),onKeyDown:A}),jsx(a$1,{isLoading:L,loading:jsx(o,{alignItems:"center",justifyContent:"center",flex:1,children:jsx(F,{})}),isEmpty:d.length===0,empty:jsx(a$2,{text:$&&k?`Nenhum ${g} encontrado`:`Nenhum ${g} selecionado`,sx:{svg:{height:140},marginTop:"56px",backgroundColor:"transparent"}}),children:jsx(a$3,{sx:{maxHeight:280},children:d.map(e=>jsxs(o,{gap:1,children:[jsxs(o,{direction:"row",gap:.5,alignItems:"center",marginTop:"8px",children:[K(e),jsx(h,{size:"small",checked:l.includes(e),onChange:a=>J(e,a.target.checked)}),e.label]}),jsx(f,{})]},e.id))})})]})]})})]})})},ue=Z;
|
|
21
21
|
|
|
22
|
-
export {
|
|
22
|
+
export { ue as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|