karsten-design-system 1.2.84 → 1.2.86
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.
- package/README.md +207 -207
- package/dist/index.js +31 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
# Karsten Design System
|
|
2
|
-
|
|
3
|
-
Uma biblioteca de componentes React estilizados para projetos da Karsten, construída sobre o PrimeReact.
|
|
4
|
-
|
|
5
|
-
## Instalação
|
|
6
|
-
|
|
7
|
-
Com npm:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install karsten-design-system
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Com yarn:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
yarn add karsten-design-system
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Configuração do PrimeReact
|
|
20
|
-
|
|
21
|
-
No main.tsx adicione:
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import { StrictMode } from "react";
|
|
25
|
-
import { createRoot } from "react-dom/client";
|
|
26
|
-
import "./index.css";
|
|
27
|
-
import App from "./App.tsx";
|
|
28
|
-
|
|
29
|
-
import { PrimeReactProvider } from 'primereact/api'; // Adicione o PrimeReactProvider
|
|
30
|
-
import Tailwind from 'primereact/passthrough/tailwind'; // Importe o Tailwind
|
|
31
|
-
import './index.css';
|
|
32
|
-
|
|
33
|
-
createRoot(document.getElementById("root")!).render(
|
|
34
|
-
<StrictMode>
|
|
35
|
-
<PrimeReactProvider value={{ pt: Tailwind }}> {/* Envolva o app no Provider do PrimeReact */}
|
|
36
|
-
<App />
|
|
37
|
-
</PrimeReactProvider>
|
|
38
|
-
</StrictMode>
|
|
39
|
-
);
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Pré-requisitos
|
|
43
|
-
|
|
44
|
-
Esta biblioteca requer as seguintes dependências:
|
|
45
|
-
|
|
46
|
-
- React 18 ou superior
|
|
47
|
-
- React DOM 18 ou superior
|
|
48
|
-
- React Router DOM 7 ou superior
|
|
49
|
-
- Tailwind 3.4.0 ou superior
|
|
50
|
-
- @types/date-fns 2 ou superior
|
|
51
|
-
- Chart.js 4 ou superior
|
|
52
|
-
- clsx 2 ou superior
|
|
53
|
-
- date-fns 1 ou superior
|
|
54
|
-
- Primeicons 7 ou superior
|
|
55
|
-
- Primereact 10 ou superior
|
|
56
|
-
- Postcss 8 ou superior
|
|
57
|
-
- Autoprefixer 10 ou superior
|
|
58
|
-
|
|
59
|
-
## Como usar
|
|
60
|
-
|
|
61
|
-
1. Importe o componente desejado da biblioteca:
|
|
62
|
-
|
|
63
|
-
```jsx
|
|
64
|
-
import { Button } from 'karsten-design-system'
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
2. Use o componente em seu projeto:
|
|
68
|
-
|
|
69
|
-
```jsx
|
|
70
|
-
function App() {
|
|
71
|
-
return <Button label="Clique aqui" />
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Componentes Disponíveis
|
|
76
|
-
|
|
77
|
-
- `Accordion` - Componente para exibir conteúdo em seções expansíveis e colapsáveis.
|
|
78
|
-
- `AutoComplete` - Campo de entrada com sugestões automáticas baseadas no texto digitado.
|
|
79
|
-
- `Breadcrumb` - Navegação hierárquica para indicar a localização atual do usuário.
|
|
80
|
-
- `Button` - Botão estilizado com variantes primária e secundária.
|
|
81
|
-
- `Card` - Contêiner estilizado para exibir informações agrupadas.
|
|
82
|
-
- `Chart` - Gráficos para visualização de dados em diferentes formatos.
|
|
83
|
-
- `DateInput` - Campo de entrada para seleção de datas.
|
|
84
|
-
- `Dialog` - Modal para exibição de mensagens ou ações secundárias.
|
|
85
|
-
- `Divider` - Linha divisória para separação visual de conteúdo.
|
|
86
|
-
- `Header` - Cabeçalho estilizado para títulos ou menus.
|
|
87
|
-
- `IconButton` - Botão com ícone, ideal para ações rápidas.
|
|
88
|
-
- `InfoCard` - Cartão informativo para exibir alertas ou dados destacados.
|
|
89
|
-
- `Input` - Campo de entrada para texto.
|
|
90
|
-
- `InternalMenu` - Menu de navegação interna, útil para dashboards.
|
|
91
|
-
- `Link` - Link estilizado para navegação.
|
|
92
|
-
- `MegaMenu` - Menu expandido com múltiplas opções organizadas.
|
|
93
|
-
- `Notification` - Notificação para exibir alertas e mensagens.
|
|
94
|
-
- `Paginator` - Paginação para navegação em listas ou tabelas.
|
|
95
|
-
- `RadioButton` - Botões de seleção única dentro de um grupo.
|
|
96
|
-
- `Select` - Componente para seleção de opções em um menu suspenso.
|
|
97
|
-
- `Sidebar` - Barra lateral para navegação ou exibição de conteúdo adicional.
|
|
98
|
-
- `Skeleton` - Elementos de carregamento em estilo esqueleto.
|
|
99
|
-
- `Spinner` - Indicador de carregamento animado.
|
|
100
|
-
- `Table` - Tabela para exibição de dados estruturados.
|
|
101
|
-
- `Toast` - Mensagens temporárias exibidas no canto da tela.
|
|
102
|
-
|
|
103
|
-
## Desenvolvimento
|
|
104
|
-
|
|
105
|
-
Para contribuir com o projeto:
|
|
106
|
-
|
|
107
|
-
1. Clone o repositório:
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
git clone https://github.com/KarstenSA/karsten-design-system.git
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
2. Instale as dependências:
|
|
114
|
-
|
|
115
|
-
Com npm:
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
npm install
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Com yarn:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
yarn
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
3. Execute o Storybook para desenvolvimento:
|
|
128
|
-
|
|
129
|
-
Com npm:
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
npm run storybook
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
Com yarn:
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
yarn storybook
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## Scripts Disponíveis
|
|
142
|
-
|
|
143
|
-
Com npm:
|
|
144
|
-
|
|
145
|
-
- `npm run storybook` - Inicia o ambiente de desenvolvimento do Storybook
|
|
146
|
-
- `npm run build-storybook` - Gera o build da biblioteca para hospedagem
|
|
147
|
-
- `npm run build` - Gera o build da biblioteca para publicação no npm
|
|
148
|
-
|
|
149
|
-
Com yarn:
|
|
150
|
-
|
|
151
|
-
- `yarn storybook` - Inicia o ambiente de desenvolvimento do Storybook
|
|
152
|
-
- `yarn build-storybook` - Gera o build do Storybook para hospedagem
|
|
153
|
-
- `yarn build` - Gera o build da biblioteca para publicação no npm
|
|
154
|
-
|
|
155
|
-
## Publicando uma Nova Versão no NPM
|
|
156
|
-
|
|
157
|
-
1. Atualizar a Versão
|
|
158
|
-
|
|
159
|
-
Antes de publicar, aumente a versão no `package.json` e `package-lock.json`.
|
|
160
|
-
|
|
161
|
-
2. Fazer o Build
|
|
162
|
-
|
|
163
|
-
Com npm:
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
npm run build
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Com yarn:
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
yarn build
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
3. Login no NPM
|
|
176
|
-
|
|
177
|
-
Se ainda não estiver autenticado, faça login:
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
npm login
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
4. Publicar
|
|
184
|
-
|
|
185
|
-
```bash
|
|
186
|
-
npm publish --access public
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
## Resolução de Problemas
|
|
190
|
-
|
|
191
|
-
Se você encontrar o erro "peer dependencies missing", instale as dependências necessárias:
|
|
192
|
-
|
|
193
|
-
Com npm:
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
npm install react@^18 react-dom@^18 tailwindcss@^3.4.0 @types/date-fns@^2 chart.js@^4 clsx@^2 date-fns@^1 primeicons@^7 primereact@^10 postcss@^8 autoprefixer@^10
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
Com yarn:
|
|
200
|
-
|
|
201
|
-
```bash
|
|
202
|
-
yarn add react@^18 react-dom@^18 tailwindcss@^3.4.0 @types/date-fns@^2 chart.js@^4 clsx@^2 date-fns@^1 primeicons@^7 primereact@^10 postcss@^8 autoprefixer@^10
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Licença
|
|
206
|
-
|
|
207
|
-
Este projeto está licenciado sob a licença MIT.
|
|
1
|
+
# Karsten Design System
|
|
2
|
+
|
|
3
|
+
Uma biblioteca de componentes React estilizados para projetos da Karsten, construída sobre o PrimeReact.
|
|
4
|
+
|
|
5
|
+
## Instalação
|
|
6
|
+
|
|
7
|
+
Com npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install karsten-design-system
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Com yarn:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add karsten-design-system
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuração do PrimeReact
|
|
20
|
+
|
|
21
|
+
No main.tsx adicione:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { StrictMode } from "react";
|
|
25
|
+
import { createRoot } from "react-dom/client";
|
|
26
|
+
import "./index.css";
|
|
27
|
+
import App from "./App.tsx";
|
|
28
|
+
|
|
29
|
+
import { PrimeReactProvider } from 'primereact/api'; // Adicione o PrimeReactProvider
|
|
30
|
+
import Tailwind from 'primereact/passthrough/tailwind'; // Importe o Tailwind
|
|
31
|
+
import './index.css';
|
|
32
|
+
|
|
33
|
+
createRoot(document.getElementById("root")!).render(
|
|
34
|
+
<StrictMode>
|
|
35
|
+
<PrimeReactProvider value={{ pt: Tailwind }}> {/* Envolva o app no Provider do PrimeReact */}
|
|
36
|
+
<App />
|
|
37
|
+
</PrimeReactProvider>
|
|
38
|
+
</StrictMode>
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Pré-requisitos
|
|
43
|
+
|
|
44
|
+
Esta biblioteca requer as seguintes dependências:
|
|
45
|
+
|
|
46
|
+
- React 18 ou superior
|
|
47
|
+
- React DOM 18 ou superior
|
|
48
|
+
- React Router DOM 7 ou superior
|
|
49
|
+
- Tailwind 3.4.0 ou superior
|
|
50
|
+
- @types/date-fns 2 ou superior
|
|
51
|
+
- Chart.js 4 ou superior
|
|
52
|
+
- clsx 2 ou superior
|
|
53
|
+
- date-fns 1 ou superior
|
|
54
|
+
- Primeicons 7 ou superior
|
|
55
|
+
- Primereact 10 ou superior
|
|
56
|
+
- Postcss 8 ou superior
|
|
57
|
+
- Autoprefixer 10 ou superior
|
|
58
|
+
|
|
59
|
+
## Como usar
|
|
60
|
+
|
|
61
|
+
1. Importe o componente desejado da biblioteca:
|
|
62
|
+
|
|
63
|
+
```jsx
|
|
64
|
+
import { Button } from 'karsten-design-system'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. Use o componente em seu projeto:
|
|
68
|
+
|
|
69
|
+
```jsx
|
|
70
|
+
function App() {
|
|
71
|
+
return <Button label="Clique aqui" />
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Componentes Disponíveis
|
|
76
|
+
|
|
77
|
+
- `Accordion` - Componente para exibir conteúdo em seções expansíveis e colapsáveis.
|
|
78
|
+
- `AutoComplete` - Campo de entrada com sugestões automáticas baseadas no texto digitado.
|
|
79
|
+
- `Breadcrumb` - Navegação hierárquica para indicar a localização atual do usuário.
|
|
80
|
+
- `Button` - Botão estilizado com variantes primária e secundária.
|
|
81
|
+
- `Card` - Contêiner estilizado para exibir informações agrupadas.
|
|
82
|
+
- `Chart` - Gráficos para visualização de dados em diferentes formatos.
|
|
83
|
+
- `DateInput` - Campo de entrada para seleção de datas.
|
|
84
|
+
- `Dialog` - Modal para exibição de mensagens ou ações secundárias.
|
|
85
|
+
- `Divider` - Linha divisória para separação visual de conteúdo.
|
|
86
|
+
- `Header` - Cabeçalho estilizado para títulos ou menus.
|
|
87
|
+
- `IconButton` - Botão com ícone, ideal para ações rápidas.
|
|
88
|
+
- `InfoCard` - Cartão informativo para exibir alertas ou dados destacados.
|
|
89
|
+
- `Input` - Campo de entrada para texto.
|
|
90
|
+
- `InternalMenu` - Menu de navegação interna, útil para dashboards.
|
|
91
|
+
- `Link` - Link estilizado para navegação.
|
|
92
|
+
- `MegaMenu` - Menu expandido com múltiplas opções organizadas.
|
|
93
|
+
- `Notification` - Notificação para exibir alertas e mensagens.
|
|
94
|
+
- `Paginator` - Paginação para navegação em listas ou tabelas.
|
|
95
|
+
- `RadioButton` - Botões de seleção única dentro de um grupo.
|
|
96
|
+
- `Select` - Componente para seleção de opções em um menu suspenso.
|
|
97
|
+
- `Sidebar` - Barra lateral para navegação ou exibição de conteúdo adicional.
|
|
98
|
+
- `Skeleton` - Elementos de carregamento em estilo esqueleto.
|
|
99
|
+
- `Spinner` - Indicador de carregamento animado.
|
|
100
|
+
- `Table` - Tabela para exibição de dados estruturados.
|
|
101
|
+
- `Toast` - Mensagens temporárias exibidas no canto da tela.
|
|
102
|
+
|
|
103
|
+
## Desenvolvimento
|
|
104
|
+
|
|
105
|
+
Para contribuir com o projeto:
|
|
106
|
+
|
|
107
|
+
1. Clone o repositório:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
git clone https://github.com/KarstenSA/karsten-design-system.git
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
2. Instale as dependências:
|
|
114
|
+
|
|
115
|
+
Com npm:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npm install
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Com yarn:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
yarn
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
3. Execute o Storybook para desenvolvimento:
|
|
128
|
+
|
|
129
|
+
Com npm:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm run storybook
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Com yarn:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
yarn storybook
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Scripts Disponíveis
|
|
142
|
+
|
|
143
|
+
Com npm:
|
|
144
|
+
|
|
145
|
+
- `npm run storybook` - Inicia o ambiente de desenvolvimento do Storybook
|
|
146
|
+
- `npm run build-storybook` - Gera o build da biblioteca para hospedagem
|
|
147
|
+
- `npm run build` - Gera o build da biblioteca para publicação no npm
|
|
148
|
+
|
|
149
|
+
Com yarn:
|
|
150
|
+
|
|
151
|
+
- `yarn storybook` - Inicia o ambiente de desenvolvimento do Storybook
|
|
152
|
+
- `yarn build-storybook` - Gera o build do Storybook para hospedagem
|
|
153
|
+
- `yarn build` - Gera o build da biblioteca para publicação no npm
|
|
154
|
+
|
|
155
|
+
## Publicando uma Nova Versão no NPM
|
|
156
|
+
|
|
157
|
+
1. Atualizar a Versão
|
|
158
|
+
|
|
159
|
+
Antes de publicar, aumente a versão no `package.json` e `package-lock.json`.
|
|
160
|
+
|
|
161
|
+
2. Fazer o Build
|
|
162
|
+
|
|
163
|
+
Com npm:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm run build
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Com yarn:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
yarn build
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
3. Login no NPM
|
|
176
|
+
|
|
177
|
+
Se ainda não estiver autenticado, faça login:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npm login
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
4. Publicar
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npm publish --access public
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Resolução de Problemas
|
|
190
|
+
|
|
191
|
+
Se você encontrar o erro "peer dependencies missing", instale as dependências necessárias:
|
|
192
|
+
|
|
193
|
+
Com npm:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
npm install react@^18 react-dom@^18 tailwindcss@^3.4.0 @types/date-fns@^2 chart.js@^4 clsx@^2 date-fns@^1 primeicons@^7 primereact@^10 postcss@^8 autoprefixer@^10
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Com yarn:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
yarn add react@^18 react-dom@^18 tailwindcss@^3.4.0 @types/date-fns@^2 chart.js@^4 clsx@^2 date-fns@^1 primeicons@^7 primereact@^10 postcss@^8 autoprefixer@^10
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Licença
|
|
206
|
+
|
|
207
|
+
Este projeto está licenciado sob a licença MIT.
|
package/dist/index.js
CHANGED
|
@@ -205,14 +205,14 @@ function Card({ children, className, ariaLabel = 'Card de informação', }) {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
function CardButton({ label, description, onClick }) {
|
|
208
|
-
return (jsxs("div", { className: "cursor-pointer rounded-2xl p-4 h-[160px] w-full bg-gradient-to-br hover:shadow-md transition-shadow duration-200 border from-[#f3f4f6] to-light-500 border-[#f3f4f6]\
|
|
208
|
+
return (jsxs("div", { className: "cursor-pointer rounded-2xl p-4 h-[160px] w-full bg-gradient-to-br hover:shadow-md transition-shadow duration-200 border from-[#f3f4f6] to-light-500 border-[#f3f4f6]\n dark:from-dark-400 dark:to-dark-100 dark:border-dark-400 dark:bg-dark-100 dark:shadow-dark-400", onClick: () => {
|
|
209
209
|
if (onClick)
|
|
210
210
|
onClick();
|
|
211
211
|
}, children: [jsx("h3", { className: "text-lg font-bold text-primary dark:text-light-500", children: label }), description && (jsx("p", { className: "text-sm mt-2 line-clamp-3 text-primary dark:text-light-500", children: description }))] }));
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
function CardIconsButton({ label, leftIcon, onClick, }) {
|
|
215
|
-
return (jsxs("div", { className: "cursor-pointer rounded-xl p-4 w-full min-h-[60px] bg-gradient-to-br hover:shadow-md transition-shadow duration-200 border flex items-center justify-between gap-4 from-[#f3f4f6] to-light-500 border-[#f3f4f6]\
|
|
215
|
+
return (jsxs("div", { className: "cursor-pointer rounded-xl p-4 w-full min-h-[60px] bg-gradient-to-br hover:shadow-md transition-shadow duration-200 border flex items-center justify-between gap-4 from-[#f3f4f6] to-light-500 border-[#f3f4f6]\n dark:from-dark-400 dark:to-dark-100 dark:border-dark-400 dark:bg-dark-100 dark:shadow-dark-400", onClick: () => {
|
|
216
216
|
if (onClick)
|
|
217
217
|
onClick();
|
|
218
218
|
}, "aria-label": `Botão de navegação para ${label}`, children: [jsxs("div", { className: "flex items-center gap-3 flex-grow overflow-hidden", children: [leftIcon && (jsx("div", { className: "text-xl flex-shrink-0 flex items-center dark:text-light-500 text-primary", children: leftIcon })), jsx("h3", { className: "text-base font-semibold break-words dark:text-light-500 text-primary", children: label })] }), jsx("div", { className: "flex items-center justify-center h-full", children: jsx("i", { className: "pi pi-angle-right text-xl flex-shrink-0 dark:text-light-500 text-primary" }) })] }));
|
|
@@ -4668,32 +4668,6 @@ function parseDateRange(value) {
|
|
|
4668
4668
|
return [null, null];
|
|
4669
4669
|
}
|
|
4670
4670
|
}
|
|
4671
|
-
const useLocalStorage = (storageKey, key, defaultValue = {}) => {
|
|
4672
|
-
const getStoredValue = () => {
|
|
4673
|
-
if (!storageKey)
|
|
4674
|
-
return defaultValue;
|
|
4675
|
-
try {
|
|
4676
|
-
const stored = localStorage.getItem(`${storageKey}_${key}`);
|
|
4677
|
-
return stored ? JSON.parse(stored) : defaultValue;
|
|
4678
|
-
}
|
|
4679
|
-
catch {
|
|
4680
|
-
return defaultValue;
|
|
4681
|
-
}
|
|
4682
|
-
};
|
|
4683
|
-
const [storedValue, setStoredValue] = useState(getStoredValue);
|
|
4684
|
-
const setValue = (value) => {
|
|
4685
|
-
try {
|
|
4686
|
-
setStoredValue(value);
|
|
4687
|
-
if (storageKey) {
|
|
4688
|
-
localStorage.setItem(`${storageKey}_${key}`, JSON.stringify(value));
|
|
4689
|
-
}
|
|
4690
|
-
}
|
|
4691
|
-
catch (error) {
|
|
4692
|
-
console.error(`Erro ao salvar ${key} no localStorage:`, error);
|
|
4693
|
-
}
|
|
4694
|
-
};
|
|
4695
|
-
return [storedValue, setValue];
|
|
4696
|
-
};
|
|
4697
4671
|
const getFromLocalStorage = (localStorageKey, key) => {
|
|
4698
4672
|
try {
|
|
4699
4673
|
const stored = localStorage.getItem(`${localStorageKey}_${key}`);
|
|
@@ -4753,7 +4727,7 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4753
4727
|
buttonApplyFilterMessage: 'Aplicar',
|
|
4754
4728
|
noResultsMessage: 'Não há dados disponíveis',
|
|
4755
4729
|
selectColumnsMessage: 'Selecionar colunas',
|
|
4756
|
-
permanentFilterMessage: 'Manter filtro ativo
|
|
4730
|
+
permanentFilterMessage: 'Manter filtro sempre ativo',
|
|
4757
4731
|
},
|
|
4758
4732
|
en: {
|
|
4759
4733
|
filterByMessage: 'Filter by',
|
|
@@ -4767,7 +4741,7 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4767
4741
|
buttonApplyFilterMessage: 'Apply',
|
|
4768
4742
|
noResultsMessage: 'No data available',
|
|
4769
4743
|
selectColumnsMessage: 'Select columns',
|
|
4770
|
-
permanentFilterMessage: 'Keep filter active
|
|
4744
|
+
permanentFilterMessage: 'Keep filter always active',
|
|
4771
4745
|
},
|
|
4772
4746
|
es: {
|
|
4773
4747
|
filterByMessage: 'Filtrar por',
|
|
@@ -4781,7 +4755,7 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4781
4755
|
buttonApplyFilterMessage: 'Aplicar',
|
|
4782
4756
|
noResultsMessage: 'No hay datos disponibles',
|
|
4783
4757
|
selectColumnsMessage: 'Seleccionar columnas',
|
|
4784
|
-
permanentFilterMessage: 'Mantener filtro activo
|
|
4758
|
+
permanentFilterMessage: 'Mantener filtro siempre activo',
|
|
4785
4759
|
},
|
|
4786
4760
|
};
|
|
4787
4761
|
return messages[systemLanguage || 'pt'];
|
|
@@ -4814,23 +4788,6 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4814
4788
|
useEffect(() => {
|
|
4815
4789
|
setSortedData(data);
|
|
4816
4790
|
}, [data]);
|
|
4817
|
-
const [, setStoredFilters] = useLocalStorage(isPermanentFilterEnabled ? localStorageKey : undefined, 'permanentFilterValues', {});
|
|
4818
|
-
const [, setStoredPermanentFilters] = useLocalStorage(isPermanentFilterEnabled ? localStorageKey : undefined, 'permanentFilters', {});
|
|
4819
|
-
useEffect(() => {
|
|
4820
|
-
if (isPermanentFilterEnabled && localStorageKey) {
|
|
4821
|
-
setStoredFilters(filters);
|
|
4822
|
-
}
|
|
4823
|
-
}, [filters, setStoredFilters, isPermanentFilterEnabled, localStorageKey]);
|
|
4824
|
-
useEffect(() => {
|
|
4825
|
-
if (isPermanentFilterEnabled && localStorageKey) {
|
|
4826
|
-
setStoredPermanentFilters(localPermanentFilters);
|
|
4827
|
-
}
|
|
4828
|
-
}, [
|
|
4829
|
-
localPermanentFilters,
|
|
4830
|
-
setStoredPermanentFilters,
|
|
4831
|
-
isPermanentFilterEnabled,
|
|
4832
|
-
localStorageKey,
|
|
4833
|
-
]);
|
|
4834
4791
|
useEffect(() => {
|
|
4835
4792
|
if (isPermanentFilterEnabled && localStorageKey) {
|
|
4836
4793
|
let filtersToApply = {};
|
|
@@ -4890,11 +4847,32 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4890
4847
|
...prev,
|
|
4891
4848
|
[dataIndex]: filterValue ? 'applied' : 'default',
|
|
4892
4849
|
}));
|
|
4893
|
-
if (isPermanentFilterEnabled &&
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4850
|
+
if (isPermanentFilterEnabled && localStorageKey) {
|
|
4851
|
+
try {
|
|
4852
|
+
localStorage.setItem(`${localStorageKey}_permanentFilters`, JSON.stringify(localPermanentFilters));
|
|
4853
|
+
}
|
|
4854
|
+
catch (error) {
|
|
4855
|
+
console.error('Erro ao salvar filtros permanentes:', error);
|
|
4856
|
+
}
|
|
4857
|
+
const permanentFiltersOnly = {};
|
|
4858
|
+
Object.keys(filters).forEach((filterDataIndex) => {
|
|
4859
|
+
if (localPermanentFilters[filterDataIndex] &&
|
|
4860
|
+
filters[filterDataIndex]) {
|
|
4861
|
+
permanentFiltersOnly[filterDataIndex] = filters[filterDataIndex];
|
|
4862
|
+
}
|
|
4863
|
+
});
|
|
4864
|
+
try {
|
|
4865
|
+
localStorage.setItem(`${localStorageKey}_permanentFilterValues`, JSON.stringify(permanentFiltersOnly));
|
|
4866
|
+
}
|
|
4867
|
+
catch (error) {
|
|
4868
|
+
console.error('Erro ao salvar valores dos filtros permanentes:', error);
|
|
4869
|
+
}
|
|
4870
|
+
if (!filterValue) {
|
|
4871
|
+
setLocalPermanentFilters((prev) => ({
|
|
4872
|
+
...prev,
|
|
4873
|
+
[dataIndex]: false,
|
|
4874
|
+
}));
|
|
4875
|
+
}
|
|
4898
4876
|
}
|
|
4899
4877
|
};
|
|
4900
4878
|
const handleClearFilter = (column) => {
|