@grazziotin/react-components 1.0.3 → 1.0.4
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 +34 -24
- package/dist/150.index.js +1 -0
- package/dist/815.index.js +1 -0
- package/dist/908.index.js +2 -0
- package/dist/908.index.js.LICENSE.txt +9 -0
- package/dist/988.index.js +1 -0
- package/dist/assets/fonts/Montserrat-Black.ttf +0 -0
- package/dist/assets/fonts/Montserrat-BlackItalic.ttf +0 -0
- package/dist/assets/fonts/Montserrat-Bold.ttf +0 -0
- package/dist/assets/fonts/Montserrat-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/Montserrat-ExtraBold.ttf +0 -0
- package/dist/assets/fonts/Montserrat-ExtraBoldItalic.ttf +0 -0
- package/dist/assets/fonts/Montserrat-ExtraLight.ttf +0 -0
- package/dist/assets/fonts/Montserrat-ExtraLightItalic.ttf +0 -0
- package/dist/assets/fonts/Montserrat-Italic.ttf +0 -0
- package/dist/assets/fonts/Montserrat-Light.ttf +0 -0
- package/dist/assets/fonts/Montserrat-LightItalic.ttf +0 -0
- package/dist/assets/fonts/Montserrat-Medium.ttf +0 -0
- package/dist/assets/fonts/Montserrat-MediumItalic.ttf +0 -0
- package/dist/assets/fonts/Montserrat-Regular.ttf +0 -0
- package/dist/assets/fonts/Montserrat-SemiBold.ttf +0 -0
- package/dist/assets/fonts/Montserrat-SemiBoldItalic.ttf +0 -0
- package/dist/assets/fonts/Montserrat-Thin.ttf +0 -0
- package/dist/assets/fonts/Montserrat-ThinItalic.ttf +0 -0
- package/dist/components/Inputs/Input/index.d.ts +39 -18
- package/dist/components/Inputs/Input/index.js +122 -28
- package/dist/components/Inputs/Input/utils/input-styled.d.ts +4 -0
- package/dist/components/Inputs/Input/utils/input-styled.js +63 -0
- package/dist/components/Inputs/Input/utils/interface.d.ts +21 -0
- package/dist/components/Inputs/Input/utils/interface.js +1 -0
- package/dist/components/Inputs/Input/utils/mask-custom.d.ts +4 -0
- package/dist/components/Inputs/Input/utils/mask-custom.js +30 -0
- package/dist/components/Inputs/input-select/index.d.ts +42 -0
- package/dist/components/Inputs/input-select/index.js +84 -0
- package/dist/components/Inputs/input-select/utils/interface.d.ts +43 -0
- package/dist/components/Inputs/input-select/utils/interface.js +1 -0
- package/dist/components/Loader/index.d.ts +5 -0
- package/dist/components/Loader/index.js +7 -0
- package/dist/components/barcode/BarcodeScanner.d.ts +26 -0
- package/dist/components/barcode/barcode-scanner.d.ts +26 -0
- package/dist/components/barcode/barcode-scanner.js +433 -0
- package/dist/components/barcode/index.d.ts +36 -0
- package/dist/components/barcode/index.js +65 -0
- package/dist/components/barcode/utils/constants.d.ts +139 -0
- package/dist/components/barcode/utils/constants.js +224 -0
- package/dist/components/barcode/utils/interface.d.ts +50 -0
- package/dist/components/barcode/utils/interface.js +1 -0
- package/dist/components/button/button-excel/index.d.ts +32 -0
- package/dist/components/button/button-excel/index.js +143 -0
- package/dist/components/button/index.d.ts +21 -0
- package/dist/components/button/index.js +101 -0
- package/dist/components/card/index.d.ts +21 -0
- package/dist/components/card/index.js +48 -0
- package/dist/components/datatable/index.d.ts +8 -0
- package/dist/components/datatable/index.js +103 -0
- package/dist/components/datatable/utils/constants.d.ts +8 -0
- package/dist/components/datatable/utils/constants.js +42 -0
- package/dist/components/filtro/components/card.d.ts +24 -0
- package/dist/components/filtro/components/card.js +49 -0
- package/dist/components/filtro/components/filtros.d.ts +19 -0
- package/dist/components/filtro/components/filtros.js +77 -0
- package/dist/components/filtro/index.d.ts +28 -0
- package/dist/components/filtro/index.js +38 -0
- package/dist/components/filtro/utils/interface.d.ts +105 -0
- package/dist/components/filtro/utils/interface.js +1 -0
- package/dist/components/icons/index.d.ts +21 -0
- package/dist/components/icons/index.js +39 -0
- package/dist/components/tabs/index.d.ts +24 -0
- package/dist/components/tabs/index.js +39 -0
- package/dist/functions/mascaras/index.js +1 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.js +1 -1
- package/dist/theme.css +1039 -98
- package/package.json +24 -14
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Mensagens de erro e informação para o componente
|
|
39
|
+
*/
|
|
40
|
+
export var MENSAGENS = {
|
|
41
|
+
HTTPS_REQUERIDO: 'Esta funcionalidade só está disponível em dispositivos móveis e com conexão segura (HTTPS).',
|
|
42
|
+
TITULO: 'Leitor de código de barras',
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Mapa de mensagens de erro para diferentes tipos de erro de câmera
|
|
46
|
+
*/
|
|
47
|
+
export var MENSAGENS_ERRO_CAMERA = new Map([
|
|
48
|
+
[
|
|
49
|
+
'NotAllowedError',
|
|
50
|
+
'Permissão da câmera negada. Verifique as configurações do navegador',
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
'PermissionDeniedError',
|
|
54
|
+
'Permissão da câmera negada. Verifique as configurações do navegador',
|
|
55
|
+
],
|
|
56
|
+
['NotFoundError', 'Câmera não encontrada no dispositivo'],
|
|
57
|
+
['DevicesNotFoundError', 'Câmera não encontrada no dispositivo'],
|
|
58
|
+
['NotReadableError', 'Câmera está sendo usada por outro aplicativo'],
|
|
59
|
+
['TrackStartError', 'Câmera está sendo usada por outro aplicativo'],
|
|
60
|
+
['OverconstrainedError', 'Câmera não suporta as configurações solicitadas'],
|
|
61
|
+
[
|
|
62
|
+
'ConstraintNotSatisfiedError',
|
|
63
|
+
'Câmera não suporta as configurações solicitadas',
|
|
64
|
+
],
|
|
65
|
+
['NotSupportedError', 'Navegador não suporta acesso à câmera'],
|
|
66
|
+
['TypeError', 'Erro de configuração. Verifique se está usando HTTPS'],
|
|
67
|
+
]);
|
|
68
|
+
/**
|
|
69
|
+
* Configurações de timeout e delays
|
|
70
|
+
*/
|
|
71
|
+
export var TIMEOUTS = {
|
|
72
|
+
CONFIRMACAO_THRESHOLD: 2,
|
|
73
|
+
LIMPEZA_CONTADOR: 3000,
|
|
74
|
+
INICIALIZACAO: 300,
|
|
75
|
+
LOADING_DELAY: 1000,
|
|
76
|
+
FECHAMENTO_MODAL: 100,
|
|
77
|
+
TENTAR_NOVAMENTE: 200,
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Configurações de validação
|
|
81
|
+
*/
|
|
82
|
+
export var VALIDACAO = {
|
|
83
|
+
TAMANHO_MINIMO_CODIGO: 3,
|
|
84
|
+
REGEX_CARACTERES_REPETIDOS: /^(.)\1{5,}$/,
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Configurações da câmera
|
|
88
|
+
*/
|
|
89
|
+
export var CONFIG_CAMERA = {
|
|
90
|
+
CONSTRAINTS: {
|
|
91
|
+
WIDTH: { min: 640, ideal: 1280, max: 1920 },
|
|
92
|
+
HEIGHT: { min: 480, ideal: 720, max: 1080 },
|
|
93
|
+
ASPECT_RATIO: { ideal: 1.7777777778 },
|
|
94
|
+
},
|
|
95
|
+
AREA_SCANNER: { top: '20%', right: '10%', left: '10%', bottom: '20%' },
|
|
96
|
+
WORKERS: { MOBILE: 2, DESKTOP: 4 },
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Readers suportados pelo Quagga
|
|
100
|
+
*/
|
|
101
|
+
export var READERS_SUPORTADOS = [
|
|
102
|
+
'code_128_reader',
|
|
103
|
+
'ean_reader',
|
|
104
|
+
'ean_8_reader',
|
|
105
|
+
'code_39_reader',
|
|
106
|
+
'code_39_vin_reader',
|
|
107
|
+
'codabar_reader',
|
|
108
|
+
'upc_reader',
|
|
109
|
+
'upc_e_reader',
|
|
110
|
+
'i2of5_reader',
|
|
111
|
+
'code_93_reader',
|
|
112
|
+
];
|
|
113
|
+
/**
|
|
114
|
+
* Configuração padrão do Quagga
|
|
115
|
+
*/
|
|
116
|
+
export var getQuaggaConfig = function (target, isMobile) { return ({
|
|
117
|
+
inputStream: {
|
|
118
|
+
name: 'Live',
|
|
119
|
+
type: 'LiveStream',
|
|
120
|
+
constraints: {
|
|
121
|
+
width: CONFIG_CAMERA.CONSTRAINTS.WIDTH,
|
|
122
|
+
height: CONFIG_CAMERA.CONSTRAINTS.HEIGHT,
|
|
123
|
+
facingMode: 'environment',
|
|
124
|
+
aspectRatio: CONFIG_CAMERA.CONSTRAINTS.ASPECT_RATIO,
|
|
125
|
+
},
|
|
126
|
+
target: target,
|
|
127
|
+
area: CONFIG_CAMERA.AREA_SCANNER,
|
|
128
|
+
},
|
|
129
|
+
locator: {
|
|
130
|
+
halfSample: true,
|
|
131
|
+
patchSize: isMobile ? 'medium' : 'large',
|
|
132
|
+
debug: {
|
|
133
|
+
showCanvas: false,
|
|
134
|
+
showPatches: false,
|
|
135
|
+
showFoundPatches: false,
|
|
136
|
+
showSkeleton: false,
|
|
137
|
+
showLabels: false,
|
|
138
|
+
showPatchLabels: false,
|
|
139
|
+
showRemainingPatchLabels: false,
|
|
140
|
+
boxFromPatches: {
|
|
141
|
+
showTransformed: false,
|
|
142
|
+
showTransformedBox: false,
|
|
143
|
+
showBB: false,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
numOfWorkers: isMobile
|
|
148
|
+
? CONFIG_CAMERA.WORKERS.MOBILE
|
|
149
|
+
: CONFIG_CAMERA.WORKERS.DESKTOP,
|
|
150
|
+
decoder: { readers: READERS_SUPORTADOS, multiple: false },
|
|
151
|
+
locate: true,
|
|
152
|
+
debug: false,
|
|
153
|
+
frequency: 5,
|
|
154
|
+
}); };
|
|
155
|
+
/**
|
|
156
|
+
* Verifica se o protocolo atual é HTTPS ou se está em desenvolvimento local
|
|
157
|
+
* @returns {boolean} True se for HTTPS ou localhost, false caso contrário
|
|
158
|
+
*/
|
|
159
|
+
export var contextoSeguro = function () {
|
|
160
|
+
return (globalThis.location.protocol === 'https:' ||
|
|
161
|
+
globalThis.location.hostname === 'localhost' ||
|
|
162
|
+
globalThis.location.hostname === '127.0.0.1');
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Verifica se o navegador suporta acesso à câmera
|
|
166
|
+
* @throws {Error} Quando o navegador não suporta câmera ou não está em contexto seguro
|
|
167
|
+
*/
|
|
168
|
+
export var verificarSuporteCamera = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
+
var devices, hasCamera;
|
|
170
|
+
var _a;
|
|
171
|
+
return __generator(this, function (_b) {
|
|
172
|
+
switch (_b.label) {
|
|
173
|
+
case 0:
|
|
174
|
+
if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia))
|
|
175
|
+
throw new Error('Seu navegador não suporta acesso à câmera');
|
|
176
|
+
if (!contextoSeguro())
|
|
177
|
+
throw new Error('Acesso à câmera requer HTTPS');
|
|
178
|
+
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
179
|
+
case 1:
|
|
180
|
+
devices = _b.sent();
|
|
181
|
+
hasCamera = devices.some(function (device) { return device.kind === 'videoinput'; });
|
|
182
|
+
if (!hasCamera) {
|
|
183
|
+
throw new Error('Nenhuma câmera encontrada no dispositivo');
|
|
184
|
+
}
|
|
185
|
+
return [2 /*return*/];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}); };
|
|
189
|
+
/**
|
|
190
|
+
* Solicita permissão para acessar a câmera
|
|
191
|
+
* @returns {Promise<boolean>} True se a permissão foi concedida
|
|
192
|
+
* @throws {Error} Quando a permissão é negada ou há erro no acesso
|
|
193
|
+
*/
|
|
194
|
+
export var solicitarPermissaoCamera = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
195
|
+
var stream, err_1, error, message;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
_a.trys.push([0, 2, , 3]);
|
|
200
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
201
|
+
video: { facingMode: 'environment' },
|
|
202
|
+
audio: false,
|
|
203
|
+
})];
|
|
204
|
+
case 1:
|
|
205
|
+
stream = _a.sent();
|
|
206
|
+
stream.getTracks().forEach(function (track) { return track.stop(); });
|
|
207
|
+
return [2 /*return*/, true];
|
|
208
|
+
case 2:
|
|
209
|
+
err_1 = _a.sent();
|
|
210
|
+
error = err_1;
|
|
211
|
+
message = MENSAGENS_ERRO_CAMERA.get(error.name) || 'Erro ao acessar câmera';
|
|
212
|
+
throw new Error(message);
|
|
213
|
+
case 3: return [2 /*return*/];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}); };
|
|
217
|
+
export var style = {
|
|
218
|
+
padding: '16px',
|
|
219
|
+
color: '#D32F2F',
|
|
220
|
+
textAlign: 'center',
|
|
221
|
+
backgroundColor: '#FFEBEE',
|
|
222
|
+
borderRadius: '4px',
|
|
223
|
+
border: '1px solid #FFCDD2',
|
|
224
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props para o componente BarcodeDialog
|
|
3
|
+
* @interface BarcodeDialogProps
|
|
4
|
+
*/
|
|
5
|
+
export interface BarcodeDialogProps {
|
|
6
|
+
/** Estado que controla se o dialog está aberto ou fechado */
|
|
7
|
+
open: boolean;
|
|
8
|
+
/** Função callback para definir o código de barras lido */
|
|
9
|
+
setCode: (code: string) => void;
|
|
10
|
+
/** Função para alterar o estado de abertura/fechamento do dialog */
|
|
11
|
+
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Props para o componente BarcodeScanner
|
|
15
|
+
* @interface BarcodeScannerProps
|
|
16
|
+
*/
|
|
17
|
+
export interface BarcodeScannerProps {
|
|
18
|
+
setCode: (code: string) => void;
|
|
19
|
+
open: boolean;
|
|
20
|
+
setOpen: (open: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Interface para representar uma caixa/box no resultado do Quagga
|
|
24
|
+
* @interface Box
|
|
25
|
+
*/
|
|
26
|
+
export interface Box {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Interface para o resultado do processamento do Quagga
|
|
32
|
+
* @interface QuaggaResult
|
|
33
|
+
*/
|
|
34
|
+
export interface QuaggaResult {
|
|
35
|
+
boxes?: Box[];
|
|
36
|
+
box?: Box;
|
|
37
|
+
line?: Box;
|
|
38
|
+
codeResult?: {
|
|
39
|
+
code: string;
|
|
40
|
+
format?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Interface para erros do Quagga
|
|
45
|
+
* @interface QuaggaError
|
|
46
|
+
*/
|
|
47
|
+
export interface QuaggaError {
|
|
48
|
+
name: string;
|
|
49
|
+
message: string;
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ButtonExcelProps<T> {
|
|
2
|
+
mr?: boolean;
|
|
3
|
+
nomeArq: string;
|
|
4
|
+
nomePlanilha?: string;
|
|
5
|
+
cabecalhos: string[];
|
|
6
|
+
keys: string[];
|
|
7
|
+
data: T[];
|
|
8
|
+
filho?: string;
|
|
9
|
+
widthColumn?: {
|
|
10
|
+
width: number;
|
|
11
|
+
column: string;
|
|
12
|
+
}[];
|
|
13
|
+
title?: string;
|
|
14
|
+
onLoading?: (e: boolean) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Componente de botão para download de dados em formato Excel.
|
|
18
|
+
*
|
|
19
|
+
* @component
|
|
20
|
+
* @param {object} props - Propriedades do componente.
|
|
21
|
+
* @param {boolean} [props.mr] - Indica se deve haver margem à direita.
|
|
22
|
+
* @param {string} props.nomeArq - Nome do arquivo Excel a ser baixado.
|
|
23
|
+
* @param {string} [props.nomePlanilha] - Nome da planilha no arquivo Excel.
|
|
24
|
+
* @param {string[]} props.cabecalhos - Cabeçalhos das colunas da planilha.
|
|
25
|
+
* @param {string[]} props.keys - Chaves para obter os valores das colunas a partir dos dados.
|
|
26
|
+
* @param {Array} props.data - Dados a serem incluídos na planilha.
|
|
27
|
+
* @param {string} [props.filho] - Nome da propriedade contendo dados filhos alinhados.
|
|
28
|
+
* @param {Array} [props.widthColumn] - Configuração da largura das colunas na planilha.
|
|
29
|
+
*
|
|
30
|
+
* @returns {JSX.Element} Retorna o JSX do componente ButtonExcel.
|
|
31
|
+
*/
|
|
32
|
+
export default function ButtonExcel<T>({ mr, cabecalhos, nomeArq, nomePlanilha, data, keys, filho, widthColumn, title, onLoading, }: Readonly<ButtonExcelProps<T>>): JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
38
|
+
import ExcelJS from 'exceljs';
|
|
39
|
+
import { cn } from 'src/lib/utils';
|
|
40
|
+
import { Tooltip, Zoom } from '@mui/material';
|
|
41
|
+
import { ExcelIcon } from 'src/components/icons';
|
|
42
|
+
import Button from 'src/components/button';
|
|
43
|
+
/**
|
|
44
|
+
* Componente de botão para download de dados em formato Excel.
|
|
45
|
+
*
|
|
46
|
+
* @component
|
|
47
|
+
* @param {object} props - Propriedades do componente.
|
|
48
|
+
* @param {boolean} [props.mr] - Indica se deve haver margem à direita.
|
|
49
|
+
* @param {string} props.nomeArq - Nome do arquivo Excel a ser baixado.
|
|
50
|
+
* @param {string} [props.nomePlanilha] - Nome da planilha no arquivo Excel.
|
|
51
|
+
* @param {string[]} props.cabecalhos - Cabeçalhos das colunas da planilha.
|
|
52
|
+
* @param {string[]} props.keys - Chaves para obter os valores das colunas a partir dos dados.
|
|
53
|
+
* @param {Array} props.data - Dados a serem incluídos na planilha.
|
|
54
|
+
* @param {string} [props.filho] - Nome da propriedade contendo dados filhos alinhados.
|
|
55
|
+
* @param {Array} [props.widthColumn] - Configuração da largura das colunas na planilha.
|
|
56
|
+
*
|
|
57
|
+
* @returns {JSX.Element} Retorna o JSX do componente ButtonExcel.
|
|
58
|
+
*/
|
|
59
|
+
export default function ButtonExcel(_a) {
|
|
60
|
+
/**
|
|
61
|
+
* Adiciona os valores da planilha à worksheet.
|
|
62
|
+
*
|
|
63
|
+
* @param {ExcelJS.Worksheet} ws - Instância da planilha Excel.
|
|
64
|
+
* @returns {Promise<void>} Uma Promise vazia.
|
|
65
|
+
*/
|
|
66
|
+
var _this = this;
|
|
67
|
+
var mr = _a.mr, cabecalhos = _a.cabecalhos, nomeArq = _a.nomeArq, nomePlanilha = _a.nomePlanilha, data = _a.data, keys = _a.keys, _b = _a.filho, filho = _b === void 0 ? '' : _b, widthColumn = _a.widthColumn, _c = _a.title, title = _c === void 0 ? 'Download para excel' : _c, onLoading = _a.onLoading;
|
|
68
|
+
var addValoresPlanilha = function (ws) { return __awaiter(_this, void 0, void 0, function () {
|
|
69
|
+
var bordas, cabecalho;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
bordas = {
|
|
72
|
+
top: { style: 'thin', color: { argb: '666666' } },
|
|
73
|
+
left: { style: 'thin', color: { argb: '666666' } },
|
|
74
|
+
bottom: { style: 'thin', color: { argb: '666666' } },
|
|
75
|
+
right: { style: 'thin', color: { argb: '666666' } },
|
|
76
|
+
};
|
|
77
|
+
cabecalho = ws.addRow(cabecalhos);
|
|
78
|
+
cabecalho.eachCell(function (cell) {
|
|
79
|
+
cell.fill = {
|
|
80
|
+
type: 'pattern',
|
|
81
|
+
pattern: 'solid',
|
|
82
|
+
fgColor: { argb: '00B2A6' },
|
|
83
|
+
};
|
|
84
|
+
cell.font = { bold: true, name: 'Calibri' };
|
|
85
|
+
cell.alignment = {
|
|
86
|
+
vertical: 'middle',
|
|
87
|
+
horizontal: 'center',
|
|
88
|
+
};
|
|
89
|
+
cell.border = bordas;
|
|
90
|
+
});
|
|
91
|
+
data.forEach(function (v) {
|
|
92
|
+
var rowValues = keys.map(function (key) { return v[key]; });
|
|
93
|
+
var row = ws.addRow(rowValues);
|
|
94
|
+
widthColumn === null || widthColumn === void 0 ? void 0 : widthColumn.forEach(function (v) {
|
|
95
|
+
ws.getColumn(v.column).width = v.width;
|
|
96
|
+
});
|
|
97
|
+
row.eachCell({ includeEmpty: true }, function (cell) {
|
|
98
|
+
cell.border = bordas;
|
|
99
|
+
});
|
|
100
|
+
if (Object.hasOwn(v, filho)) {
|
|
101
|
+
row.font = { bold: true, name: 'Calibri' };
|
|
102
|
+
var arrayFilho = v[filho];
|
|
103
|
+
if (Array.isArray(arrayFilho)) {
|
|
104
|
+
arrayFilho.forEach(function (objFilho) {
|
|
105
|
+
var valorAlterado = keys.map(function (key) { return objFilho[key]; });
|
|
106
|
+
var row1 = ws.addRow(valorAlterado);
|
|
107
|
+
row1.font = { name: 'Calibri' };
|
|
108
|
+
});
|
|
109
|
+
ws.addRow(['']);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return [2 /*return*/];
|
|
114
|
+
});
|
|
115
|
+
}); };
|
|
116
|
+
var gerarExcel = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
117
|
+
var wb, ws, buffer, blob, link;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
onLoading && onLoading(true);
|
|
122
|
+
wb = new ExcelJS.Workbook();
|
|
123
|
+
ws = wb.addWorksheet(nomePlanilha !== null && nomePlanilha !== void 0 ? nomePlanilha : 'planilha');
|
|
124
|
+
return [4 /*yield*/, addValoresPlanilha(ws)];
|
|
125
|
+
case 1:
|
|
126
|
+
_a.sent();
|
|
127
|
+
return [4 /*yield*/, wb.xlsx.writeBuffer()];
|
|
128
|
+
case 2:
|
|
129
|
+
buffer = _a.sent();
|
|
130
|
+
blob = new Blob([buffer], {
|
|
131
|
+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
132
|
+
});
|
|
133
|
+
link = document.createElement('a');
|
|
134
|
+
link.href = URL.createObjectURL(blob);
|
|
135
|
+
link.download = "".concat(nomeArq, ".xlsx");
|
|
136
|
+
link.click();
|
|
137
|
+
onLoading && onLoading(false);
|
|
138
|
+
return [2 /*return*/];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}); };
|
|
142
|
+
return (_jsx(Tooltip, { placement: "left", title: title, TransitionComponent: Zoom, children: _jsx(Button, { variant: "contained", color: "primary", type: "button", borderRadius: "6px", onClick: function () { return gerarExcel(); }, className: cn('min-w-10 h-9 p-0 justify-center flex transition-all duration-300 hover:bg-grzsecondary [&_img]:w-5 [&_img]:h-5', { 'mr-4': mr }), children: _jsx(ExcelIcon, {}) }) }));
|
|
143
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonProps } from '@mui/material';
|
|
3
|
+
export type ButtonColor = 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning' | 'inherit';
|
|
4
|
+
export interface ButtonDisprops extends ButtonProps {
|
|
5
|
+
width?: string;
|
|
6
|
+
height?: string;
|
|
7
|
+
fontSize?: string;
|
|
8
|
+
fontWeight?: string;
|
|
9
|
+
borderRadius?: string;
|
|
10
|
+
textTransform?: 'uppercase' | 'none';
|
|
11
|
+
border?: string;
|
|
12
|
+
color?: ButtonColor;
|
|
13
|
+
variant?: 'contained' | 'outlined' | 'text';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* button personalizado do MUI com a mesma extrutura mas com personalizações padrões do site
|
|
17
|
+
* @version 1.0.2
|
|
18
|
+
* @Flaviasoz
|
|
19
|
+
*/
|
|
20
|
+
declare const Button: React.ForwardRefExoticComponent<Omit<ButtonDisprops, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
export default Button;
|
|
@@ -0,0 +1,101 @@
|
|
|
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 React from 'react';
|
|
25
|
+
import { Button as ButtonMui, ThemeProvider, createTheme, } from '@mui/material';
|
|
26
|
+
var theme = createTheme({
|
|
27
|
+
palette: {
|
|
28
|
+
primary: {
|
|
29
|
+
main: '#00B2A6',
|
|
30
|
+
light: '#019F98',
|
|
31
|
+
dark: '#019F98',
|
|
32
|
+
contrastText: '#FFFFFF',
|
|
33
|
+
},
|
|
34
|
+
secondary: {
|
|
35
|
+
main: '#05376A',
|
|
36
|
+
light: '#253E56',
|
|
37
|
+
dark: '#253E56',
|
|
38
|
+
contrastText: '#FFFFFF',
|
|
39
|
+
},
|
|
40
|
+
error: {
|
|
41
|
+
main: '#EF4058',
|
|
42
|
+
light: '#CA3449',
|
|
43
|
+
dark: '#CA3449',
|
|
44
|
+
contrastText: '#FFFFFF',
|
|
45
|
+
},
|
|
46
|
+
warning: {
|
|
47
|
+
main: '#ECC005',
|
|
48
|
+
light: '#E0B605',
|
|
49
|
+
dark: '#E0B605',
|
|
50
|
+
contrastText: '#FFFFFF',
|
|
51
|
+
},
|
|
52
|
+
orange: {
|
|
53
|
+
main: '#ED5500',
|
|
54
|
+
light: '#E45505',
|
|
55
|
+
dark: '#E45505',
|
|
56
|
+
contrastText: '#FFFFFF',
|
|
57
|
+
},
|
|
58
|
+
purple: {
|
|
59
|
+
main: '#5E4FA2',
|
|
60
|
+
light: '#542788',
|
|
61
|
+
dark: '#542788',
|
|
62
|
+
contrastText: '#FFFFFF',
|
|
63
|
+
},
|
|
64
|
+
info: {
|
|
65
|
+
main: '#0878BD',
|
|
66
|
+
light: '#0768A4',
|
|
67
|
+
dark: '#0768A4',
|
|
68
|
+
contrastText: '#FFFFFF',
|
|
69
|
+
},
|
|
70
|
+
inherit: {
|
|
71
|
+
disabledBackground: '#E0E0E0 !important',
|
|
72
|
+
disabled: '#CBCBCB !important',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* button personalizado do MUI com a mesma extrutura mas com personalizações padrões do site
|
|
78
|
+
* @version 1.0.2
|
|
79
|
+
* @Flaviasoz
|
|
80
|
+
*/
|
|
81
|
+
var Button = React.forwardRef(function (_a, ref) {
|
|
82
|
+
var width = _a.width, height = _a.height, children = _a.children, fontSize = _a.fontSize, fontWeight = _a.fontWeight, borderRadius = _a.borderRadius, textTransform = _a.textTransform, border = _a.border, _b = _a.color, color = _b === void 0 ? 'primary' : _b, rest = __rest(_a, ["width", "height", "children", "fontSize", "fontWeight", "borderRadius", "textTransform", "border", "color"]);
|
|
83
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(ButtonMui, __assign({ ref: ref, color: (rest.disabled && 'inherit') || color, sx: {
|
|
84
|
+
'&.MuiButton-root': {
|
|
85
|
+
fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : '12px',
|
|
86
|
+
fontWeight: fontWeight !== null && fontWeight !== void 0 ? fontWeight : '800',
|
|
87
|
+
fontFamily: 'Montserrat',
|
|
88
|
+
textTransform: textTransform !== null && textTransform !== void 0 ? textTransform : 'uppercase',
|
|
89
|
+
borderRadius: borderRadius !== null && borderRadius !== void 0 ? borderRadius : '8px',
|
|
90
|
+
width: width,
|
|
91
|
+
height: height,
|
|
92
|
+
border: rest.variant === 'outlined' && !border && color === 'primary'
|
|
93
|
+
? '1px solid #00B2A6'
|
|
94
|
+
: border,
|
|
95
|
+
minWidth: 'auto',
|
|
96
|
+
minHeight: 'auto',
|
|
97
|
+
},
|
|
98
|
+
} }, rest, { children: children || rest.title })) }));
|
|
99
|
+
});
|
|
100
|
+
Button.displayName = 'Button';
|
|
101
|
+
export default Button;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CardProps {
|
|
3
|
+
width?: string;
|
|
4
|
+
height?: string;
|
|
5
|
+
margin?: string;
|
|
6
|
+
borderRadius?: string;
|
|
7
|
+
titulo?: string;
|
|
8
|
+
widthTitulo?: string;
|
|
9
|
+
corTitulo?: string;
|
|
10
|
+
borderTitulo?: string;
|
|
11
|
+
justifyContentTitulo?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
size?: 'small';
|
|
15
|
+
}
|
|
16
|
+
declare function Card({ width, height, margin, borderRadius, titulo, justifyContentTitulo, widthTitulo, corTitulo, borderTitulo, children, size, onClick, }: Readonly<CardProps>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare namespace Card {
|
|
18
|
+
var displayName: string;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: React.MemoExoticComponent<typeof Card>;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { cn } from 'src/lib/utils';
|
|
14
|
+
import { memo } from 'react';
|
|
15
|
+
import { useDimension } from 'src/hooks';
|
|
16
|
+
function Card(_a) {
|
|
17
|
+
var width = _a.width, height = _a.height, margin = _a.margin, _b = _a.borderRadius, borderRadius = _b === void 0 ? '15px' : _b, titulo = _a.titulo, justifyContentTitulo = _a.justifyContentTitulo, widthTitulo = _a.widthTitulo, corTitulo = _a.corTitulo, borderTitulo = _a.borderTitulo, children = _a.children, size = _a.size, onClick = _a.onClick;
|
|
18
|
+
var mobile = useDimension(800);
|
|
19
|
+
var pl = mobile || justifyContentTitulo === 'flex-start' ? '20px' : '0px';
|
|
20
|
+
var containerProps = onClick
|
|
21
|
+
? {
|
|
22
|
+
role: 'button',
|
|
23
|
+
tabIndex: 0,
|
|
24
|
+
onClick: onClick,
|
|
25
|
+
onKeyDown: function (e) {
|
|
26
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
onClick();
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
: {};
|
|
33
|
+
return (_jsxs("div", __assign({ className: cn('pb-5 bg-white shadow-(--shadow-3-strong) max-w-full', onClick && 'cursor-pointer', size === 'small' && 'text-sm pb-3'), style: {
|
|
34
|
+
width: width !== null && width !== void 0 ? width : 'auto',
|
|
35
|
+
height: height,
|
|
36
|
+
margin: margin,
|
|
37
|
+
borderRadius: borderRadius,
|
|
38
|
+
} }, containerProps, { children: [titulo != null && titulo !== '' && (_jsx("div", { className: "flex flex-row text-white items-center overflow-hidden", style: {
|
|
39
|
+
justifyContent: justifyContentTitulo !== null && justifyContentTitulo !== void 0 ? justifyContentTitulo : 'center',
|
|
40
|
+
width: widthTitulo !== null && widthTitulo !== void 0 ? widthTitulo : '50%',
|
|
41
|
+
backgroundColor: corTitulo !== null && corTitulo !== void 0 ? corTitulo : '#00B2A6',
|
|
42
|
+
borderRadius: borderTitulo !== null && borderTitulo !== void 0 ? borderTitulo : "".concat(borderRadius, " 0px ").concat(Number(borderRadius.replace('px', '')) * 1.5, "px 0px"),
|
|
43
|
+
paddingLeft: pl,
|
|
44
|
+
height: size === 'small' ? '24px' : '32px',
|
|
45
|
+
}, children: _jsx("p", { className: "font-semibold whitespace-nowrap overflow-hidden text-ellipsis", children: titulo }) })), _jsx("div", { className: "text-system-900 bg-white", children: children })] })));
|
|
46
|
+
}
|
|
47
|
+
Card.displayName = 'Card';
|
|
48
|
+
export default memo(Card);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DataGridProps } from '@mui/x-data-grid';
|
|
2
|
+
export interface DataTableHeaderProps {
|
|
3
|
+
title?: string;
|
|
4
|
+
countText?: string;
|
|
5
|
+
}
|
|
6
|
+
export type DataTableProps = DataGridProps & DataTableHeaderProps;
|
|
7
|
+
declare const DataTable: ({ title, countText, ...rest }: DataTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default DataTable;
|