@ssplib/react-components 0.0.274 → 0.0.276

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.
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ interface TableErrorStateProps {
3
+ error: null | {
4
+ status: number;
5
+ };
6
+ customErrorMsg?: string | ReactNode;
7
+ }
8
+ export declare function TableErrorState({ customErrorMsg, error }: TableErrorStateProps): JSX.Element;
9
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TableErrorState = void 0;
7
+ const icons_material_1 = require("@mui/icons-material");
8
+ const material_1 = require("@mui/material");
9
+ const react_1 = __importDefault(require("react"));
10
+ function TableErrorState({ customErrorMsg, error }) {
11
+ return (react_1.default.createElement(material_1.Box, { bgcolor: '#fff2c8', color: '#3e3129', padding: 2, marginX: 2, borderRadius: 4 },
12
+ react_1.default.createElement(material_1.Typography, { fontSize: 24, textAlign: 'center', fontFamily: 'Inter' },
13
+ error.status === 403 && 'Acesso negado',
14
+ error.status === 500 && (react_1.default.createElement(material_1.Box, { fontWeight: 500, textAlign: 'center' },
15
+ react_1.default.createElement(icons_material_1.ReportProblemRounded, { sx: {
16
+ transform: 'scale(2)',
17
+ marginY: 1,
18
+ fill: '#3e3129',
19
+ } }),
20
+ react_1.default.createElement(material_1.Box, null, customErrorMsg ? (customErrorMsg) : (react_1.default.createElement(react_1.default.Fragment, null,
21
+ "N\u00E3o foi poss\u00EDvel se conectar ao servidor no momento. Por favor, aguarde alguns instantes e tente de novo.",
22
+ react_1.default.createElement("br", null),
23
+ react_1.default.createElement("br", null),
24
+ "Caso precise de ajuda, entre em contato pelo email: ",
25
+ react_1.default.createElement("strong", null, "cdes@ssp.df.gov.br")))))))));
26
+ }
27
+ exports.TableErrorState = TableErrorState;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface TableLoadingStateProps {
3
+ tableName: string;
4
+ }
5
+ export declare function TableLoadingState({ tableName }: TableLoadingStateProps): JSX.Element;
6
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TableLoadingState = void 0;
7
+ const icons_material_1 = require("@mui/icons-material");
8
+ const material_1 = require("@mui/material");
9
+ const Typography_1 = __importDefault(require("@mui/material/Typography"));
10
+ const react_1 = __importDefault(require("react"));
11
+ function TableLoadingState({ tableName }) {
12
+ return (react_1.default.createElement(material_1.Stack, { sx: {
13
+ height: '100%',
14
+ width: '100%',
15
+ }, justifyContent: 'center', alignItems: 'center' },
16
+ react_1.default.createElement(material_1.Box, { width: '100%' },
17
+ react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'center', alignItems: 'center', justifyItems: 'center', spacing: 2, marginY: 4 },
18
+ react_1.default.createElement(icons_material_1.PendingRounded, { sx: {
19
+ fill: '#5e5e5e',
20
+ } }),
21
+ react_1.default.createElement(Typography_1.default, { fontWeight: 600, fontSize: 20, textTransform: 'capitalize', textAlign: 'center', color: '#5e5e5e' },
22
+ "Carregando ",
23
+ tableName)),
24
+ react_1.default.createElement(material_1.LinearProgress, { color: 'inherit' }),
25
+ Array(10)
26
+ .fill('')
27
+ .map((x) => (react_1.default.createElement(material_1.Stack, { direction: {
28
+ xs: 'column',
29
+ md: 'row',
30
+ }, spacing: {
31
+ xs: 3,
32
+ md: 1,
33
+ }, justifyContent: 'space-between', paddingY: 8, borderBottom: '1px solid #cacaca' }, Array(7)
34
+ .fill(0)
35
+ .map((y) => (react_1.default.createElement(material_1.Box, null,
36
+ react_1.default.createElement(material_1.Skeleton, { width: 60 }),
37
+ react_1.default.createElement(material_1.Skeleton, { width: 120 }))))))))));
38
+ }
39
+ exports.TableLoadingState = TableLoadingState;
@@ -1,8 +1,8 @@
1
1
  import { BoxProps } from '@mui/material';
