@zydon/common-csr 2.0.7 → 2.0.8

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.
@@ -0,0 +1,18 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface Items {
4
+ value: string;
5
+ label: string;
6
+ }
7
+ interface Item {
8
+ name: string;
9
+ list: Items[];
10
+ label: string;
11
+ }
12
+ interface FilterRuleProps {
13
+ items: Item[];
14
+ }
15
+
16
+ declare const FilterRule: ({ items }: FilterRuleProps) => react_jsx_runtime.JSX.Element;
17
+
18
+ export { FilterRule as default };
@@ -0,0 +1,24 @@
1
+ import '../../../chunk-6KMKD42J.mjs';
2
+ import { useState, useEffect } from 'react';
3
+ import { useFormContext } from 'react-hook-form';
4
+ import P from '@mui/material/Accordion';
5
+ import B from '@mui/material/AccordionDetails';
6
+ import H from '@mui/material/AccordionSummary';
7
+ import _ from '@mui/material/Button';
8
+ import C from '@mui/material/Checkbox';
9
+ import L from '@mui/material/FormControlLabel';
10
+ import M from '@mui/material/List';
11
+ import k from '@mui/material/ListItem';
12
+ import w from '@mui/material/Stack';
13
+ import { styled, alpha } from '@mui/material/styles';
14
+ import m from '@mui/material/Typography';
15
+ import $ from '@zydon/common/components/EmptyView';
16
+ import j from '@zydon/common/components/Icon';
17
+ import G from '@zydon/common/components/Label';
18
+ import U from '@zydon/common/components/SearchInput';
19
+ import z from '@zydon/common/components/Scrollbar';
20
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
21
+
22
+ var v=styled(z)(()=>({maxHeight:"260px"}));var W=({items:i})=>{let{setValue:f,getValues:x}=useFormContext(),[a,A]=useState(-1),[p,d]=useState(""),E=Object.fromEntries(i.map((t,o)=>[o,[]])),[c,h]=useState(E);useEffect(()=>()=>{f("config",{});},[]);let F=(t,o)=>{A(o?t:-1),o&&T();},T=()=>{d("");},y=(t,o,e)=>{let n=e.target.checked?[...c[a],o]:c[a].filter(l=>l!==o);h({...c,[a]:n}),b(t,n);},S=t=>{d(t);},I=()=>{let o=i[a].list.every(e=>c[a].includes(e.value))?[]:[...i[a].list.map(e=>e.value)];h({...c,[a]:o}),b(i[a].name,o);},b=(t,o)=>{let e={},n=x("config"),l=i[a];if(l){let V=l.list.filter(u=>c[a].includes(u.value)).map(u=>u.value);e[l.name]={type:"FIELD",values:l.name===t?o:V},f("config",{...n,...e});}};return jsx(Fragment,{children:i.map((t,o)=>jsxs(P,{expanded:a===o,onChange:(e,n)=>F(o,n),children:[jsx(H,{expandIcon:jsx(j,{icon:"CHEVRON_UP"}),id:`${o}`,children:jsxs(w,{alignItems:"center",direction:"row",children:[jsx(m,{variant:"subtitle2",color:"grey.600",children:t.label}),jsxs(G,{variant:"soft",color:"primary",marginLeft:1,sx:e=>({backgroundColor:`${alpha(e.palette.grey[400],.2)}`,cursor:"pointer"}),children:[c[o].length," selecionados"]})]})}),jsxs(B,{children:[jsxs(w,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[jsx(U,{onSearch:S,onChange:e=>S(e.target.value),iconPosition:"start",size:"small",placeholder:"Buscar",value:p,fullWidth:!0}),jsx(_,{onClick:()=>I(),size:"small",children:jsx(m,{variant:"overline",children:"TODOS"})})]}),jsx(v,{children:jsx(M,{children:a>-1&&(t.list.filter(e=>e.label.toLowerCase().includes(p.toLowerCase())).map((e,n)=>jsx(k,{children:jsx(L,{control:jsx(C,{size:"small",checked:c[a].includes(e.value),onChange:l=>y(t.name,e.value,l),name:e.label}),label:jsx(m,{variant:"caption",color:"grey.600",children:e.label})})},n)).length===0?jsx($,{sx:{svg:{height:100}},text:"Nenhum registro para ser apresentado"}):t.list.filter(e=>e.label.toLowerCase().includes(p.toLowerCase())).map((e,n)=>jsx(k,{children:jsx(L,{control:jsx(C,{size:"small",checked:c[a].includes(e.value),onChange:l=>y(t.name,e.value,l),name:e.label}),label:jsx(m,{variant:"caption",color:"grey.600",children:e.label})})},n)))})})]})]},o))})},he=W;
23
+
24
+ export { he as default };
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ interface ListingRulesProps {
5
+ setRuleType?(ruleType: string): void;
6
+ rules?: {
7
+ value: string;
8
+ component: ReactNode;
9
+ toggleTitle: string;
10
+ }[];
11
+ }
12
+
13
+ declare const ListingRules: ({ rules, setRuleType }: ListingRulesProps) => react_jsx_runtime.JSX.Element;
14
+
15
+ export { ListingRules as default };
@@ -0,0 +1,14 @@
1
+ import '../../../chunk-6KMKD42J.mjs';
2
+ import { useState, useEffect } from 'react';
3
+ import { useFormContext } from 'react-hook-form';
4
+ import v from '@mui/material/Stack';
5
+ import u from '@mui/material/Typography';
6
+ import h from '@zydon/common/form/Field';
7
+ import { styled } from '@mui/material/styles';
8
+ import s from '@mui/material/ToggleButton';
9
+ import c from '@mui/material/ToggleButtonGroup';
10
+ import { jsxs, jsx } from 'react/jsx-runtime';
11
+
12
+ var g=styled(s)(({theme:o})=>({width:"100%","&.Mui-selected":{backgroundColor:o.palette.primary.main,color:o.palette.common.white,"&:hover":{backgroundColor:o.palette.primary.main}}})),m=styled(c)(()=>({display:"flex",justifyContent:"space-between"}));var S=({rules:o,setRuleType:a})=>{let[n,i]=useState(),{setValue:d}=useFormContext();return useEffect(()=>{if(o&&o.length>0&&(i(o[0].value),a))return a(o[0].value)},[]),useEffect(()=>()=>{d("config",{});},[]),jsxs(v,{gap:2,children:[jsx(h,{name:"name",label:"Nome da regra",required:!0,rules:{required:{value:!0,message:"Nome da regra \xE9 obrigat\xF3rio"}}}),jsx(u,{color:"grey.500",variant:"overline",children:"Selecione a regra"}),o&&jsx(m,{color:"primary",value:n,size:"small",exclusive:!0,onChange:(t,e)=>{if(e!==null&&(i(e),a))return a(e)},children:o.map((t,e)=>jsx(g,{value:t.value,size:"small",color:"primary",children:jsx(u,{variant:"body2",children:t.toggleTitle})},e))}),o&&o.map((t,e)=>t.value===n?jsx("div",{children:t.component},e):null)]})},N=S;
13
+
14
+ export { N as default };
@@ -0,0 +1,18 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { GridColDef, GridRowsProp } from '@mui/x-data-grid-premium';
3
+
4
+ interface ManualRuleProps {
5
+ columns: GridColDef[];
6
+ rows: GridRowsProp;
7
+ loading: boolean;
8
+ fetching: boolean;
9
+ totalRows: number;
10
+ handlePaginationChange: ({ pageSize, page, }: {
11
+ pageSize?: number | undefined;
12
+ page?: number | undefined;
13
+ }) => void;
14
+ }
15
+
16
+ declare const ManualRules: ({ columns, rows, loading, fetching, totalRows, handlePaginationChange, }: ManualRuleProps) => react_jsx_runtime.JSX.Element;
17
+
18
+ export { ManualRules as default };
@@ -0,0 +1,13 @@
1
+ import '../../../chunk-6KMKD42J.mjs';
2
+ import { useEffect, useState } from 'react';
3
+ import { useFormContext } from 'react-hook-form';
4
+ import s from '@mui/material/Stack';
5
+ import k from '@mui/material/Typography';
6
+ import G from '@zydon/common/components/DataGrid';
7
+ import v from '@zydon/common/components/SearchInput';
8
+ import x from '@zydon/common/hooks/useDatagrid';
9
+ import { jsxs, jsx } from 'react/jsx-runtime';
10
+
11
+ var z=({columns:c,rows:p,loading:g,fetching:d,totalRows:u,handlePaginationChange:f})=>{let{setValue:n}=useFormContext(),{apiRef:m,page:r,perPage:S}=x();useEffect(()=>()=>{n("config",{});},[]);let[h,M]=useState([]),[w,a]=useState(),y=e=>{M(e),n("config.products",{type:"FIELD",values:e});},R=()=>{let e=w?.toLowerCase();return p.filter(C=>Object.values(C).some(o=>typeof o=="string"||o instanceof String?o.toLowerCase().includes(e||""):!1))};return jsxs(s,{gap:2,children:[jsxs(s,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsx(v,{onSearch:e=>a(e),onChange:e=>a(e.target.value),iconPosition:"start",size:"small",placeholder:"Buscar"}),jsxs(k,{variant:"body1",color:"text.disabled",children:[h.length," selecionados"]})]}),jsx(G,{apiRef:m,columns:c,rows:R(),pagination:!0,paginationModel:{page:r,pageSize:S},rowCount:u,paginationMode:"server",onPaginationModelChange:f,initialState:{pagination:{paginationModel:{pageSize:5,page:r}}},loading:g,fetching:d,checkboxSelection:!0,onRowSelectionModelChange:y})]})},j=z;
12
+
13
+ export { j as default };
@@ -1,3 +1,4 @@
1
+ import '../../chunk-6KMKD42J.mjs';
1
2
  import { forwardRef } from 'react';
