@grazziotin/react-components 1.0.1 → 1.0.3
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/README.md +3 -5
- package/dist/components/Dialog/Dialog.stories.d.ts +9 -0
- package/dist/components/Dialog/Dialog.stories.js +80 -0
- package/dist/components/Dialog/index.d.ts +12 -0
- package/dist/components/Dialog/index.js +10 -0
- package/dist/components/Filter/Filter.stories.d.ts +8 -0
- package/dist/components/Filter/Filter.stories.js +85 -0
- package/dist/components/Filter/components/FiltroCard.d.ts +3 -0
- package/dist/components/Filter/components/FiltroCard.js +13 -0
- package/dist/components/Filter/components/Filtros.d.ts +3 -0
- package/dist/components/Filter/components/Filtros.js +59 -0
- package/dist/components/Filter/components/InputSelect.d.ts +3 -0
- package/dist/components/Filter/components/InputSelect.js +13 -0
- package/dist/components/Filter/index.d.ts +10 -0
- package/dist/components/Filter/index.js +20 -0
- package/dist/components/Filter/utils/interface.d.ts +76 -0
- package/dist/components/Filter/utils/interface.js +1 -0
- package/dist/components/Inputs/Input/Input.stories.d.ts +13 -0
- package/dist/components/Inputs/Input/Input.stories.js +99 -0
- package/dist/components/Inputs/InputSelectMultiple/index.d.ts +22 -0
- package/dist/components/Inputs/InputSelectMultiple/index.js +38 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -2
- package/dist/index.js.LICENSE.txt +1 -20
- package/dist/theme.css +500 -0
- package/package.json +37 -5
package/README.md
CHANGED
|
@@ -10,14 +10,12 @@ npm install @grazziotin/react-components
|
|
|
10
10
|
|
|
11
11
|
### Dependências necessárias
|
|
12
12
|
|
|
13
|
-
O pacote usa **peer dependencies**. Instale no seu projeto:
|
|
14
|
-
|
|
15
13
|
```bash
|
|
16
|
-
npm
|
|
14
|
+
npm @mui/material @mui/icons-material
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
- `react` e `react-dom` >= 17
|
|
20
|
-
- `@mui/material` e `@mui/icons-material` >=
|
|
17
|
+
- `react` e `react-dom` >= 17
|
|
18
|
+
- `@mui/material` e `@mui/icons-material` >= 7 (para Input, Dialog, Filtro, etc.)
|
|
21
19
|
|
|
22
20
|
## Uso
|
|
23
21
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Dialog from './index';
|
|
3
|
+
declare const meta: Meta<typeof Dialog>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Dialog>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithActions: Story;
|
|
8
|
+
export declare const WithoutTitle: Story;
|
|
9
|
+
export declare const SmallWidth: Story;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import Dialog from './index';
|
|
15
|
+
import { Button } from '@mui/material';
|
|
16
|
+
var meta = {
|
|
17
|
+
title: 'Components/Dialog',
|
|
18
|
+
component: Dialog,
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: 'centered',
|
|
21
|
+
},
|
|
22
|
+
tags: ['autodocs'],
|
|
23
|
+
argTypes: {
|
|
24
|
+
open: { control: 'boolean' },
|
|
25
|
+
title: { control: 'text' },
|
|
26
|
+
maxWidth: {
|
|
27
|
+
control: 'select',
|
|
28
|
+
options: [false, 'xs', 'sm', 'md', 'lg', 'xl'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export default meta;
|
|
33
|
+
function DefaultStory(args) {
|
|
34
|
+
var _a = useState(false), open = _a[0], setOpen = _a[1];
|
|
35
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "contained", onClick: function () { return setOpen(true); }, children: "Abrir Dialog" }), _jsx(Dialog, __assign({}, args, { open: open, onClose: function () { return setOpen(false); }, actions: _jsxs(_Fragment, { children: [_jsx(Button, { onClick: function () { return setOpen(false); }, children: "Cancelar" }), _jsx(Button, { variant: "contained", onClick: function () { return setOpen(false); }, children: "Confirmar" })] }) }))] }));
|
|
36
|
+
}
|
|
37
|
+
export var Default = {
|
|
38
|
+
args: {
|
|
39
|
+
open: true,
|
|
40
|
+
title: 'Título do diálogo',
|
|
41
|
+
children: 'Conteúdo do diálogo. Você pode colocar qualquer conteúdo aqui.',
|
|
42
|
+
},
|
|
43
|
+
render: function (args) { return _jsx(DefaultStory, __assign({}, args)); },
|
|
44
|
+
};
|
|
45
|
+
function WithActionsStory(args) {
|
|
46
|
+
var _a = useState(false), open = _a[0], setOpen = _a[1];
|
|
47
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outlined", onClick: function () { return setOpen(true); }, children: "Abrir com a\u00E7\u00F5es" }), _jsx(Dialog, __assign({}, args, { open: open, onClose: function () { return setOpen(false); }, actions: _jsxs(_Fragment, { children: [_jsx(Button, { onClick: function () { return setOpen(false); }, children: "Cancelar" }), _jsx(Button, { variant: "contained", color: "error", onClick: function () { return setOpen(false); }, children: "Excluir" })] }) }))] }));
|
|
48
|
+
}
|
|
49
|
+
export var WithActions = {
|
|
50
|
+
args: {
|
|
51
|
+
open: true,
|
|
52
|
+
title: 'Confirmar ação',
|
|
53
|
+
children: 'Deseja realmente continuar? Esta ação não pode ser desfeita.',
|
|
54
|
+
},
|
|
55
|
+
render: function (args) { return _jsx(WithActionsStory, __assign({}, args)); },
|
|
56
|
+
};
|
|
57
|
+
function WithoutTitleStory(args) {
|
|
58
|
+
var _a = useState(false), open = _a[0], setOpen = _a[1];
|
|
59
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "contained", onClick: function () { return setOpen(true); }, children: "Abrir sem t\u00EDtulo" }), _jsx(Dialog, __assign({}, args, { open: open, onClose: function () { return setOpen(false); }, actions: _jsx(Button, { onClick: function () { return setOpen(false); }, children: "Fechar" }) }))] }));
|
|
60
|
+
}
|
|
61
|
+
export var WithoutTitle = {
|
|
62
|
+
args: {
|
|
63
|
+
open: true,
|
|
64
|
+
children: 'Dialog sem título, apenas conteúdo.',
|
|
65
|
+
},
|
|
66
|
+
render: function (args) { return _jsx(WithoutTitleStory, __assign({}, args)); },
|
|
67
|
+
};
|
|
68
|
+
function SmallWidthStory(args) {
|
|
69
|
+
var _a = useState(false), open = _a[0], setOpen = _a[1];
|
|
70
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "contained", onClick: function () { return setOpen(true); }, children: "Abrir (xs)" }), _jsx(Dialog, __assign({}, args, { open: open, onClose: function () { return setOpen(false); }, actions: _jsx(Button, { onClick: function () { return setOpen(false); }, children: "Fechar" }) }))] }));
|
|
71
|
+
}
|
|
72
|
+
export var SmallWidth = {
|
|
73
|
+
args: {
|
|
74
|
+
open: true,
|
|
75
|
+
title: 'Dialog pequeno',
|
|
76
|
+
maxWidth: 'xs',
|
|
77
|
+
children: 'maxWidth="xs"',
|
|
78
|
+
},
|
|
79
|
+
render: function (args) { return _jsx(SmallWidthStory, __assign({}, args)); },
|
|
80
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Breakpoint } from '@mui/material';
|
|
3
|
+
export interface DialogProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
title?: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
actions?: React.ReactNode;
|
|
9
|
+
maxWidth?: false | Breakpoint;
|
|
10
|
+
}
|
|
11
|
+
declare const Dialog: ({ open, onClose, title, children, actions, maxWidth, }: DialogProps) => JSX.Element;
|
|
12
|
+
export default Dialog;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import DialogMui from '@mui/material/Dialog';
|
|
3
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
4
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
5
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
6
|
+
var Dialog = function (_a) {
|
|
7
|
+
var open = _a.open, onClose = _a.onClose, title = _a.title, children = _a.children, actions = _a.actions, maxWidth = _a.maxWidth;
|
|
8
|
+
return (_jsxs(DialogMui, { onClose: onClose, open: open, maxWidth: maxWidth, fullWidth: true, children: [title && (_jsx(DialogTitle, { children: _jsx("p", { className: "text-base font-semibold", children: title }) })), _jsx(DialogContent, { className: "text-black", children: children }), actions && _jsx(DialogActions, { children: actions })] }));
|
|
9
|
+
};
|
|
10
|
+
export default Dialog;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Filtro from './index';
|
|
3
|
+
declare const meta: Meta<typeof Filtro>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Filtro>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const ComPesquisa: Story;
|
|
8
|
+
export declare const ComCsv: Story;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import Filtro from './index';
|
|
15
|
+
var meta = {
|
|
16
|
+
title: 'Components/Filtro',
|
|
17
|
+
component: Filtro,
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: 'fullscreen',
|
|
20
|
+
},
|
|
21
|
+
tags: ['autodocs'],
|
|
22
|
+
};
|
|
23
|
+
export default meta;
|
|
24
|
+
function FiltroStory(args) {
|
|
25
|
+
var _a = useState(''), pesquisa = _a[0], setPesquisa = _a[1];
|
|
26
|
+
return (_jsx(Filtro, __assign({}, args, { pesquisa: pesquisa, setPesquisa: setPesquisa, onClear: function () {
|
|
27
|
+
setPesquisa('');
|
|
28
|
+
}, onSubmit: function () { } })));
|
|
29
|
+
}
|
|
30
|
+
export var Default = {
|
|
31
|
+
args: {
|
|
32
|
+
title: 'Listagem',
|
|
33
|
+
inputs: [
|
|
34
|
+
{
|
|
35
|
+
label: 'Nome',
|
|
36
|
+
name: 'nome',
|
|
37
|
+
order: 1,
|
|
38
|
+
xs: 12,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'E-mail',
|
|
42
|
+
name: 'email',
|
|
43
|
+
type: 'email',
|
|
44
|
+
order: 2,
|
|
45
|
+
xs: 12,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
inputSelect: [
|
|
49
|
+
{
|
|
50
|
+
options: [
|
|
51
|
+
{ value: '', label: 'Todos' },
|
|
52
|
+
{ value: 'ativo', label: 'Ativo' },
|
|
53
|
+
{ value: 'inativo', label: 'Inativo' },
|
|
54
|
+
],
|
|
55
|
+
label: 'Status',
|
|
56
|
+
name: 'status',
|
|
57
|
+
order: 3,
|
|
58
|
+
xs: 12,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
render: function (args) { return _jsx(FiltroStory, __assign({}, args)); },
|
|
63
|
+
};
|
|
64
|
+
export var ComPesquisa = {
|
|
65
|
+
args: {
|
|
66
|
+
title: 'Busca',
|
|
67
|
+
setPesquisa: function () { },
|
|
68
|
+
inputs: [
|
|
69
|
+
{ label: 'Código', name: 'codigo', order: 1, xs: 6 },
|
|
70
|
+
{ label: 'Descrição', name: 'descricao', order: 2, xs: 6 },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
render: function (args) { return _jsx(FiltroStory, __assign({}, args)); },
|
|
74
|
+
};
|
|
75
|
+
export var ComCsv = {
|
|
76
|
+
args: {
|
|
77
|
+
title: 'Exportar',
|
|
78
|
+
csv: {
|
|
79
|
+
onClick: function () { },
|
|
80
|
+
isLoading: false,
|
|
81
|
+
},
|
|
82
|
+
inputs: [{ label: 'Filtro', name: 'filtro', order: 1, xs: 12 }],
|
|
83
|
+
},
|
|
84
|
+
render: function (args) { return _jsx(FiltroStory, __assign({}, args)); },
|
|
85
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IconButton, Tooltip, CircularProgress } from '@mui/material';
|
|
3
|
+
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
4
|
+
import TableChartIcon from '@mui/icons-material/TableChart';
|
|
5
|
+
import Input from 'src/components/Inputs/Input';
|
|
6
|
+
import { cn } from 'src/lib/utils';
|
|
7
|
+
function FiltroCard(_a) {
|
|
8
|
+
var csv = _a.csv, title = _a.title, setOpen = _a.setOpen, pesquisa = _a.pesquisa, excelProps = _a.excelProps, setPesquisa = _a.setPesquisa, renderFiltro = _a.renderFiltro;
|
|
9
|
+
return (_jsxs("div", { className: "h-15 flex items-center w-full bg-white shadow-full mb-2 rounded-md", children: [_jsx("div", { className: "h-full w-2 bg-grzprimary rounded-tl-md rounded-bl-md" }), _jsxs("div", { className: "w-full flex justify-between items-center p-3", children: [_jsx("h1", { className: "font-semibold text-lg whitespace-nowrap text-ellipsis overflow-hidden ml-1 text-black/80", children: title }), _jsxs("div", { className: "flex items-center gap-4", children: [renderFiltro && (_jsx(Tooltip, { title: "Ver filtros", placement: "bottom-end", children: _jsx("span", { className: "flex items-center", children: _jsx("button", { type: "button", onClick: function () { return setOpen(true); }, className: "bg-grzprimary h-10 w-10 rounded-md flex items-center justify-center transition-all duration-500 hover:bg-grzsecondary shadow-md shadow-gray-900/10 hover:shadow-lg hover:shadow-gray-900/20", children: _jsx(FilterListIcon, { className: "h-7 w-7 text-white" }) }) }) })), csv && (_jsx(Tooltip, { title: "Exportar CSV", placement: "bottom-end", children: _jsx("span", { children: _jsx(IconButton, { className: cn('bg-grzprimary min-w-10 min-h-10', {
|
|
10
|
+
'bg-system-100': csv.isLoading,
|
|
11
|
+
}), onClick: csv.onClick, disabled: csv.isLoading, size: "small", children: csv.isLoading ? (_jsx(CircularProgress, { size: 20, color: "inherit" })) : (_jsx(TableChartIcon, { sx: { color: 'white' } })) }) }) })), (excelProps === null || excelProps === void 0 ? void 0 : excelProps.onClick) && !csv && (_jsx(Tooltip, { title: "Exportar Excel", placement: "bottom-end", children: _jsx("span", { children: _jsx(IconButton, { className: "bg-grzprimary min-w-10 min-h-10", onClick: excelProps.onClick, disabled: excelProps.isLoading, size: "small", children: excelProps.isLoading ? (_jsx(CircularProgress, { size: 20, color: "inherit" })) : (_jsx(TableChartIcon, { sx: { color: 'white' } })) }) }) })), setPesquisa && (_jsx(Input, { type: "search", value: pesquisa !== null && pesquisa !== void 0 ? pesquisa : '', placeholder: "Digite para filtrar", onChange: function (e) { return setPesquisa(e.target.value); } }))] })] })] }));
|
|
12
|
+
}
|
|
13
|
+
export default FiltroCard;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { Button, Drawer, Grid } from '@mui/material';
|
|
23
|
+
import Input from 'src/components/Inputs/Input';
|
|
24
|
+
import InputSelect from './InputSelect';
|
|
25
|
+
import { useDimension } from 'src/hooks';
|
|
26
|
+
function isInputSelect(obj) {
|
|
27
|
+
return 'options' in obj && Array.isArray(obj.options);
|
|
28
|
+
}
|
|
29
|
+
function Filtros(_a) {
|
|
30
|
+
var _b;
|
|
31
|
+
var open = _a.open, setOpen = _a.setOpen, onClear = _a.onClear, onSubmit = _a.onSubmit, _c = _a.inputs, inputs = _c === void 0 ? [] : _c, _d = _a.inputSelect, inputSelect = _d === void 0 ? [] : _d;
|
|
32
|
+
var m640 = useDimension(640);
|
|
33
|
+
var m1120 = useDimension(1120);
|
|
34
|
+
var allInputs = __spreadArray(__spreadArray([], (inputs !== null && inputs !== void 0 ? inputs : []), true), (inputSelect !== null && inputSelect !== void 0 ? inputSelect : []), true).sort(function (a, b) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
var orderA = (_a = a.order) !== null && _a !== void 0 ? _a : 99;
|
|
37
|
+
var orderB = (_b = b.order) !== null && _b !== void 0 ? _b : 99;
|
|
38
|
+
return orderA - orderB;
|
|
39
|
+
});
|
|
40
|
+
var render = function (input, i) {
|
|
41
|
+
var _a, _b, _c, _d, _e;
|
|
42
|
+
if (isInputSelect(input)) {
|
|
43
|
+
var span_1 = (_c = (_b = (_a = input.textFieldProps) === null || _a === void 0 ? void 0 : _a.xs) !== null && _b !== void 0 ? _b : input.xs) !== null && _c !== void 0 ? _c : gridSize;
|
|
44
|
+
return (_jsx(Grid, { size: { xs: 12, sm: span_1 }, children: _jsx(InputSelect, __assign({}, input, { id: (_d = input.id) !== null && _d !== void 0 ? _d : "inputSM".concat(i), fullWidth: true })) }, "inputSelect-".concat(i)));
|
|
45
|
+
}
|
|
46
|
+
var span = (_e = input.xs) !== null && _e !== void 0 ? _e : gridSize;
|
|
47
|
+
return (_jsx(Grid, { size: { xs: 12, sm: span }, children: _jsx(Input, __assign({}, input, { fullWidth: true })) }, "input-".concat(i)));
|
|
48
|
+
};
|
|
49
|
+
var handleSubmit = function (event) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
if (onSubmit) {
|
|
52
|
+
onSubmit(event);
|
|
53
|
+
setOpen(false);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var gridSize = m640 ? 12 : m1120 ? 4 : 3;
|
|
57
|
+
return (_jsx(Drawer, { anchor: "top", open: open !== null && open !== void 0 ? open : false, onClose: function () { return setOpen(false); }, sx: (_b = {}, _b["& .MuiDrawer-paper"] = { borderRadius: '0px 0px 20px 20px' }, _b), children: _jsxs("form", { className: "w-full flex flex-col pl-5 py-4 select-none", onSubmit: handleSubmit, children: [_jsx("p", { className: "text-system-900 font-semibold text-lg", children: "Filtros" }), _jsx("p", { className: "text-system-700 text-sm pt-1 pb-5", children: "Para que possamos apresentar dados espec\u00EDficos, por favor, preencha os campos abaixo." }), _jsx(Grid, { container: true, pr: 2, rowSpacing: 2, columnSpacing: 1, children: allInputs.map(function (input, index) { return render(input, index); }) }), _jsxs("div", { className: "flex justify-end pt-4 gap-4 pr-4", children: [onClear && (_jsx(Button, { onClick: onClear, variant: "outlined", color: "secondary", children: "Limpar Filtros" })), onSubmit && (_jsx(Button, { variant: "contained", type: "submit", children: "Pesquisar" }))] })] }) }));
|
|
58
|
+
}
|
|
59
|
+
export default Filtros;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { InputSelectProps } from '../utils/interface';
|
|
2
|
+
declare function InputSelectComponent<T = unknown, M extends boolean = false>({ options, label, value, onChange, fullWidth, multiple, name, id, placeholder, disabled, }: InputSelectProps<T, M>): JSX.Element;
|
|
3
|
+
export default InputSelectComponent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TextField, MenuItem } from '@mui/material';
|
|
3
|
+
import { ThemeProvider } from '@mui/material/styles';
|
|
4
|
+
import { theme } from 'src/styles/sx';
|
|
5
|
+
function InputSelectComponent(_a) {
|
|
6
|
+
var options = _a.options, label = _a.label, value = _a.value, onChange = _a.onChange, fullWidth = _a.fullWidth, multiple = _a.multiple, name = _a.name, id = _a.id, placeholder = _a.placeholder, disabled = _a.disabled;
|
|
7
|
+
var handleChange = function (e) {
|
|
8
|
+
var v = e.target.value;
|
|
9
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(v);
|
|
10
|
+
};
|
|
11
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(TextField, { select: true, fullWidth: fullWidth, label: label, value: value !== null && value !== void 0 ? value : '', onChange: handleChange, name: name, id: id, placeholder: placeholder, disabled: disabled, size: "small", variant: "outlined", SelectProps: { multiple: multiple }, children: options.map(function (opt) { return (_jsx(MenuItem, { value: opt.value, children: opt.label }, String(opt.value))); }) }) }));
|
|
12
|
+
}
|
|
13
|
+
export default InputSelectComponent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FiltroProps } from './utils/interface';
|
|
2
|
+
/**
|
|
3
|
+
* Componente de filtro genérico que permite a busca e filtragem de dados.
|
|
4
|
+
*
|
|
5
|
+
* @template T - O tipo de dados a ser filtrado.
|
|
6
|
+
* @template M - Tipo que indica se a seleção múltipla está habilitada (padrão: false).
|
|
7
|
+
*/
|
|
8
|
+
declare function Filtro<T, M extends boolean = false>({ csv, title, inputs, onClear, onSubmit, pesquisa, excelProps, setPesquisa, inputSelect, }: FiltroProps<T, M>): JSX.Element;
|
|
9
|
+
export default Filtro;
|
|
10
|
+
export type { FiltroProps, CsvProps, InputSelectOption, InputSelectProps } from './utils/interface';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import FiltroCard from './components/FiltroCard';
|
|
4
|
+
import Filtros from './components/Filtros';
|
|
5
|
+
/**
|
|
6
|
+
* Componente de filtro genérico que permite a busca e filtragem de dados.
|
|
7
|
+
*
|
|
8
|
+
* @template T - O tipo de dados a ser filtrado.
|
|
9
|
+
* @template M - Tipo que indica se a seleção múltipla está habilitada (padrão: false).
|
|
10
|
+
*/
|
|
11
|
+
function Filtro(_a) {
|
|
12
|
+
var csv = _a.csv, title = _a.title, inputs = _a.inputs, onClear = _a.onClear, onSubmit = _a.onSubmit, pesquisa = _a.pesquisa, excelProps = _a.excelProps, setPesquisa = _a.setPesquisa, inputSelect = _a.inputSelect;
|
|
13
|
+
var _b = useState(false), open = _b[0], setOpen = _b[1];
|
|
14
|
+
function renderFiltro() {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
return ((_a = inputs === null || inputs === void 0 ? void 0 : inputs.length) !== null && _a !== void 0 ? _a : 0) > 0 || ((_b = inputSelect === null || inputSelect === void 0 ? void 0 : inputSelect.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
17
|
+
}
|
|
18
|
+
return (_jsxs("div", { children: [_jsx(FiltroCard, { csv: csv, title: title, setOpen: setOpen, pesquisa: pesquisa, excelProps: excelProps, setPesquisa: setPesquisa, renderFiltro: renderFiltro() }), _jsx(Filtros, { open: open, inputs: inputs, setOpen: setOpen, onClear: onClear, onSubmit: onSubmit, inputSelect: inputSelect })] }));
|
|
19
|
+
}
|
|
20
|
+
export default Filtro;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { InputProps } from 'src/components/Inputs/Input';
|
|
2
|
+
/**
|
|
3
|
+
* Propriedades para o componente CSV.
|
|
4
|
+
*/
|
|
5
|
+
export interface CsvProps {
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Propriedades para o botão Excel (opcional).
|
|
11
|
+
*/
|
|
12
|
+
export interface ExcelButtonProps<T = unknown> {
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
isLoading?: boolean;
|
|
15
|
+
data?: T[];
|
|
16
|
+
filename?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Propriedades para o componente FiltroCard.
|
|
20
|
+
*/
|
|
21
|
+
export interface FiltroCardProps<T = unknown> {
|
|
22
|
+
csv?: CsvProps;
|
|
23
|
+
title?: string;
|
|
24
|
+
pesquisa?: string;
|
|
25
|
+
renderFiltro: boolean;
|
|
26
|
+
excelProps?: ExcelButtonProps<T>;
|
|
27
|
+
setPesquisa?: (value: string) => void;
|
|
28
|
+
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Propriedades adicionais para inputs.
|
|
32
|
+
*/
|
|
33
|
+
export interface AdicionalPropsInput {
|
|
34
|
+
order?: number;
|
|
35
|
+
xs?: number;
|
|
36
|
+
}
|
|
37
|
+
export type InputsTypeFiltro = InputProps & AdicionalPropsInput;
|
|
38
|
+
/**
|
|
39
|
+
* Opção para select.
|
|
40
|
+
*/
|
|
41
|
+
export interface InputSelectOption {
|
|
42
|
+
value: string | number;
|
|
43
|
+
label: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Propriedades para o componente InputSelect.
|
|
47
|
+
*/
|
|
48
|
+
export interface InputSelectProps<T = unknown, M extends boolean = false> {
|
|
49
|
+
options: InputSelectOption[];
|
|
50
|
+
label?: string;
|
|
51
|
+
value?: M extends true ? (string | number)[] : string | number;
|
|
52
|
+
onChange?: (value: M extends true ? (string | number)[] : string | number) => void;
|
|
53
|
+
fullWidth?: boolean;
|
|
54
|
+
multiple?: M;
|
|
55
|
+
textFieldProps?: AdicionalPropsInput;
|
|
56
|
+
name?: string;
|
|
57
|
+
id?: string;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Propriedades para o componente Filtros.
|
|
63
|
+
*/
|
|
64
|
+
export interface FiltrosProps<T = unknown, M extends boolean = false> {
|
|
65
|
+
open?: boolean;
|
|
66
|
+
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
67
|
+
inputs?: InputsTypeFiltro[];
|
|
68
|
+
inputSelect?: Array<InputSelectProps<T, M> & AdicionalPropsInput>;
|
|
69
|
+
onClear?: () => void;
|
|
70
|
+
onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Propriedades para o componente Filtro.
|
|
74
|
+
*/
|
|
75
|
+
export interface FiltroProps<T = unknown, M extends boolean = false> extends Omit<FiltroCardProps<T>, 'renderFiltro' | 'setOpen'>, Omit<FiltrosProps<T, M>, 'open' | 'setOpen'> {
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Input from './index';
|
|
3
|
+
declare const meta: Meta<typeof Input>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Input>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithValue: Story;
|
|
8
|
+
export declare const Password: Story;
|
|
9
|
+
export declare const Real: Story;
|
|
10
|
+
export declare const OnKeyEnter: Story;
|
|
11
|
+
export declare const Disabled: Story;
|
|
12
|
+
export declare const ReadOnly: Story;
|
|
13
|
+
export declare const Standard: Story;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useState } from 'react';
|
|
12
|
+
import Input from './index';
|
|
13
|
+
var meta = {
|
|
14
|
+
title: 'Components/Input',
|
|
15
|
+
component: Input,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: 'centered',
|
|
18
|
+
},
|
|
19
|
+
tags: ['autodocs'],
|
|
20
|
+
argTypes: {
|
|
21
|
+
label: { control: 'text' },
|
|
22
|
+
placeholder: { control: 'text' },
|
|
23
|
+
type: {
|
|
24
|
+
control: 'select',
|
|
25
|
+
options: ['text', 'number', 'email', 'password', 'real', 'float'],
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
control: 'select',
|
|
29
|
+
options: ['small', 'medium'],
|
|
30
|
+
},
|
|
31
|
+
disabled: { control: 'boolean' },
|
|
32
|
+
readOnly: { control: 'boolean' },
|
|
33
|
+
shrink: { control: 'boolean' },
|
|
34
|
+
variant: {
|
|
35
|
+
control: 'select',
|
|
36
|
+
options: ['outlined', 'filled', 'standard'],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
export default meta;
|
|
41
|
+
export var Default = {
|
|
42
|
+
args: {
|
|
43
|
+
label: 'Label',
|
|
44
|
+
placeholder: 'Digite aqui...',
|
|
45
|
+
variant: 'outlined',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export var WithValue = {
|
|
49
|
+
args: {
|
|
50
|
+
label: 'Nome',
|
|
51
|
+
value: 'João Silva',
|
|
52
|
+
variant: 'outlined',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
export var Password = {
|
|
56
|
+
args: {
|
|
57
|
+
label: 'Senha',
|
|
58
|
+
type: 'password',
|
|
59
|
+
placeholder: '••••••••',
|
|
60
|
+
variant: 'outlined',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export var Real = {
|
|
64
|
+
args: {},
|
|
65
|
+
render: function RealStory() {
|
|
66
|
+
var _a = useState(''), value = _a[0], setValue = _a[1];
|
|
67
|
+
return (_jsx(Input, { label: "Valor (R$)", type: "real", value: value, onChange: function (e) { return setValue(e.target.value); }, variant: "outlined" }));
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export var OnKeyEnter = {
|
|
71
|
+
args: {},
|
|
72
|
+
render: function OnKeyEnterStory() {
|
|
73
|
+
var _a = useState([]), log = _a[0], setLog = _a[1];
|
|
74
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 16 }, children: [_jsx(Input, { label: "Pressione Enter", placeholder: "Digite e pressione Enter", onKeyEnter: function () { return setLog(function (prev) { return __spreadArray(__spreadArray([], prev, true), ['Enter pressionado!'], false); }); }, variant: "outlined" }), log.length > 0 && (_jsx("ul", { style: { margin: 0, paddingLeft: 20 }, children: log.map(function (item, i) { return (_jsx("li", { children: item }, "log-".concat(i, "-").concat(item))); }) }))] }));
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
export var Disabled = {
|
|
78
|
+
args: {
|
|
79
|
+
label: 'Desabilitado',
|
|
80
|
+
value: 'Não editável',
|
|
81
|
+
disabled: true,
|
|
82
|
+
variant: 'outlined',
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
export var ReadOnly = {
|
|
86
|
+
args: {
|
|
87
|
+
label: 'Somente leitura',
|
|
88
|
+
value: 'Apenas leitura',
|
|
89
|
+
readOnly: true,
|
|
90
|
+
variant: 'outlined',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
export var Standard = {
|
|
94
|
+
args: {
|
|
95
|
+
label: 'Standard variant',
|
|
96
|
+
placeholder: 'Variante standard',
|
|
97
|
+
variant: 'standard',
|
|
98
|
+
},
|
|
99
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AutocompleteProps } from '@mui/material/Autocomplete';
|
|
3
|
+
import type { InputProps } from '../Input';
|
|
4
|
+
export interface CustomAutocompleteProps<T> extends Omit<AutocompleteProps<T, boolean, boolean, boolean, 'div'>, 'renderInput'> {
|
|
5
|
+
renderInput?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface InputSelectMultipleProps<T> extends CustomAutocompleteProps<T> {
|
|
8
|
+
className?: string;
|
|
9
|
+
textFieldProps: InputProps;
|
|
10
|
+
optionLabel: (data: T) => string;
|
|
11
|
+
xs?: number;
|
|
12
|
+
order?: number;
|
|
13
|
+
render?: boolean;
|
|
14
|
+
disablePortal?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Componente de selects múltiplos, serve para quando temos listas grandes para tratar.
|
|
18
|
+
* @version 1.5.0
|
|
19
|
+
* @ViniciusCLoeblein
|
|
20
|
+
*/
|
|
21
|
+
declare function InputSelectMultiple<T>({ className, textFieldProps, optionLabel, disablePortal, ...rest }: Readonly<InputSelectMultipleProps<T>>): JSX.Element;
|
|
22
|
+
export default InputSelectMultiple;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
25
|
+
import { sxTextField } from 'src/styles/sx';
|
|
26
|
+
import Input from '../Input';
|
|
27
|
+
/**
|
|
28
|
+
* Componente de selects múltiplos, serve para quando temos listas grandes para tratar.
|
|
29
|
+
* @version 1.5.0
|
|
30
|
+
* @ViniciusCLoeblein
|
|
31
|
+
*/
|
|
32
|
+
function InputSelectMultiple(_a) {
|
|
33
|
+
var className = _a.className, textFieldProps = _a.textFieldProps, optionLabel = _a.optionLabel, _b = _a.disablePortal, disablePortal = _b === void 0 ? true : _b, rest = __rest(_a, ["className", "textFieldProps", "optionLabel", "disablePortal"]);
|
|
34
|
+
return (_jsx("div", { className: className, children: _jsx(Autocomplete, __assign({ disablePortal: disablePortal, sx: sxTextField, filterSelectedOptions: true, getOptionLabel: function (data) {
|
|
35
|
+
return typeof data !== 'string' ? optionLabel(data) : 'Não há dados';
|
|
36
|
+
} }, rest, { renderInput: function (params) { return _jsx(Input, __assign({}, params, textFieldProps)); } })) }));
|
|
37
|
+
}
|
|
38
|
+
export default InputSelectMultiple;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export { default as Input } from './components/Inputs/Input';
|
|
2
2
|
export type { InputProps } from './components/Inputs/Input';
|
|
3
|
+
export { default as InputSelectMultiple } from './components/Inputs/InputSelectMultiple';
|
|
4
|
+
export type { InputSelectMultipleProps, CustomAutocompleteProps, } from './components/Inputs/InputSelectMultiple';
|
|
5
|
+
export { default as Dialog } from './components/Dialog';
|
|
6
|
+
export type { DialogProps } from './components/Dialog';
|
|
7
|
+
export { default as Filtro } from './components/Filter';
|
|
8
|
+
export type { FiltroProps, CsvProps, InputSelectOption, InputSelectProps, } from './components/Filter';
|