@ssplib/react-components 0.0.282 → 0.0.284

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, csv, columnSize, action, useKC, itemCount, expandTextMaxLength, collapsedSize, customMargin, customMarginMobile, filtersFunc, filters, orderBy, customErrorMsg, customTableStyle, id, initialData, isExpandable, }: TableProps): JSX.Element;
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
- }, csv, 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, }) {
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);
@@ -302,9 +302,9 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
302
302
  localStorage.removeItem(localTableName);
303
303
  setFilterKey(new Date().getTime().toString());
304
304
  }
305
- const handleCSVDownload = (list) => {
305
+ const handleCSVDownload = (list, all = false) => {
306
306
  var _a;
307
- (0, utils_1.downloadCSVFile)(list, csvConfig, JSON.parse((_a = localStorage.getItem(localTableName)) !== null && _a !== void 0 ? _a : '[]') || []);
307
+ (0, utils_1.downloadCSVFile)(list, Object.assign(Object.assign({}, csvConfig), (all ? { downloadAll: true } : {})), JSON.parse((_a = localStorage.getItem(localTableName)) !== null && _a !== void 0 ? _a : '[]') || []);
308
308
  };
309
309
  const handleFiltrarDados = (dt) => {
310
310
  (0, utils_1.filtrarDados)({
@@ -465,14 +465,14 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
465
465
  }, spacing: {
466
466
  xs: 2,
467
467
  md: 0,
468
- }, justifyContent: 'space-between', alignItems: 'center' }, csv && (react_1.default.createElement(material_1.Stack, { direction: {
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 },
472
472
  JSON.parse((_b = localStorage.getItem(localTableName)) !== null && _b !== void 0 ? _b : '[]')
473
473
  .filter((x) => x.value || (x.operator === 'entre' && (x.value || x.value2))).length > 0 &&
474
474
  react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: (e) => handleCSVDownload(list), sx: { backgroundColor: '#a5a5a5', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, "Baixar Filtrados"),
475
- react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: (e) => handleCSVDownload(startData.current), sx: { backgroundColor: '#22C55E', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, "Baixar Tabela")))))),
475
+ react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: (e) => handleCSVDownload(startData.current, true), sx: { backgroundColor: '#22C55E', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, "Baixar Tabela")))))),
476
476
  react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'center', paddingY: 1, paddingTop: 2 },
477
477
  react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'center', alignItems: 'center', spacing: 2 },
478
478
  react_1.default.createElement(material_1.Button, { onClick: (e) => setListPage((s) => {
@@ -37,6 +37,7 @@ export interface CsvMapProps {
37
37
  }
38
38
  export interface CsvConfigProp {
39
39
  fileName: string;
40
+ downloadAll?: boolean;
40
41
  map: CsvMapProps[];
41
42
  }
42
43
  /**
@@ -79,10 +80,6 @@ export interface TableProps {
79
80
  expandTextMaxLength?: number;
80
81
  /** Ações por linha */
81
82
  action: (prop: any) => JSX.Element;
82
- /** Configuração para exportação CSV */
83
- csv?: {
84
- fileName: string;
85
- };
86
83
  /** Quantidade de itens por página */
87
84
  itemCount?: number;
88
85
  /** Número de colunas da tabela */
@@ -305,7 +305,7 @@ function downloadCSVFile(list, config, filters) {
305
305
  const obj = {};
306
306
  config.map.forEach(m => {
307
307
  // opção de usar o valor do filtro no próprio campo
308
- if (m.useFilterValue) {
308
+ if (m.useFilterValue && !config.downloadAll) {
309
309
  const filterValueList = filters.filter(f => f.label == m.useFilterValue.label && m.useFilterValue.operators.includes(f.operator));
310
310
  const filterValue = filterValueList.length > 0 ? (filterValueList.reduce(r => r.value).value || undefined) : undefined;
311
311
  obj[m.name] = filterValue || (0, lodash_get_1.default)(x, m.key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.282",
3
+ "version": "0.0.284",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",