@ssplib/react-components 0.0.281 → 0.0.283
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TableProps } from './types';
|
|
3
|
-
export declare function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg, dataPath, tableName, csvConfig,
|
|
3
|
+
export declare function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg, dataPath, tableName, csvConfig, columnSize, action, useKC, itemCount, expandTextMaxLength, collapsedSize, customMargin, customMarginMobile, filtersFunc, filters, orderBy, customErrorMsg, customTableStyle, id, initialData, isExpandable, }: TableProps): JSX.Element;
|
|
4
4
|
declare const _default: React.MemoExoticComponent<typeof Table>;
|
|
5
5
|
export default _default;
|
|
@@ -56,7 +56,7 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
56
56
|
}, dataPath = '', tableName = 'Dado', csvConfig = {
|
|
57
57
|
fileName: tableName,
|
|
58
58
|
map: []
|
|
59
|
-
},
|
|
59
|
+
}, columnSize, action, useKC = true, itemCount = 10, expandTextMaxLength = 50, collapsedSize = 53, customMargin = 4, customMarginMobile = 0, filtersFunc, filters = [], orderBy = [], customErrorMsg = undefined, customTableStyle = {}, id, initialData = null, isExpandable = true, }) {
|
|
60
60
|
var _a, _b;
|
|
61
61
|
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
62
62
|
const [error, setError] = (0, react_1.useState)(null);
|
|
@@ -465,7 +465,7 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
465
465
|
}, spacing: {
|
|
466
466
|
xs: 2,
|
|
467
467
|
md: 0,
|
|
468
|
-
}, justifyContent: 'space-between', alignItems: 'center' },
|
|
468
|
+
}, justifyContent: 'space-between', alignItems: 'center' }, csvConfig.map.length > 0 && (react_1.default.createElement(material_1.Stack, { direction: {
|
|
469
469
|
xs: 'column',
|
|
470
470
|
md: 'row',
|
|
471
471
|
}, justifyContent: 'flex-end', spacing: 1 },
|
|
@@ -79,10 +79,6 @@ export interface TableProps {
|
|
|
79
79
|
expandTextMaxLength?: number;
|
|
80
80
|
/** Ações por linha */
|
|
81
81
|
action: (prop: any) => JSX.Element;
|
|
82
|
-
/** Configuração para exportação CSV */
|
|
83
|
-
csv?: {
|
|
84
|
-
fileName: string;
|
|
85
|
-
};
|
|
86
82
|
/** Quantidade de itens por página */
|
|
87
83
|
itemCount?: number;
|
|
88
84
|
/** Número de colunas da tabela */
|
|
@@ -304,8 +304,10 @@ function downloadCSVFile(list, config, filters) {
|
|
|
304
304
|
const newData = list.map(x => {
|
|
305
305
|
const obj = {};
|
|
306
306
|
config.map.forEach(m => {
|
|
307
|
+
// opção de usar o valor do filtro no próprio campo
|
|
307
308
|
if (m.useFilterValue) {
|
|
308
|
-
const
|
|
309
|
+
const filterValueList = filters.filter(f => f.label == m.useFilterValue.label && m.useFilterValue.operators.includes(f.operator));
|
|
310
|
+
const filterValue = filterValueList.length > 0 ? (filterValueList.reduce(r => r.value).value || undefined) : undefined;
|
|
309
311
|
obj[m.name] = filterValue || (0, lodash_get_1.default)(x, m.key);
|
|
310
312
|
return;
|
|
311
313
|
}
|
|
@@ -315,7 +317,7 @@ function downloadCSVFile(list, config, filters) {
|
|
|
315
317
|
});
|
|
316
318
|
const worksheet = XLSX.utils.json_to_sheet(newData);
|
|
317
319
|
const workbook = XLSX.utils.book_new();
|
|
318
|
-
XLSX.utils.book_append_sheet(workbook, worksheet,
|
|
320
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, config.fileName);
|
|
319
321
|
XLSX.writeFile(workbook, `${config.fileName}.xlsx`);
|
|
320
322
|
});
|
|
321
323
|
}
|