2
2
  import { ReactNode } from 'react';
3
- export interface ColumnData<T> {
3
+ export interface ColumnData {
4
4
  title: string;
5
- keyName: Partial<T>;
5
+ keyName: string;
6
6
  customComponent?: (content: string, obj: any) => JSX.Element;
7
7
  size?: number;
8
8
  }
@@ -30,181 +30,103 @@ export interface FilterValue {
30
30
  /**
31
31
  * Interface para as propriedades do componente Table.
32
32
  */
33
- export interface GenericTableProps<T> {
34
- /**
35
- * Identificador único da tabela.
36
- */
33
+ export interface TableProps {
34
+ /** ID único da tabela */
37
35
  id: string;
38
- /**
39
- * Configuração de largura para exibição em telas grandes.
40
- */
36
+ /** Configurações de largura para telas grandes */
41
37
  mediaQueryLG?: {
42
38
  all: number;
43
39
  action: number;
44
40
  };
45
- /**
46
- * Funções de filtragem aplicáveis à tabela.
47
- */
41
+ /** Funções de transformação para filtros */
48
42
  filtersFunc?: {
49
43
  [key: string]: (value: string) => any;
50
44
  };
51
- /**
52
- * Lista de filtros disponíveis.
53
- */
45
+ /** Filtros disponíveis */
54
46
  filters?: FilterValue[];
55
- /**
56
- * Configuração da ordenação das colunas.
57
- */
47
+ /** Ordenação por colunas */
58
48
  orderBy?: OrderBy[];
59
- /**
60
- * Margem personalizada para o componente.
61
- */
49
+ /** Margem personalizada (desktop) */
62
50
  customMargin?: number;
63
- /**
64
- * Margem personalizada para visualização em dispositivos móveis.
65
- */
51
+ /** Margem personalizada (mobile) */
66
52
  customMarginMobile?: number;
67
- /**
68
- * Define se os valores CSV devem ser normalizados (removendo acentos, por exemplo).
69
- */
53
+ /** Normaliza textos (remove acentos) */
70
54
  normalize?: boolean;
71
- /**
72
- * Define se os valores CSV devem ser convertidos para maiúsculas.
73
- */
55
+ /** Converte textos para maiúsculas */
74
56
  csvUpper?: boolean;
75
- /**
76
- * Estilo personalizado para a tabela.
77
- */
57
+ /** Estilo customizado da tabela */
78
58
  customTableStyle?: BoxProps;
79
- /**
80
- * Caminho múltiplo para os dados dentro do JSON retornado pela API.
81
- */
59
+ /** Caminho múltiplo dentro dos dados */
82
60
  multipleDataPath?: string;
83
- /**
84
- * Mensagem de erro personalizada para exibição na tabela.
85
- */
61
+ /** Mensagem de erro personalizada */
86
62
  customErrorMsg?: string | ReactNode;
87
- /**
88
- * Remove aspas dos valores no CSV.
89
- */
63
+ /** Remove aspas dos valores no CSV */
90
64
  removeQuotes?: boolean;
91
- /**
92
- * Lista de colunas a serem exibidas na tabela.
93
- */
94
- columns: ColumnData<T>[];
95
- /**
96
- * Nome da tabela para exibição.
97
- */
65
+ /** Colunas da tabela */
66
+ columns: any[];
67
+ /** Nome da tabela */
98
68
  tableName: string;
99
- /**
100
- * Exibe botão para exportar todos os dados para CSV.
101
- */
69
+ /** Exibe botão para exportar todos os dados */
102
70
  csvShowAllButton?: boolean;
103
- /**
104
- * Lista de chaves que devem ser excluídas da exportação para CSV.
105
- */
71
+ /** Chaves excluídas da exportação (upper) */
106
72
  csvExcludeUpper?: string[];
107
- /**
108
- * Define se o CSV será exportado sem compactação.
109
- */
73
+ /** Exporta CSV sem compactação */
110
74
  csvWithoutZip?: boolean;
111
- /**
112
- * Define o tamanho colapsado das células expansíveis.
113
- */
75
+ /** Altura da célula colapsada */
114
76
  collapsedSize?: number;
115
- /**
116
- * Título do botão para exportação de todos os dados em CSV.
117
- */
77
+ /** Texto do botão "Exportar todos em CSV" */
118
78
  csvAllButtonTitle?: string;
119
- /**
120
- * Título do botão para exportação em CSV.
121
- */
79
+ /** Texto do botão "Exportar CSV" */
122
80
  csvButtonTitle?: string;
123
- /**
124
- * Título do botão para exportação sem compactação.
125
- */
81
+ /** Texto do botão "Exportar sem ZIP" */
126
82
  csvNoZipText?: string;
127
- /**
128
- * Chave usada para nomeação de arquivos CSV compactados.
129
- */
83
+ /** Chave para nomear arquivos ZIP */
130
84
  csvZipFileNamesKey?: string;
131
- /**
132
- * Define se será gerado um ZIP contendo os arquivos CSV.
133
- */
85
+ /** Gera arquivo ZIP ao exportar */
134
86
  generateCsvZip?: boolean;
135
- /**
136
- * Função de validação para exclusão de chaves ao exportar CSV.
137
- */
87
+ /** Validação para exclusão de chaves no CSV */
138
88
  csvExcludeValidate?: (key: string, value: string | number) => boolean;
139
- /**
140
- * Mapeamento de nomes personalizados para colunas do CSV.
141
- */
89
+ /** Mapeia nomes customizados de colunas no CSV */
142
90
  csvCustomKeyNames?: {
143
91
  [key: string]: string;
144
92
  };
145
- /**
146
- * Define o tamanho máximo do texto antes de ser colapsado.
147
- */
93
+ /** Tamanho máximo do texto antes de colapsar */
148
94
  expandTextMaxLength?: number;
149
- /**
150
- * Lista de chaves a serem excluídas da exportação para CSV.
151
- */
95
+ /** Chaves excluídas da exportação CSV simples */
152
96
  csvExcludeKeysCSV?: string[];
153
- /**
154
- * Lista de chaves a serem excluídas da exportação geral para CSV.
155
- */
97
+ /** Chaves excluídas da exportação geral */
156
98
  csvExcludeKeys?: string[];
157
- /**
158
- * Define se o título deve ser ocultado na exportação CSV.
159
- */
99
+ /** Oculta o título na exportação CSV */
160
100
  hideTitleCSV?: boolean;
161
- /**
162
- * Lista de chaves a serem excluídas na exportação de todos os dados.
163
- */
101
+ /** Chaves excluídas no CSV com todos os dados */
164
102
  csvExcludeKeysAll?: string[];
165
- /**
166
- * Nome da chave do status para identificação de status da linha.
167
- */
103
+ /** Nome da chave para status da linha */
168
104
  statusKeyName?: string;
169
- /**
170
- * Quantidade de itens por página.
171
- */
105
+ /** Quantidade de itens por página */
172
106
  itemCount?: number;
173
- /**
174
- * Componente para exibir ações específicas para cada linha.
175
- */
107
+ /** Ações por linha */
176
108
  action: (prop: any) => JSX.Element;
177
- /**
178
- * Configuração para exportação de arquivos CSV.
179
- */
109
+ /** Configuração para exportação CSV */
180
110
  csv?: {
181
111
  fileName: string;
182
112
  };
183
- /**
184
- * Define o número de colunas exibidas na tabela.
185
- */
113
+ /** Número de colunas da tabela */
186
114
  columnSize: number;
187
- /**
188
- * Mensagens exibidas quando não há dados na tabela.
189
- */
115
+ /** Função para buscar dados */
116
+ fetchFunc?: () => Promise<Response>;
117
+ /** Mensagens para quando não há dados */
190
118
  emptyMsg?: {
191
119
  user: string;
192
120
  public: string;
193
121
  };
194
- /**
195
- * Caminho dentro do JSON de resposta onde os dados estão armazenados.
196
- */
122
+ /** Caminho dos dados no JSON da resposta */
197
123
  dataPath?: string;
198
- /**
199
- * Define se a autenticação via Keycloak será utilizada.
200
- */
124
+ /** Usa autenticação via Keycloak */
201
125
  useKC?: boolean;
202
- /**
203
- * Dados da tabela
204
- */
205
- initialData: Array<Partial<T>> | null;
206
- /**
207
- * Variável para renderizar componente de carregamento
208
- */
126
+ /** Dados iniciais da tabela */
127
+ initialData: Array<{
128
+ [key: string]: any;
129
+ }> | null;
130
+ /** Flag de carregamento dos dados da tabela */
209
131
  isLoading?: boolean;
210
132
  }
@@ -0,0 +1,51 @@
1
+ /// <reference types="react" />
2
+ import { FilterValue, OrderBy } from './types';
3
+ export declare const getCount: (countData: any[], itemsCount: number) => number;
4
+ export declare function transformArrayObjectInString(o: Object): String;
5
+ export declare function removePunctuationAndAccents(text: string): string;
6
+ export declare function formatarString(str: string | number): string;
7
+ interface FiltrarProps {
8
+ startData: any[];
9
+ filterData: FilterValue[];
10
+ filtersFuncData: {
11
+ [key: string]: (value: string) => any;
12
+ };
13
+ localTableName: string;
14
+ setList: (arg: any) => void;
15
+ setPagCount: (arg: any) => void;
16
+ setCurrentPage: (arg: number) => void;
17
+ setListPage: (arg: number) => void;
18
+ setListClone: (arg: any) => void;
19
+ itemsCount: number;
20
+ }
21
+ export declare function filtrarDados({ filterData, startData, filtersFuncData, localTableName, setCurrentPage, setList, setListClone, setListPage, setPagCount, itemsCount }: FiltrarProps): void;
22
+ interface OrdenarDadosProps {
23
+ order: OrderBy;
24
+ list: any[];
25
+ orderAsc: boolean;
26
+ }
27
+ export declare function ordenarDados({ order, list, orderAsc }: OrdenarDadosProps): any[];
28
+ export interface CsvExportOptions {
29
+ list: any[];
30
+ csvUpper?: boolean;
31
+ csvExcludeUpper?: string[];
32
+ csvExcludeKeys?: string[];
33
+ csvExcludeKeysCSV?: string[];
34
+ csvExcludeKeysAll?: string[];
35
+ csvCustomKeyNames?: {
36
+ [key: string]: string;
37
+ };
38
+ csvExcludeValidate?: (key: string, value: any) => boolean;
39
+ csv?: {
40
+ fileName: string;
41
+ };
42
+ multipleDataPath?: string;
43
+ normalize?: boolean;
44
+ removeQuotes?: boolean;
45
+ hideTitleCSV?: boolean;
46
+ generateCsvZip?: boolean;
47
+ csvZipFileNamesKey?: string;
48
+ }
49
+ export declare function downloadCSVFile(e: React.MouseEvent, zip: boolean, options: CsvExportOptions): Promise<void>;
50
+ export declare function downloadCSVAll(e: React.MouseEvent, list: any[], keys: string[], fileName: string): void;
51
+ export {};