@ssplib/react-components 0.0.144 → 0.0.146
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.
|
@@ -5,7 +5,7 @@ interface ColumnData {
|
|
|
5
5
|
size?: number;
|
|
6
6
|
}
|
|
7
7
|
type FilterTypes = 'a-z' | 'z-a' | 'items' | 'date-interval' | 'data-a-z' | 'data-z-a';
|
|
8
|
-
export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableName, csv, columnSize, action, isPublic, statusKeyName, csvExcludeKeys, csvExcludeKeysAll, csvCustomKeyNames, csvExcludeValidate, csvButtonTitle, csvNoZipText, csvAllButtonTitle, removeQuotes, normalize, csvShowAllButton, csvWithoutZip, itemCount, csvUpper, csvZipFileNamesKey, generateCsvZip, filters, hideTitleCSV, filterSeparator, filterStorageName, }: {
|
|
8
|
+
export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableName, csv, columnSize, action, isPublic, statusKeyName, csvExcludeKeys, csvExcludeKeysCSV, csvExcludeKeysAll, csvCustomKeyNames, csvExcludeValidate, csvButtonTitle, csvNoZipText, csvAllButtonTitle, removeQuotes, normalize, csvShowAllButton, csvWithoutZip, itemCount, csvUpper, csvZipFileNamesKey, generateCsvZip, filters, hideTitleCSV, csvExcludeUpper, filterSeparator, filterStorageName, }: {
|
|
9
9
|
normalize?: boolean;
|
|
10
10
|
csvUpper?: boolean;
|
|
11
11
|
filterStorageName?: string;
|
|
@@ -13,6 +13,7 @@ export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableNam
|
|
|
13
13
|
columns: ColumnData[];
|
|
14
14
|
tableName: string;
|
|
15
15
|
csvShowAllButton?: boolean;
|
|
16
|
+
csvExcludeUpper?: string[];
|
|
16
17
|
csvWithoutZip?: boolean;
|
|
17
18
|
csvAllButtonTitle?: string;
|
|
18
19
|
csvButtonTitle?: string;
|
|
@@ -23,6 +24,7 @@ export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableNam
|
|
|
23
24
|
csvCustomKeyNames?: {
|
|
24
25
|
[key: string]: string;
|
|
25
26
|
};
|
|
27
|
+
csvExcludeKeysCSV?: string[];
|
|
26
28
|
csvExcludeKeys?: string[];
|
|
27
29
|
hideTitleCSV?: boolean;
|
|
28
30
|
csvExcludeKeysAll?: string[];
|
|
@@ -46,7 +46,7 @@ let startData = [];
|
|
|
46
46
|
function Table({ columns, fetchFunc, emptyMsg = {
|
|
47
47
|
user: 'Nenhum dado encontrado',
|
|
48
48
|
public: 'Nenhum dado encontrado',
|
|
49
|
-
}, dataPath = '', tableName = 'Dados', csv, columnSize, action, isPublic = false, statusKeyName = '', csvExcludeKeys = [], 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, filters = {}, hideTitleCSV = false, filterSeparator = '|', filterStorageName = 'tableFilters', }) {
|
|
49
|
+
}, dataPath = '', tableName = 'Dados', csv, columnSize, action, isPublic = false, 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, filters = {}, hideTitleCSV = false, csvExcludeUpper = [], filterSeparator = '|', filterStorageName = 'tableFilters', }) {
|
|
50
50
|
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
51
51
|
const [error, setError] = (0, react_1.useState)(null);
|
|
52
52
|
const [data, setData] = (0, react_1.useState)(null);
|
|
@@ -210,9 +210,9 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
210
210
|
if (list.length <= 0)
|
|
211
211
|
return;
|
|
212
212
|
const originalKeys = Object.keys(list[0]);
|
|
213
|
-
const keys = originalKeys.filter((k) => !csvExcludeKeys.includes(k));
|
|
214
|
-
const header = keys.map((k) => (csvCustomKeyNames[k] ? csvCustomKeyNames[k] : k)).join(',') + '\n';
|
|
215
213
|
if (generateCsvZip && zip) {
|
|
214
|
+
const keys = originalKeys.filter((k) => !csvExcludeKeys.includes(k));
|
|
215
|
+
const header = keys.map((k) => (csvCustomKeyNames[k] ? csvCustomKeyNames[k] : k)).join(',') + '\n';
|
|
216
216
|
const zip = new jszip_1.default();
|
|
217
217
|
const obj = {};
|
|
218
218
|
list.forEach((x) => {
|
|
@@ -261,6 +261,8 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
263
|
else {
|
|
264
|
+
const keys = originalKeys.filter((k) => !csvExcludeKeysCSV.includes(k));
|
|
265
|
+
const header = keys.map((k) => (csvCustomKeyNames[k] ? csvCustomKeyNames[k] : k)).join(',') + '\n';
|
|
264
266
|
const values = [];
|
|
265
267
|
list.forEach((x) => {
|
|
266
268
|
let include = true;
|
|
@@ -278,7 +280,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
278
280
|
if (k === 'rlEventoData')
|
|
279
281
|
return `${x[k][0]['DT_INICIO']} - ${x[k][0]['HR_INICIO']}`;
|
|
280
282
|
if (typeof x[k] === 'string') {
|
|
281
|
-
let item = csvUpper ? x[k].toUpperCase() : x[k];
|
|
283
|
+
let item = csvUpper && !csvExcludeUpper.includes(k) ? x[k].toUpperCase() : x[k];
|
|
282
284
|
item = normalize ? item.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : item;
|
|
283
285
|
return removeQuotes ? `${item}` : `"${item}"`;
|
|
284
286
|
}
|
|
@@ -653,7 +655,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
653
655
|
xs: 'column',
|
|
654
656
|
md: 'row',
|
|
655
657
|
}, justifyContent: 'flex-end', spacing: 1 },
|
|
656
|
-
csvWithoutZip && (react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: downloadCSV, sx: { backgroundColor: '#5a88b0', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } },
|
|
658
|
+
csvWithoutZip && (react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: downloadCSV, sx: { backgroundColor: '#5a88b0', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, csvNoZipText)),
|
|
657
659
|
csvShowAllButton && (react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: downloadCSVAll, sx: { backgroundColor: '#64748B', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, csvAllButtonTitle)),
|
|
658
660
|
react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: (e) => downloadCSV(e, true), sx: { backgroundColor: '#22C55E', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, csvButtonTitle)))))),
|
|
659
661
|
react_1.default.createElement(material_1.SwipeableDrawer, { anchor: isSmall ? 'bottom' : 'right', open: filterOpen, onClose: (e) => setFilterOpen(false), onOpen: (e) => setFilterOpen(true) },
|