@grazziotin/react-components-next 2.1.0 → 2.2.0

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 CHANGED
@@ -1,266 +1,272 @@
1
- # Grazziotin React Components Library
2
-
3
- Biblioteca de componentes React reutilizáveis para o projeto Grazziotin, construída com TypeScript, Tailwind CSS, Material UI e Mantine.
4
-
5
- ## Instalação
6
-
7
- ```bash
8
- npm install @grazziotin/react-components-next
9
- ```
10
-
11
- ### Requisitos
12
-
13
- - React `>= 18`
14
- - Tailwind CSS v4 configurado no projeto consumidor
15
- - `ThemeProvider` do MUI e `MantineProvider` do Mantine envolvendo a aplicação
16
-
17
- ### Configuração no projeto consumidor
18
-
19
- Importe os estilos da biblioteca e configure as variáveis CSS do tema:
20
-
21
- ```tsx
22
- import "@grazziotin/react-components-next/styles";
23
-
24
- import { CssBaseline, ThemeProvider, createTheme } from "@mui/material";
25
- import { MantineProvider } from "@mantine/core";
26
- import "@mantine/core/styles.css";
27
-
28
- const theme = createTheme({
29
- typography: { fontFamily: "var(--font-family, inherit)" },
30
- });
31
-
32
- export function AppProviders({ children }: { children: React.ReactNode }) {
33
- return (
34
- <ThemeProvider theme={theme}>
35
- <CssBaseline />
36
- <MantineProvider>{children}</MantineProvider>
37
- </ThemeProvider>
38
- );
39
- }
40
- ```
41
-
42
- ```css
43
- :root {
44
- --primary-color: #00b2a6;
45
- --font-family: "Poppins", sans-serif;
46
- }
47
- ```
48
-
49
- > **Atenção:** vários componentes usam classes do Tailwind CSS e dependem do MUI/Mantine. Certifique-se de que o Tailwind esteja configurado e os providers estejam na raiz da aplicação.
50
-
51
- ## Componentes disponíveis
52
-
53
- | Componente | Descrição |
54
- | ------------ | --------------------------------------------------------------- |
55
- | `Card` | Container com cabeçalho colorido, título, ícone e tooltip |
56
- | `Dialog` | Modal baseado no MUI com título, conteúdo e ações opcionais |
57
- | `DataTable` | Tabela de dados com MUI DataGrid, filtros e textos em português |
58
- | `Tab`/`Tabs` | Abas estilizadas com indicador e tipografia customizáveis |
59
-
60
- ## Funções utilitárias
61
-
62
- | Função | Descrição |
63
- | --------------- | ------------------------------------------------ |
64
- | `cn` | Mescla classes CSS com `clsx` e `tailwind-merge` |
65
- | `nvl` | Retorna valor padrão quando `null`/`undefined` |
66
- | `formatCpfCnpj` | Formata CPF ou CNPJ |
67
- | `formatPhoneBr` | Formata telefone brasileiro |
68
-
69
- ## Uso
70
-
71
- ```tsx
72
- import {
73
- Card,
74
- Dialog,
75
- DataTable,
76
- Tab,
77
- Tabs,
78
- cn,
79
- formatCpfCnpj,
80
- } from "@grazziotin/react-components-next";
81
- import type { GridColDef } from "@mui/x-data-grid";
82
-
83
- const colunas: GridColDef[] = [
84
- { field: "id", headerName: "ID", width: 80 },
85
- { field: "nome", headerName: "Nome", flex: 1 },
86
- { field: "documento", headerName: "CPF/CNPJ", width: 180 },
87
- ];
88
-
89
- const linhas = [
90
- { id: 1, nome: "Ana Silva", documento: formatCpfCnpj("12345678901") },
91
- ];
92
-
93
- export function Example() {
94
- return (
95
- <Card title="Colaboradores" toolTip className={cn("max-w-3xl")}>
96
- <DataTable rows={linhas} columns={colunas} pageSizeOptions={[10, 20]} />
97
- </Card>
98
- );
99
- }
100
- ```
101
-
102
- ## Entry points
103
-
104
- A biblioteca expõe múltiplos pontos de entrada:
105
-
106
- | Import | Conteúdo |
107
- | --------------------------------------------- | ---------------------------------------- |
108
- | `@grazziotin/react-components-next` | Componentes e funções (export principal) |
109
- | `@grazziotin/react-components-next/ui` | Apenas componentes de UI |
110
- | `@grazziotin/react-components-next/functions` | Apenas funções utilitárias |
111
- | `@grazziotin/react-components-next/styles` | CSS compilado da biblioteca |
112
-
113
- ## Componentes
114
-
115
- ### Card
116
-
117
- ```tsx
118
- <Card
119
- title="Título do card"
120
- toolTip={false}
121
- width="100%"
122
- height="auto"
123
- titleColor="var(--primary-color)"
124
- borderRadius="10px"
125
- borderTitle="10px 10px 0 0"
126
- icon={<Icon />}
127
- onClick={() => {}}
128
- className="text-sm"
129
- >
130
- Conteúdo do card
131
- </Card>
132
- ```
133
-
134
- ### Dialog
135
-
136
- ```tsx
137
- <Dialog
138
- open={open}
139
- title="Confirmar exclusão"
140
- onClose={() => setOpen(false)}
141
- maxWidth="sm"
142
- blurBackdrop={false}
143
- actions={<button onClick={() => setOpen(false)}>OK</button>}
144
- >
145
- Deseja realmente excluir este item?
146
- </Dialog>
147
- ```
148
-
149
- ### DataTable
150
-
151
- Wrapper sobre o MUI `DataGrid` com estilização, textos em português e operador de filtro "entre" automático para colunas `string` e `number`. Aceita todas as props do `DataGrid`.
152
-
153
- ```tsx
154
- <DataTable
155
- rows={dados}
156
- columns={colunas}
157
- loading={carregando}
158
- pageSizeOptions={[10, 20, 50]}
159
- />
160
- ```
161
-
162
- ### Tab / Tabs
163
-
164
- ```tsx
165
- const [value, setValue] = useState(0);
166
-
167
- <Tabs
168
- value={value}
169
- onChange={(_, newValue) => setValue(newValue)}
170
- color="var(--primary-color)"
171
- >
172
- <Tab label="Geral" />
173
- <Tab label="Detalhes" />
174
- </Tabs>;
175
- ```
176
-
177
- ## Funções
178
-
179
- ### cn
180
-
181
- ```tsx
182
- cn("px-4 py-2", condicao && "bg-teal-500", "px-6");
183
- ```
184
-
185
- ### nvl
186
-
187
- ```tsx
188
- nvl(valor, "padrão"); // retorna "padrão" se valor for null/undefined
189
- ```
190
-
191
- ### formatCpfCnpj
192
-
193
- ```tsx
194
- formatCpfCnpj("12345678901"); // "123.456.789-01"
195
- formatCpfCnpj("12345678000199"); // "12.345.678/0001-99"
196
- ```
197
-
198
- ### formatPhoneBr
199
-
200
- ```tsx
201
- formatPhoneBr("11987654321"); // "(11) 98765-4321"
202
- formatPhoneBr("1133334444"); // "(11) 3333-4444"
203
- ```
204
-
205
- ## Desenvolvimento
206
-
207
- ```bash
208
- # Instalar dependências
209
- npm install
210
-
211
- # Storybook (visualização e documentação dos componentes)
212
- npm run storybook
213
-
214
- # Build estático do Storybook
215
- npm run build-storybook
216
-
217
- # Build da biblioteca para npm
218
- npm run build:lib
219
-
220
- # Verificar tipos TypeScript
221
- npm run type-check
222
-
223
- # Lint
224
- npm run lint
225
- ```
226
-
227
- ## Publicar no npm
228
-
229
- ```bash
230
- # Fazer login no npm
231
- npm login
232
-
233
- # Publicar (executa build:lib automaticamente via prepublishOnly)
234
- npm publish
235
- ```
236
-
237
- ## Estrutura do projeto
238
-
239
- ```
240
- src/
241
- ├── app/ # Next.js App Router (página inicial mínima)
242
- │ ├── globals.css # Variáveis CSS e tema
243
- │ ├── layout.tsx # Providers MUI + Mantine
244
- │ └── page.tsx
245
- ├── components/
246
- │ ├── index.ts
247
- │ └── ui/
248
- ├── card/
249
- ├── dialog/
250
- ├── data-table/
251
- │ └── tab/
252
- ├── core/ # Utilitários internos
253
- ├── functions/
254
- ├── cn/
255
- ├── nvl/
256
- ├── format-cpf-cnpj/
257
- └── format-phone-br/
258
- ├── providers/
259
- ├── styles/
260
- └── index.css # Entrada do Tailwind para o build CSS
261
- └── index.ts # Entrypoint principal da biblioteca
262
- ```
263
-
264
- ## Licença
265
-
266
- MIT
1
+ # Grazziotin React Components Library
2
+
3
+ Biblioteca de componentes React reutilizáveis para o projeto Grazziotin, construída com TypeScript, Tailwind CSS, Material UI e Mantine.
4
+
5
+ ## Instalação
6
+
7
+ ```bash
8
+ npm install @grazziotin/react-components-next
9
+ ```
10
+
11
+ ### Requisitos
12
+
13
+ - React `>= 18`
14
+ - Tailwind CSS v4 configurado no projeto consumidor
15
+ - `ThemeProvider` do MUI e `MantineProvider` do Mantine envolvendo a aplicação
16
+
17
+ ### Configuração no projeto consumidor
18
+
19
+ Importe os estilos da biblioteca e configure as variáveis CSS do tema:
20
+
21
+ ```tsx
22
+ import "@grazziotin/react-components-next/styles";
23
+
24
+ import { CssBaseline, ThemeProvider, createTheme } from "@mui/material";
25
+ import { MantineProvider } from "@mantine/core";
26
+ import "@mantine/core/styles.css";
27
+
28
+ const theme = createTheme({
29
+ typography: { fontFamily: "var(--font-family, inherit)" },
30
+ });
31
+
32
+ export function AppProviders({ children }: { children: React.ReactNode }) {
33
+ return (
34
+ <ThemeProvider theme={theme}>
35
+ <CssBaseline />
36
+ <MantineProvider>{children}</MantineProvider>
37
+ </ThemeProvider>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ```css
43
+ :root {
44
+ --primary-color: #00b2a6;
45
+ --font-family: "Poppins", sans-serif;
46
+ }
47
+ ```
48
+
49
+ > **Atenção:** vários componentes usam classes do Tailwind CSS e dependem do MUI/Mantine. Certifique-se de que o Tailwind esteja configurado e os providers estejam na raiz da aplicação.
50
+
51
+ ## Componentes disponíveis
52
+
53
+
54
+ | Componente | Descrição |
55
+ | ------------ | --------------------------------------------------------------- |
56
+ | `Card` | Container com cabeçalho colorido, título, ícone e tooltip |
57
+ | `Dialog` | Modal baseado no MUI com título, conteúdo e ações opcionais |
58
+ | `DataTable` | Tabela de dados com MUI DataGrid, filtros e textos em português |
59
+ | `Tab`/`Tabs` | Abas estilizadas com indicador e tipografia customizáveis |
60
+
61
+
62
+ ## Funções utilitárias
63
+
64
+
65
+ | Função | Descrição |
66
+ | --------------- | ------------------------------------------------ |
67
+ | `cn` | Mescla classes CSS com `clsx` e `tailwind-merge` |
68
+ | `nvl` | Retorna valor padrão quando `null`/`undefined` |
69
+ | `formatCpfCnpj` | Formata CPF ou CNPJ |
70
+ | `formatPhoneBr` | Formata telefone brasileiro |
71
+
72
+
73
+ ## Uso
74
+
75
+ ```tsx
76
+ import {
77
+ Card,
78
+ Dialog,
79
+ DataTable,
80
+ Tab,
81
+ Tabs,
82
+ cn,
83
+ formatCpfCnpj,
84
+ } from "@grazziotin/react-components-next";
85
+ import type { GridColDef } from "@mui/x-data-grid";
86
+
87
+ const colunas: GridColDef[] = [
88
+ { field: "id", headerName: "ID", width: 80 },
89
+ { field: "nome", headerName: "Nome", flex: 1 },
90
+ { field: "documento", headerName: "CPF/CNPJ", width: 180 },
91
+ ];
92
+
93
+ const linhas = [
94
+ { id: 1, nome: "Ana Silva", documento: formatCpfCnpj("12345678901") },
95
+ ];
96
+
97
+ export function Example() {
98
+ return (
99
+ <Card title="Colaboradores" toolTip className={cn("max-w-3xl")}>
100
+ <DataTable rows={linhas} columns={colunas} pageSizeOptions={[10, 20]} />
101
+ </Card>
102
+ );
103
+ }
104
+ ```
105
+
106
+ ## Entry points
107
+
108
+ A biblioteca expõe múltiplos pontos de entrada:
109
+
110
+
111
+ | Import | Conteúdo |
112
+ | --------------------------------------------- | ---------------------------------------- |
113
+ | `@grazziotin/react-components-next` | Componentes e funções (export principal) |
114
+ | `@grazziotin/react-components-next/ui` | Apenas componentes de UI |
115
+ | `@grazziotin/react-components-next/functions` | Apenas funções utilitárias |
116
+ | `@grazziotin/react-components-next/styles` | CSS compilado da biblioteca |
117
+
118
+
119
+ ## Componentes
120
+
121
+ ### Card
122
+
123
+ ```tsx
124
+ <Card
125
+ title="Título do card"
126
+ toolTip={false}
127
+ width="100%"
128
+ height="auto"
129
+ titleColor="var(--primary-color)"
130
+ borderRadius="10px"
131
+ borderTitle="10px 10px 0 0"
132
+ icon={<Icon />}
133
+ onClick={() => {}}
134
+ className="text-sm"
135
+ >
136
+ Conteúdo do card
137
+ </Card>
138
+ ```
139
+
140
+ ### Dialog
141
+
142
+ ```tsx
143
+ <Dialog
144
+ open={open}
145
+ title="Confirmar exclusão"
146
+ onClose={() => setOpen(false)}
147
+ maxWidth="sm"
148
+ blurBackdrop={false}
149
+ actions={<button onClick={() => setOpen(false)}>OK</button>}
150
+ >
151
+ Deseja realmente excluir este item?
152
+ </Dialog>
153
+ ```
154
+
155
+ ### DataTable
156
+
157
+ Wrapper sobre o MUI `DataGrid` com estilização, textos em português e operador de filtro "entre" automático para colunas `string` e `number`. Aceita todas as props do `DataGrid`.
158
+
159
+ ```tsx
160
+ <DataTable
161
+ rows={dados}
162
+ columns={colunas}
163
+ loading={carregando}
164
+ pageSizeOptions={[10, 20, 50]}
165
+ />
166
+ ```
167
+
168
+ ### Tab / Tabs
169
+
170
+ ```tsx
171
+ const [value, setValue] = useState(0);
172
+
173
+ <Tabs
174
+ value={value}
175
+ onChange={(_, newValue) => setValue(newValue)}
176
+ color="var(--primary-color)"
177
+ >
178
+ <Tab label="Geral" />
179
+ <Tab label="Detalhes" />
180
+ </Tabs>;
181
+ ```
182
+
183
+ ## Funções
184
+
185
+ ### cn
186
+
187
+ ```tsx
188
+ cn("px-4 py-2", condicao && "bg-teal-500", "px-6");
189
+ ```
190
+
191
+ ### nvl
192
+
193
+ ```tsx
194
+ nvl(valor, "padrão"); // retorna "padrão" se valor for null/undefined
195
+ ```
196
+
197
+ ### formatCpfCnpj
198
+
199
+ ```tsx
200
+ formatCpfCnpj("12345678901"); // "123.456.789-01"
201
+ formatCpfCnpj("12345678000199"); // "12.345.678/0001-99"
202
+ ```
203
+
204
+ ### formatPhoneBr
205
+
206
+ ```tsx
207
+ formatPhoneBr("11987654321"); // "(11) 98765-4321"
208
+ formatPhoneBr("1133334444"); // "(11) 3333-4444"
209
+ ```
210
+
211
+ ## Desenvolvimento
212
+
213
+ ```bash
214
+ # Instalar dependências
215
+ npm install
216
+
217
+ # Storybook (visualização e documentação dos componentes)
218
+ npm run storybook
219
+
220
+ # Build estático do Storybook
221
+ npm run build-storybook
222
+
223
+ # Build da biblioteca para npm
224
+ npm run build:lib
225
+
226
+ # Verificar tipos TypeScript
227
+ npm run type-check
228
+
229
+ # Lint
230
+ npm run lint
231
+ ```
232
+
233
+ ## Publicar no npm
234
+
235
+ ```bash
236
+ # Fazer login no npm
237
+ npm login
238
+
239
+ # Publicar (executa build:lib automaticamente via prepublishOnly)
240
+ npm publish
241
+ ```
242
+
243
+ ## Estrutura do projeto
244
+
245
+ ```
246
+ src/
247
+ ├── app/ # Next.js App Router (página inicial mínima)
248
+ ├── globals.css # Variáveis CSS e tema
249
+ ├── layout.tsx # Providers MUI + Mantine
250
+ └── page.tsx
251
+ ├── components/
252
+ ├── index.ts
253
+ │ └── ui/
254
+ ├── card/
255
+ ├── dialog/
256
+ ├── data-table/
257
+ └── tab/
258
+ ├── core/ # Utilitários internos
259
+ ├── functions/
260
+ ├── cn/
261
+ │ ├── nvl/
262
+ │ ├── format-cpf-cnpj/
263
+ │ └── format-phone-br/
264
+ ├── providers/
265
+ ├── styles/
266
+ │ └── index.css # Entrada do Tailwind para o build CSS
267
+ └── index.ts # Entrypoint principal da biblioteca
268
+ ```
269
+
270
+ ## Licença
271
+
272
+ MIT