2
3
  import { LazyLoadImage } from 'react-lazy-load-image-component';
3
4
  import p from '@mui/material/Box';
@@ -1,3 +1,4 @@
1
+ import '../../chunk-6KMKD42J.mjs';
1
2
  import { stylesMode, paper, varAlpha } from '@zydon/common/theme/styles';
2
3
  import { forwardRef, cloneElement, useState, useCallback, useRef, useEffect, useMemo } from 'react';
3
4
  import U from '@mui/material/Box';
@@ -1,3 +1,4 @@
1
+ import '../chunk-6KMKD42J.mjs';
1
2
  import { useLocation, matchPath } from 'react-router-dom';
2
3
 
3
4
  var a=(e,i=!0)=>{let{pathname:t}=useLocation(),o=e?!!matchPath({path:e,end:!0},t):!1,r=e?!!matchPath({path:e,end:!1},t):!1;return {active:i?r:o,isExternalLink:e.includes("http")}},l=a;
package/dist/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import './chunk-6KMKD42J.mjs';
2
+
1
3
  var t=()=>!0;
2
4
 
3
5
  export { t as test };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.7",
2
+ "version": "2.0.8",
3
3
  "name": "@zydon/common-csr",
4
4
  "description": "Zydon common resources for React projects (only Client-Side Rendering (CSR))",
5
5
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "import": "./dist/components/*/index.mjs",
33
33
  "types": "./dist/components/*/index.d.ts"
34
34
  },
35
- "./components/filters/*": {
35
+ "./filters/*": {
36
36
  "import": "./dist/components/filters/*/index.mjs",
37
37
  "types": "./dist/components/filters/*/index.d.ts"
38
38
  },