@ssplib/react-components 0.0.224 → 0.0.225
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/components/form/table/Table.d.ts +24 -19
- package/components/form/table/Table.js +384 -402
- package/components/modal/Modal.d.ts +2 -0
- package/components/modal/Modal.js +27 -3
- package/components/utils/Bt.d.ts +9 -0
- package/components/utils/Bt.js +35 -0
- package/components/utils/CustomMenu.d.ts +12 -0
- package/components/utils/CustomMenu.js +39 -0
- package/package.json +2 -1
|
@@ -5,18 +5,24 @@ interface ColumnData {
|
|
|
5
5
|
customComponent?: (content: string, obj: any) => JSX.Element;
|
|
6
6
|
size?: number;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
interface OrderBy {
|
|
9
|
+
label: string;
|
|
10
|
+
key: string;
|
|
11
|
+
type: 'string' | 'number';
|
|
12
|
+
}
|
|
13
|
+
export declare function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg, dataPath, tableName, csv, columnSize, action, useKC, statusKeyName, csvExcludeKeys, csvExcludeKeysCSV, csvExcludeKeysAll, csvCustomKeyNames, csvExcludeValidate, csvButtonTitle, csvNoZipText, csvAllButtonTitle, removeQuotes, normalize, csvShowAllButton, csvWithoutZip, itemCount, csvUpper, csvZipFileNamesKey, generateCsvZip, hideTitleCSV, csvExcludeUpper, multipleDataPath, expandTextMaxLength, collapsedSize, customMargin, customMarginMobile, filters, orderBy, id, }: {
|
|
14
|
+
id: string;
|
|
10
15
|
mediaQueryLG?: {
|
|
11
16
|
all: number;
|
|
12
17
|
action: number;
|
|
13
18
|
};
|
|
19
|
+
filters?: FilterValue[];
|
|
20
|
+
orderBy?: OrderBy[];
|
|
14
21
|
customMargin?: number;
|
|
15
22
|
customMarginMobile?: number;
|
|
16
23
|
normalize?: boolean;
|
|
17
24
|
csvUpper?: boolean;
|
|
18
25
|
multipleDataPath?: string;
|
|
19
|
-
filterStorageName?: string;
|
|
20
26
|
removeQuotes?: boolean;
|
|
21
27
|
columns: ColumnData[];
|
|
22
28
|
tableName: string;
|
|
@@ -52,22 +58,21 @@ export declare function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg, data
|
|
|
52
58
|
};
|
|
53
59
|
dataPath?: string;
|
|
54
60
|
useKC?: boolean;
|
|
55
|
-
filters?: {
|
|
56
|
-
[key: string]: {
|
|
57
|
-
type: FilterTypes;
|
|
58
|
-
keyName: string;
|
|
59
|
-
name: string;
|
|
60
|
-
listEndpoint?: string;
|
|
61
|
-
selectList?: string[];
|
|
62
|
-
referenceKey?: string;
|
|
63
|
-
options?: {
|
|
64
|
-
name: string;
|
|
65
|
-
color: string;
|
|
66
|
-
key: string;
|
|
67
|
-
}[];
|
|
68
|
-
}[];
|
|
69
|
-
};
|
|
70
|
-
filterSeparator?: string;
|
|
71
61
|
}): JSX.Element;
|
|
62
|
+
type FilterType = 'string' | 'number' | 'date';
|
|
63
|
+
type FilterOperators = 'igual' | 'contem' | 'maior que' | 'menor que' | 'data exata' | 'após' | 'antes de' | 'entre' | 'tem um dos';
|
|
64
|
+
interface FilterValue {
|
|
65
|
+
label: string;
|
|
66
|
+
keyName: string;
|
|
67
|
+
type: FilterType;
|
|
68
|
+
operator: FilterOperators;
|
|
69
|
+
operators: FilterOperators[];
|
|
70
|
+
value: string | any[];
|
|
71
|
+
value2?: string | any[];
|
|
72
|
+
useList?: {
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
}[];
|
|
76
|
+
}
|
|
72
77
|
declare const _default: React.MemoExoticComponent<typeof Table>;
|
|
73
78
|
export default _default;
|
|
@@ -27,23 +27,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Table = void 0;
|
|
30
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
31
|
+
const Clear_1 = __importDefault(require("@mui/icons-material/Clear"));
|
|
30
32
|
const FileDownload_1 = __importDefault(require("@mui/icons-material/FileDownload"));
|
|
33
|
+
const NavigateNextRounded_1 = __importDefault(require("@mui/icons-material/NavigateNextRounded"));
|
|
31
34
|
const Search_1 = __importDefault(require("@mui/icons-material/Search"));
|
|
32
35
|
const material_1 = require("@mui/material");
|
|
33
36
|
const Grid_1 = __importDefault(require("@mui/material/Grid"));
|
|
34
37
|
const Pagination_1 = __importDefault(require("@mui/material/Pagination"));
|
|
35
38
|
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
36
39
|
const Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
40
|
+
const x_date_pickers_1 = require("@mui/x-date-pickers");
|
|
41
|
+
const AdapterDayjs_1 = require("@mui/x-date-pickers/AdapterDayjs");
|
|
42
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
43
|
+
const jszip_1 = __importDefault(require("jszip"));
|
|
37
44
|
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
38
45
|
const react_1 = __importStar(require("react"));
|
|
39
46
|
const auth_1 = require("../../../context/auth");
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const DatePicker_1 = __importDefault(require("../date/DatePicker"));
|
|
43
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
44
|
-
const jszip_1 = __importDefault(require("jszip"));
|
|
45
|
-
const NavigateNextRounded_1 = __importDefault(require("@mui/icons-material/NavigateNextRounded"));
|
|
46
|
-
const axios_1 = __importDefault(require("axios"));
|
|
47
|
+
const Modal_1 = require("../../modal/Modal");
|
|
48
|
+
const CustomMenu_1 = __importDefault(require("../../utils//CustomMenu"));
|
|
47
49
|
function removePunctuationAndAccents(text) {
|
|
48
50
|
// Remove accents and diacritics
|
|
49
51
|
const normalizedText = text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
@@ -53,31 +55,37 @@ function removePunctuationAndAccents(text) {
|
|
|
53
55
|
}
|
|
54
56
|
let startData = [];
|
|
55
57
|
let isExpandAll = false;
|
|
58
|
+
let localTableName = '';
|
|
59
|
+
let orderAsc = false;
|
|
56
60
|
function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
57
61
|
user: 'Nenhum dado encontrado',
|
|
58
62
|
public: 'Nenhum dado encontrado',
|
|
59
|
-
}, dataPath = '', tableName = 'Dados', csv, columnSize, action, useKC = true, statusKeyName = '', csvExcludeKeys = [], csvExcludeKeysCSV = [], csvExcludeKeysAll = [], csvCustomKeyNames = {}, csvExcludeValidate = (key, value) => false, csvButtonTitle = 'Salvar .CSV', csvNoZipText = 'Salvar .CSV', csvAllButtonTitle = 'Salvar todos em CSV', removeQuotes = false, normalize = false, csvShowAllButton = false, csvWithoutZip = false, itemCount = 10, csvUpper = false, csvZipFileNamesKey = '', generateCsvZip = false,
|
|
63
|
+
}, dataPath = '', tableName = 'Dados', csv, columnSize, action, useKC = true, statusKeyName = '', csvExcludeKeys = [], csvExcludeKeysCSV = [], csvExcludeKeysAll = [], csvCustomKeyNames = {}, csvExcludeValidate = (key, value) => false, csvButtonTitle = 'Salvar .CSV', csvNoZipText = 'Salvar .CSV', csvAllButtonTitle = 'Salvar todos em CSV', removeQuotes = false, normalize = false, csvShowAllButton = false, csvWithoutZip = false, itemCount = 10, csvUpper = false, csvZipFileNamesKey = '', generateCsvZip = false,
|
|
64
|
+
// filters = {},
|
|
65
|
+
// filterSeparator = '|',
|
|
66
|
+
hideTitleCSV = false, csvExcludeUpper = [], multipleDataPath = '', expandTextMaxLength = 50, collapsedSize = 53, customMargin = 4, customMarginMobile = 0, filters = [], orderBy = [], id, }) {
|
|
67
|
+
var _a;
|
|
60
68
|
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
61
69
|
const [error, setError] = (0, react_1.useState)(null);
|
|
62
70
|
const [data, setData] = (0, react_1.useState)(null);
|
|
63
71
|
const { user, userLoaded } = (0, react_1.useContext)(auth_1.AuthContext);
|
|
64
72
|
const [list, setList] = (0, react_1.useState)([]);
|
|
73
|
+
const [listClone, setListClone] = (0, react_1.useState)([]);
|
|
65
74
|
//numero de items pra ser mostrado
|
|
66
75
|
const [itemsCount, setItemsCount] = (0, react_1.useState)(itemCount);
|
|
67
76
|
const [currentPage, setCurrentPage] = (0, react_1.useState)(0);
|
|
68
77
|
const [paginationCount, setPagCount] = (0, react_1.useState)(1);
|
|
69
78
|
const [listPage, setListPage] = (0, react_1.useState)(1);
|
|
70
|
-
const [appliedFilters, setAppliedFilters] = (0, react_1.useState)([]);
|
|
71
79
|
const [oldSelectState, setOldSelectState] = (0, react_1.useState)('');
|
|
72
80
|
const [expandObj, setExpandObj] = (0, react_1.useState)({});
|
|
73
81
|
const [showExpandObj, setShowExpandObj] = (0, react_1.useState)({});
|
|
74
82
|
const [showExpandObjOnExited, setShowExpandObjOnExited] = (0, react_1.useState)({});
|
|
75
|
-
|
|
76
|
-
const [filterCollapse, setFilterCollapse] = (0, react_1.useState)(Array(Object.keys(filters).length).fill(false));
|
|
77
|
-
const [filterOpen, setFilterOpen] = (0, react_1.useState)(false);
|
|
83
|
+
const [filterKey, setFilterKey] = (0, react_1.useState)('filterKey');
|
|
78
84
|
const theme = (0, material_1.useTheme)();
|
|
79
85
|
const isSmall = (0, material_1.useMediaQuery)(theme.breakpoints.only('xs'));
|
|
86
|
+
const filterContainer = (0, react_1.useRef)(null);
|
|
80
87
|
const lg = (0, material_1.useMediaQuery)(theme.breakpoints.up(2000));
|
|
88
|
+
localTableName = `tableFilter_${id}`;
|
|
81
89
|
(0, react_1.useEffect)(() => {
|
|
82
90
|
setError(null);
|
|
83
91
|
if (userLoaded || !useKC) {
|
|
@@ -109,11 +117,6 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
109
117
|
else {
|
|
110
118
|
setData(value);
|
|
111
119
|
startData = JSON.parse(JSON.stringify(value));
|
|
112
|
-
const oldFilters = localStorage.getItem(filterStorageName);
|
|
113
|
-
if (oldFilters) {
|
|
114
|
-
const filters = JSON.parse(oldFilters);
|
|
115
|
-
setAppliedFilters(filters);
|
|
116
|
-
}
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
setIsLoading(false);
|
|
@@ -142,8 +145,13 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
142
145
|
(0, react_1.useEffect)(() => {
|
|
143
146
|
if (isLoading || error || !getData(data))
|
|
144
147
|
return;
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
const value = getData(data);
|
|
149
|
+
setList(value);
|
|
150
|
+
setListClone(value);
|
|
151
|
+
setPagCount(getCount(value));
|
|
152
|
+
if (localStorage.getItem(localTableName)) {
|
|
153
|
+
filtrar(JSON.parse(localStorage.getItem(localTableName)));
|
|
154
|
+
}
|
|
147
155
|
}, [itemsCount, isLoading, data, getCount, error]);
|
|
148
156
|
(0, react_1.useEffect)(() => {
|
|
149
157
|
setCurrentPage(listPage - 1);
|
|
@@ -151,14 +159,15 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
151
159
|
const onPaginationChange = (0, react_1.useCallback)((e, page) => {
|
|
152
160
|
setListPage(page);
|
|
153
161
|
}, []);
|
|
154
|
-
|
|
162
|
+
function onInputChange(e) {
|
|
163
|
+
console.log(listClone);
|
|
155
164
|
const searchValue = e.target.value;
|
|
156
165
|
if (searchValue === '') {
|
|
157
|
-
setList(
|
|
158
|
-
setPagCount(getCount(getData(
|
|
166
|
+
setList(listClone);
|
|
167
|
+
setPagCount(getCount(getData(list)));
|
|
159
168
|
return;
|
|
160
169
|
}
|
|
161
|
-
const listData = getData(
|
|
170
|
+
const listData = getData(list);
|
|
162
171
|
const newList = [];
|
|
163
172
|
listData.forEach((x) => {
|
|
164
173
|
const dataStr = [];
|
|
@@ -227,7 +236,7 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
227
236
|
setPagCount(getCount(newList));
|
|
228
237
|
setCurrentPage(0);
|
|
229
238
|
setListPage(1);
|
|
230
|
-
}
|
|
239
|
+
}
|
|
231
240
|
const getMaxItems = (0, react_1.useCallback)(() => {
|
|
232
241
|
const start = currentPage * itemsCount;
|
|
233
242
|
return list.slice(start, start + itemsCount);
|
|
@@ -427,284 +436,145 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
427
436
|
link.setAttribute('download', `${csv === null || csv === void 0 ? void 0 : csv.fileName}.csv`);
|
|
428
437
|
link.click();
|
|
429
438
|
}, [list]);
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
var _a;
|
|
435
|
-
let rawList = JSON.parse(JSON.stringify(Array.isArray(startData) ? startData : (_a = (0, lodash_get_1.default)(startData, dataPath)) !== null && _a !== void 0 ? _a : '[]'));
|
|
436
|
-
if (filteredList.length <= 0 || rawList.length <= 0) {
|
|
437
|
-
setList(rawList);
|
|
438
|
-
setPagCount(getCount(rawList));
|
|
439
|
-
setCurrentPage(0);
|
|
440
|
-
setListPage(1);
|
|
441
|
-
return;
|
|
439
|
+
function expandAll() {
|
|
440
|
+
let obj = {};
|
|
441
|
+
for (let i = 0; i < itemCount; i++) {
|
|
442
|
+
obj[i] = !isExpandAll;
|
|
442
443
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
setList(rawList);
|
|
459
|
-
setPagCount(getCount(rawList));
|
|
460
|
-
setCurrentPage(0);
|
|
461
|
-
setListPage(1);
|
|
444
|
+
setShowExpandObjOnExited(obj);
|
|
445
|
+
setExpandObj(obj);
|
|
446
|
+
isExpandAll = !isExpandAll;
|
|
447
|
+
}
|
|
448
|
+
function reset() {
|
|
449
|
+
// setData(baseFilters)
|
|
450
|
+
// setResetFields((s) => !s)
|
|
451
|
+
setList(startData);
|
|
452
|
+
setListClone(startData);
|
|
453
|
+
localStorage.removeItem(localTableName);
|
|
454
|
+
setFilterKey(new Date().getTime().toString());
|
|
455
|
+
}
|
|
456
|
+
function filtrar(filterData) {
|
|
457
|
+
console.log(startData);
|
|
458
|
+
if (!startData)
|
|
462
459
|
return;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
valueA = String(aValue).toLowerCase();
|
|
496
|
-
valueB = String(bValue).toLowerCase();
|
|
497
|
-
}
|
|
498
|
-
if (valueA < valueB) {
|
|
499
|
-
return 1;
|
|
500
|
-
}
|
|
501
|
-
if (valueA > valueB) {
|
|
502
|
-
return -1;
|
|
503
|
-
}
|
|
504
|
-
return 0;
|
|
505
|
-
});
|
|
506
|
-
} //
|
|
507
|
-
else if (type === 'items' || type === 'select') {
|
|
508
|
-
rawList = rawList
|
|
509
|
-
.filter((x) => String(x[keyName])
|
|
510
|
-
.toLowerCase()
|
|
511
|
-
.includes(customValue !== null && customValue !== void 0 ? customValue : ''))
|
|
512
|
-
.sort((a, b) => {
|
|
513
|
-
const aValue = String(a[keyName]);
|
|
514
|
-
const bValue = String(b[keyName]);
|
|
515
|
-
const valueA = typeof aValue === 'number' ? aValue : aValue.toLowerCase();
|
|
516
|
-
const valueB = typeof bValue === 'number' ? bValue : bValue.toLowerCase();
|
|
517
|
-
if (valueA.includes(customValue !== null && customValue !== void 0 ? customValue : ''))
|
|
518
|
-
return -1;
|
|
519
|
-
if (valueB.includes(customValue !== null && customValue !== void 0 ? customValue : ''))
|
|
520
|
-
return 1;
|
|
521
|
-
if (valueA < valueB) {
|
|
522
|
-
return -1;
|
|
523
|
-
}
|
|
524
|
-
if (valueA > valueB) {
|
|
525
|
-
return 1;
|
|
526
|
-
}
|
|
527
|
-
return 0;
|
|
528
|
-
});
|
|
529
|
-
if (referencekey) {
|
|
530
|
-
const data = [];
|
|
531
|
-
let newFiltered = rawList.filter((x) => {
|
|
532
|
-
const item = String(x[keyName]);
|
|
533
|
-
const value = typeof item === 'number' ? item : item.toLowerCase();
|
|
534
|
-
if (value === customValue) {
|
|
535
|
-
data.push(x);
|
|
536
|
-
return false;
|
|
537
|
-
}
|
|
538
|
-
return true;
|
|
539
|
-
});
|
|
540
|
-
data.sort((a, b) => {
|
|
541
|
-
const aValue = String(a[referencekey]);
|
|
542
|
-
const bValue = String(b[referencekey]);
|
|
543
|
-
const valueA = typeof aValue === 'number' ? aValue : aValue.toLowerCase();
|
|
544
|
-
const valueB = typeof bValue === 'number' ? bValue : bValue.toLowerCase();
|
|
545
|
-
if (valueA < valueB) {
|
|
546
|
-
return 1;
|
|
547
|
-
}
|
|
548
|
-
if (valueA > valueB) {
|
|
549
|
-
return -1;
|
|
550
|
-
}
|
|
551
|
-
return 0;
|
|
552
|
-
});
|
|
553
|
-
data.forEach((x) => {
|
|
554
|
-
newFiltered.unshift(x);
|
|
555
|
-
});
|
|
556
|
-
rawList = newFiltered;
|
|
557
|
-
}
|
|
558
|
-
} //
|
|
559
|
-
else if (type === 'data-a-z') {
|
|
560
|
-
rawList = rawList.sort((a, b) => {
|
|
561
|
-
const aValue = a[keyName];
|
|
562
|
-
const bValue = b[keyName];
|
|
563
|
-
const separator = filterSeparator;
|
|
564
|
-
const aDt = aValue.split(separator).map((k) => { var _a; return ((_a = k.match(/[0-9]+\/[0-9]+\/[0-9]+/)) !== null && _a !== void 0 ? _a : [])[0]; })[0];
|
|
565
|
-
const bDt = bValue.split(separator).map((k) => { var _a; return ((_a = k.match(/[0-9]+\/[0-9]+\/[0-9]+/)) !== null && _a !== void 0 ? _a : [])[0]; })[0];
|
|
566
|
-
if (!aDt && !bDt)
|
|
567
|
-
return 0;
|
|
568
|
-
const valueA = (0, dayjs_1.default)(aDt, 'D/M/YYYY');
|
|
569
|
-
const valueB = (0, dayjs_1.default)(bDt, 'D/M/YYYY');
|
|
570
|
-
if (valueA.isBefore(valueB)) {
|
|
571
|
-
return -1;
|
|
572
|
-
}
|
|
573
|
-
if (valueA.isAfter(valueB)) {
|
|
574
|
-
return 1;
|
|
460
|
+
let currentData = JSON.parse(JSON.stringify(startData));
|
|
461
|
+
filterData
|
|
462
|
+
.filter((dt) => dt.value)
|
|
463
|
+
.forEach((dt) => {
|
|
464
|
+
let filteredData = [];
|
|
465
|
+
switch (dt.type) {
|
|
466
|
+
case 'number':
|
|
467
|
+
switch (dt.operator) {
|
|
468
|
+
case 'igual':
|
|
469
|
+
currentData.forEach((cd) => {
|
|
470
|
+
const value = Number((0, lodash_get_1.default)(cd, dt.keyName, ''));
|
|
471
|
+
if (value === Number(dt.value)) {
|
|
472
|
+
filteredData.push(cd);
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
break;
|
|
476
|
+
case 'maior que':
|
|
477
|
+
currentData.forEach((cd) => {
|
|
478
|
+
const value = Number((0, lodash_get_1.default)(cd, dt.keyName, ''));
|
|
479
|
+
if (value > Number(dt.value)) {
|
|
480
|
+
filteredData.push(cd);
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
break;
|
|
484
|
+
case 'menor que':
|
|
485
|
+
currentData.forEach((cd) => {
|
|
486
|
+
const value = Number((0, lodash_get_1.default)(cd, dt.keyName, ''));
|
|
487
|
+
if (value < Number(dt.value)) {
|
|
488
|
+
filteredData.push(cd);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
break;
|
|
575
492
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
493
|
+
break;
|
|
494
|
+
case 'string':
|
|
495
|
+
switch (dt.operator) {
|
|
496
|
+
case 'igual':
|
|
497
|
+
currentData.forEach((cd) => {
|
|
498
|
+
const value = (0, lodash_get_1.default)(cd, dt.keyName, '');
|
|
499
|
+
if (value === dt.value) {
|
|
500
|
+
filteredData.push(cd);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
break;
|
|
504
|
+
case 'contem':
|
|
505
|
+
currentData.forEach((cd) => {
|
|
506
|
+
const value = (0, lodash_get_1.default)(cd, dt.keyName, '');
|
|
507
|
+
if (value.includes(dt.value)) {
|
|
508
|
+
filteredData.push(cd);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
break;
|
|
512
|
+
case 'tem um dos':
|
|
513
|
+
currentData.forEach((cd) => {
|
|
514
|
+
const value = (0, lodash_get_1.default)(cd, dt.keyName, '');
|
|
515
|
+
if (dt.value.includes(value)) {
|
|
516
|
+
filteredData.push(cd);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
break;
|
|
588
520
|
}
|
|
589
|
-
|
|
590
|
-
|
|
521
|
+
break;
|
|
522
|
+
case 'date':
|
|
523
|
+
switch (dt.operator) {
|
|
524
|
+
case 'data exata':
|
|
525
|
+
currentData.forEach((cd) => {
|
|
526
|
+
const value = (0, dayjs_1.default)((0, lodash_get_1.default)(cd, dt.keyName, ''), 'DD/MM/YYYY');
|
|
527
|
+
if (!value.isValid())
|
|
528
|
+
return;
|
|
529
|
+
if (value.isSame((0, dayjs_1.default)(dt.value, 'DD/MM/YYYY'))) {
|
|
530
|
+
filteredData.push(cd);
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
break;
|
|
534
|
+
case 'entre':
|
|
535
|
+
currentData.forEach((cd) => {
|
|
536
|
+
const value = (0, dayjs_1.default)((0, lodash_get_1.default)(cd, dt.keyName, ''), 'DD/MM/YYYY');
|
|
537
|
+
const dateA = (0, dayjs_1.default)(dt.value, 'DD/MM/YYYY');
|
|
538
|
+
const dateB = (0, dayjs_1.default)(dt.value2, 'DD/MM/YYYY');
|
|
539
|
+
console.log(dateA.isValid(), dateB.isValid());
|
|
540
|
+
if (!dateA.isValid() || !dateB.isValid())
|
|
541
|
+
return;
|
|
542
|
+
if ((value.isAfter(dateA) || value.isSame(dateA)) && (value.isBefore(dateB) || value.isSame(dateB))) {
|
|
543
|
+
filteredData.push(cd);
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
break;
|
|
591
547
|
}
|
|
592
|
-
|
|
593
|
-
});
|
|
548
|
+
break;
|
|
594
549
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
const dtTo = (0, dayjs_1.default)(to, 'D/M/YYYY');
|
|
610
|
-
if ((dtFrom.isBefore(dt) || dtFrom.isSame(dt)) && (dtTo.isAfter(dt) || dtTo.isSame(dt))) {
|
|
611
|
-
inside = true;
|
|
612
|
-
}
|
|
613
|
-
} //
|
|
614
|
-
else {
|
|
615
|
-
if (dtFrom.isBefore(dt) || dtFrom.isSame(dt)) {
|
|
616
|
-
inside = true;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
return inside;
|
|
621
|
-
});
|
|
622
|
-
rawList = rawList.sort((a, b) => {
|
|
623
|
-
const aValue = a[keyName];
|
|
624
|
-
const bValue = b[keyName];
|
|
625
|
-
const separator = filterSeparator;
|
|
626
|
-
const aDt = aValue.split(separator).map((k) => { var _a; return ((_a = k.match(/[0-9]+\/[0-9]+\/[0-9]+/)) !== null && _a !== void 0 ? _a : [])[0]; })[0];
|
|
627
|
-
const bDt = bValue.split(separator).map((k) => { var _a; return ((_a = k.match(/[0-9]+\/[0-9]+\/[0-9]+/)) !== null && _a !== void 0 ? _a : [])[0]; })[0];
|
|
628
|
-
if (!aDt && !bDt)
|
|
629
|
-
return 0;
|
|
630
|
-
const valueA = (0, dayjs_1.default)(aDt, 'D/M/YYYY');
|
|
631
|
-
const valueB = (0, dayjs_1.default)(bDt, 'D/M/YYYY');
|
|
632
|
-
if (valueA.isBefore(valueB)) {
|
|
550
|
+
console.log('filtred: ', filteredData);
|
|
551
|
+
currentData = filteredData;
|
|
552
|
+
});
|
|
553
|
+
setList(currentData);
|
|
554
|
+
localStorage.setItem(localTableName, JSON.stringify(filterData));
|
|
555
|
+
setListClone(currentData);
|
|
556
|
+
}
|
|
557
|
+
function ordenar(order) {
|
|
558
|
+
let oldList = [...list];
|
|
559
|
+
oldList.sort((a, b) => {
|
|
560
|
+
const aValue = order.type === 'string' ? (0, lodash_get_1.default)(a, order.key, '') : Number((0, lodash_get_1.default)(a, order.key, 0));
|
|
561
|
+
const bValue = order.type === 'string' ? (0, lodash_get_1.default)(b, order.key, '') : Number((0, lodash_get_1.default)(b, order.key, 0));
|
|
562
|
+
if (orderAsc) {
|
|
563
|
+
if (aValue < bValue)
|
|
633
564
|
return -1;
|
|
634
|
-
|
|
635
|
-
if (valueA.isAfter(valueB)) {
|
|
565
|
+
if (aValue > bValue)
|
|
636
566
|
return 1;
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
date(x.from, x.to, x.keyName);
|
|
646
|
-
});
|
|
647
|
-
setList(rawList);
|
|
648
|
-
setPagCount(getCount(rawList));
|
|
649
|
-
setCurrentPage(0);
|
|
650
|
-
setListPage(1);
|
|
651
|
-
};
|
|
652
|
-
const handleFilterOption = (type, keyName, uniqueName, customValue, referencekey) => {
|
|
653
|
-
setAppliedFilters((s) => {
|
|
654
|
-
const value = [
|
|
655
|
-
...s.filter((x) => (x.isDate ? true : x.keyName !== keyName)),
|
|
656
|
-
{
|
|
657
|
-
type,
|
|
658
|
-
keyName,
|
|
659
|
-
uniqueName,
|
|
660
|
-
customValue,
|
|
661
|
-
referencekey,
|
|
662
|
-
},
|
|
663
|
-
];
|
|
664
|
-
localStorage.setItem(filterStorageName, JSON.stringify(value));
|
|
665
|
-
return value;
|
|
666
|
-
});
|
|
667
|
-
};
|
|
668
|
-
const handleFilterReset = () => {
|
|
669
|
-
const value = JSON.parse(JSON.stringify(Array.isArray(startData) ? startData : (0, lodash_get_1.default)(startData, dataPath)));
|
|
670
|
-
setList(value);
|
|
671
|
-
setAppliedFilters([]);
|
|
672
|
-
localStorage.setItem(filterStorageName, JSON.stringify([]));
|
|
673
|
-
};
|
|
674
|
-
const removeFilter = (uniqueName) => {
|
|
675
|
-
if (uniqueName === 'isDate')
|
|
676
|
-
setAppliedFilters((s) => s.filter((x) => !x.isDate));
|
|
677
|
-
else
|
|
678
|
-
setAppliedFilters((s) => {
|
|
679
|
-
const value = s.filter((x) => x.uniqueName !== uniqueName);
|
|
680
|
-
localStorage.setItem(filterStorageName, JSON.stringify(value));
|
|
681
|
-
return value;
|
|
682
|
-
});
|
|
683
|
-
};
|
|
684
|
-
const handleDateFilter = (from, to, keyName) => {
|
|
685
|
-
setAppliedFilters((s) => {
|
|
686
|
-
const value = [
|
|
687
|
-
...s.filter((x) => !x.isDate),
|
|
688
|
-
{
|
|
689
|
-
isDate: true,
|
|
690
|
-
from,
|
|
691
|
-
to,
|
|
692
|
-
keyName,
|
|
693
|
-
id: from + keyName,
|
|
694
|
-
},
|
|
695
|
-
];
|
|
696
|
-
localStorage.setItem(filterStorageName, JSON.stringify(value));
|
|
697
|
-
return value;
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
if (aValue > bValue)
|
|
570
|
+
return -1;
|
|
571
|
+
if (aValue < bValue)
|
|
572
|
+
return 1;
|
|
573
|
+
}
|
|
574
|
+
return 0;
|
|
698
575
|
});
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
let obj = {};
|
|
702
|
-
for (let i = 0; i < itemCount; i++) {
|
|
703
|
-
obj[i] = !isExpandAll;
|
|
704
|
-
}
|
|
705
|
-
setShowExpandObjOnExited(obj);
|
|
706
|
-
setExpandObj(obj);
|
|
707
|
-
isExpandAll = !isExpandAll;
|
|
576
|
+
orderAsc = !orderAsc;
|
|
577
|
+
setList(oldList);
|
|
708
578
|
}
|
|
709
579
|
// effect usado quando for mostrar "VER MAIS" e "VER MENOS"
|
|
710
580
|
(0, react_1.useEffect)(() => {
|
|
@@ -719,6 +589,9 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
719
589
|
});
|
|
720
590
|
setShowExpandObj(obj);
|
|
721
591
|
}, [list, itemsCount, currentPage]);
|
|
592
|
+
(0, react_1.useEffect)(() => {
|
|
593
|
+
console.log(filterContainer.current);
|
|
594
|
+
}, [filterContainer.current]);
|
|
722
595
|
if (error)
|
|
723
596
|
return (react_1.default.createElement(material_1.Box, { bgcolor: '#E2E8F0', padding: 2, marginX: 2 },
|
|
724
597
|
react_1.default.createElement(Typography_1.default, { fontSize: 24, textAlign: 'center', fontFamily: 'Inter' },
|
|
@@ -735,7 +608,7 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
735
608
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
736
609
|
react_1.default.createElement(material_1.Box, { marginX: isSmall ? customMarginMobile : customMargin, bgcolor: 'white', p: 2, borderRadius: 6 },
|
|
737
610
|
react_1.default.createElement(material_1.Stack, { spacing: 1.5, direction: { xs: 'column', md: 'row' } },
|
|
738
|
-
react_1.default.createElement(material_1.Stack, { spacing: 1.5, direction: { xs: 'column', md: 'row' },
|
|
611
|
+
react_1.default.createElement(material_1.Stack, { spacing: 1.5, direction: { xs: 'column', md: 'row' }, height: { md: '40px', xs: 'inherit' }, width: '100%' },
|
|
739
612
|
react_1.default.createElement(TextField_1.default, { InputProps: {
|
|
740
613
|
startAdornment: react_1.default.createElement(Search_1.default, { sx: { marginRight: 1, fill: '#c0c0c0' } }),
|
|
741
614
|
sx: {
|
|
@@ -747,37 +620,40 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
747
620
|
borderRadius: '50px',
|
|
748
621
|
maxWidth: '600px',
|
|
749
622
|
}, size: 'small', onChange: onInputChange, fullWidth: true, placeholder: `Pesquisar ${tableName}` }),
|
|
750
|
-
|
|
751
|
-
|
|
623
|
+
Modal_1.MODAL.reparent(react_1.default.createElement(CriarFiltro, { key: filterKey, reset: reset, filtrar: filtrar, baseFilters: [...filters], filters: localStorage.getItem(localTableName) ? JSON.parse(localStorage.getItem(localTableName)) : [...filters] }), 0),
|
|
624
|
+
react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.FilterAlt, null), variant: 'contained', onClick: (e) => Modal_1.MODAL.openReparented(0), sx: {
|
|
625
|
+
borderRadius: 3,
|
|
752
626
|
paddingX: '24px',
|
|
753
627
|
paddingY: '8px',
|
|
754
|
-
minWidth: 200,
|
|
755
628
|
backgroundColor: '#208FE8',
|
|
756
629
|
textTransform: 'capitalize',
|
|
757
630
|
} },
|
|
758
|
-
react_1.default.createElement(material_1.Stack, { direction: 'row',
|
|
759
|
-
react_1.default.createElement("span", null, "
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
react_1.default.createElement(material_1.Stack, { alignItems: 'end', width: { xs: '100%', md: '20%' },
|
|
780
|
-
react_1.default.createElement(Typography_1.default, { fontWeight: 600, textAlign: 'end' },
|
|
631
|
+
react_1.default.createElement(material_1.Stack, { direction: 'row', borderRadius: 5, padding: 0 },
|
|
632
|
+
react_1.default.createElement("span", null, "Filtrar"))),
|
|
633
|
+
react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 1 },
|
|
634
|
+
react_1.default.createElement(CustomMenu_1.default, { data: orderBy.map((x) => ({
|
|
635
|
+
name: x.label,
|
|
636
|
+
onClick: () => ordenar(x),
|
|
637
|
+
})), btProps: {
|
|
638
|
+
startIcon: react_1.default.createElement(icons_material_1.KeyboardArrowDown, null),
|
|
639
|
+
fullWidth: true,
|
|
640
|
+
} }, "Ordenar"),
|
|
641
|
+
react_1.default.createElement(material_1.Button, { variant: 'contained', fullWidth: true, startIcon: isExpandAll ? react_1.default.createElement(icons_material_1.KeyboardArrowUp, null) : react_1.default.createElement(icons_material_1.KeyboardArrowDown, null), sx: {
|
|
642
|
+
backgroundColor: '#637082',
|
|
643
|
+
':hover': {
|
|
644
|
+
backgroundColor: '#3c4757',
|
|
645
|
+
},
|
|
646
|
+
textTransform: 'capitalize',
|
|
647
|
+
borderRadius: 3,
|
|
648
|
+
padding: {
|
|
649
|
+
md: '0px 8px',
|
|
650
|
+
},
|
|
651
|
+
}, onClick: expandAll }, isExpandAll ? 'Recolher' : 'Expandir'))),
|
|
652
|
+
react_1.default.createElement(material_1.Stack, { alignItems: 'end', width: { xs: '100%', md: '20%' }, direction: { xs: 'row', md: 'column' }, spacing: { xs: 1, md: 0 } },
|
|
653
|
+
react_1.default.createElement(Typography_1.default, { fontWeight: 600, textAlign: 'end' },
|
|
654
|
+
"Registro de ",
|
|
655
|
+
tableName,
|
|
656
|
+
"s"),
|
|
781
657
|
react_1.default.createElement(material_1.Stack, { justifyContent: 'center' },
|
|
782
658
|
react_1.default.createElement(Typography_1.default, null,
|
|
783
659
|
"Exibindo ",
|
|
@@ -786,6 +662,28 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
786
662
|
currentPage * itemsCount + 1 + getMaxItems().length - 1,
|
|
787
663
|
" de ",
|
|
788
664
|
list.length)))),
|
|
665
|
+
localStorage.getItem(localTableName) && (react_1.default.createElement(material_1.Box, { display: 'inline-flex', flexWrap: 'wrap', padding: 0.5, borderRadius: 4, marginBottom: 1 }, JSON.parse((_a = localStorage.getItem(localTableName)) !== null && _a !== void 0 ? _a : '[]')
|
|
666
|
+
.filter((x) => x.value)
|
|
667
|
+
.map((x) => (react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 1, bgcolor: '#4e85c1', color: 'white', width: 'fit-content', paddingY: 0.5, borderRadius: 2, paddingX: 1, m: 0.5 },
|
|
668
|
+
react_1.default.createElement(Typography_1.default, { fontWeight: 700 }, x.label),
|
|
669
|
+
react_1.default.createElement(Typography_1.default, { fontStyle: 'italic' }, x.operator),
|
|
670
|
+
react_1.default.createElement(Typography_1.default, { bgcolor: 'white', borderRadius: 2, paddingX: 1, color: 'black' }, x.value.toString()),
|
|
671
|
+
react_1.default.createElement(material_1.IconButton, { onClick: (e) => {
|
|
672
|
+
var _a;
|
|
673
|
+
let currentValue = JSON.parse((_a = localStorage.getItem(localTableName)) !== null && _a !== void 0 ? _a : '[]');
|
|
674
|
+
currentValue = currentValue.map((item) => {
|
|
675
|
+
if (item.label === x.label) {
|
|
676
|
+
return Object.assign(Object.assign(Object.assign({}, item), { value: '' }), (item.value2 ? { value2: '' } : {}));
|
|
677
|
+
}
|
|
678
|
+
return item;
|
|
679
|
+
});
|
|
680
|
+
filtrar(currentValue);
|
|
681
|
+
}, size: 'small', sx: {
|
|
682
|
+
padding: 0,
|
|
683
|
+
} },
|
|
684
|
+
react_1.default.createElement(Clear_1.default, { sx: {
|
|
685
|
+
fill: 'white',
|
|
686
|
+
} }))))))),
|
|
789
687
|
react_1.default.createElement(material_1.Stack, { spacing: 0.2 }, getMaxItems().length <= 0 ? (react_1.default.createElement(material_1.Stack, { sx: { backgroundColor: '#E2E8F0', padding: 2, marginX: { xs: 2, md: 0 } }, justifyContent: 'center', alignItems: 'center' },
|
|
790
688
|
react_1.default.createElement(Typography_1.default, { fontSize: 21, fontFamily: 'Inter', fontWeight: 600, textAlign: 'center' }, user ? emptyMsg.user : emptyMsg.public))) : (getMaxItems().map((x, index) => (react_1.default.createElement(material_1.Paper, { key: index, sx: {
|
|
791
689
|
padding: 0.5,
|
|
@@ -872,90 +770,174 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
872
770
|
}
|
|
873
771
|
return paginationCount;
|
|
874
772
|
}), sx: { bgcolor: 'white', borderRadius: '50px', height: '40px', width: '40px', minWidth: 0, border: 'solid 1px #E2E8F0' } },
|
|
875
|
-
react_1.default.createElement(NavigateNextRounded_1.default, { sx: { transform: 'scale(1.5)' } }))))
|
|
876
|
-
react_1.default.createElement(material_1.SwipeableDrawer, { anchor: isSmall ? 'bottom' : 'right', open: filterOpen, onClose: (e) => setFilterOpen(false), onOpen: (e) => setFilterOpen(true) },
|
|
877
|
-
react_1.default.createElement(material_1.List, { sx: { minWidth: 310 } }, Object.keys(filters).map((f, fIndex) => (react_1.default.createElement(react_1.default.Fragment, { key: JSON.stringify({ f, fIndex }) },
|
|
878
|
-
react_1.default.createElement(material_1.ListItemButton, { onClick: (e) => setFilterCollapse((s) => s.map((x, idx) => {
|
|
879
|
-
if (idx === fIndex)
|
|
880
|
-
return !x;
|
|
881
|
-
return x;
|
|
882
|
-
})), sx: {
|
|
883
|
-
backgroundColor: '#ebeef2',
|
|
884
|
-
} },
|
|
885
|
-
react_1.default.createElement(material_1.ListItemIcon, null,
|
|
886
|
-
react_1.default.createElement(icons_material_1.Circle, { transform: 'scale(0.4)' })),
|
|
887
|
-
react_1.default.createElement(material_1.ListItemText, { primary: f }),
|
|
888
|
-
filterCollapse[fIndex] ? react_1.default.createElement(icons_material_1.ExpandLess, null) : react_1.default.createElement(icons_material_1.ExpandMore, null)),
|
|
889
|
-
react_1.default.createElement(material_1.Collapse, { in: filterCollapse[fIndex], timeout: 'auto', unmountOnExit: true },
|
|
890
|
-
react_1.default.createElement(material_1.List, { component: 'div', disablePadding: true, sx: { backgroundColor: 'white' } }, filters[f].map((x, index) => (react_1.default.createElement(react_1.default.Fragment, { key: JSON.stringify({ f, index }) }, x.options ? (x.options.map((o) => (react_1.default.createElement(material_1.ListItemButton, { sx: Object.assign({ pl: 4, borderBottom: 1, borderColor: '#ebeef2' }, (appliedFilters.map((x) => x.uniqueName).includes(`${f}:${JSON.stringify(o)}`) && {
|
|
891
|
-
bgcolor: '#b7e4c7',
|
|
892
|
-
':hover': { bgcolor: '#b7e4c7' },
|
|
893
|
-
})) },
|
|
894
|
-
react_1.default.createElement(material_1.ListItemText, { primary: o.name, onClick: (e) => handleFilterOption(x.type, x.keyName, `${f}:${JSON.stringify(o)}`, o.key, x.referenceKey), sx: { color: o.color, fontWeight: 600 } }),
|
|
895
|
-
react_1.default.createElement(material_1.Box, null, appliedFilters.map((x) => x.uniqueName).includes(`${f}:${JSON.stringify(o)}`) && (react_1.default.createElement(material_1.Tooltip, { title: 'Remover' },
|
|
896
|
-
react_1.default.createElement(material_1.IconButton, { sx: { bgcolor: '#c71c1c', height: '30px', width: '30px', ':hover': { bgcolor: 'red', border: '2px solid #9e2929' } }, onClick: (e) => removeFilter(`${f}:${JSON.stringify(o)}`) },
|
|
897
|
-
react_1.default.createElement(icons_material_1.Delete, { sx: { fill: 'white', transform: 'scale(0.8, 0.8)' } }))))))))) : x.type === 'date-interval' ? (react_1.default.createElement(material_1.Box, { padding: 2 },
|
|
898
|
-
react_1.default.createElement(FormProvider_1.default, { onSubmit: (d) => handleDateFilter(d['filterDtStart'], d['filterDtEnd'], x.keyName) },
|
|
899
|
-
react_1.default.createElement(DatePicker_1.default, { name: 'filterDtStart', title: 'A partir de:', required: true }),
|
|
900
|
-
react_1.default.createElement(material_1.Box, { marginTop: 2 }),
|
|
901
|
-
react_1.default.createElement(DatePicker_1.default, { name: 'filterDtEnd', title: 'At\u00E9 (opcional):' }),
|
|
902
|
-
react_1.default.createElement(material_1.Stack, { marginTop: 2 },
|
|
903
|
-
react_1.default.createElement(material_1.Button, { type: 'submit', variant: 'outlined', startIcon: react_1.default.createElement(icons_material_1.CalendarToday, null), sx: { width: '100%' } }, "Filtrar por Data"),
|
|
904
|
-
react_1.default.createElement(material_1.Box, null, appliedFilters.filter((x) => x.isDate).length > 0 && (react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.Delete, { sx: { fill: 'white' } }), variant: 'contained', color: 'error', sx: { width: '100%', marginTop: 1 }, onClick: (e) => removeFilter('isDate') }, "Remover Filtro Data"))))))) : x.selectList ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
905
|
-
react_1.default.createElement(material_1.Autocomplete, { options: x.selectList.map((x) => ({
|
|
906
|
-
id: x.toLowerCase(),
|
|
907
|
-
label: x,
|
|
908
|
-
})), onFocus: (e) => console.log('ata'), onChange: (e, value) => {
|
|
909
|
-
if (value) {
|
|
910
|
-
const id = `${f}:${JSON.stringify(value)}`;
|
|
911
|
-
handleFilterOption(x.type, x.keyName, id, value === null || value === void 0 ? void 0 : value.label.toLowerCase(), x.referenceKey);
|
|
912
|
-
setOldSelectState(id);
|
|
913
|
-
}
|
|
914
|
-
else {
|
|
915
|
-
removeFilter(oldSelectState);
|
|
916
|
-
}
|
|
917
|
-
}, sx: {
|
|
918
|
-
margin: 1,
|
|
919
|
-
}, size: 'small', renderInput: (params) => react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: 'Teste' })) }))) : x.listEndpoint ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
920
|
-
react_1.default.createElement(FetchSelectAutoComplete, { url: x.listEndpoint, label: x.name, onChange: (e, value) => {
|
|
921
|
-
if (value) {
|
|
922
|
-
const id = `${f}:${JSON.stringify(value)}`;
|
|
923
|
-
handleFilterOption(x.type, x.keyName, id, value === null || value === void 0 ? void 0 : value.id.toLowerCase(), x.referenceKey);
|
|
924
|
-
setOldSelectState(id);
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
removeFilter(oldSelectState);
|
|
928
|
-
}
|
|
929
|
-
} }))) : (react_1.default.createElement(material_1.Stack, { direction: 'row', sx: Object.assign({}, (appliedFilters.map((x) => x.uniqueName).includes(`${f}:${JSON.stringify(x)}`) && {
|
|
930
|
-
bgcolor: '#b7e4c7',
|
|
931
|
-
':hover': { bgcolor: '#b7e4c7' },
|
|
932
|
-
})) },
|
|
933
|
-
react_1.default.createElement(material_1.ListItemButton, { sx: {
|
|
934
|
-
pl: 4,
|
|
935
|
-
borderBottom: 1,
|
|
936
|
-
borderColor: '#ebeef2',
|
|
937
|
-
}, onClick: (e) => handleFilterOption(x.type, x.keyName, `${f}:${JSON.stringify(x)}`) },
|
|
938
|
-
react_1.default.createElement(material_1.ListItemIcon, { sx: { minWidth: '25px' } }, x.type === 'a-z' || x.type === 'data-a-z' ? (react_1.default.createElement(icons_material_1.South, { transform: 'scale(0.5)' })) : x.type === 'z-a' || x.type === 'data-z-a' ? (react_1.default.createElement(icons_material_1.North, { transform: 'scale(0.5)' })) : null),
|
|
939
|
-
react_1.default.createElement(material_1.ListItemText, { primary: x.name })),
|
|
940
|
-
react_1.default.createElement(material_1.Stack, { justifyContent: 'center', marginX: 2 }, appliedFilters.map((x) => x.uniqueName).includes(`${f}:${JSON.stringify(x)}`) && (react_1.default.createElement(material_1.Tooltip, { title: 'Remover' },
|
|
941
|
-
react_1.default.createElement(material_1.IconButton, { sx: { bgcolor: '#c71c1c', height: '30px', width: '30px', ':hover': { bgcolor: 'red', border: '2px solid #9e2929' } }, onClick: (e) => removeFilter(`${f}:${JSON.stringify(x)}`) },
|
|
942
|
-
react_1.default.createElement(icons_material_1.Delete, { sx: { fill: 'white', transform: 'scale(0.8, 0.8)' } })))))))))))))))),
|
|
943
|
-
react_1.default.createElement(material_1.Button, { variant: 'contained', onClick: handleFilterReset, startIcon: react_1.default.createElement(icons_material_1.RestartAlt, null), sx: { marginX: 2, marginBottom: 2 } }, "Reiniciar"))));
|
|
773
|
+
react_1.default.createElement(NavigateNextRounded_1.default, { sx: { transform: 'scale(1.5)' } }))))));
|
|
944
774
|
}
|
|
945
775
|
exports.Table = Table;
|
|
946
|
-
function
|
|
947
|
-
const [data, setData] = (0, react_1.useState)(
|
|
776
|
+
function CriarFiltro({ filters, baseFilters, filtrar, reset }) {
|
|
777
|
+
const [data, setData] = (0, react_1.useState)(filters);
|
|
778
|
+
const [resetFields, setResetFields] = (0, react_1.useState)(false);
|
|
779
|
+
function addRule(filter) {
|
|
780
|
+
setData((dt) => {
|
|
781
|
+
return [...dt, filter];
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
const [anchorEl, setAnchorEl] = react_1.default.useState(null);
|
|
785
|
+
const open = Boolean(anchorEl);
|
|
786
|
+
const handleClick = (event) => {
|
|
787
|
+
setAnchorEl(event.currentTarget);
|
|
788
|
+
};
|
|
789
|
+
const handleClose = () => {
|
|
790
|
+
setAnchorEl(null);
|
|
791
|
+
};
|
|
792
|
+
return (react_1.default.createElement(material_1.Box, null,
|
|
793
|
+
react_1.default.createElement(material_1.Menu, { open: open, onClose: handleClose, anchorEl: anchorEl }, baseFilters.map((x) => (react_1.default.createElement(material_1.MenuItem, { onClick: (e) => {
|
|
794
|
+
addRule(x);
|
|
795
|
+
setAnchorEl(null);
|
|
796
|
+
} }, x.label)))),
|
|
797
|
+
react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'space-between' },
|
|
798
|
+
react_1.default.createElement(Typography_1.default, { fontWeight: 700, fontSize: 18 }, "Filtrar"),
|
|
799
|
+
react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.Refresh, null), sx: {
|
|
800
|
+
textTransform: 'capitalize',
|
|
801
|
+
}, onClick: reset }, "Limpar")),
|
|
802
|
+
react_1.default.createElement(material_1.Box, { marginBottom: 1 },
|
|
803
|
+
react_1.default.createElement(material_1.Alert, { severity: 'warning' }, "Preencha apenas os campos que deseja filtrar.")),
|
|
804
|
+
react_1.default.createElement(material_1.Stack, null, resetFields ? (data.map((d, idx) => (react_1.default.createElement(FilterRow, { filterValue: d, setReset: setResetFields, idx: idx, setDt: (valueData) => {
|
|
805
|
+
setData((dt) => {
|
|
806
|
+
let arr = [...dt];
|
|
807
|
+
arr[idx] = valueData;
|
|
808
|
+
return arr;
|
|
809
|
+
});
|
|
810
|
+
}, removeDt: () => {
|
|
811
|
+
setData((dt) => {
|
|
812
|
+
let arr = [...dt];
|
|
813
|
+
arr.splice(idx, 1);
|
|
814
|
+
return arr;
|
|
815
|
+
});
|
|
816
|
+
} })))) : (react_1.default.createElement(material_1.Box, null, data.map((d, idx) => (react_1.default.createElement(FilterRow, { filterValue: d, setReset: setResetFields, idx: idx, setDt: (valueData) => {
|
|
817
|
+
setData((dt) => {
|
|
818
|
+
let arr = [...dt];
|
|
819
|
+
arr[idx] = valueData;
|
|
820
|
+
return arr;
|
|
821
|
+
});
|
|
822
|
+
}, removeDt: () => {
|
|
823
|
+
setData((dt) => {
|
|
824
|
+
let arr = [...dt];
|
|
825
|
+
arr.splice(idx, 1);
|
|
826
|
+
return arr;
|
|
827
|
+
});
|
|
828
|
+
} })))))),
|
|
829
|
+
react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'flex-end', marginTop: 1 },
|
|
830
|
+
react_1.default.createElement(material_1.Button, { variant: 'contained', color: 'success', startIcon: react_1.default.createElement(Search_1.default, null), sx: {
|
|
831
|
+
textTransform: 'capitalize',
|
|
832
|
+
}, onClick: (e) => {
|
|
833
|
+
filtrar(data);
|
|
834
|
+
Modal_1.MODAL.close();
|
|
835
|
+
} }, "Filtrar"))));
|
|
836
|
+
}
|
|
837
|
+
function FilterRow({ filterValue, setDt, removeDt, idx, setReset, }) {
|
|
838
|
+
const [currentOperator, setCurrentOperator] = (0, react_1.useState)(filterValue.operator);
|
|
839
|
+
const [data, setData] = (0, react_1.useState)(filterValue);
|
|
840
|
+
const theme = (0, material_1.useTheme)();
|
|
841
|
+
const isSmall = (0, material_1.useMediaQuery)(theme.breakpoints.only('xs'));
|
|
948
842
|
(0, react_1.useEffect)(() => {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
843
|
+
setDt(data);
|
|
844
|
+
}, [data]);
|
|
845
|
+
return (react_1.default.createElement(material_1.Stack, { direction: 'row', alignItems: 'end', spacing: 1, width: '100%', bgcolor: idx % 2 === 0 ? '#ededed' : 'inherit', padding: 0.5, borderRadius: 2 },
|
|
846
|
+
!isSmall && (react_1.default.createElement(Typography_1.default, { width: '100%', alignContent: 'center', fontWeight: 600, color: '#323232' }, filterValue.label)),
|
|
847
|
+
react_1.default.createElement(material_1.FormControl, { sx: {
|
|
848
|
+
width: '100%',
|
|
849
|
+
} },
|
|
850
|
+
isSmall && react_1.default.createElement(Typography_1.default, null, filterValue.label),
|
|
851
|
+
react_1.default.createElement(material_1.Select, { onChange: (e) => {
|
|
852
|
+
const value = e.target.value;
|
|
853
|
+
setData((obj) => (Object.assign(Object.assign({}, obj), { operator: value, value: '' })));
|
|
854
|
+
setCurrentOperator(value);
|
|
855
|
+
}, defaultValue: currentOperator, size: 'small', sx: {
|
|
856
|
+
bgcolor: 'white',
|
|
857
|
+
}, fullWidth: true }, filterValue.operators.map((x) => (react_1.default.createElement(material_1.MenuItem, { value: x }, x))))),
|
|
858
|
+
react_1.default.createElement(FilterField, { filterValue: filterValue, operator: data.operator, onChange: (value, type = 'value') => {
|
|
859
|
+
setData((obj) => (Object.assign(Object.assign({}, obj), { [type]: value })));
|
|
860
|
+
} }),
|
|
861
|
+
react_1.default.createElement(material_1.IconButton, { onClick: (e) => {
|
|
862
|
+
setDt(Object.assign(Object.assign({}, data), { value: '' }));
|
|
863
|
+
setReset((s) => !s);
|
|
864
|
+
} },
|
|
865
|
+
react_1.default.createElement(icons_material_1.Refresh, null))));
|
|
866
|
+
}
|
|
867
|
+
function FilterField({ filterValue, operator, onChange }) {
|
|
868
|
+
switch (filterValue.type) {
|
|
869
|
+
case 'number':
|
|
870
|
+
return (react_1.default.createElement(TextField_1.default, { type: 'number', size: 'small', placeholder: 'Valor', defaultValue: filterValue.value, onChange: (e) => {
|
|
871
|
+
onChange(e.target.value);
|
|
872
|
+
}, sx: {
|
|
873
|
+
bgcolor: 'white',
|
|
874
|
+
}, fullWidth: true }));
|
|
875
|
+
case 'string':
|
|
876
|
+
if (filterValue.useList) {
|
|
877
|
+
switch (operator) {
|
|
878
|
+
case 'tem um dos':
|
|
879
|
+
return (react_1.default.createElement(material_1.Autocomplete, { multiple: true, id: 'tags-standard', onChange: (e, value) => {
|
|
880
|
+
onChange(value);
|
|
881
|
+
}, options: filterValue.useList, defaultValue: Array.isArray(filterValue.value) ? filterValue.value : [], renderInput: (params) => react_1.default.createElement(TextField_1.default, Object.assign({}, params, { variant: 'standard', placeholder: 'Escolha os valores', fullWidth: true })), fullWidth: true }));
|
|
882
|
+
case 'contem':
|
|
883
|
+
return (react_1.default.createElement(material_1.Box, { width: '100%' },
|
|
884
|
+
react_1.default.createElement(material_1.Autocomplete, { options: filterValue.useList, onChange: (e, value) => {
|
|
885
|
+
onChange(value ? value.id : '');
|
|
886
|
+
}, defaultValue: filterValue.value && typeof filterValue.value === 'string' ? filterValue.useList.find((item) => item.id === filterValue.value) : undefined, isOptionEqualToValue: (option, value) => option.label === value.label, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { size: 'small', placeholder: 'Escolha um valor', fullWidth: true, sx: {
|
|
887
|
+
bgcolor: 'white',
|
|
888
|
+
} }))), fullWidth: true })));
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
return (react_1.default.createElement(TextField_1.default, { size: 'small', placeholder: 'Valor', defaultValue: filterValue.value, onChange: (e) => {
|
|
892
|
+
onChange(e.target.value);
|
|
893
|
+
}, sx: {
|
|
894
|
+
bgcolor: 'white',
|
|
895
|
+
}, fullWidth: true }));
|
|
896
|
+
case 'date':
|
|
897
|
+
switch (operator) {
|
|
898
|
+
case 'data exata':
|
|
899
|
+
return (react_1.default.createElement(x_date_pickers_1.LocalizationProvider, { adapterLocale: 'pt-br', dateAdapter: AdapterDayjs_1.AdapterDayjs },
|
|
900
|
+
react_1.default.createElement(x_date_pickers_1.DatePicker, { format: 'DD/MM/YYYY', onChange: (dt) => {
|
|
901
|
+
onChange(dt.isValid() ? dt.format('DD/MM/YYYY') : '');
|
|
902
|
+
}, defaultValue: filterValue.value ? (0, dayjs_1.default)(filterValue.value, 'DD/MM/YYYY') : undefined, sx: {
|
|
903
|
+
div: {
|
|
904
|
+
input: {
|
|
905
|
+
paddingX: 2,
|
|
906
|
+
paddingY: 1.05,
|
|
907
|
+
},
|
|
908
|
+
},
|
|
909
|
+
width: '100%',
|
|
910
|
+
bgcolor: 'white',
|
|
911
|
+
}, inputRef: (params) => react_1.default.createElement(TextField_1.default, Object.assign({}, params, { size: 'small', fullWidth: true })) })));
|
|
912
|
+
case 'entre':
|
|
913
|
+
return (react_1.default.createElement(x_date_pickers_1.LocalizationProvider, { adapterLocale: 'pt-br', dateAdapter: AdapterDayjs_1.AdapterDayjs },
|
|
914
|
+
react_1.default.createElement(x_date_pickers_1.DatePicker, { format: 'DD/MM/YYYY', onChange: (dt) => {
|
|
915
|
+
onChange(dt.isValid() ? dt.format('DD/MM/YYYY') : '');
|
|
916
|
+
}, defaultValue: filterValue.value ? (0, dayjs_1.default)(filterValue.value, 'DD/MM/YYYY') : undefined, sx: {
|
|
917
|
+
div: {
|
|
918
|
+
input: {
|
|
919
|
+
paddingX: 2,
|
|
920
|
+
paddingY: 1.05,
|
|
921
|
+
},
|
|
922
|
+
},
|
|
923
|
+
width: '100%',
|
|
924
|
+
bgcolor: 'white',
|
|
925
|
+
}, inputRef: (params) => react_1.default.createElement(TextField_1.default, Object.assign({}, params, { size: 'small', fullWidth: true })) }),
|
|
926
|
+
react_1.default.createElement(x_date_pickers_1.DatePicker, { format: 'DD/MM/YYYY', onChange: (dt) => {
|
|
927
|
+
onChange(dt.isValid() ? dt.format('DD/MM/YYYY') : '', 'value2');
|
|
928
|
+
}, defaultValue: filterValue.value2 ? (0, dayjs_1.default)(filterValue.value2, 'DD/MM/YYYY') : undefined, sx: {
|
|
929
|
+
div: {
|
|
930
|
+
input: {
|
|
931
|
+
paddingX: 2,
|
|
932
|
+
paddingY: 1.05,
|
|
933
|
+
},
|
|
934
|
+
},
|
|
935
|
+
width: '100%',
|
|
936
|
+
bgcolor: 'white',
|
|
937
|
+
}, inputRef: (params) => react_1.default.createElement(TextField_1.default, Object.assign({}, params, { size: 'small', fullWidth: true })) })));
|
|
938
|
+
}
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
960
942
|
}
|
|
961
943
|
exports.default = react_1.default.memo(Table);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare let MODAL: {
|
|
3
3
|
open: (customCompoment?: JSX.Element | JSX.Element[] | (() => JSX.Element)) => void;
|
|
4
|
+
reparent: (child: JSX.Element, id: string | number) => JSX.Element;
|
|
5
|
+
openReparented: (id: string | number) => void;
|
|
4
6
|
close: () => void;
|
|
5
7
|
};
|
|
6
8
|
export declare function CustomModalProvider(): JSX.Element;
|
|
@@ -33,17 +33,37 @@ const react_1 = __importStar(require("react"));
|
|
|
33
33
|
exports.MODAL = {
|
|
34
34
|
open: () => { },
|
|
35
35
|
close: () => { },
|
|
36
|
+
openReparented: () => { },
|
|
37
|
+
reparent: () => react_1.default.createElement(react_1.default.Fragment, null),
|
|
36
38
|
};
|
|
39
|
+
function ReparentHelper() {
|
|
40
|
+
const ref = (0, react_1.useRef)(null);
|
|
41
|
+
return react_1.default.createElement("div", { ref: ref });
|
|
42
|
+
}
|
|
37
43
|
function CustomModalProvider() {
|
|
38
44
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
39
|
-
const [content, setContent] = (0, react_1.useState)(
|
|
45
|
+
const [content, setContent] = (0, react_1.useState)(null);
|
|
46
|
+
// const contentRef = useRef<JSX.Element | JSX.Element[]>(<></>)
|
|
40
47
|
const handleClose = () => setOpen(false);
|
|
48
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
41
49
|
const theme = (0, material_1.useTheme)();
|
|
42
50
|
const isDesktop = (0, material_1.useMediaQuery)(theme.breakpoints.up('sm'));
|
|
51
|
+
const [idRef, setIdRef] = (0, react_1.useState)({});
|
|
52
|
+
const [currentId, setCurrentId] = (0, react_1.useState)(-1321465654);
|
|
43
53
|
(0, react_1.useEffect)(() => {
|
|
44
54
|
exports.MODAL.open = (customCompoment) => {
|
|
45
55
|
if (customCompoment)
|
|
46
56
|
setContent(customCompoment);
|
|
57
|
+
setCurrentId(-1321465654);
|
|
58
|
+
setOpen(true);
|
|
59
|
+
};
|
|
60
|
+
exports.MODAL.reparent = (element, id) => {
|
|
61
|
+
setIdRef((obj) => (Object.assign(Object.assign({}, obj), { [id]: react_1.default.createElement(react_1.default.Fragment, null, element) })));
|
|
62
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
63
|
+
};
|
|
64
|
+
exports.MODAL.openReparented = (id) => {
|
|
65
|
+
setCurrentId(id);
|
|
66
|
+
setContent(null);
|
|
47
67
|
setOpen(true);
|
|
48
68
|
};
|
|
49
69
|
exports.MODAL.close = handleClose;
|
|
@@ -55,7 +75,9 @@ function CustomModalProvider() {
|
|
|
55
75
|
} },
|
|
56
76
|
react_1.default.createElement(material_1.Stack, { direction: 'row', onClick: handleClose, maxHeight: '8vh', height: '8vh', justifyContent: 'center', alignItems: 'center' },
|
|
57
77
|
react_1.default.createElement(material_1.Typography, { fontWeight: 600, color: 'white' }, "Clique fora para fechar")),
|
|
58
|
-
react_1.default.createElement(material_1.Box, { p: 2, maxHeight: '92vh', bgcolor: 'white', overflow: 'auto' },
|
|
78
|
+
react_1.default.createElement(material_1.Box, { p: 2, maxHeight: '92vh', bgcolor: 'white', overflow: 'auto' },
|
|
79
|
+
content,
|
|
80
|
+
idRef[currentId]))) : (react_1.default.createElement(material_1.Modal, { open: open, onClose: handleClose },
|
|
59
81
|
react_1.default.createElement(material_1.Box, { sx: {
|
|
60
82
|
position: 'absolute',
|
|
61
83
|
top: '50%',
|
|
@@ -76,6 +98,8 @@ function CustomModalProvider() {
|
|
|
76
98
|
react_1.default.createElement(CloseRounded_1.default, { sx: {
|
|
77
99
|
transform: 'scale(.9)',
|
|
78
100
|
} })),
|
|
79
|
-
react_1.default.createElement(material_1.Box, { overflow: 'auto', maxHeight: '90vh', p: 2, marginTop: 4, borderTop: 'solid 1px gray', bgcolor: '#F9F9F9', borderRadius: 2 },
|
|
101
|
+
react_1.default.createElement(material_1.Box, { overflow: 'auto', maxHeight: '90vh', p: 2, marginTop: 4, borderTop: 'solid 1px gray', bgcolor: '#F9F9F9', borderRadius: 2 },
|
|
102
|
+
content,
|
|
103
|
+
idRef[currentId]))))));
|
|
80
104
|
}
|
|
81
105
|
exports.CustomModalProvider = CustomModalProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonProps } from '@mui/material';
|
|
3
|
+
import tinycolor from 'tinycolor2';
|
|
4
|
+
interface CustomButton extends ButtonProps {
|
|
5
|
+
customColor?: tinycolor.ColorInput;
|
|
6
|
+
customFontColor?: tinycolor.ColorInput;
|
|
7
|
+
}
|
|
8
|
+
export default function Bt({ customColor, customFontColor, ...props }: CustomButton): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const material_1 = require("@mui/material");
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const tinycolor2_1 = __importDefault(require("tinycolor2"));
|
|
20
|
+
function Bt(_a) {
|
|
21
|
+
var { customColor = '#383838', customFontColor = 'white' } = _a, props = __rest(_a, ["customColor", "customFontColor"]);
|
|
22
|
+
const bgColor = (0, tinycolor2_1.default)(customColor);
|
|
23
|
+
return (react_1.default.createElement(material_1.Button, Object.assign({}, props, { sx: {
|
|
24
|
+
bgcolor: bgColor.toHexString(),
|
|
25
|
+
color: (0, tinycolor2_1.default)(customFontColor).toHexString(),
|
|
26
|
+
':hover': {
|
|
27
|
+
bgcolor: bgColor.darken(10).toHexString(),
|
|
28
|
+
},
|
|
29
|
+
boxShadow: 'none',
|
|
30
|
+
borderRadius: 3,
|
|
31
|
+
textTransform: 'capitalize',
|
|
32
|
+
paddingX: 2,
|
|
33
|
+
}, size: 'small' }), props.children));
|
|
34
|
+
}
|
|
35
|
+
exports.default = Bt;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface MenuProps {
|
|
4
|
+
data: {
|
|
5
|
+
name: string;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
}[];
|
|
8
|
+
btProps?: ButtonProps;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export default function CustomMenu({ data, ...props }: MenuProps): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const material_1 = require("@mui/material");
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const Bt_1 = __importDefault(require("./Bt"));
|
|
20
|
+
function CustomMenu(_a) {
|
|
21
|
+
var { data = [] } = _a, props = __rest(_a, ["data"]);
|
|
22
|
+
const [anchorEl, setAnchorEl] = react_1.default.useState(null);
|
|
23
|
+
const open = Boolean(anchorEl);
|
|
24
|
+
const handleClick = (event) => {
|
|
25
|
+
setAnchorEl(event.currentTarget);
|
|
26
|
+
};
|
|
27
|
+
const handleClose = () => {
|
|
28
|
+
setAnchorEl(null);
|
|
29
|
+
};
|
|
30
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
31
|
+
react_1.default.createElement(Bt_1.default, Object.assign({}, props.btProps, { onClick: handleClick }), props.children),
|
|
32
|
+
react_1.default.createElement(material_1.Menu, { id: 'basic-menu', anchorEl: anchorEl, open: open, onClose: handleClose, MenuListProps: {
|
|
33
|
+
'aria-labelledby': 'basic-button',
|
|
34
|
+
} }, data.map((x) => (react_1.default.createElement(material_1.MenuItem, { onClick: (e) => {
|
|
35
|
+
x.onClick && x.onClick();
|
|
36
|
+
handleClose();
|
|
37
|
+
} }, x.name))))));
|
|
38
|
+
}
|
|
39
|
+
exports.default = CustomMenu;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssplib/react-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.225",
|
|
4
4
|
"description": "SSP React Components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Pedro Henrique <sr.hudrick@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"cookies-next": "^2.1.1",
|
|
10
|
+
"tinycolor2": "^1.6.0",
|
|
10
11
|
"lodash.get": "^4.4.2",
|
|
11
12
|
"jwt-decode": "^3.1.2",
|
|
12
13
|
"react-hook-form": "^7.43.9",
|