@zydon/common 2.2.54 → 2.2.55
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.
- package/dist/chunk-VLEKZG4Z.js +11 -0
- package/dist/components/DataCards/index.d.ts +10 -3
- package/dist/components/DataCards/index.js +11 -10
- package/dist/components/Incrementer/index.js +1 -1
- package/dist/components/form/Incrementer/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-MWE6DITP.js +0 -11
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { f } from './chunk-ANAHA3L6.js';
|
|
2
|
+
import { a } from './chunk-7KZ2UT76.js';
|
|
3
|
+
import { a as a$1 } from './chunk-M6UXUQUU.js';
|
|
4
|
+
import { forwardRef, useState, useRef, useMemo, useCallback } from 'react';
|
|
5
|
+
import A from '@mui/material/IconButton';
|
|
6
|
+
import C from '@mui/material/InputAdornment';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var M=forwardRef(({name:R,increment:r=1,updadteForMultiple:D,allowNegative:u=!1,value:I,onChange:f$1,minValue:n,maxValue:e,decimalScale:p,disabled:m,tabIndex:T,labelIncrementer:w,labelDecrementer:B,placeholder:O,...v},z)=>{let[E,L]=useState(`incrementer-input-${Date.now()}`),i=useRef(null),s=Number(I||0),b=()=>{i.current&&(clearTimeout(i.current),i.current=null);},N=useMemo(()=>{let o=s-r;return typeof n=="number"&&o<n?!0:m||!u&&o<0},[m,s,r,n,u]),_=useMemo(()=>{let o=s+r;return typeof e=="number"&&o>e?!0:m},[m,s,r,e]),$=useCallback(()=>{if(b(),!u&&s-r<0)return;let o=s-r,t=n!==void 0&&o<n?n:f(o,p);f$1(t);},[s,r,n,p,f$1,u]),G=useCallback(()=>{b();let o=s+r,t=e!==void 0&&o>e?e:f(o,p);f$1(t);},[s,r,e,p,f$1]),H=useCallback(o=>{b();let t=Number(o.target.value||0);(r!==1||D)&&(t=t+r/2,t-=t%r),!u&&t<0&&(t=0),typeof n=="number"&&t<n&&(t=n),typeof e=="number"&&t>e&&(t=e),t=f(t,p),t===I&&(i.current=setTimeout(()=>{L(`incrementer-input-${Date.now()}`);},600)),f$1(t);},[I,r,n,e,p,f$1,D,u]);return jsx(a,{ref:z,name:R,value:I,minValue:n,maxValue:e,allowNegative:u,decimalScale:p,InputProps:{startAdornment:jsx(C,{position:"start",children:jsx(A,{size:"medium",onClick:$,disabled:N,"aria-label":B||"Decrementa",children:jsx(a$1,{icon:"MINUS_SIGN",width:14,height:14,color:"primary.main"})})}),endAdornment:jsx(C,{position:"end",children:jsx(A,{size:"medium",onClick:G,disabled:_,"aria-label":w||"Incrementa",children:jsx(a$1,{icon:"SIMPLE_ADD",width:14,height:14,color:"primary.main"})})}),inputProps:{style:{textAlign:"center"}}},inputProps:{tabIndex:T},onChange:H,disabled:m,placeholder:O,...v},E)});M.displayName="Incrementer";var j=M;
|
|
10
|
+
|
|
11
|
+
export { j as a };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { GridValidRowModel, GridRowParams, MuiEvent } from '@mui/x-data-grid-premium';
|
|
2
|
+
import { GridValidRowModel, GridRowParams, MuiEvent, GridRowSelectionModel } from '@mui/x-data-grid-premium';
|
|
3
3
|
import { DatagridRow, Columns, Row } from '../../types/datagrid.js';
|
|
4
4
|
import * as _mui_x_data_grid from '@mui/x-data-grid';
|
|
5
5
|
|
|
@@ -24,20 +24,27 @@ interface DataCardsProps {
|
|
|
24
24
|
fetching?: boolean;
|
|
25
25
|
getRowId: (row: DatagridRow) => string;
|
|
26
26
|
onClick?: (params: GridRowParams<object>, event: MuiEvent<React.MouseEvent<HTMLElement, MouseEvent>>, details: unknown) => void;
|
|
27
|
+
checkboxSelection?: boolean;
|
|
28
|
+
onSelectionRow?: (selectedRows: GridRowSelectionModel) => void;
|
|
29
|
+
selectedRows?: GridRowSelectionModel;
|
|
27
30
|
}
|
|
28
31
|
interface DataCardProps {
|
|
29
32
|
fields: MappedRow[];
|
|
30
33
|
id: string;
|
|
31
34
|
title: string;
|
|
35
|
+
row: DatagridRow;
|
|
32
36
|
onClick?: (params: GridRowParams<object>, event: MuiEvent<React.MouseEvent<HTMLElement, MouseEvent>>, details: unknown) => void;
|
|
37
|
+
checkboxSelection?: boolean;
|
|
38
|
+
onSelectionRow?: (selectedRows: GridRowSelectionModel) => void;
|
|
39
|
+
selectedRows?: GridRowSelectionModel;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
declare const DataCard: ({ fields, id, title, onClick }: DataCardProps) => react_jsx_runtime.JSX.Element;
|
|
42
|
+
declare const DataCard: ({ fields, id, row, title, onClick, checkboxSelection, selectedRows, onSelectionRow, }: DataCardProps) => react_jsx_runtime.JSX.Element;
|
|
36
43
|
|
|
37
44
|
declare const DataCardSkeleton: () => react_jsx_runtime.JSX.Element;
|
|
38
45
|
|
|
39
46
|
declare const getFieldData: (columns: readonly _mui_x_data_grid.GridColDef<any>[], row: Row) => MappedRow[];
|
|
40
47
|
|
|
41
|
-
declare const DataCards: ({ title, rows, columns, getRowId, onClick, loading, fetching, pagination, }: DataCardsProps) => react_jsx_runtime.JSX.Element;
|
|
48
|
+
declare const DataCards: ({ title, rows, columns, getRowId, onClick, loading, fetching, pagination, checkboxSelection, onSelectionRow, selectedRows, }: DataCardsProps) => react_jsx_runtime.JSX.Element;
|
|
42
49
|
|
|
43
50
|
export { DataCard, DataCardSkeleton, DataCards as default, getFieldData };
|
|
@@ -4,17 +4,18 @@ import { a as a$1 } from '../../chunk-YWEB6IAI.js';
|
|
|
4
4
|
import { a as a$2 } from '../../chunk-ZODC2MGF.js';
|
|
5
5
|
import '../../chunk-ZDHXW74M.js';
|
|
6
6
|
import '../../chunk-D27ND54J.js';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import ct from '@mui/material/Pagination';
|
|
8
|
+
import C from '@mui/material/Stack';
|
|
9
9
|
import { useMemo } from 'react';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
10
|
+
import Z from '@mui/material/CardContent';
|
|
11
|
+
import tt from '@mui/material/Checkbox';
|
|
12
|
+
import x from '@mui/material/Typography';
|
|
13
|
+
import V from '@mui/material/Card';
|
|
14
|
+
import X from '@mui/material/CardActionArea';
|
|
15
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
15
16
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
16
|
-
import
|
|
17
|
+
import g from '@mui/material/Skeleton';
|
|
17
18
|
|
|
18
|
-
var
|
|
19
|
+
var A=styled(V)(({theme:o})=>({boxShadow:"none",border:`1px solid ${alpha(o.palette.grey[500],.2)}`})),I=styled(X)(({disableRipple:o})=>({".MuiCardActionArea-focusHighlight":{background:"transparent"},...o&&{"&:hover":{cursor:"default"}}}));var $=o=>{o.stopPropagation();},et=({fields:o,id:t,row:p,title:s,onClick:r,checkboxSelection:m,selectedRows:d,onSelectionRow:n})=>{let c$1=useMemo(()=>d?.includes(t),[t,d]),a$1=o.find(e=>e.label.toLowerCase()==="status"||e.type==="status"||e.field==="status"),S=useMemo(()=>a$1?.renderCell?.({value:a$1.value,field:t,row:{[t]:a$1.value}})||a$1?.value,[a$1,t]),b=o.find(e=>e.type==="actions"||e.id==="actions"),f=useMemo(()=>b?.getActions({id:t,row:p})||null,[b,t,p]),h=useMemo(()=>o.filter(e=>e.label.toLowerCase()!=="status"&&e.value?.toString()!==t&&e.type!=="actions"),[o,t]),O=e=>{r?.({id:t},e,o);},Q=e=>{let v=d||[];n?.(e?[...v,t]:v.filter(U=>U!==t));},T=jsxs(Z,{sx:{padding:"0!important"},children:[jsxs(C,{flexDirection:"row",justifyContent:"space-between",p:2,children:[jsxs(C,{flexDirection:"row",alignItems:"center",gap:1,children:[m&&jsx(tt,{checked:c$1||!1,onChange:(e,v)=>Q(v)}),jsx(x,{variant:"body1",fontWeight:600,color:"text.secondary",children:s}),jsxs(x,{variant:"body1",fontWeight:600,children:[c(t)?"#":"",t]})]}),jsxs(C,{className:"actions",flexDirection:"row",alignItems:"center",gap:1,children:[jsx(x,{variant:"body2",color:"text.secondary",textTransform:"uppercase",fontSize:14,fontWeight:600,children:S}),jsx(C,{onClick:$,onMouseDown:$,children:f})]})]}),jsx(a,{}),jsx(C,{flexWrap:"wrap",direction:"row",justifyContent:"space-between",p:2,pb:0,children:h.map(e=>e.value!=t&&jsxs(C,{flexBasis:"50%",pb:2,order:e.order,children:[jsx(x,{variant:"body2",color:"text.secondary",children:e.label}),jsx(x,{variant:"body1",children:e.valueGetter?e.valueFormatter(e.valueGetter(e.value)):e.value})]},`data-card-field-${t}-${e.label}`))})]});return r?jsx(A,{onClick:O,children:jsx(I,{component:"div",children:T})}):jsx(A,{children:T})},G=et;var rt=()=>jsxs(V,{children:[jsxs(C,{justifyContent:"space-between",direction:"row",spacing:2,p:2,children:[jsx(g,{height:24,width:200}),jsx(g,{height:24,width:100})]}),jsxs(C,{justifyContent:"space-between",flexWrap:"wrap",direction:"row",p:2,children:[jsxs(C,{width:"50%",spacing:1,children:[jsx(g,{height:24,width:100}),jsx(g,{sx:{maxWidth:"95%"},height:24,width:230})]}),jsxs(C,{width:"50%",spacing:1,children:[jsx(g,{height:24,width:80}),jsx(g,{sx:{maxWidth:"100%"},height:27,width:250})]})]})]}),P=rt;var L=(o,t)=>{let p=[];o.forEach(r=>{r.field&&r.field!=="actions"&&p.push({...r,label:r.headerName||r.field,value:t[r.field],type:r.type,order:r?.order||0,id:r.field});});let s=o.find(r=>r.field==="actions");return s&&p.push({...s,label:"Actions",value:null,order:0,type:"actions",id:"actions"}),p};var _=styled(C)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.2)}`,borderRadius:16})),j=styled(C)(()=>({padding:"12px 28px",flexDirection:"row",alignItems:"center",backgroundColor:"#F4F4F4",gap:14,borderRadius:"16px 16px 0 0"}));var st=({children:o,title:t,rows:p,onSelectionRow:s,selectedRows:r,totalItems:m})=>{let d=c=>{s?.(c?p.map(a=>a["@id"]):[]);},n=r?.length||0;return jsxs(_,{children:[jsxs(j,{children:[jsx(tt,{onChange:(c,a)=>d(a),checked:n===m,indeterminate:n>0&&n<m}),jsx(x,{variant:"subtitle2",component:"span",color:"grey.600",children:t})]}),jsx(C,{gap:1.5,p:1.5,children:o})]})},q=st;var lt=({title:o,rows:t,columns:p,getRowId:s,onClick:r,loading:m,fetching:d,pagination:n,checkboxSelection:c,onSelectionRow:a,selectedRows:S})=>{let b=d&&jsx(a$1,{sx:{zIndex:1}});return m?jsxs(Fragment,{children:[b,jsx(P,{}),jsx(P,{}),jsx(P,{})]}):jsxs(C,{gap:2,component:c?q:"div",...c&&{title:o,rows:t,onSelectionRow:a,selectedRows:S,totalItems:n?.total||t.length},children:[b,t.length===0&&jsx(a$2,{sx:{mb:3},title:"Nenhum registro encontrado"}),t.map(f=>{let h=s(f);return jsx(G,{title:o,id:h,row:f,fields:L(p,f),onClick:r,checkboxSelection:c,selectedRows:S,onSelectionRow:a},`data-card-${h}`)}),n&&t.length>0&&jsx(C,{direction:"row",justifyContent:"center",children:jsx(ct,{page:n?.page,onChange:(f,h)=>{n?.onPageChange(h);},count:n?.total})})]})},Ut=lt;
|
|
19
20
|
|
|
20
|
-
export {
|
|
21
|
+
export { G as DataCard, P as DataCardSkeleton, Ut as default, L as getFieldData };
|
package/package.json
CHANGED
package/dist/chunk-MWE6DITP.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { f } from './chunk-ANAHA3L6.js';
|
|
2
|
-
import { a } from './chunk-7KZ2UT76.js';
|
|
3
|
-
import { a as a$1 } from './chunk-M6UXUQUU.js';
|
|
4
|
-
import { forwardRef, useState, useRef, useMemo, useCallback } from 'react';
|
|
5
|
-
import A from '@mui/material/IconButton';
|
|
6
|
-
import C from '@mui/material/InputAdornment';
|
|
7
|
-
import { jsx } from 'react/jsx-runtime';
|
|
8
|
-
|
|
9
|
-
var M=forwardRef(({name:R,increment:r=1,updadteForMultiple:D,allowNegative:s=!1,value:d=0,onChange:c,minValue:n,maxValue:e,decimalScale:p,disabled:i,tabIndex:T,labelIncrementer:w,labelDecrementer:B,...O},v)=>{let[z,E]=useState(`incrementer-input-${Date.now()}`),m=useRef(null),u=Number(d||0),b=()=>{m.current&&(clearTimeout(m.current),m.current=null);},L=useMemo(()=>{let o=u-r;return typeof n=="number"&&o<n?!0:i||!s&&o<0},[i,u,r,n,s]),N=useMemo(()=>{let o=u+r;return typeof e=="number"&&o>e?!0:i},[i,u,r,e]),_=useCallback(()=>{if(b(),!s&&u-r<0)return;let o=u-r,t=n!==void 0&&o<n?n:f(o,p);c(t);},[u,r,n,p,c,s]),$=useCallback(()=>{b();let o=u+r,t=e!==void 0&&o>e?e:f(o,p);c(t);},[u,r,e,p,c]),G=useCallback(o=>{b();let t=Number(o.target.value||0);(r!==1||D)&&(t=t+r/2,t-=t%r),!s&&t<0&&(t=0),typeof n=="number"&&t<n&&(t=n),typeof e=="number"&&t>e&&(t=e),t=f(t,p),t===d&&(m.current=setTimeout(()=>{E(`incrementer-input-${Date.now()}`);},600)),c(t);},[d,r,n,e,p,c,D,s]);return jsx(a,{ref:v,name:R,value:u,minValue:n,maxValue:e,allowNegative:s,decimalScale:p,InputProps:{startAdornment:jsx(C,{position:"start",children:jsx(A,{size:"medium",onClick:_,disabled:L,"aria-label":B||"Decrementa",children:jsx(a$1,{icon:"MINUS_SIGN",width:14,height:14,color:"primary.main"})})}),endAdornment:jsx(C,{position:"end",children:jsx(A,{size:"medium",onClick:$,disabled:N,"aria-label":w||"Incrementa",children:jsx(a$1,{icon:"SIMPLE_ADD",width:14,height:14,color:"primary.main"})})}),inputProps:{style:{textAlign:"center"}}},inputProps:{tabIndex:T},onChange:G,disabled:i,...O},z)});M.displayName="Incrementer";var Z=M;
|
|
10
|
-
|
|
11
|
-
export { Z as a };
|