@ssplib/react-components 0.0.125 → 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
- return `"${x[k]}"`;
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
- return `"${x[k]}"`;
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(',');
@@ -276,6 +282,8 @@ function Table({ columns, fetchFunc, emptyMsg = {
276
282
  return (react_1.default.createElement(Typography_1.default, { color: '#22C55E', fontWeight: 600, fontFamily: 'Inter' }, "LICENCIADO"));
277
283
  case 'PA':
278
284
  return (react_1.default.createElement(Typography_1.default, { color: '#6366F1', fontWeight: 600, fontFamily: 'Inter' }, "PR\u00C9 APROVADO"));
285
+ case 'FP':
286
+ return (react_1.default.createElement(Typography_1.default, { color: '#991b1b', fontWeight: 600, fontFamily: 'Inter' }, "FORA DO PRAZO"));
279
287
  }
280
288
  }, []);
281
289
  const toggleDrawer = (open) => (event) => {
@@ -484,7 +492,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
484
492
  react_1.default.createElement(TextField_1.default, { InputProps: {
485
493
  startAdornment: react_1.default.createElement(Search_1.default, { sx: { marginRight: 1, fill: '#c0c0c0' } }),
486
494
  }, size: 'small', onChange: onInputChange, fullWidth: true, placeholder: `Pesquisar ${tableName}` }),
487
- 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"))),
488
496
  react_1.default.createElement(material_1.Stack, { spacing: 0.2 },
489
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' },
490
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 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.125",
3
+ "version": "0.0.127",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",