argous 1.2.230 → 1.2.232
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/components/ArgousComplexTable/ArgousComplexTable.js +30 -15
- package/dist/components/ArgousComplexTableBody/ArgousComplexTableBody.js +19 -2
- package/dist/components/UtilTextField/UtilTextField.d.ts +23 -0
- package/dist/components/UtilTextField/UtilTextField.js +96 -0
- package/dist/components/UtilTextField/index.d.ts +2 -0
- package/dist/components/UtilTextField/index.js +8 -0
- package/dist/components/index.d.ts +4 -1
- package/dist/components/index.js +4 -1
- package/dist/utils/index.d.ts +31 -0
- package/dist/utils/index.js +41 -3
- package/lib/components/ArgousComplexTable/ArgousComplexTable.js +56 -43
- package/lib/components/ArgousComplexTableBody/ArgousComplexTableBody.js +51 -8
- package/lib/components/UtilTextField/UtilTextField.d.ts +23 -0
- package/lib/components/UtilTextField/UtilTextField.js +69 -0
- package/lib/components/UtilTextField/index.d.ts +2 -0
- package/lib/components/UtilTextField/index.js +1 -0
- package/lib/components/index.d.ts +4 -1
- package/lib/components/index.js +4 -1
- package/lib/utils/index.ts +40 -2
- package/package.json +1 -1
|
@@ -65,6 +65,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
65
65
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
69
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
70
|
+
to[j] = from[i];
|
|
71
|
+
return to;
|
|
72
|
+
};
|
|
68
73
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
69
74
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
70
75
|
};
|
|
@@ -174,6 +179,30 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
|
|
|
174
179
|
var _3 = react_1.useState({ qtRegs: defaultRowsPerPage, pgAtl: 1 }), ctrlPgn = _3[0], setCtrlPgn = _3[1];
|
|
175
180
|
var qtRegs = ctrlPgn.qtRegs, pgAtl = ctrlPgn.pgAtl, ordCols = ctrlPgn.ordCols;
|
|
176
181
|
var enableCheck = checkEnabled || (enableCheckIfSelected && !!selected.length);
|
|
182
|
+
var dadosNaoCortados = react_1.useMemo(function () {
|
|
183
|
+
if (method)
|
|
184
|
+
return lista || [];
|
|
185
|
+
if (lodash_1.isArray(lista) && lista.length > 0)
|
|
186
|
+
return stableSort(lista, getComparator(order, orderBy), line)
|
|
187
|
+
.filter(function (linha) { return lodash_1.isArray(line(linha)) ? line(linha).filter(function (item) { return filter ? new RegExp(".*" + filter + ".*", 'gi').test(item === null || item === void 0 ? void 0 : item.toString()) : true; }).length > 0 : true; }) || [];
|
|
188
|
+
return [];
|
|
189
|
+
}, [lista, filter, order, orderBy, method, line]);
|
|
190
|
+
var usePagination = ((rowsPerPageOptions !== 0) && (Math.ceil(((method || externalCtrlPgn) ? ctrlPgn.recordCount : dadosNaoCortados.length) / parseInt(rowsPerPageOptions[0], 10)) > 1));
|
|
191
|
+
var cortaDados = react_1.useCallback(function (dados) { return dados === null || dados === void 0 ? void 0 : dados.slice(defaultRowsPerPage === 0 ? (undefined) : page * rowsPerPage, defaultRowsPerPage === 0 ? (undefined) : page * rowsPerPage + rowsPerPage); }, [page, rowsPerPage, defaultRowsPerPage]);
|
|
192
|
+
var fillListToKeepHeight = react_1.useCallback(function (array) {
|
|
193
|
+
var newArray = __spreadArray([], array);
|
|
194
|
+
if (newArray.length < rowsPerPage) {
|
|
195
|
+
var gap = (rowsPerPage - newArray.length);
|
|
196
|
+
var arrayToFillGap = Array.from(Array(gap)).fill(Array.from(Array(head.length)).fill(''));
|
|
197
|
+
newArray.push.apply(newArray, arrayToFillGap);
|
|
198
|
+
}
|
|
199
|
+
return newArray;
|
|
200
|
+
}, [head, rowsPerPage]);
|
|
201
|
+
var dadosMostrados = react_1.useMemo(function () {
|
|
202
|
+
if (method || externalCtrlPgn)
|
|
203
|
+
return (usePagination) ? fillListToKeepHeight(lista || []) : (lista || []);
|
|
204
|
+
return (usePagination) ? fillListToKeepHeight(cortaDados(dadosNaoCortados) || []) : (cortaDados(dadosNaoCortados) || []);
|
|
205
|
+
}, [method, externalCtrlPgn, lista, dadosNaoCortados, cortaDados, usePagination, fillListToKeepHeight]);
|
|
177
206
|
react_1.useEffect(function () {
|
|
178
207
|
dispatch({ type: 'mount', value: savedState.current });
|
|
179
208
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -246,20 +275,6 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
|
|
|
246
275
|
onSelect(selected);
|
|
247
276
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
248
277
|
}, [selected]);
|
|
249
|
-
var dadosNaoCortados = react_1.useMemo(function () {
|
|
250
|
-
if (method)
|
|
251
|
-
return lista || [];
|
|
252
|
-
if (lodash_1.isArray(lista) && lista.length > 0)
|
|
253
|
-
return stableSort(lista, getComparator(order, orderBy), line)
|
|
254
|
-
.filter(function (linha) { return lodash_1.isArray(line(linha)) ? line(linha).filter(function (item) { return filter ? new RegExp(".*" + filter + ".*", 'gi').test(item === null || item === void 0 ? void 0 : item.toString()) : true; }).length > 0 : true; }) || [];
|
|
255
|
-
return [];
|
|
256
|
-
}, [lista, filter, order, orderBy, method, line]);
|
|
257
|
-
var cortaDados = react_1.useCallback(function (dados) { return dados === null || dados === void 0 ? void 0 : dados.slice(defaultRowsPerPage === 0 ? (undefined) : page * rowsPerPage, defaultRowsPerPage === 0 ? (undefined) : page * rowsPerPage + rowsPerPage); }, [page, rowsPerPage, defaultRowsPerPage]);
|
|
258
|
-
var dadosMostrados = react_1.useMemo(function () {
|
|
259
|
-
if (method || externalCtrlPgn)
|
|
260
|
-
return lista || [];
|
|
261
|
-
return cortaDados(dadosNaoCortados) || [];
|
|
262
|
-
}, [method, externalCtrlPgn, lista, dadosNaoCortados, cortaDados]);
|
|
263
278
|
var handleOpenClose = react_1.useCallback(function (index) {
|
|
264
279
|
if (index === open || (!index && index !== 0)) {
|
|
265
280
|
dispatch({ type: 'setOpen', value: undefined });
|
|
@@ -319,7 +334,7 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
|
|
|
319
334
|
onClick: onClick, onDoubleClick: onDoubleClick, indexToSelect: indexToSelect, open: open, dadosMostrados: dadosMostrados, customKey: customKey, disableCheckIf: disableCheckIf
|
|
320
335
|
})),
|
|
321
336
|
FooterComponent && react_1.default.createElement(FooterComponent, __assign({}, footerProps))),
|
|
322
|
-
(
|
|
337
|
+
(usePagination) && (react_1.default.createElement(PaginationComponent, __assign({ count: (method || externalCtrlPgn) ? ctrlPgn.recordCount : dadosNaoCortados.length, onChangePage: function (_, value) {
|
|
323
338
|
dispatch({ type: 'setPage', value: value });
|
|
324
339
|
setCtrlPgn(__assign(__assign({}, ctrlPgn), { pgAtl: value + 1 }));
|
|
325
340
|
}, onChangeRowsPerPage: function (e) {
|
|
@@ -83,6 +83,18 @@ var useStyles = core_1.makeStyles(function (theme) { return ({
|
|
|
83
83
|
loading: {
|
|
84
84
|
textAlign: 'center',
|
|
85
85
|
padding: '7px'
|
|
86
|
+
},
|
|
87
|
+
ghost: {
|
|
88
|
+
borderBottom: '1px solid #0000',
|
|
89
|
+
userSelect: 'none',
|
|
90
|
+
'&:hover': {
|
|
91
|
+
backgroundColor: '#0000 !important'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
tableCell: {
|
|
95
|
+
overflow: 'hidden',
|
|
96
|
+
whiteSpace: 'nowrap',
|
|
97
|
+
textOverflow: 'ellipsis'
|
|
86
98
|
}
|
|
87
99
|
}); });
|
|
88
100
|
var ArgousComplexTableBody = react_1.memo(function (_a) {
|
|
@@ -118,6 +130,7 @@ var ArgousComplexTableBody = react_1.memo(function (_a) {
|
|
|
118
130
|
react_1.default.createElement(core_1.CircularProgress, { disableShrink: true })))) : dadosMostrados.length ? dadosMostrados.map(function (linha, i) {
|
|
119
131
|
var isItemSelected = isSelected(linha[indexToSelect]);
|
|
120
132
|
var isItemOpen = i === open;
|
|
133
|
+
var fullyEmpty = !linha.some(function (value) { return !!value; });
|
|
121
134
|
var _a = rowProps({ index: i, linhaOriginal: linha, linhaFormatada: line(linha), itensSelecionados: selected }) || {}, title = _a.title, rowProperties = __rest(_a, ["title"]);
|
|
122
135
|
return react_1.default.createElement(dist_1.Draggable, { key: customKey ? lista[i][customKey] : i, render: function (draggableRef) {
|
|
123
136
|
var _a;
|
|
@@ -126,7 +139,11 @@ var ArgousComplexTableBody = react_1.memo(function (_a) {
|
|
|
126
139
|
//TODO criar proprio draggable pois esse remove classes do filho
|
|
127
140
|
react_1.default.createElement(react_1.Fragment, null,
|
|
128
141
|
react_1.default.createElement(exports.CustomTooltip, { title: lineTitle || title },
|
|
129
|
-
react_1.default.createElement(core_1.TableRow, __assign({ component: dist_1.Draggable }, rowProperties, { className: clsx_1.default((_a = {},
|
|
142
|
+
react_1.default.createElement(core_1.TableRow, __assign({ component: dist_1.Draggable }, rowProperties, { className: clsx_1.default((_a = {},
|
|
143
|
+
_a[classes.hover] = isItemSelected,
|
|
144
|
+
_a[classes.open] = (isItemOpen && !!children),
|
|
145
|
+
_a[classes.ghost] = fullyEmpty,
|
|
146
|
+
_a), lineClass(line(linha), linha, i), rowProperties.className), hover: true, role: 'checkbox', tabIndex: -1, selected: isItemSelected, style: lineStyle ? lineStyle(linha, line(linha), i) : undefined, onClick: (fullyEmpty) ? undefined : (onClick) ? function (e) { return onClick(e, linha, line(linha), i); } : (children) ? function () { return handleOpenClose(i); } : undefined, onDoubleClick: (fullyEmpty) ? undefined : (onDoubleClick) ? function (e) { return onDoubleClick(e, linha, line(linha), i); } : undefined, innerRef: draggableRef }),
|
|
130
147
|
enableDrag && react_1.default.createElement(core_1.TableCell, { padding: 'checkbox' },
|
|
131
148
|
react_1.default.createElement(core_1.Tooltip, { title: 'Arrastar' },
|
|
132
149
|
react_1.default.createElement(core_1.IconButton, { size: 'small', className: classes.dragHandle },
|
|
@@ -136,7 +153,7 @@ var ArgousComplexTableBody = react_1.memo(function (_a) {
|
|
|
136
153
|
e.stopPropagation();
|
|
137
154
|
handleClick(linha[indexToSelect]);
|
|
138
155
|
}, checked: isItemSelected })),
|
|
139
|
-
lodash_1.isArray(line(linha)) && line(linha).map(function (coluna, j) { return (react_1.default.createElement(core_1.TableCell, __assign({ key: j }, columnProps(j, coluna, linha, line(linha)), { style: columnStyles ? columnStyles[j] : undefined }), getCellContent(coluna, dadosMostrados[i], j, i))); }))),
|
|
156
|
+
lodash_1.isArray(line(linha)) && line(linha).map(function (coluna, j) { return ((fullyEmpty) ? (react_1.default.createElement(core_1.TableCell, __assign({ key: j }, columnProps(j, coluna, linha, line(linha)), { style: columnStyles ? columnStyles[j] : undefined, className: clsx_1.default(classes.tableCell, classes.ghost) }), "\u00A0")) : (react_1.default.createElement(core_1.TableCell, __assign({ key: j }, columnProps(j, coluna, linha, line(linha)), { style: columnStyles ? columnStyles[j] : undefined, className: classes.tableCell }), getCellContent(coluna, dadosMostrados[i], j, i)))); }))),
|
|
140
157
|
children && (react_1.default.createElement(core_1.TableRow, { className: classes.group },
|
|
141
158
|
react_1.default.createElement(core_1.TableCell, { colSpan: (dadosMostrados === null || dadosMostrados === void 0 ? void 0 : dadosMostrados.length) && ((_b = line(dadosMostrados[0])) === null || _b === void 0 ? void 0 : _b.length) + (enableCheck ? 1 : 0) + (enableDrag ? 1 : 0), style: { padding: open === i ? 8 : 0 }, className: 'argous-complex-table-group-cell' },
|
|
142
159
|
react_1.default.createElement(core_1.Collapse, { in: open === i, mountOnEnter: true, unmountOnExit: true }, typeof children === 'function' ? children({ linha: line(linha), linhaOriginal: linha, index: i }) : children))))));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseTextFieldProps } from '@material-ui/core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export interface UtilTextFieldProps extends BaseTextFieldProps {
|
|
6
|
+
/**
|
|
7
|
+
* Type of format
|
|
8
|
+
*/
|
|
9
|
+
type: 'cpf' | 'cnpj' | 'cep' | 'telephone',
|
|
10
|
+
/**
|
|
11
|
+
* Callback fired when the value change
|
|
12
|
+
*
|
|
13
|
+
* @param event — The event source of the callback
|
|
14
|
+
*
|
|
15
|
+
* @param value — The new value of the component
|
|
16
|
+
*/
|
|
17
|
+
onChange?: ((event: React.ChangeEvent<{}>, value: any) => void) | undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
declare function UtilTextField(props: UtilTextFieldProps): JSX.Element
|
|
22
|
+
|
|
23
|
+
export default UtilTextField;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
33
|
+
var t = {};
|
|
34
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
35
|
+
t[p] = s[p];
|
|
36
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
37
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
38
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
39
|
+
t[p[i]] = s[p[i]];
|
|
40
|
+
}
|
|
41
|
+
return t;
|
|
42
|
+
};
|
|
43
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
|
+
};
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
var utils_1 = require("../../utils");
|
|
48
|
+
var core_1 = require("@material-ui/core");
|
|
49
|
+
var react_1 = __importStar(require("react"));
|
|
50
|
+
var react_maskedinput_1 = __importDefault(require("react-maskedinput"));
|
|
51
|
+
var cepMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '11111-111' }, props)); } };
|
|
52
|
+
var cpfMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '111.111.111-11' }, props)); } };
|
|
53
|
+
var cnpjMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '11.111.111/1111-11' }, props)); } };
|
|
54
|
+
var telephoneMaskedInput = { inputComponent: function (props) { return react_1.default.createElement(react_maskedinput_1.default, __assign({ mask: '(11) 111111111' }, props)); } };
|
|
55
|
+
var UtilTextField = function (_a) {
|
|
56
|
+
var type = _a.type, onChange = _a.onChange, props = __rest(_a, ["type", "onChange"]);
|
|
57
|
+
var standard = react_1.useMemo(function () {
|
|
58
|
+
var standardObject = {
|
|
59
|
+
valueHandler: function (value) { return value; },
|
|
60
|
+
InputProps: {},
|
|
61
|
+
label: ''
|
|
62
|
+
};
|
|
63
|
+
switch (type) {
|
|
64
|
+
case 'cep':
|
|
65
|
+
standardObject.valueHandler = function (value) { return utils_1.numbersOnly(value); };
|
|
66
|
+
standardObject.InputProps = __assign({}, cepMaskedInput);
|
|
67
|
+
standardObject.label = 'CEP';
|
|
68
|
+
break;
|
|
69
|
+
case 'cpf':
|
|
70
|
+
standardObject.valueHandler = function (value) { return utils_1.numbersOnly(value); };
|
|
71
|
+
standardObject.InputProps = __assign({}, cpfMaskedInput);
|
|
72
|
+
standardObject.label = 'CPF';
|
|
73
|
+
break;
|
|
74
|
+
case 'cnpj':
|
|
75
|
+
standardObject.valueHandler = function (value) { return utils_1.numbersOnly(value); };
|
|
76
|
+
standardObject.InputProps = __assign({}, cnpjMaskedInput);
|
|
77
|
+
standardObject.label = 'CNPJ';
|
|
78
|
+
break;
|
|
79
|
+
case 'telephone':
|
|
80
|
+
standardObject.valueHandler = function (value) { return utils_1.numbersOnly(value); };
|
|
81
|
+
standardObject.InputProps = __assign({}, telephoneMaskedInput);
|
|
82
|
+
standardObject.label = 'TELEFONE';
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
return standardObject;
|
|
88
|
+
}, [type]);
|
|
89
|
+
var handleOnChange = function (event) {
|
|
90
|
+
var newValue = event.target.value;
|
|
91
|
+
newValue = standard.valueHandler(newValue);
|
|
92
|
+
onChange(event, newValue);
|
|
93
|
+
};
|
|
94
|
+
return (react_1.default.createElement(core_1.TextField, __assign({}, props, { label: (props === null || props === void 0 ? void 0 : props.label) || standard.label, InputProps: __assign(__assign({}, standard.InputProps), ((props === null || props === void 0 ? void 0 : props.InputProps) || {})), onChange: handleOnChange })));
|
|
95
|
+
};
|
|
96
|
+
exports.default = UtilTextField;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var UtilTextField_1 = require("./UtilTextField");
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(UtilTextField_1).default; } });
|
|
@@ -171,4 +171,7 @@ export * from './Carousel';
|
|
|
171
171
|
export { default as Cam } from './Cam';
|
|
172
172
|
export * from './Cam';
|
|
173
173
|
|
|
174
|
-
export * from './Document';
|
|
174
|
+
export * from './Document';
|
|
175
|
+
|
|
176
|
+
export { default as UtilTextField } from './UtilTextField';
|
|
177
|
+
export * from './UtilTextField';
|
package/dist/components/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.AutoCompleteFavorites = exports.UtilAutoComplete = exports.ThreadLog = exports.TextArea = exports.Tabs = exports.TablePicker = exports.Stepper = exports.SimpleTable = exports.Select = exports.ProgressBar = exports.Programa = exports.Pagination = exports.OutputText = exports.OtpInput = exports.MultipleSelect = exports.MonthPicker = exports.ModalProvider = exports.MenuBar = exports.MaterialButton = exports.ListSelect = exports.InputTags = exports.Input = exports.ImageResizeButton = exports.ImageResize = exports.Highlight = exports.FormVisualizer = exports.FileUploader = exports.FilePreparer = exports.DropArea = exports.Compartilhar = exports.Collapse = exports.CartaoUsuario = exports.Calendar = exports.Cabecalho = exports.Button = exports.BarraFerramentas = exports.BarChart = exports.AutoComplete = exports.ArgousSimpleTable = exports.ArgousProgressBar = exports.ArgousPagination = exports.ArgousInput = exports.ArgousComplexTableToolbar = exports.ArgousComplexTableHead = exports.ArgousComplexTableBody = exports.ArgousComplexTable = exports.ArgousComplexPagination = exports.ArgousAvatar = exports.ArgousAction = exports.Alert = void 0;
|
|
17
|
-
exports.Cam = exports.Carousel = exports.Zoom = exports.TextToHtml = exports.UserCard = exports.HalfGauge = exports.PercentageDisplay = void 0;
|
|
17
|
+
exports.UtilTextField = exports.Cam = exports.Carousel = exports.Zoom = exports.TextToHtml = exports.UserCard = exports.HalfGauge = exports.PercentageDisplay = void 0;
|
|
18
18
|
var Alert_1 = require("./Alert");
|
|
19
19
|
Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return __importDefault(Alert_1).default; } });
|
|
20
20
|
__exportStar(require("./Alert"), exports);
|
|
@@ -186,3 +186,6 @@ var Cam_1 = require("./Cam");
|
|
|
186
186
|
Object.defineProperty(exports, "Cam", { enumerable: true, get: function () { return __importDefault(Cam_1).default; } });
|
|
187
187
|
__exportStar(require("./Cam"), exports);
|
|
188
188
|
__exportStar(require("./Document"), exports);
|
|
189
|
+
var UtilTextField_1 = require("./UtilTextField");
|
|
190
|
+
Object.defineProperty(exports, "UtilTextField", { enumerable: true, get: function () { return __importDefault(UtilTextField_1).default; } });
|
|
191
|
+
__exportStar(require("./UtilTextField"), exports);
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ export declare const storageMeasures: {
|
|
|
74
74
|
export declare const bytesTranslator: (bytes?: number, decimals?: number, binary?: boolean) => object;
|
|
75
75
|
export declare const formatCpfCnpj: (value: (string | number)) => string;
|
|
76
76
|
export declare function dataUrlToBlob(dataUrl: string): Blob | undefined;
|
|
77
|
+
export declare function allCharactersSame(s: string): boolean;
|
|
77
78
|
export declare function cpfTest(cpf: (string | number)): boolean;
|
|
78
79
|
interface PrintScreenParameters {
|
|
79
80
|
/**
|
|
@@ -121,4 +122,34 @@ declare global {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
export declare function stopPrntScr(e: KeyboardEvent): boolean;
|
|
125
|
+
export declare const documentType: {
|
|
126
|
+
cpf: {
|
|
127
|
+
length: number;
|
|
128
|
+
symbols: {
|
|
129
|
+
length: number;
|
|
130
|
+
};
|
|
131
|
+
lengthWithSymbols: number;
|
|
132
|
+
};
|
|
133
|
+
cnpj: {
|
|
134
|
+
length: number;
|
|
135
|
+
symbols: {
|
|
136
|
+
length: number;
|
|
137
|
+
};
|
|
138
|
+
lengthWithSymbols: number;
|
|
139
|
+
};
|
|
140
|
+
cep: {
|
|
141
|
+
length: number;
|
|
142
|
+
symbols: {
|
|
143
|
+
length: number;
|
|
144
|
+
};
|
|
145
|
+
lengthWithSymbols: number;
|
|
146
|
+
};
|
|
147
|
+
telephone: {
|
|
148
|
+
length: number;
|
|
149
|
+
symbols: {
|
|
150
|
+
length: number;
|
|
151
|
+
};
|
|
152
|
+
lengthWithSymbols: number;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
124
155
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -85,7 +85,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
85
85
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
86
86
|
};
|
|
87
87
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
88
|
-
exports.stopPrntScr = exports.printUrl = exports.geraLog = exports.printScreen = exports.cpfTest = exports.dataUrlToBlob = exports.formatCpfCnpj = exports.bytesTranslator = exports.storageMeasures = exports.confirm = exports.copyToClipboard = exports.toFloat = exports.currencyMask = exports.numbersOnly = exports.formataCpf = exports.useWebSocket = exports.formataTelefone = exports.reduxDispatch = exports.useStore = exports.useModal = exports.useGraph = exports.randomColor = exports.humanFileSize = exports.sanitizaHTML = exports.formataDinheiro = exports.useUpdateEffect = exports.usePrevious = exports.getNumeroFromInitials = exports.getInitials = exports.getRandomColor = exports.printPdf = exports.downloadFromUrl = exports.downloadBase64 = exports.formataNome = exports.addExtraZero = exports.getCookie = exports.widthToCenterVertically = void 0;
|
|
88
|
+
exports.documentType = exports.stopPrntScr = exports.printUrl = exports.geraLog = exports.printScreen = exports.cpfTest = exports.allCharactersSame = exports.dataUrlToBlob = exports.formatCpfCnpj = exports.bytesTranslator = exports.storageMeasures = exports.confirm = exports.copyToClipboard = exports.toFloat = exports.currencyMask = exports.numbersOnly = exports.formataCpf = exports.useWebSocket = exports.formataTelefone = exports.reduxDispatch = exports.useStore = exports.useModal = exports.useGraph = exports.randomColor = exports.humanFileSize = exports.sanitizaHTML = exports.formataDinheiro = exports.useUpdateEffect = exports.usePrevious = exports.getNumeroFromInitials = exports.getInitials = exports.getRandomColor = exports.printPdf = exports.downloadFromUrl = exports.downloadBase64 = exports.formataNome = exports.addExtraZero = exports.getCookie = exports.widthToCenterVertically = void 0;
|
|
89
89
|
var api_1 = require("./api");
|
|
90
90
|
var store_1 = require("./store");
|
|
91
91
|
var api_2 = require("../api");
|
|
@@ -457,11 +457,19 @@ function dataUrlToBlob(dataUrl) {
|
|
|
457
457
|
return blob;
|
|
458
458
|
}
|
|
459
459
|
exports.dataUrlToBlob = dataUrlToBlob;
|
|
460
|
+
function allCharactersSame(s) {
|
|
461
|
+
var n = s.length;
|
|
462
|
+
for (var i = 1; i < n; i++)
|
|
463
|
+
if (s[i] !== s[0])
|
|
464
|
+
return false;
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
exports.allCharactersSame = allCharactersSame;
|
|
460
468
|
function cpfTest(cpf) {
|
|
461
|
-
if (cpf === '00000000000' || !cpf)
|
|
462
|
-
return false;
|
|
463
469
|
if (typeof cpf === 'number')
|
|
464
470
|
cpf = cpf.toString();
|
|
471
|
+
if (!cpf || allCharactersSame(cpf))
|
|
472
|
+
return false;
|
|
465
473
|
var sum = 0;
|
|
466
474
|
var rest;
|
|
467
475
|
for (var index = 1; index <= 9; index++)
|
|
@@ -576,3 +584,33 @@ function stopPrntScr(e) {
|
|
|
576
584
|
return false;
|
|
577
585
|
}
|
|
578
586
|
exports.stopPrntScr = stopPrntScr;
|
|
587
|
+
exports.documentType = {
|
|
588
|
+
cpf: {
|
|
589
|
+
length: 11,
|
|
590
|
+
symbols: {
|
|
591
|
+
length: 3
|
|
592
|
+
},
|
|
593
|
+
lengthWithSymbols: 14
|
|
594
|
+
},
|
|
595
|
+
cnpj: {
|
|
596
|
+
length: 14,
|
|
597
|
+
symbols: {
|
|
598
|
+
length: 4
|
|
599
|
+
},
|
|
600
|
+
lengthWithSymbols: 18
|
|
601
|
+
},
|
|
602
|
+
cep: {
|
|
603
|
+
length: 8,
|
|
604
|
+
symbols: {
|
|
605
|
+
length: 1
|
|
606
|
+
},
|
|
607
|
+
lengthWithSymbols: 9
|
|
608
|
+
},
|
|
609
|
+
telephone: {
|
|
610
|
+
length: 11,
|
|
611
|
+
symbols: {
|
|
612
|
+
length: 2
|
|
613
|
+
},
|
|
614
|
+
lengthWithSymbols: 13
|
|
615
|
+
}
|
|
616
|
+
};
|
|
@@ -18,9 +18,9 @@ const useStyles = makeStyles({
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
export const TableContext = createContext();
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
const ehData = valor => {
|
|
25
25
|
const retorno = (format) => moment(valor, format).format('YYYYMMDDHHmmss');
|
|
26
26
|
if (/[0-9]{2}\/[0-9]{2}\/[0-9]{4}/.test(valor)) return retorno('DD/MM/YYYY');
|
|
@@ -29,7 +29,7 @@ const ehData = valor => {
|
|
|
29
29
|
if (/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(.\d)*/.test(valor)) return retorno('YYYY-MM-DD HH:mm:ss');
|
|
30
30
|
return valor;
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
function descendingComparator(a, b, orderBy) {
|
|
34
34
|
const aO = ehData(a[orderBy]);
|
|
35
35
|
const bO = ehData(b[orderBy]);
|
|
@@ -37,13 +37,13 @@ function descendingComparator(a, b, orderBy) {
|
|
|
37
37
|
if (bO > aO) return 1;
|
|
38
38
|
return 0;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
function getComparator(order, orderBy) {
|
|
42
42
|
return order === 'desc'
|
|
43
43
|
? (a, b) => descendingComparator(a, b, orderBy)
|
|
44
44
|
: (a, b) => -descendingComparator(a, b, orderBy);
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
function stableSort(array, comparator, line) {
|
|
48
48
|
const stabilizedThis = array.map((el, index) => [el, line(el), index]);
|
|
49
49
|
stabilizedThis.sort((a, b) => {
|
|
@@ -53,7 +53,7 @@ function stableSort(array, comparator, line) {
|
|
|
53
53
|
});
|
|
54
54
|
return stabilizedThis.map((el) => el[0]);
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
const reducer = (state, action) => {
|
|
58
58
|
switch (action.type) {
|
|
59
59
|
case 'setSelected':
|
|
@@ -108,7 +108,7 @@ const reducer = (state, action) => {
|
|
|
108
108
|
return state;
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
const initialState = (defaultRowsPerPage) => ({
|
|
113
113
|
selected: [],
|
|
114
114
|
page: 0,
|
|
@@ -119,7 +119,7 @@ const initialState = (defaultRowsPerPage) => ({
|
|
|
119
119
|
open: undefined,
|
|
120
120
|
loading: false
|
|
121
121
|
});
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
const ArgousComplexTable = forwardRef(({
|
|
124
124
|
ToolbarComponent = ArgousComplexTableToolbar,
|
|
125
125
|
HeadComponent = ArgousComplexTableHead,
|
|
@@ -180,31 +180,60 @@ const ArgousComplexTable = forwardRef(({
|
|
|
180
180
|
code = '',
|
|
181
181
|
token = ''
|
|
182
182
|
}, ref) => {
|
|
183
|
+
|
|
183
184
|
const classes = useStyles();
|
|
184
185
|
const [state, dispatch] = useReducer(reducer, initialState(defaultRowsPerPage));
|
|
185
186
|
const memoState = useMemo(() => ({ ...state, dispatch }), [state, dispatch]);
|
|
186
187
|
const { selected, page, rowsPerPage, order, orderBy, filter, open } = memoState;
|
|
187
|
-
|
|
188
|
+
|
|
188
189
|
const [lista, setLista] = useState(dados/*.map(linha => isArray(linha) ? linha : Object.values(linha))*/ || []);
|
|
189
190
|
const [ctrlPgn, setCtrlPgn] = useState({ qtRegs: defaultRowsPerPage, pgAtl: 1 });
|
|
190
191
|
const { qtRegs, pgAtl, ordCols } = ctrlPgn;
|
|
191
|
-
|
|
192
|
+
|
|
192
193
|
const enableCheck = checkEnabled || (enableCheckIfSelected && !!selected.length);
|
|
193
|
-
|
|
194
|
+
|
|
195
|
+
const dadosNaoCortados = useMemo(() => {
|
|
196
|
+
if (method) return lista || [];
|
|
197
|
+
if (isArray(lista) && lista.length > 0) return stableSort(lista, getComparator(order, orderBy), line)
|
|
198
|
+
.filter(linha => isArray(line(linha)) ? line(linha).filter(item => filter ? new RegExp(`.*${filter}.*`, 'gi').test(item?.toString()) : true).length > 0 : true) || [];
|
|
199
|
+
return [];
|
|
200
|
+
}, [lista, filter, order, orderBy, method, line]);
|
|
201
|
+
|
|
202
|
+
const usePagination = ((rowsPerPageOptions !== 0) && (Math.ceil(((method || externalCtrlPgn) ? ctrlPgn.recordCount : dadosNaoCortados.length) / parseInt(rowsPerPageOptions[0], 10)) > 1));
|
|
203
|
+
|
|
204
|
+
const cortaDados = useCallback((dados) => dados
|
|
205
|
+
?.slice(defaultRowsPerPage === 0 ? (undefined) : page * rowsPerPage, defaultRowsPerPage === 0 ? (undefined) : page * rowsPerPage + rowsPerPage),
|
|
206
|
+
[page, rowsPerPage, defaultRowsPerPage]);
|
|
207
|
+
|
|
208
|
+
const fillListToKeepHeight = useCallback((array) => {
|
|
209
|
+
let newArray = [...array];
|
|
210
|
+
if (newArray.length < rowsPerPage) {
|
|
211
|
+
const gap = (rowsPerPage - newArray.length);
|
|
212
|
+
const arrayToFillGap = Array.from(Array(gap)).fill(Array.from(Array(head.length)).fill(''));
|
|
213
|
+
newArray.push(...arrayToFillGap);
|
|
214
|
+
}
|
|
215
|
+
return newArray;
|
|
216
|
+
}, [head, rowsPerPage]);
|
|
217
|
+
|
|
218
|
+
const dadosMostrados = useMemo(() => {
|
|
219
|
+
if (method || externalCtrlPgn) return (usePagination) ? fillListToKeepHeight(lista || []) : (lista || []);
|
|
220
|
+
return (usePagination) ? fillListToKeepHeight(cortaDados(dadosNaoCortados) || []) : (cortaDados(dadosNaoCortados) || []);
|
|
221
|
+
}, [method, externalCtrlPgn, lista, dadosNaoCortados, cortaDados, usePagination, fillListToKeepHeight]);
|
|
222
|
+
|
|
194
223
|
useEffect(() => {
|
|
195
224
|
dispatch({ type: 'mount', value: savedState.current });
|
|
196
225
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
197
226
|
}, []);
|
|
198
|
-
|
|
227
|
+
|
|
199
228
|
useEffect(() => {
|
|
200
|
-
return () => savedState.current = state;
|
|
229
|
+
return () => savedState.current = state;
|
|
201
230
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
202
231
|
}, [state]);
|
|
203
|
-
|
|
232
|
+
|
|
204
233
|
useEffect(() => {
|
|
205
234
|
if (isArray(dados)) setLista(dados/*.map(linha => isArray(linha) ? linha : Object.values(linha))*/ || []);
|
|
206
235
|
}, [dados]);
|
|
207
|
-
|
|
236
|
+
|
|
208
237
|
const retornaAcao = useCallback((pgAtl, page) => {
|
|
209
238
|
if (page === pgAtl) return undefined;
|
|
210
239
|
else if (page === pgAtl + 1) return 'N';
|
|
@@ -213,7 +242,7 @@ const ArgousComplexTable = forwardRef(({
|
|
|
213
242
|
else if (page === 0) return 'F';
|
|
214
243
|
return `S=${page}`;
|
|
215
244
|
}, [ctrlPgn.recordCount]);
|
|
216
|
-
|
|
245
|
+
|
|
217
246
|
const buscaMetodo = useCallback(async () => {
|
|
218
247
|
if (!method || !allowMethodRequest) return;
|
|
219
248
|
dispatch({ type: 'setLoading', value: true });
|
|
@@ -233,45 +262,29 @@ const ArgousComplexTable = forwardRef(({
|
|
|
233
262
|
dispatch({ type: 'setLoading', value: false });
|
|
234
263
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
235
264
|
}, [method, allowMethodRequest, qtRegs, pgAtl, retornaAcao, ctrlPgn.pgAtl, page, orderBy, order, methodPrms, handleMethodError, methodResultList, code, token]);
|
|
236
|
-
|
|
265
|
+
|
|
237
266
|
useEffect(() => {
|
|
238
267
|
buscaMetodo();
|
|
239
268
|
}, [buscaMetodo]);
|
|
240
|
-
|
|
269
|
+
|
|
241
270
|
const fielValue = useMemo(() => /*isArray(getField(field, 'value')) ? */getField(field, 'value')/*?.map(item => isArray(item) ? item : Object.values(item)) : []*/, [field]);
|
|
242
|
-
|
|
271
|
+
|
|
243
272
|
useEffect(() => {
|
|
244
273
|
if (field && !isEqual(lista, fielValue)) setLista(fielValue || []);
|
|
245
274
|
}, [field, lista, fielValue]);
|
|
246
|
-
|
|
275
|
+
|
|
247
276
|
useEffect(() => {
|
|
248
277
|
if (method || field || externalCtrlPgn) return;
|
|
249
278
|
if (isArray(lista) && lista.length > 0 && page === Math.ceil(method ? ctrlPgn.recordCount : lista.length / parseInt(rowsPerPage, 10))) dispatch({ type: 'decremmentPage' });
|
|
250
279
|
}, [page, method, lista.length, rowsPerPage, ctrlPgn.recordCount, lista, field, externalCtrlPgn]);
|
|
251
|
-
|
|
280
|
+
|
|
252
281
|
useEffect(() => dispatch({ type: 'setSelected', value: [] }), [lista]);
|
|
253
|
-
|
|
282
|
+
|
|
254
283
|
useEffect(() => {
|
|
255
284
|
if (onSelect) onSelect(selected);
|
|
256
285
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
257
286
|
}, [selected]);
|
|
258
|
-
|
|
259
|
-
const dadosNaoCortados = useMemo(() => {
|
|
260
|
-
if (method) return lista || [];
|
|
261
|
-
if (isArray(lista) && lista.length > 0) return stableSort(lista, getComparator(order, orderBy), line)
|
|
262
|
-
.filter(linha => isArray(line(linha)) ? line(linha).filter(item => filter ? new RegExp(`.*${filter}.*`, 'gi').test(item?.toString()) : true).length > 0 : true) || [];
|
|
263
|
-
return [];
|
|
264
|
-
}, [lista, filter, order, orderBy, method, line]);
|
|
265
|
-
|
|
266
|
-
const cortaDados = useCallback((dados) => dados
|
|
267
|
-
?.slice(defaultRowsPerPage === 0 ? (undefined) : page * rowsPerPage, defaultRowsPerPage === 0 ? (undefined) : page * rowsPerPage + rowsPerPage),
|
|
268
|
-
[page, rowsPerPage, defaultRowsPerPage]);
|
|
269
|
-
|
|
270
|
-
const dadosMostrados = useMemo(() => {
|
|
271
|
-
if (method || externalCtrlPgn) return lista || [];
|
|
272
|
-
return cortaDados(dadosNaoCortados) || [];
|
|
273
|
-
}, [method, externalCtrlPgn, lista, dadosNaoCortados, cortaDados]);
|
|
274
|
-
|
|
287
|
+
|
|
275
288
|
const handleOpenClose = useCallback((index) => {
|
|
276
289
|
if (index === open || (!index && index !== 0)) {
|
|
277
290
|
dispatch({ type: 'setOpen', value: undefined });
|
|
@@ -281,7 +294,7 @@ const ArgousComplexTable = forwardRef(({
|
|
|
281
294
|
if (onOpen) onOpen({ linhaOriginal: dadosMostrados[index], linhaFormatada: line(dadosMostrados[index]) });
|
|
282
295
|
}
|
|
283
296
|
}, [open, onClose, onOpen, dadosMostrados, dispatch, line]);
|
|
284
|
-
|
|
297
|
+
|
|
285
298
|
useImperativeHandle(ref, () => ({
|
|
286
299
|
setOpen: index => handleOpenClose(index),
|
|
287
300
|
getOpen: dadosMostrados[open],
|
|
@@ -353,7 +366,7 @@ const ArgousComplexTable = forwardRef(({
|
|
|
353
366
|
}}/>
|
|
354
367
|
{FooterComponent && <FooterComponent {...footerProps}/>}
|
|
355
368
|
</Table>
|
|
356
|
-
{(
|
|
369
|
+
{(usePagination) && (
|
|
357
370
|
<PaginationComponent
|
|
358
371
|
count={(method || externalCtrlPgn) ? ctrlPgn.recordCount : dadosNaoCortados.length}
|
|
359
372
|
onChangePage={(_, value) => {
|
|
@@ -373,7 +386,7 @@ const ArgousComplexTable = forwardRef(({
|
|
|
373
386
|
</TableContext.Provider>
|
|
374
387
|
);
|
|
375
388
|
});
|
|
376
|
-
|
|
389
|
+
|
|
377
390
|
ArgousComplexTable.propTypes = {
|
|
378
391
|
dados: PropTypes.array,
|
|
379
392
|
head: PropTypes.array,
|
|
@@ -411,5 +424,5 @@ ArgousComplexTable.propTypes = {
|
|
|
411
424
|
externalCtrlPgn: PropTypes.object,
|
|
412
425
|
setExternalCtrlPgn: PropTypes.func
|
|
413
426
|
};
|
|
414
|
-
|
|
427
|
+
|
|
415
428
|
export default memo(ArgousComplexTable, isEqual);
|
|
@@ -37,6 +37,18 @@ const useStyles = makeStyles(theme => ({
|
|
|
37
37
|
loading: {
|
|
38
38
|
textAlign: 'center',
|
|
39
39
|
padding: '7px'
|
|
40
|
+
},
|
|
41
|
+
ghost: {
|
|
42
|
+
borderBottom: '1px solid #0000',
|
|
43
|
+
userSelect: 'none',
|
|
44
|
+
'&:hover': {
|
|
45
|
+
backgroundColor: '#0000 !important'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
tableCell: {
|
|
49
|
+
overflow: 'hidden',
|
|
50
|
+
whiteSpace: 'nowrap',
|
|
51
|
+
textOverflow: 'ellipsis'
|
|
40
52
|
}
|
|
41
53
|
}));
|
|
42
54
|
|
|
@@ -96,10 +108,13 @@ const ArgousComplexTableBody = memo(({
|
|
|
96
108
|
{loading ? (
|
|
97
109
|
<TableRow><TableCell className={classes.loading} colSpan={dadosMostrados?.length && line(dadosMostrados[0])?.length + (enableCheck ? 1 : 0) + (enableDrag ? 1 : 0)}><CircularProgress disableShrink/></TableCell></TableRow>
|
|
98
110
|
) : dadosMostrados.length ? dadosMostrados.map((linha, i) => {
|
|
111
|
+
|
|
99
112
|
const isItemSelected = isSelected(linha[indexToSelect]);
|
|
100
113
|
const isItemOpen = i === open;
|
|
101
|
-
|
|
114
|
+
const fullyEmpty = !linha.some((value) => !!value);
|
|
102
115
|
const { title, ...rowProperties } = rowProps({ index: i, linhaOriginal: linha, linhaFormatada: line(linha), itensSelecionados: selected }) || {};
|
|
116
|
+
|
|
117
|
+
|
|
103
118
|
return <Draggable key={customKey ? lista[i][customKey] : i} render={draggableRef => (
|
|
104
119
|
//TODO criar proprio draggable pois esse remove classes do filho
|
|
105
120
|
<Fragment>
|
|
@@ -107,15 +122,25 @@ const ArgousComplexTableBody = memo(({
|
|
|
107
122
|
<TableRow
|
|
108
123
|
component={Draggable}
|
|
109
124
|
{...rowProperties}
|
|
110
|
-
className={
|
|
125
|
+
className={
|
|
126
|
+
clsx(
|
|
127
|
+
{
|
|
128
|
+
[classes.hover]: isItemSelected,
|
|
129
|
+
[classes.open]: (isItemOpen && !!children),
|
|
130
|
+
[classes.ghost]: fullyEmpty
|
|
131
|
+
},
|
|
132
|
+
lineClass(line(linha), linha, i),
|
|
133
|
+
rowProperties.className
|
|
134
|
+
)
|
|
135
|
+
}
|
|
111
136
|
hover
|
|
112
137
|
role='checkbox'
|
|
113
138
|
tabIndex={-1}
|
|
114
139
|
selected={isItemSelected}
|
|
115
140
|
style={lineStyle ? lineStyle(linha, line(linha), i) : undefined}
|
|
116
|
-
onClick={onClick ? e => onClick(e, linha, line(linha), i) : children ? () => handleOpenClose(i) : undefined}
|
|
117
|
-
onDoubleClick={onDoubleClick ? e => onDoubleClick(e, linha, line(linha), i) : undefined}
|
|
118
|
-
innerRef={draggableRef}
|
|
141
|
+
onClick={(fullyEmpty) ? undefined : (onClick) ? e => onClick(e, linha, line(linha), i) : (children) ? () => handleOpenClose(i) : undefined}
|
|
142
|
+
onDoubleClick={(fullyEmpty) ? undefined : (onDoubleClick) ? e => onDoubleClick(e, linha, line(linha), i) : undefined}
|
|
143
|
+
innerRef={draggableRef}
|
|
119
144
|
>
|
|
120
145
|
{enableDrag && <TableCell padding='checkbox'>
|
|
121
146
|
<Tooltip title='Arrastar'>
|
|
@@ -131,7 +156,25 @@ const ArgousComplexTableBody = memo(({
|
|
|
131
156
|
}} checked={isItemSelected} />
|
|
132
157
|
</TableCell>}
|
|
133
158
|
{isArray(line(linha)) && line(linha).map((coluna, j) => (
|
|
134
|
-
|
|
159
|
+
(fullyEmpty) ? (
|
|
160
|
+
<TableCell
|
|
161
|
+
key={j}
|
|
162
|
+
{...columnProps(j, coluna, linha, line(linha))}
|
|
163
|
+
style={columnStyles ? columnStyles[j] : undefined}
|
|
164
|
+
className={clsx(classes.tableCell, classes.ghost)}
|
|
165
|
+
>
|
|
166
|
+
|
|
167
|
+
</TableCell>
|
|
168
|
+
) : (
|
|
169
|
+
<TableCell
|
|
170
|
+
key={j}
|
|
171
|
+
{...columnProps(j, coluna, linha, line(linha))}
|
|
172
|
+
style={columnStyles ? columnStyles[j] : undefined}
|
|
173
|
+
className={classes.tableCell}
|
|
174
|
+
>
|
|
175
|
+
{getCellContent(coluna, dadosMostrados[i], j, i)}
|
|
176
|
+
</TableCell>
|
|
177
|
+
)
|
|
135
178
|
))}
|
|
136
179
|
</TableRow>
|
|
137
180
|
</CustomTooltip>
|
|
@@ -139,7 +182,7 @@ const ArgousComplexTableBody = memo(({
|
|
|
139
182
|
<TableRow className={classes.group}>
|
|
140
183
|
<TableCell colSpan={dadosMostrados?.length && line(dadosMostrados[0])?.length + (enableCheck ? 1 : 0) + (enableDrag ? 1 : 0)} style={{ padding: open === i ? 8 : 0 }} className='argous-complex-table-group-cell'>
|
|
141
184
|
<Collapse in={open === i} mountOnEnter unmountOnExit>
|
|
142
|
-
{typeof children === 'function' ? children({ linha: line(linha), linhaOriginal: linha, index: i }) : children}
|
|
185
|
+
{typeof children === 'function' ? children({ linha: line(linha), linhaOriginal: linha, index: i }) : children}
|
|
143
186
|
</Collapse>
|
|
144
187
|
</TableCell>
|
|
145
188
|
</TableRow>
|
|
@@ -158,5 +201,5 @@ export const CustomTooltip = ({ title, children }) => {
|
|
|
158
201
|
if (title) return <Tooltip arrow title={title}>
|
|
159
202
|
{children}
|
|
160
203
|
</Tooltip>;
|
|
161
|
-
return children;
|
|
204
|
+
return children;
|
|
162
205
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseTextFieldProps } from '@material-ui/core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export interface UtilTextFieldProps extends BaseTextFieldProps {
|
|
6
|
+
/**
|
|
7
|
+
* Type of format
|
|
8
|
+
*/
|
|
9
|
+
type: 'cpf' | 'cnpj' | 'cep' | 'telephone',
|
|
10
|
+
/**
|
|
11
|
+
* Callback fired when the value change
|
|
12
|
+
*
|
|
13
|
+
* @param event — The event source of the callback
|
|
14
|
+
*
|
|
15
|
+
* @param value — The new value of the component
|
|
16
|
+
*/
|
|
17
|
+
onChange?: ((event: React.ChangeEvent<{}>, value: any) => void) | undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
declare function UtilTextField(props: UtilTextFieldProps): JSX.Element
|
|
22
|
+
|
|
23
|
+
export default UtilTextField;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { numbersOnly } from '../../utils';
|
|
2
|
+
import { TextField } from '@material-ui/core';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import MaskedInput from 'react-maskedinput';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const cepMaskedInput = { inputComponent: (props) => <MaskedInput mask='11111-111' {...props} /> };
|
|
8
|
+
const cpfMaskedInput = { inputComponent: (props) => <MaskedInput mask='111.111.111-11' {...props} /> };
|
|
9
|
+
const cnpjMaskedInput = { inputComponent: (props) => <MaskedInput mask='11.111.111/1111-11' {...props} /> };
|
|
10
|
+
const telephoneMaskedInput = { inputComponent: (props) => <MaskedInput mask='(11) 111111111' {...props} /> };
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const UtilTextField = ({ type, onChange, ...props }) => {
|
|
14
|
+
|
|
15
|
+
const standard = useMemo(() => {
|
|
16
|
+
|
|
17
|
+
let standardObject = {
|
|
18
|
+
valueHandler: (value) => value,
|
|
19
|
+
InputProps: {},
|
|
20
|
+
label: ''
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
switch (type) {
|
|
24
|
+
case 'cep':
|
|
25
|
+
standardObject.valueHandler = (value) => numbersOnly(value);
|
|
26
|
+
standardObject.InputProps = { ...cepMaskedInput };
|
|
27
|
+
standardObject.label = 'CEP';
|
|
28
|
+
break;
|
|
29
|
+
case 'cpf':
|
|
30
|
+
standardObject.valueHandler = (value) => numbersOnly(value);
|
|
31
|
+
standardObject.InputProps = { ...cpfMaskedInput };
|
|
32
|
+
standardObject.label = 'CPF';
|
|
33
|
+
break;
|
|
34
|
+
case 'cnpj':
|
|
35
|
+
standardObject.valueHandler = (value) => numbersOnly(value);
|
|
36
|
+
standardObject.InputProps = { ...cnpjMaskedInput };
|
|
37
|
+
standardObject.label = 'CNPJ';
|
|
38
|
+
break;
|
|
39
|
+
case 'telephone':
|
|
40
|
+
standardObject.valueHandler = (value) => numbersOnly(value);
|
|
41
|
+
standardObject.InputProps = { ...telephoneMaskedInput };
|
|
42
|
+
standardObject.label = 'TELEFONE';
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return standardObject;
|
|
49
|
+
}, [type]);
|
|
50
|
+
|
|
51
|
+
const handleOnChange = (event) => {
|
|
52
|
+
let newValue = event.target.value;
|
|
53
|
+
newValue = standard.valueHandler(newValue);
|
|
54
|
+
onChange(event, newValue);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<TextField
|
|
60
|
+
{...props}
|
|
61
|
+
label={props?.label || standard.label}
|
|
62
|
+
InputProps={{ ...standard.InputProps, ...(props?.InputProps || {}) }}
|
|
63
|
+
onChange={handleOnChange}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export default UtilTextField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './UtilTextField';
|
|
@@ -171,4 +171,7 @@ export * from './Carousel';
|
|
|
171
171
|
export { default as Cam } from './Cam';
|
|
172
172
|
export * from './Cam';
|
|
173
173
|
|
|
174
|
-
export * from './Document';
|
|
174
|
+
export * from './Document';
|
|
175
|
+
|
|
176
|
+
export { default as UtilTextField } from './UtilTextField';
|
|
177
|
+
export * from './UtilTextField';
|
package/lib/components/index.js
CHANGED
|
@@ -169,4 +169,7 @@ export * from './Carousel';
|
|
|
169
169
|
export { default as Cam } from './Cam';
|
|
170
170
|
export * from './Cam';
|
|
171
171
|
|
|
172
|
-
export * from './Document';
|
|
172
|
+
export * from './Document';
|
|
173
|
+
|
|
174
|
+
export { default as UtilTextField } from './UtilTextField';
|
|
175
|
+
export * from './UtilTextField';
|
package/lib/utils/index.ts
CHANGED
|
@@ -367,10 +367,17 @@ export function dataUrlToBlob(dataUrl: string) {
|
|
|
367
367
|
return blob;
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
+
export function allCharactersSame(s: string) {
|
|
371
|
+
let n = s.length;
|
|
372
|
+
for (let i = 1; i < n; i++)
|
|
373
|
+
if (s[i] !== s[0]) return false;
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
|
|
370
377
|
export function cpfTest(cpf: (string|number)) {
|
|
371
378
|
|
|
372
|
-
if (cpf === '00000000000' || !cpf) return false;
|
|
373
379
|
if (typeof cpf === 'number') cpf = cpf.toString();
|
|
380
|
+
if (!cpf || allCharactersSame(cpf)) return false;
|
|
374
381
|
|
|
375
382
|
let sum = 0;
|
|
376
383
|
let rest: number;
|
|
@@ -498,4 +505,35 @@ export function stopPrntScr(e: KeyboardEvent) {
|
|
|
498
505
|
document.execCommand('copy');
|
|
499
506
|
inpFld.remove();
|
|
500
507
|
return false;
|
|
501
|
-
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export const documentType = {
|
|
511
|
+
cpf: {
|
|
512
|
+
length: 11,
|
|
513
|
+
symbols: {
|
|
514
|
+
length: 3
|
|
515
|
+
},
|
|
516
|
+
lengthWithSymbols: 14
|
|
517
|
+
},
|
|
518
|
+
cnpj: {
|
|
519
|
+
length: 14,
|
|
520
|
+
symbols: {
|
|
521
|
+
length: 4
|
|
522
|
+
},
|
|
523
|
+
lengthWithSymbols: 18
|
|
524
|
+
},
|
|
525
|
+
cep: {
|
|
526
|
+
length: 8,
|
|
527
|
+
symbols: {
|
|
528
|
+
length: 1
|
|
529
|
+
},
|
|
530
|
+
lengthWithSymbols: 9
|
|
531
|
+
},
|
|
532
|
+
telephone: {
|
|
533
|
+
length: 11,
|
|
534
|
+
symbols: {
|
|
535
|
+
length: 2
|
|
536
|
+
},
|
|
537
|
+
lengthWithSymbols: 13
|
|
538
|
+
}
|
|
539
|
+
};
|