@ssplib/react-components 0.0.126 → 0.0.127
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,10 @@ 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, csvCustomKeyNames, csvExcludeValidate, csvButtonTitle, csvAllButtonTitle, csvShowAllButton, itemCount, filters, filterSeparator, }: {
|
|
8
|
+
export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableName, csv, columnSize, action, isPublic, statusKeyName, csvExcludeKeys, csvCustomKeyNames, csvExcludeValidate, csvButtonTitle, csvAllButtonTitle, removeQuotes, normalize, csvShowAllButton, itemCount, csvUpper, filters, filterSeparator, }: {
|
|
9
|
+
normalize?: boolean;
|
|
10
|
+
csvUpper?: boolean;
|
|
11
|
+
removeQuotes?: boolean;
|
|
9
12
|
columns: ColumnData[];
|
|
10
13
|
tableName: string;
|
|
11
14
|
csvShowAllButton?: boolean;
|
|
@@ -45,7 +45,7 @@ let startData = [];
|
|
|
45
45
|
function Table({ columns, fetchFunc, emptyMsg = {
|
|
46
46
|
user: 'Nenhum dado encontrado',
|
|
47
47
|
public: 'Nenhum dado encontrado',
|
|
48
|
-
}, dataPath = '', tableName = 'Dados', csv, columnSize, action, isPublic = false, statusKeyName = '', csvExcludeKeys = [], csvCustomKeyNames = {}, csvExcludeValidate = (key, value) => false, csvButtonTitle = 'Salvar .CSV', csvAllButtonTitle = 'Salvar todos em CSV', csvShowAllButton = false, itemCount = 10, filters = {}, filterSeparator = '|', }) {
|
|
48
|
+
}, dataPath = '', tableName = 'Dados', csv, columnSize, action, isPublic = false, statusKeyName = '', csvExcludeKeys = [], csvCustomKeyNames = {}, csvExcludeValidate = (key, value) => false, csvButtonTitle = 'Salvar .CSV', csvAllButtonTitle = 'Salvar todos em CSV', removeQuotes = false, normalize = false, csvShowAllButton = false, itemCount = 10, csvUpper = false, filters = {}, filterSeparator = '|', }) {
|
|
49
49
|
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
50
50
|
const [error, setError] = (0, react_1.useState)(null);
|
|
51
51
|
const [data, setData] = (0, react_1.useState)(null);
|
|
@@ -219,8 +219,11 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
219
219
|
return x[k]['NO_CIDADE'];
|
|
220
220
|
if (k === 'rlEventoData')
|
|
221
221
|
return `${x[k][0]['DT_INICIO']} - ${x[k][0]['HR_INICIO']}`;
|
|
222
|
-
if (typeof x[k] === 'string')
|
|
223
|
-
|
|
222
|
+
if (typeof x[k] === 'string') {
|
|
223
|
+
let item = csvUpper ? x[k].toUpperCase() : x[k];
|
|
224
|
+
item = normalize ? item.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : item;
|
|
225
|
+
return removeQuotes ? `${item}` : `"${item}"`;
|
|
226
|
+
}
|
|
224
227
|
return x[k];
|
|
225
228
|
})
|
|
226
229
|
.join(',');
|
|
@@ -248,8 +251,11 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
248
251
|
return x[k]['NO_CIDADE'];
|
|
249
252
|
if (k === 'rlEventoData')
|
|
250
253
|
return `${x[k][0]['DT_INICIO']} - ${x[k][0]['HR_INICIO']}`;
|
|
251
|
-
if (typeof x[k] === 'string')
|
|
252
|
-
|
|
254
|
+
if (typeof x[k] === 'string') {
|
|
255
|
+
let item = csvUpper ? x[k].toUpperCase() : x[k];
|
|
256
|
+
item = normalize ? item.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : item;
|
|
257
|
+
return removeQuotes ? `${item}` : `"${item}"`;
|
|
258
|
+
}
|
|
253
259
|
return x[k];
|
|
254
260
|
})
|
|
255
261
|
.join(',');
|
|
@@ -486,7 +492,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
486
492
|
react_1.default.createElement(TextField_1.default, { InputProps: {
|
|
487
493
|
startAdornment: react_1.default.createElement(Search_1.default, { sx: { marginRight: 1, fill: '#c0c0c0' } }),
|
|
488
494
|
}, size: 'small', onChange: onInputChange, fullWidth: true, placeholder: `Pesquisar ${tableName}` }),
|
|
489
|
-
react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.FilterAlt, null), variant: 'contained', onClick: (e) => setFilterOpen(true) }, "Filtrar")),
|
|
495
|
+
Object.keys(filters).length > 0 && (react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.FilterAlt, null), variant: 'contained', onClick: (e) => setFilterOpen(true) }, "Filtrar"))),
|
|
490
496
|
react_1.default.createElement(material_1.Stack, { spacing: 0.2 },
|
|
491
497
|
getMaxItems().length <= 0 ? (react_1.default.createElement(material_1.Stack, { sx: { backgroundColor: '#E2E8F0', padding: 2, marginX: { xs: 2, md: 0 } }, justifyContent: 'center', alignItems: 'center' },
|
|
492
498
|
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: { padding: 0.5, backgroundColor: index % 2 === 0 ? '#E2E8F0' : '#F8FAFC', paddingY: 2 }, elevation: 0 },
|