@ssplib/react-components 0.0.143 → 0.0.144

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, csvAllButtonTitle, removeQuotes, normalize, csvShowAllButton, itemCount, csvUpper, csvZipFileNamesKey, generateCsvZip, filters, hideTitleCSV, filterSeparator, filterStorageName, }: {
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, }: {
9
9
  normalize?: boolean;
10
10
  csvUpper?: boolean;
11
11
  filterStorageName?: string;
@@ -13,8 +13,10 @@ export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableNam
13
13
  columns: ColumnData[];
14
14
  tableName: string;
15
15
  csvShowAllButton?: boolean;
16
+ csvWithoutZip?: boolean;
16
17
  csvAllButtonTitle?: string;
17
18
  csvButtonTitle?: string;
19
+ csvNoZipText?: string;
18
20
  csvZipFileNamesKey?: string;
19
21
  generateCsvZip?: boolean;
20
22
  csvExcludeValidate?: (key: string, value: string | number) => boolean;
@@ -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', csvAllButtonTitle = 'Salvar todos em CSV', removeQuotes = false, normalize = false, csvShowAllButton = 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 = [], 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', }) {
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);
@@ -205,14 +205,14 @@ function Table({ columns, fetchFunc, emptyMsg = {
205
205
  return list.slice(start, start + itemsCount);
206
206
  }, [list, itemsCount, currentPage]);
207
207
  // download file
208
- const downloadCSV = (0, react_1.useCallback)((e) => {
208
+ const downloadCSV = (0, react_1.useCallback)((e, zip = false) => {
209
209
  e.preventDefault();
210
210
  if (list.length <= 0)
211
211
  return;
212
212
  const originalKeys = Object.keys(list[0]);
213
213
  const keys = originalKeys.filter((k) => !csvExcludeKeys.includes(k));
214
214
  const header = keys.map((k) => (csvCustomKeyNames[k] ? csvCustomKeyNames[k] : k)).join(',') + '\n';
215
- if (generateCsvZip) {
215
+ if (generateCsvZip && zip) {
216
216
  const zip = new jszip_1.default();
217
217
  const obj = {};
218
218
  list.forEach((x) => {
@@ -653,8 +653,9 @@ function Table({ columns, fetchFunc, emptyMsg = {
653
653
  xs: 'column',
654
654
  md: 'row',
655
655
  }, 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' } } }, csvButtonTitle)),
656
657
  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)),
657
- react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: downloadCSV, sx: { backgroundColor: '#22C55E', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, csvButtonTitle)))))),
658
+ 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)))))),
658
659
  react_1.default.createElement(material_1.SwipeableDrawer, { anchor: isSmall ? 'bottom' : 'right', open: filterOpen, onClose: (e) => setFilterOpen(false), onOpen: (e) => setFilterOpen(true) },
659
660
  react_1.default.createElement(material_1.List, { sx: { minWidth: 310 } }, Object.keys(filters).map((f, fIndex) => (react_1.default.createElement(react_1.default.Fragment, null,
660
661
  react_1.default.createElement(material_1.ListItemButton, { onClick: (e) => setFilterCollapse((s) => s.map((x, idx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.143",
3
+ "version": "0.0.144",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",