@ssplib/react-components 0.0.145 → 0.0.147

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
  }
@@ -311,7 +313,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
311
313
  if (k === 'rlEventoData')
312
314
  return `${x[k][0]['DT_INICIO']} - ${x[k][0]['HR_INICIO']}`;
313
315
  if (typeof x[k] === 'string') {
314
- let item = csvUpper ? x[k].toUpperCase() : x[k];
316
+ let item = csvUpper && !csvExcludeUpper.includes(k) ? x[k].toUpperCase() : x[k];
315
317
  item = normalize ? item.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : item;
316
318
  return removeQuotes ? `${item}` : `"${item}"`;
317
319
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.145",
3
+ "version": "0.0.147",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",