blockforce-design-system 2.0.0 → 2.0.1

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.
Files changed (23) hide show
  1. package/MIGRATION.md +148 -116
  2. package/lib/commonjs/components/forms/select/select.styles.js +20 -20
  3. package/lib/commonjs/components/layout/table/table.comp.js.map +1 -1
  4. package/lib/commonjs/components/navigation/pagination/pagination.comp.js +1 -1
  5. package/lib/commonjs/components/navigation/pagination/pagination.comp.js.map +1 -1
  6. package/lib/commonjs/components/navigation/pagination/pagination.styles.js +14 -3
  7. package/lib/commonjs/components/navigation/pagination/pagination.styles.js.map +1 -1
  8. package/lib/commonjs/components/navigation/table-pagination/table-pagination.comp.js +1 -1
  9. package/lib/commonjs/components/navigation/table-pagination/table-pagination.comp.js.map +1 -1
  10. package/lib/index.d.ts +56 -42
  11. package/lib/module/components/forms/select/select.styles.js +20 -20
  12. package/lib/module/components/layout/table/table.comp.js.map +1 -1
  13. package/lib/module/components/navigation/pagination/pagination.comp.js +1 -1
  14. package/lib/module/components/navigation/pagination/pagination.comp.js.map +1 -1
  15. package/lib/module/components/navigation/pagination/pagination.styles.js +17 -6
  16. package/lib/module/components/navigation/pagination/pagination.styles.js.map +1 -1
  17. package/lib/module/components/navigation/table-pagination/table-pagination.comp.js +1 -1
  18. package/lib/module/components/navigation/table-pagination/table-pagination.comp.js.map +1 -1
  19. package/package.json +1 -1
  20. package/lib/commonjs/components/navigation/table-pagination/table-pagination.styles.js +0 -13
  21. package/lib/commonjs/components/navigation/table-pagination/table-pagination.styles.js.map +0 -1
  22. package/lib/module/components/navigation/table-pagination/table-pagination.styles.js +0 -13
  23. package/lib/module/components/navigation/table-pagination/table-pagination.styles.js.map +0 -1
package/MIGRATION.md CHANGED
@@ -30,11 +30,11 @@ O pacote mudou de nome. Há dois caminhos.
30
30
 
31
31
  ## 2. Qual tema usar
32
32
 
33
- | Projeto | Use |
34
- |---|---|
33
+ | Projeto | Use |
34
+ | --------------------------------------------------------------------- | ----------------------------------------------------- |
35
35
  | Que já usa `createTheme({...})` sobre o tema padrão, **como o front** | Continue igual. O merge passa a ser sobre o tema 2.0. |
36
- | Que quer a cara da v1 (verde) | `createTheme(legacyTheme)` |
37
- | Página pública com a marca do cliente | `createClientTheme({ primary, accent, fontFamily })` |
36
+ | Que quer a cara da v1 (verde) | `createTheme(legacyTheme)` |
37
+ | Página pública com a marca do cliente | `createClientTheme({ primary, accent, fontFamily })` |
38
38
 
39
39
  - **O front não deve usar `legacyTheme`.** Ele já era roxo e teal via `createTheme`, e o `legacyTheme` volta o verde.
40
40
  - **O que mudou no tema padrão:** a seção 4.3 lista cada valor.
@@ -45,55 +45,58 @@ O pacote mudou de nome. Há dois caminhos.
45
45
 
46
46
  ### 3.1 Renomeados (o nome antigo continua funcionando)
47
47
 
48
- | Nome v1 | Nome novo | Tipo v1 → novo |
49
- |---|---|---|
50
- | `CheckBox` | `Checkbox` | `CheckBoxProps` → `CheckboxProps` |
51
- | `DragNDrop` | `FileDropzone` | `DragNDropProps` → `FileDropzoneProps` |
52
- | `Slider` | `Carousel` | `SliderProps` → `CarouselProps` |
53
- | `Treeview` | `TreeView` | `TreeviewProps` → `TreeViewProps` |
48
+ | Nome v1 | Nome novo | Tipo v1 → novo |
49
+ | ----------------------------------- | ----------------------------- | ------------------------------------------ |
50
+ | `CheckBox` | `Checkbox` | `CheckBoxProps` → `CheckboxProps` |
51
+ | `DragNDrop` | `FileDropzone` | `DragNDropProps` → `FileDropzoneProps` |
52
+ | `Slider` | `Carousel` | `SliderProps` → `CarouselProps` |
53
+ | `Treeview` | `TreeView` | `TreeviewProps` → `TreeViewProps` |
54
+ | `TablePagination` (`total` = itens) | `Pagination` com `totalItems` | `TablePaginationProps` → `PaginationProps` |
54
55
 
55
56
  Em cada par, o nome antigo e o novo apontam para o mesmo componente. Um teste confere isso.
56
57
 
57
58
  ### 3.2 Novos
58
59
 
59
- | Componente | Para que serve |
60
- |---|---|
61
- | `IconButton` | Botão só com ícone. O `label` é obrigatório e vira o nome acessível. |
62
- | `RadioGroup` | Uma escolha entre poucas opções visíveis. |
63
- | `SearchInput` | Busca com lupa, `debounce` e botão de limpar. |
64
- | `DatePicker`, `DateRangePicker` | Uma data, ou um período com atalhos. O valor é `YYYY-MM-DD`. |
65
- | `Tag` | Etiqueta curta de status ou categoria. Tem `loading`, ícones e gradiente. |
66
- | `Toast` + `ToastProvider` + `useToast()` | Aviso rápido: `toast.success/error/warning/info(msg, { duration?, closable? })`. |
67
- | `Alert` | Aviso fixo na página. |
68
- | `EmptyState` | Área vazia, carregando ou com erro (`state`). |
69
- | `ProgressBar` | Quanto de uma tarefa já foi feito. |
70
- | `Skeleton` | Forma do conteúdo enquanto carrega. |
71
- | `ConfirmDialog` + `ConfirmDialogProvider` + `useConfirm()` | Confirmação antes de uma ação importante, com motivo opcional. |
72
- | `ActionMenu` | Menu de ações de um item. |
73
- | `Breadcrumb` | Caminho de navegação. |
74
- | `Stepper` | Passos de um fluxo longo. |
75
- | `ViewToggle` | Troca de visão do mesmo conteúdo (lista ou árvore, por exemplo). |
76
- | `Card` | Superfície de um bloco (`elevated`, `outlined` ou `subtle`), com borda em gradiente opcional, que pode ser animada. |
77
- | `StatCard` | Indicador de dashboard. |
78
- | `TitleCard` | Cabeçalho de card. |
79
- | `Divider` | Linha que separa blocos. |
80
- | `Calendar` | Mês com eventos por dia. |
81
- | `Matrix` | Grade de linhas × colunas: riscos, materialidade, status. |
82
- | `InfoItem` | Par rótulo e valor. |
83
- | `TintedSection` | Seção com fundo tingido na cor do tema. |
84
- | `TreeNode` (`.Title`, `.Caption`) | Nó da árvore de rastreabilidade. Com `onClick`, exige `aria-label`. |
85
- | `CanvasPanel`, `CanvasButton`, `DirectionToggle`, `FullscreenToggle` | Barra de ferramentas do canvas da árvore. |
86
- | `SidePanel` + `SelectableItem` | Lista lateral recolhível, com busca e item selecionado. |
87
- | `ChartLegend` | Legenda de gráfico. |
88
- | `IconBox` | Ícone dentro de uma caixinha. |
60
+ | Componente | Para que serve |
61
+ | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
62
+ | `IconButton` | Botão só com ícone. O `label` é obrigatório e vira o nome acessível. |
63
+ | `RadioGroup` | Uma escolha entre poucas opções visíveis. |
64
+ | `SearchInput` | Busca com lupa, `debounce` e botão de limpar. |
65
+ | `DatePicker`, `DateRangePicker` | Uma data, ou um período com atalhos. O valor é `YYYY-MM-DD`. |
66
+ | `Tag` | Etiqueta curta de status ou categoria. Tem `loading`, ícones e gradiente. |
67
+ | `Toast` + `ToastProvider` + `useToast()` | Aviso rápido: `toast.success/error/warning/info(msg, { duration?, closable? })`. |
68
+ | `Alert` | Aviso fixo na página. |
69
+ | `EmptyState` | Área vazia, carregando ou com erro (`state`). |
70
+ | `ProgressBar` | Quanto de uma tarefa já foi feito. |
71
+ | `Skeleton` | Forma do conteúdo enquanto carrega. |
72
+ | `ConfirmDialog` + `ConfirmDialogProvider` + `useConfirm()` | Confirmação antes de uma ação importante, com motivo opcional. |
73
+ | `ActionMenu` | Menu de ações de um item. |
74
+ | `Breadcrumb` | Caminho de navegação. |
75
+ | `Stepper` | Passos de um fluxo longo. |
76
+ | `ViewToggle` | Troca de visão do mesmo conteúdo (lista ou árvore, por exemplo). |
77
+ | `Card` | Superfície de um bloco (`elevated`, `outlined` ou `subtle`), com borda em gradiente opcional, que pode ser animada. |
78
+ | `StatCard` | Indicador de dashboard. |
79
+ | `TitleCard` | Cabeçalho de card. |
80
+ | `Divider` | Linha que separa blocos. |
81
+ | `Calendar` | Mês com eventos por dia. |
82
+ | `Matrix` | Grade de linhas × colunas: riscos, materialidade, status. |
83
+ | `InfoItem` | Par rótulo e valor. |
84
+ | `TintedSection` | Seção com fundo tingido na cor do tema. |
85
+ | `TreeNode` (`.Title`, `.Caption`) | Nó da árvore de rastreabilidade. Com `onClick`, exige `aria-label`. |
86
+ | `CanvasPanel`, `CanvasButton`, `DirectionToggle`, `FullscreenToggle` | Barra de ferramentas do canvas da árvore. |
87
+ | `SidePanel` + `SelectableItem` | Lista lateral recolhível, com busca e item selecionado. |
88
+ | `ChartLegend` | Legenda de gráfico. |
89
+ | `IconBox` | Ícone dentro de uma caixinha. |
89
90
 
90
91
  **Hooks novos:**
92
+
91
93
  - `useBreakpoint`, `useIsMobile`, `useIsTablet` e `useMediaQuery`. Eles leem a tela já no primeiro render; em Next, use `{ ssr: true }`.
92
94
  - `useToast` e `useConfirm`.
93
95
 
94
96
  ### 3.3 O que mudou nos que já existiam
95
97
 
96
98
  Legenda:
99
+
97
100
  - **+** prop nova;
98
101
  - **~** prop alterada;
99
102
  - **dep** prop marcada como `@deprecated`.
@@ -101,6 +104,7 @@ Legenda:
101
104
  Nenhuma prop foi removida.
102
105
 
103
106
  **Button**
107
+
104
108
  - **+ `variant`:** ganhou `gradient` e `gradientOutlined`.
105
109
  - **+ `size`:** `sm`, `md` ou `lg` (40, 44 ou 52 px).
106
110
  - `size="small"` da v1 é aceito e não muda nada.
@@ -111,18 +115,21 @@ Nenhuma prop foi removida.
111
115
  - **Sombra:** `theme.shadow.button`.
112
116
 
113
117
  **Spinner**
118
+
114
119
  - Virou componente, com `role="status"`.
115
120
  - **+ `variant`:** `arc` (o padrão novo, um arco fino), `gradient` ou `classic` (o anel da v1).
116
121
  - **+ `label`.**
117
122
  - **~ `color`:** aceita também `'currentColor'`.
118
123
 
119
124
  **Tooltip**
125
+
120
126
  - **+ `clickable`**, que abre no clique.
121
127
  - **Posicionamento:** vira para o outro lado quando não cabe e acompanha a rolagem.
122
128
  - **Acessibilidade:** `role="tooltip"`, abre no foco do teclado e fecha com Esc.
123
129
  - **Camada:** z-index 9999 → 1500.
124
130
 
125
131
  **Input, Select, TextArea e Autocomplete**
132
+
126
133
  - **+ `borderColor`.**
127
134
  - **Acessibilidade:** rótulo e mensagem ligados ao campo, e `aria-invalid` no erro.
128
135
  - **Borda:** só o erro pinta a borda. Sucesso e alerta mudam só a mensagem.
@@ -130,12 +137,14 @@ Nenhuma prop foi removida.
130
137
  - **Mensagens:** usam `stateText`.
131
138
 
132
139
  **Checkbox**
140
+
133
141
  - **+ `variant`:** `default` ou `gradient`.
134
142
  - **+ `align`.**
135
143
  - **+ `borderColor`.**
136
144
  - **Acessibilidade:** atributos aria e foco por teclado.
137
145
 
138
146
  **Switch**
147
+
139
148
  - **+ `size`:** `sm`, `md` ou `lg`. Um valor desconhecido cai no `md`.
140
149
  - **Trilho ligado:** `brand.gradient`, no lugar de `secondary`.
141
150
  - **Acessibilidade:** `role="switch"`.
@@ -143,15 +152,18 @@ Nenhuma prop foi removida.
143
152
  **MonthPicker:** ano e setas passaram de `secondary` para `primary`.
144
153
 
145
154
  **FileDropzone**
155
+
146
156
  - **+ `gradient`.**
147
157
  - **Cor:** borda, ícone e fundo ao arrastar passaram de `secondary` para `primary`.
148
158
  - Saiu o `console.log`.
149
159
 
150
160
  **FilePreview / FileImagePreview**
161
+
151
162
  - A prévia não cria mais uma URL a cada render.
152
163
  - Um arquivo que não é imagem mostra um ícone.
153
164
 
154
165
  **Modal**
166
+
155
167
  - **Acessibilidade:** `role="dialog"`, `aria-modal` e "Fechar" com nome.
156
168
  - **Foco:** fica preso dentro do modal e volta ao elemento de origem ao fechar.
157
169
  - **Esc:** fecha o modal, mas não quando um controle interno (DatePicker, ActionMenu) já tratou a tecla.
@@ -159,24 +171,29 @@ Nenhuma prop foi removida.
159
171
  - **Camada:** z-index 999 → **1200**.
160
172
 
161
173
  **Drawer**
174
+
162
175
  - **+ `anchor`:** **dep** `archor`.
163
176
  - **Camada:** z-index 1000 → 1100.
164
177
 
165
178
  **Popover**
179
+
166
180
  - **Camada:** z-index 1000 → **1300**, acima do modal.
167
181
  - Ganhou o atributo `data-popover`.
168
182
 
169
183
  **Accordion:** o cabeçalho é focável, com `aria-expanded`, e abre com Enter ou Espaço.
170
184
 
171
185
  **Carousel**
186
+
172
187
  - **+ `hideButtonsOnMobile`.**
173
188
  - As setas só aparecem quando há o que rolar.
174
189
 
175
190
  **TreeView**
191
+
176
192
  - **`openAll`:** acompanha a prop. Na v1 só valia na montagem.
177
193
  - **Valor `null`:** não quebra mais.
178
194
 
179
195
  **Table**
196
+
180
197
  - **+ `onRowClick`:** a linha fica clicável e focável.
181
198
  - **+ `hoverable`:** fundo `grey_6` no hover.
182
199
  - **+ `mobileLayout`:** `scroll` ou `cards`.
@@ -184,35 +201,48 @@ Nenhuma prop foi removida.
184
201
 
185
202
  **Pagination:** os números viraram `<button>`, com `aria-current`. O visual é igual ao da v1.
186
203
 
187
- **TablePagination:** guarda os itens por página internamente.
204
+ **TablePagination:** virou o próprio `Pagination` com `totalItems`. O componente antigo continua funcionando como apelido.
205
+
206
+ **Pagination:**
207
+
208
+ - **+ `totalItems`:** liga o rodapé completo de tabela (itens por página, páginas e contagem). As páginas saem de `totalItems` e `itemsPerPage`.
209
+ - **+ `itemsPerPage`, `itemsPerPageOptions`, `onChangeItemsPerPage`, `viewText`, `itemsText`, `ofText`:** vieram do `TablePagination`. `itemsPerPageOptions` é novo (padrão `[10, 50, 100]`).
210
+ - **~ `total`:** continua sendo o número de páginas, agora opcional quando há `totalItems`.
211
+ - A contagem ("20 de 78") acompanha a página clicada, mesmo sem `current` controlado.
188
212
 
189
213
  **Tabs**
214
+
190
215
  - **~ `tabs`:** aceita `string[]` ou `{ id, label, icon?, badge?, disabled? }[]`.
191
216
  - **Visual:** sempre pílula, com a ativa de borda em gradiente. **dep** `color` e **dep** `variant` não têm efeito.
192
217
  - **Acessibilidade:** navegação por setas.
193
218
 
194
219
  **Timeline**
220
+
195
221
  - **+ `variant`:** `numbered` ou `compact`.
196
222
  - **+ `status` por item:** `done`, `active` ou `pending`.
197
223
  - **Marcador:** o fundo passou a usar `color-mix`.
198
224
 
199
225
  **Text**
226
+
200
227
  - **~ `size`:** além dos valores da v1, aceita `caption`, `bodySm`, `body`, `bodyLg`, `h4`, `h3`, `h2`, `h1` e `display`.
201
228
  - **+ `weight`:** por nome.
202
229
  - **+ `lineHeight`.**
203
230
  - O `fontWeight` numérico continua valendo.
204
231
 
205
232
  **Box**
233
+
206
234
  - **Espaços:** aceitam `0`, `0.5`, `1.5` e os nomes `xs`…`2xl`.
207
235
  - **`boxShadow` e `borderRadius`:** aceitam os nomes do tema.
208
236
 
209
237
  **Icon**
238
+
210
239
  - **+ `gradient`.**
211
240
  - **Lucide:** aceita ícones no formato `lu:nome`.
212
241
 
213
242
  **Avatar:** o fundo padrão passou de `secondary` para `primary`, e a letra fica branca ou escura conforme o fundo.
214
243
 
215
244
  **DoughnutChart**
245
+
216
246
  - **+ `legend`:** `side` ou `bottom`.
217
247
  - **`customContent`:** não tem mais o tamanho e a cor do texto sobrescritos pelo DS.
218
248
 
@@ -226,62 +256,62 @@ Nenhuma prop foi removida.
226
256
 
227
257
  ### 4.1 Chaves novas
228
258
 
229
- | Grupo | Valores no tema padrão |
230
- |---|---|
231
- | `colors.white` | `#FFFFFF` |
232
- | `colors.brand.gradient` | `linear-gradient(45deg, #6633CC 0%, #00CC99 100%)`, o único gradiente da marca |
233
- | `colors.border.focus` | `#6633CC` |
234
- | `colors.interactive` | `#1779B2` (links) |
235
- | `colors.stateSubtle` | fundos claros: success `#ECFDF3`, warning `#FEF3E7`, error `#FDECEA`, info `#E8F3FA` |
236
- | `colors.stateText` | texto escuro: success `#067647`, warning `#DC6803`, error `#C0392B`, info `#0F5E8C` |
237
- | `colors.chart` | purple `#6633CC`, lilac `#B692F6`, lightBlue `#ABD0FD`, blue `#36BFFA`, teal `#00CC99`, orange `#FAC074`, pink `#F670C7`, e grey `#D9D9D9`, que é só para "outros" |
238
- | `typography.fontFamily` / `monoFamily` | `Rubik, system-ui, -apple-system, 'Segoe UI', sans-serif` / `'JetBrains Mono', …` |
239
- | `typography.fontWeight` | light 300, regular 400, medium 500, semibold 600, bold 700 |
240
- | `typography.lineHeight` | tight 1.1, snug 1.3, normal 1.5, relaxed 1.6 |
241
- | `typography.textSize` | caption 12, bodySm 14, body 16, bodyLg 18, h4 22, h3 28, h2 40, h1 56, display 72 (px) |
242
- | `spacing` | novas: `0`, `0.5` (4px), `1.5` (12px), `xs` 4, `sm` 8, `md` 16, `lg` 24, `xl` 32, `2xl` 48. As chaves 1–10 não mudaram. |
243
- | `radius` | none 0, sm 4, md 8, lg 12, xl 16, 2xl 24, full 9999 |
244
- | `shadow` | xs, sm, md, lg, xl, focus e button |
245
- | `breakpoints` | xs 480, sm 640, md 768, lg 1024, xl 1280 |
246
- | `zIndex` | drawer 1100, modal 1200, dropdown 1300, toast 1400, tooltip 1500 |
247
- | `motion` | duration fast 120ms, normal 200ms, slow 300ms; easing default, enter e exit |
259
+ | Grupo | Valores no tema padrão |
260
+ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
261
+ | `colors.white` | `#FFFFFF` |
262
+ | `colors.brand.gradient` | `linear-gradient(45deg, #6633CC 0%, #00CC99 100%)`, o único gradiente da marca |
263
+ | `colors.border.focus` | `#6633CC` |
264
+ | `colors.interactive` | `#1779B2` (links) |
265
+ | `colors.stateSubtle` | fundos claros: success `#ECFDF3`, warning `#FEF3E7`, error `#FDECEA`, info `#E8F3FA` |
266
+ | `colors.stateText` | texto escuro: success `#067647`, warning `#DC6803`, error `#C0392B`, info `#0F5E8C` |
267
+ | `colors.chart` | purple `#6633CC`, lilac `#B692F6`, lightBlue `#ABD0FD`, blue `#36BFFA`, teal `#00CC99`, orange `#FAC074`, pink `#F670C7`, e grey `#D9D9D9`, que é só para "outros" |
268
+ | `typography.fontFamily` / `monoFamily` | `Rubik, system-ui, -apple-system, 'Segoe UI', sans-serif` / `'JetBrains Mono', …` |
269
+ | `typography.fontWeight` | light 300, regular 400, medium 500, semibold 600, bold 700 |
270
+ | `typography.lineHeight` | tight 1.1, snug 1.3, normal 1.5, relaxed 1.6 |
271
+ | `typography.textSize` | caption 12, bodySm 14, body 16, bodyLg 18, h4 22, h3 28, h2 40, h1 56, display 72 (px) |
272
+ | `spacing` | novas: `0`, `0.5` (4px), `1.5` (12px), `xs` 4, `sm` 8, `md` 16, `lg` 24, `xl` 32, `2xl` 48. As chaves 1–10 não mudaram. |
273
+ | `radius` | none 0, sm 4, md 8, lg 12, xl 16, 2xl 24, full 9999 |
274
+ | `shadow` | xs, sm, md, lg, xl, focus e button |
275
+ | `breakpoints` | xs 480, sm 640, md 768, lg 1024, xl 1280 |
276
+ | `zIndex` | drawer 1100, modal 1200, dropdown 1300, toast 1400, tooltip 1500 |
277
+ | `motion` | duration fast 120ms, normal 200ms, slow 300ms; easing default, enter e exit |
248
278
 
249
279
  ### 4.2 Chaves da v1 que continuam (`@deprecated`)
250
280
 
251
- | v1 | Use |
252
- |---|---|
253
- | `colors.custom.*` | `brand`, `state` ou `chart`. Os valores não mudaram. |
254
- | `typography.family` | `typography.fontFamily` |
255
- | `typography.title_size`, `body_size` | `typography.textSize`. Os valores não mudaram. |
256
- | `border_radius.*` | `radius`. Os valores não mudaram. |
257
- | `box_shadow.*` | `shadow`. Parte dos valores mudou (4.3). |
281
+ | v1 | Use |
282
+ | ------------------------------------ | ---------------------------------------------------- |
283
+ | `colors.custom.*` | `brand`, `state` ou `chart`. Os valores não mudaram. |
284
+ | `typography.family` | `typography.fontFamily` |
285
+ | `typography.title_size`, `body_size` | `typography.textSize`. Os valores não mudaram. |
286
+ | `border_radius.*` | `radius`. Os valores não mudaram. |
287
+ | `box_shadow.*` | `shadow`. Parte dos valores mudou (4.3). |
258
288
 
259
289
  **De `custom.*` para `chart.*`:**
260
290
 
261
- | v1 | 2.0 |
262
- |---|---|
263
- | `custom.purple` (`#7F56D9`) | `chart.purple` (`#6633CC`), um tom diferente: o roxo da marca |
264
- | `custom.light_purple` (`#B692F6`) | `chart.lilac` |
265
- | `custom.blue` (`#ABD0FD`) | `chart.lightBlue` |
266
- | `custom.light_blue` (`#36BFFA`) | `chart.blue` |
267
- | `custom.orange` (`#DC6803`) | `stateText.warning`; para gráfico, `chart.orange` (`#FAC074`, mais claro) |
268
- | `custom.white` | `white` |
291
+ | v1 | 2.0 |
292
+ | --------------------------------- | ------------------------------------------------------------------------- |
293
+ | `custom.purple` (`#7F56D9`) | `chart.purple` (`#6633CC`), um tom diferente: o roxo da marca |
294
+ | `custom.light_purple` (`#B692F6`) | `chart.lilac` |
295
+ | `custom.blue` (`#ABD0FD`) | `chart.lightBlue` |
296
+ | `custom.light_blue` (`#36BFFA`) | `chart.blue` |
297
+ | `custom.orange` (`#DC6803`) | `stateText.warning`; para gráfico, `chart.orange` (`#FAC074`, mais claro) |
298
+ | `custom.white` | `white` |
269
299
 
270
300
  A tabela completa, com os hex de cada um, está no Storybook, em **Migrando da v1**.
271
301
 
272
302
  ### 4.3 Valores que mudaram no tema padrão
273
303
 
274
- | Chave | v1 | 2.0 |
275
- |---|---|---|
276
- | `colors.primary` | `#246153` (verde) | `#6633CC` (roxo) |
277
- | `colors.secondary` | `#9BD19D` (verde claro) | `#00CC99` (teal) |
278
- | `colors.grey_6` | `#F8FCFB` (esverdeado) | `#F8F7FC` (toque roxo) |
279
- | `typography.family` | `Rubik, 'sans-serif'` (o fallback não funcionava) | `Rubik, system-ui, …, sans-serif` |
280
- | `box_shadow.box` | `2px 4px 4px rgba(0,0,0,.1)` | `0px 2px 8px 0px #0000000F` |
281
- | `box_shadow.card` | `0px 1px 4px 0px rgba(36,97,83,.12)` (verde) | `0px 2px 8px 0px #0000000F` |
282
- | `box_shadow.input` | `0px 1px 2px 0px rgba(16,24,40,.05);` | `0px 1px 2px 0px #0000000D` |
283
- | `box_shadow.dropdown` | sombra dupla v1 | `0px 8px 32px 0px #0000001A` |
284
- | `box_shadow.active` | anel verde | anel roxo `0 0 0 4px #6633CC3D` |
304
+ | Chave | v1 | 2.0 |
305
+ | --------------------- | ------------------------------------------------- | --------------------------------- |
306
+ | `colors.primary` | `#246153` (verde) | `#6633CC` (roxo) |
307
+ | `colors.secondary` | `#9BD19D` (verde claro) | `#00CC99` (teal) |
308
+ | `colors.grey_6` | `#F8FCFB` (esverdeado) | `#F8F7FC` (toque roxo) |
309
+ | `typography.family` | `Rubik, 'sans-serif'` (o fallback não funcionava) | `Rubik, system-ui, …, sans-serif` |
310
+ | `box_shadow.box` | `2px 4px 4px rgba(0,0,0,.1)` | `0px 2px 8px 0px #0000000F` |
311
+ | `box_shadow.card` | `0px 1px 4px 0px rgba(36,97,83,.12)` (verde) | `0px 2px 8px 0px #0000000F` |
312
+ | `box_shadow.input` | `0px 1px 2px 0px rgba(16,24,40,.05);` | `0px 1px 2px 0px #0000000D` |
313
+ | `box_shadow.dropdown` | sombra dupla v1 | `0px 8px 32px 0px #0000001A` |
314
+ | `box_shadow.active` | anel verde | anel roxo `0 0 0 4px #6633CC3D` |
285
315
 
286
316
  **Sem mudança:** `grey_1`…`grey_5`, `state.*`, `custom.*`, `title_size`, `body_size`, `border_radius` e `spacing` 1–10.
287
317
 
@@ -291,15 +321,16 @@ O `legacyTheme` mantém todos os valores da v1.
291
321
 
292
322
  **Novos:**
293
323
 
294
- | Utilitário | O que faz |
295
- |---|---|
296
- | `defaultTheme`, `GlobalStyle`, `tokens` | Agora exportados. |
297
- | `media.up/down` | Breakpoints para usar em styled-components. |
298
- | `getChartColors(theme)`, `CHART_COLOR_ORDER`, `CHART_OTHER_COLOR` | Paleta de gráfico: 7 séries, mais o cinza de "outros". |
299
- | `getContrastRatio`, `getReadableTextColor`, `mixColors` | Contraste e mistura de cores. |
300
- | `createClientTheme` | Monta o tema de cliente. Só aceita hex `#RGB` ou `#RRGGBB`. |
324
+ | Utilitário | O que faz |
325
+ | ----------------------------------------------------------------- | ----------------------------------------------------------- |
326
+ | `defaultTheme`, `GlobalStyle`, `tokens` | Agora exportados. |
327
+ | `media.up/down` | Breakpoints para usar em styled-components. |
328
+ | `getChartColors(theme)`, `CHART_COLOR_ORDER`, `CHART_OTHER_COLOR` | Paleta de gráfico: 7 séries, mais o cinza de "outros". |
329
+ | `getContrastRatio`, `getReadableTextColor`, `mixColors` | Contraste e mistura de cores. |
330
+ | `createClientTheme` | Monta o tema de cliente. Só aceita hex `#RGB` ou `#RRGGBB`. |
301
331
 
302
332
  **Corrigidos:**
333
+
303
334
  - `getThemeContrastColor` calculava o azul errado.
304
335
  - `getThemeSpacing(0)` quebrava.
305
336
  - `getThemeColor` aceita caminhos com ponto, como `'state.success'` e `'chart.purple'`.
@@ -307,6 +338,7 @@ O `legacyTheme` mantém todos os valores da v1.
307
338
  ### 4.5 Tokens fora do React
308
339
 
309
340
  O build gera dois arquivos a partir de `tokens/*.tokens.json`, no formato W3C DTCG:
341
+
310
342
  - **`lib/tokens/tokens.css`:** variáveis `--bf-*`.
311
343
  - **`lib/tokens/blockforce.tokens.json`:** os tokens em DTCG.
312
344
 
@@ -316,12 +348,12 @@ Use para landing, slides, vídeos e HTML sem React.
316
348
 
317
349
  ## 5. Pacote e ferramentas
318
350
 
319
- | | v1 | 2.0 |
320
- |---|---|---|
321
- | Nome | `fairfashion-design-system` | `blockforce-design-system` |
322
- | Release | GitLab | GitHub Actions (`release.yml`) e npm |
323
- | Storybook | 7.6 | 10, com temas Blockforce, Legacy v1 e Cliente exemplo, painel de acessibilidade, Fundamentos e Visão geral |
324
- | Build | `tsc && rollup` | `yarn tokens && tsc && rollup` |
351
+ | | v1 | 2.0 |
352
+ | --------- | --------------------------- | ---------------------------------------------------------------------------------------------------------- |
353
+ | Nome | `fairfashion-design-system` | `blockforce-design-system` |
354
+ | Release | GitLab | GitHub Actions (`release.yml`) e npm |
355
+ | Storybook | 7.6 | 10, com temas Blockforce, Legacy v1 e Cliente exemplo, painel de acessibilidade, Fundamentos e Visão geral |
356
+ | Build | `tsc && rollup` | `yarn tokens && tsc && rollup` |
325
357
 
326
358
  ---
327
359
 
@@ -329,27 +361,27 @@ Use para landing, slides, vídeos e HTML sem React.
329
361
 
330
362
  ### 6.1 O que muda sem mudar código
331
363
 
332
- | Onde | O que acontece | Como lidar |
333
- |---|---|---|
334
- | Button `contained` sem `backgroundColor` | O fundo vai de `secondary` para `primary`. | Passe `backgroundColor="secondary"` onde quiser manter. |
335
- | Button `loading` | Não fica mais `disabled`. | Testes com `toBeDisabled()` precisam olhar `aria-busy`. |
336
- | Spinner sem `variant` | Vira arco fino. | Use `variant="classic"` para o anel da v1. |
337
- | Campos com `state="success"` ou `"warning"` | A borda não muda de cor. | Use `borderColor`, se precisar. |
338
- | Foco dos campos, Switch, Avatar, MonthPicker, FileDropzone | Visual novo. | Nada. |
339
- | Tabs do DS | Sempre pílula. | Nada. |
340
- | `grey_6` e sombras | Novos valores (4.3). | Nada. |
341
- | Modal (z-index 1200) | Listas próprias com z-index 1000 ficam atrás dele. | Suba essas listas para `theme.zIndex.dropdown` (1300). |
364
+ | Onde | O que acontece | Como lidar |
365
+ | ---------------------------------------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------- |
366
+ | Button `contained` sem `backgroundColor` | O fundo vai de `secondary` para `primary`. | Passe `backgroundColor="secondary"` onde quiser manter. |
367
+ | Button `loading` | Não fica mais `disabled`. | Testes com `toBeDisabled()` precisam olhar `aria-busy`. |
368
+ | Spinner sem `variant` | Vira arco fino. | Use `variant="classic"` para o anel da v1. |
369
+ | Campos com `state="success"` ou `"warning"` | A borda não muda de cor. | Use `borderColor`, se precisar. |
370
+ | Foco dos campos, Switch, Avatar, MonthPicker, FileDropzone | Visual novo. | Nada. |
371
+ | Tabs do DS | Sempre pílula. | Nada. |
372
+ | `grey_6` e sombras | Novos valores (4.3). | Nada. |
373
+ | Modal (z-index 1200) | Listas próprias com z-index 1000 ficam atrás dele. | Suba essas listas para `theme.zIndex.dropdown` (1300). |
342
374
  | Estilos do projeto que sobrescrevem estilos internos do DS | Podem ganhar ou perder pela ordem de carregamento dos estilos. | Revise as telas. O DoughnutChart foi um caso real, já corrigido. |
343
375
 
344
376
  ### 6.2 Compatibilidades adicionadas
345
377
 
346
- | O quê | Detalhe |
347
- |---|---|
348
- | Button `size="small"` | Aceito no tipo (`LegacyButtonSize`) e sem efeito visual. O `PrimaryButton` do front compila e renderiza igual à v1. |
349
- | `size` desconhecido no Button ou no Switch | Cai no padrão, em vez de quebrar a tela. |
350
- | `customRender` da Table | Aceita `null`. |
351
- | `customContent` do DoughnutChart | Mantém o estilo do projeto. |
352
- | Nomes, props e chaves de tema da v1 | Todos continuam aceitos (3.1, 4.2). |
378
+ | O quê | Detalhe |
379
+ | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- |
380
+ | Button `size="small"` | Aceito no tipo (`LegacyButtonSize`) e sem efeito visual. O `PrimaryButton` do front compila e renderiza igual à v1. |
381
+ | `size` desconhecido no Button ou no Switch | Cai no padrão, em vez de quebrar a tela. |
382
+ | `customRender` da Table | Aceita `null`. |
383
+ | `customContent` do DoughnutChart | Mantém o estilo do projeto. |
384
+ | Nomes, props e chaves de tema da v1 | Todos continuam aceitos (3.1, 4.2). |
353
385
 
354
386
  ### 6.3 Tipos ao testar com o código-fonte do DS
355
387
 
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("styled-components"),o=require("../form.styles.js"),t=require("../../layout/box/box.comp.js"),r=require("../../../theme/theme.util.js");const i=e.styled(t.Box)`
1
+ "use strict";var e=require("styled-components"),o=require("../form.styles.js"),t=require("../../../theme/theme.util.js"),r=require("../../layout/box/box.comp.js");const i=e.styled(r.Box)`
2
2
  position: relative;
3
3
  height: 44px;
4
4
  width: 100%;
@@ -7,9 +7,9 @@
7
7
  width: 100%;
8
8
  border-radius: ${({theme:e})=>e.border_radius.input};
9
9
  padding: ${({theme:e,padding:o})=>o||`${e.spacing[1]} ${e.spacing[2]}`};
10
- padding-right: ${({theme:e})=>`calc(${r.getThemeSpacing(2,e)} + 20px)`};
10
+ padding-right: ${({theme:e})=>`calc(${t.getThemeSpacing(2,e)} + 20px)`};
11
11
  font-size: ${({theme:e})=>e.typography.body_size.normal};
12
- color: ${({value:e,theme:o})=>e?r.getThemeColor("grey_1",o):r.getThemeColor("grey_3",o)};
12
+ color: ${({value:e,theme:o})=>e?t.getThemeColor("grey_1",o):t.getThemeColor("grey_3",o)};
13
13
  cursor: pointer;
14
14
 
15
15
  -webkit-appearance: none;
@@ -22,64 +22,64 @@
22
22
  ${o.fieldFocus}
23
23
 
24
24
  &:disabled {
25
- background-color: ${({theme:e})=>r.getThemeColor("grey_5",e)};
25
+ background-color: ${({theme:e})=>t.getThemeColor("grey_5",e)};
26
26
  }
27
27
 
28
- ${({variant:e,theme:o})=>"outlined"===e?`\n border: 1px solid ${r.getThemeColor("grey_4",o)};\n box-shadow: ${o.box_shadow.input};\n background-color: ${r.getThemeColor("white",o)};\n `:"\n border: none;\n box-shadow: none;\n "}
28
+ ${({variant:e,theme:o})=>"outlined"===e?`\n border: 1px solid ${t.getThemeColor("grey_4",o)};\n box-shadow: ${o.box_shadow.input};\n background-color: ${t.getThemeColor("white",o)};\n `:"\n border: none;\n box-shadow: none;\n "}
29
29
 
30
30
  ${o.fieldBorder}
31
- `,a=e.styled(t.Box)`
31
+ `,a=e.styled(r.Box)`
32
32
  position: absolute;
33
33
  right: 0;
34
34
  height: 100%;
35
35
  align-items: center;
36
36
  z-index: 999;
37
- padding-right: ${({theme:e})=>r.getThemeSpacing(2,e)};
37
+ padding-right: ${({theme:e})=>t.getThemeSpacing(2,e)};
38
38
  cursor: pointer;
39
- `,d=e.styled(t.Box)`
39
+ `,d=e.styled(r.Box)`
40
40
  width: 100%;
41
41
  padding: ${({theme:e})=>`${e.spacing[1]} ${e.spacing[2]}`};
42
- border-bottom: 1px solid ${({theme:e})=>r.getThemeColor("grey_5",e)};
42
+ border-bottom: 1px solid ${({theme:e})=>t.getThemeColor("grey_5",e)};
43
43
  cursor: pointer;
44
44
  justify-content: space-between;
45
45
 
46
46
  &:hover {
47
- background-color: ${({selected:e,theme:o})=>e||r.getThemeColor("grey_5",o)};
47
+ background-color: ${({selected:e,theme:o})=>e||t.getThemeColor("grey_5",o)};
48
48
  }
49
49
 
50
- ${({selected:e,theme:o})=>{if(e)return`\n background-color: ${r.getThemeColor("secondary",o)}22;\n `}}
50
+ ${({selected:e,theme:o})=>{if(e)return`\n background-color: ${t.getThemeColor("secondary",o)}22;\n `}}
51
51
  `,h=e.styled.select.withConfig({shouldForwardProp:e=>!["variant","state","padding"].includes(e)})`
52
52
  height: 44px;
53
53
  width: 100%;
54
54
  border-radius: ${({theme:e})=>e.border_radius.input};
55
55
  padding: ${({theme:e,padding:o})=>o||`${e.spacing[1]} ${e.spacing[2]}`};
56
- padding-right: ${({theme:e})=>`calc(${r.getThemeSpacing(2,e)} + 20px)`};
56
+ padding-right: ${({theme:e})=>`calc(${t.getThemeSpacing(2,e)} + 20px)`};
57
57
  font-size: ${({theme:e})=>e.typography.body_size.normal};
58
- color: ${({value:e,theme:o})=>e?r.getThemeColor("grey_1",o):r.getThemeColor("grey_3",o)};
58
+ color: ${({value:e,theme:o})=>e?t.getThemeColor("grey_1",o):t.getThemeColor("grey_3",o)};
59
59
  cursor: pointer;
60
- border: 1px solid ${({theme:e})=>r.getThemeColor("grey_4",e)};
61
- background-color: ${({theme:e})=>r.getThemeColor("white",e)};
60
+ border: 1px solid ${({theme:e})=>t.getThemeColor("grey_4",e)};
61
+ background-color: ${({theme:e})=>t.getThemeColor("white",e)};
62
62
  appearance: none;
63
63
 
64
64
  ${o.fieldFocus}
65
65
 
66
66
  &:disabled {
67
- background-color: ${({theme:e})=>r.getThemeColor("grey_5",e)};
67
+ background-color: ${({theme:e})=>t.getThemeColor("grey_5",e)};
68
68
  }
69
69
 
70
70
  ${o.fieldBorder}
71
- `,s=e.styled(t.Box)`
71
+ `,s=e.styled(r.Box)`
72
72
  position: absolute;
73
73
  right: 0;
74
74
  height: 100%;
75
75
  align-items: center;
76
76
  z-index: 2;
77
- padding-right: ${({theme:e})=>r.getThemeSpacing(2,e)};
77
+ padding-right: ${({theme:e})=>t.getThemeSpacing(2,e)};
78
78
  pointer-events: none;
79
79
  display: flex;
80
80
  `,g=e.styled.option`
81
- background: ${({theme:e})=>r.getThemeColor("white",e)};
82
- color: ${({theme:e})=>r.getThemeColor("grey_1",e)};
81
+ background: ${({theme:e})=>t.getThemeColor("white",e)};
82
+ color: ${({theme:e})=>t.getThemeColor("grey_1",e)};
83
83
  font-size: ${({theme:e})=>e.typography.body_size.normal};
84
84
  padding: ${({theme:e})=>`${e.spacing[1]} ${e.spacing[2]}`};
85
85
  `;exports.IconContainer=a,exports.NativeOption=g,exports.NativeSelect=h,exports.NativeSelectIconContainer=s,exports.Option=d,exports.StyledSelect=n,exports.Wrapper=i;
@@ -1 +1 @@
1
- {"version":3,"file":"table.comp.js","sources":["../../../../../src/components/layout/table/table.comp.tsx"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nimport { Box } from '../box'\nimport { TableHead } from '../table-head'\nimport { TableRow } from '../table-row'\n\nimport { TableData, TableProps } from './table.types'\n\nimport * as Styles from './table.styles'\n\n/**\n * Tabela de dados com colunas configuráveis (`headers`), seleção de linhas (`selectable`) e conteúdo próprio por coluna (`customRender`).\n * No celular, `mobileLayout=\"cards\"` mostra cada linha como um card.\n * `onRowClick` deixa a linha clicável (com destaque no hover e teclado); `hoverable` só destaca.\n * Para listas grandes, coloque TablePagination abaixo.\n * @example <Table headers={[{ key: 'nome', label: 'Nome' }]} data={fornecedores} />\n */\nexport const Table = ({\n data,\n headers,\n onSelectionChange,\n selectable,\n selected,\n header,\n footer,\n borderRadius,\n spacing,\n boxShadow,\n mobileLayout = 'scroll',\n onRowClick,\n hoverable,\n ...rest\n}: TableProps) => {\n const [selectedRows, setSelectedRows] = useState<TableData[]>(selected || [])\n\n useEffect(() => {\n if (selected) {\n setSelectedRows(selected)\n }\n }, [selected, selectedRows])\n\n const handleToggleSelectAll = () => {\n let newSelectedRows: TableData[] = []\n if (selectedRows.length !== data.length) {\n newSelectedRows = [...data]\n }\n\n setSelectedRows(newSelectedRows)\n onSelectionChange?.(newSelectedRows)\n }\n\n const handleToggleSelect = (row: TableData) => {\n let newSelectedRows: TableData[] = selectedRows\n if (selectedRows.includes(row)) {\n newSelectedRows = selectedRows.filter(\n (selectedRow) => selectedRow !== row,\n )\n } else {\n newSelectedRows = [...selectedRows, row]\n }\n\n setSelectedRows(newSelectedRows)\n onSelectionChange?.(newSelectedRows)\n }\n\n const renderDefaultRow = (row: TableData, index: number) => (\n <TableRow\n data={row}\n headers={headers}\n selectable={selectable}\n selected={selectedRows.includes(row)}\n onSelect={handleToggleSelect}\n index={index}\n spacing={spacing}\n hoverable={hoverable ?? Boolean(onRowClick)}\n onClick={onRowClick}\n />\n )\n\n return (\n <Styles.TableWrapper\n data-testid=\"table\"\n direction=\"column\"\n borderRadius={borderRadius}\n boxShadow={boxShadow}\n {...rest}\n >\n {header && <Box width=\"100%\">{header}</Box>}\n <Styles.Table $mobileCards={mobileLayout === 'cards'}>\n <TableHead\n headers={headers}\n selectable={selectable}\n selected={selectedRows.length === data.length}\n onSelect={handleToggleSelectAll}\n spacing={spacing}\n />\n <tbody>\n {data.map((row, index) => {\n if (row.customRender) {\n return (\n <Styles.CustomTableRow\n key={`custom-row-${index}`}\n data-testid=\"custom-row\"\n >\n <Styles.TableColumn $align=\"center\" width=\"100%\">\n {row.customRender(row, index, renderDefaultRow)}\n </Styles.TableColumn>\n </Styles.CustomTableRow>\n )\n }\n return renderDefaultRow(row, index)\n })}\n </tbody>\n </Styles.Table>\n {footer && <Box width=\"100%\">{footer}</Box>}\n </Styles.TableWrapper>\n )\n}\n"],"names":["Table","data","headers","onSelectionChange","selectable","selected","header","footer","borderRadius","spacing","boxShadow","mobileLayout","onRowClick","hoverable","rest","selectedRows","setSelectedRows","useState","useEffect","handleToggleSelect","row","newSelectedRows","includes","filter","selectedRow","renderDefaultRow","index","_jsx","TableRow","onSelect","Boolean","onClick","_jsxs","Styles","direction","Box","width","children","jsxs","TableHead","length","handleToggleSelectAll","jsx","map","customRender","$align"],"mappings":"0OAiBqBA,EACnBC,OACAC,UACAC,oBACAC,aACAC,WACAC,SACAC,SACAC,eACAC,UACAC,YACAC,eAAe,SACfC,aACAC,eACGC,MAEH,MAAOC,EAAcC,GAAmBC,EAAAA,SAAsBZ,GAAY,IAE1Ea,EAAAA,WAAU,KACJb,GACFW,EAAgBX,EAClB,GACC,CAACA,EAAUU,IAEd,MAUMI,EAAsBC,IAC1B,IAAIC,EAA+BN,EAEjCM,EADEN,EAAaO,SAASF,GACNL,EAAaQ,QAC5BC,GAAgBA,IAAgBJ,IAGjB,IAAIL,EAAcK,GAGtCJ,EAAgBK,GAChBlB,IAAoBkB,EAAgB,EAGhCI,EAAmBA,CAACL,EAAgBM,IACxCC,EAAAA,IAACC,EAAAA,SACC,CAAA3B,KAAMmB,EACNlB,QAASA,EACTE,WAAYA,EACZC,SAAUU,EAAaO,SAASF,GAChCS,SAAUV,EACVO,MAAOA,EACPjB,QAASA,EACTI,UAAWA,GAAaiB,QAAQlB,GAChCmB,QAASnB,IAIb,OACEoB,EAAAA,KAACC,EAAAA,4BACa,QACZC,UAAU,SACV1B,aAAcA,EACdE,UAAWA,KACPI,YAEHR,GAAUqB,MAACQ,MAAG,CAACC,MAAM,OAAQC,SAAA/B,IAC9B0B,EAAAM,KAACL,sBAA4C,UAAjBtB,EAAwB0B,SAAA,CAClDV,MAACY,YAAS,CACRrC,QAASA,EACTE,WAAYA,EACZC,SAAUU,EAAayB,SAAWvC,EAAKuC,OACvCX,SApDsBY,KAC5B,IAAIpB,EAA+B,GAC/BN,EAAayB,SAAWvC,EAAKuC,SAC/BnB,EAAkB,IAAIpB,IAGxBe,EAAgBK,GAChBlB,IAAoBkB,EAAgB,EA8C9BZ,QAASA,IAEXkB,EAAAe,IAAA,QAAA,CAAAL,SACGpC,EAAK0C,KAAI,CAACvB,EAAKM,IACVN,EAAIwB,aAEJjB,EAAAA,IAACM,EAAAA,8BAEa,aAAYI,SAExBV,EAACe,IAAAT,cAAkB,CAAAY,OAAQ,SAAST,MAAM,OACvCC,SAAAjB,EAAIwB,aAAaxB,EAAKM,EAAOD,MAJb,cAAAC,KASlBD,EAAiBL,EAAKM,UAIlCnB,GAAUoB,EAACe,IAAAP,MAAI,CAAAC,MAAM,OAAMC,SAAE9B,MACV"}
1
+ {"version":3,"file":"table.comp.js","sources":["../../../../../src/components/layout/table/table.comp.tsx"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nimport { Box } from '../box'\nimport { TableHead } from '../table-head'\nimport { TableRow } from '../table-row'\n\nimport { TableData, TableProps } from './table.types'\n\nimport * as Styles from './table.styles'\n\n/**\n * Tabela de dados com colunas configuráveis (`headers`), seleção de linhas (`selectable`) e conteúdo próprio por coluna (`customRender`).\n * No celular, `mobileLayout=\"cards\"` mostra cada linha como um card.\n * `onRowClick` deixa a linha clicável (com destaque no hover e teclado); `hoverable` só destaca.\n * Para listas grandes, coloque `<Pagination totalItems={...} />` abaixo.\n * @example <Table headers={[{ key: 'nome', label: 'Nome' }]} data={fornecedores} />\n */\nexport const Table = ({\n data,\n headers,\n onSelectionChange,\n selectable,\n selected,\n header,\n footer,\n borderRadius,\n spacing,\n boxShadow,\n mobileLayout = 'scroll',\n onRowClick,\n hoverable,\n ...rest\n}: TableProps) => {\n const [selectedRows, setSelectedRows] = useState<TableData[]>(selected || [])\n\n useEffect(() => {\n if (selected) {\n setSelectedRows(selected)\n }\n }, [selected, selectedRows])\n\n const handleToggleSelectAll = () => {\n let newSelectedRows: TableData[] = []\n if (selectedRows.length !== data.length) {\n newSelectedRows = [...data]\n }\n\n setSelectedRows(newSelectedRows)\n onSelectionChange?.(newSelectedRows)\n }\n\n const handleToggleSelect = (row: TableData) => {\n let newSelectedRows: TableData[] = selectedRows\n if (selectedRows.includes(row)) {\n newSelectedRows = selectedRows.filter(\n (selectedRow) => selectedRow !== row,\n )\n } else {\n newSelectedRows = [...selectedRows, row]\n }\n\n setSelectedRows(newSelectedRows)\n onSelectionChange?.(newSelectedRows)\n }\n\n const renderDefaultRow = (row: TableData, index: number) => (\n <TableRow\n data={row}\n headers={headers}\n selectable={selectable}\n selected={selectedRows.includes(row)}\n onSelect={handleToggleSelect}\n index={index}\n spacing={spacing}\n hoverable={hoverable ?? Boolean(onRowClick)}\n onClick={onRowClick}\n />\n )\n\n return (\n <Styles.TableWrapper\n data-testid=\"table\"\n direction=\"column\"\n borderRadius={borderRadius}\n boxShadow={boxShadow}\n {...rest}\n >\n {header && <Box width=\"100%\">{header}</Box>}\n <Styles.Table $mobileCards={mobileLayout === 'cards'}>\n <TableHead\n headers={headers}\n selectable={selectable}\n selected={selectedRows.length === data.length}\n onSelect={handleToggleSelectAll}\n spacing={spacing}\n />\n <tbody>\n {data.map((row, index) => {\n if (row.customRender) {\n return (\n <Styles.CustomTableRow\n key={`custom-row-${index}`}\n data-testid=\"custom-row\"\n >\n <Styles.TableColumn $align=\"center\" width=\"100%\">\n {row.customRender(row, index, renderDefaultRow)}\n </Styles.TableColumn>\n </Styles.CustomTableRow>\n )\n }\n return renderDefaultRow(row, index)\n })}\n </tbody>\n </Styles.Table>\n {footer && <Box width=\"100%\">{footer}</Box>}\n </Styles.TableWrapper>\n )\n}\n"],"names":["Table","data","headers","onSelectionChange","selectable","selected","header","footer","borderRadius","spacing","boxShadow","mobileLayout","onRowClick","hoverable","rest","selectedRows","setSelectedRows","useState","useEffect","handleToggleSelect","row","newSelectedRows","includes","filter","selectedRow","renderDefaultRow","index","_jsx","TableRow","onSelect","Boolean","onClick","_jsxs","Styles","direction","Box","width","children","jsxs","TableHead","length","handleToggleSelectAll","jsx","map","customRender","$align"],"mappings":"0OAiBqBA,EACnBC,OACAC,UACAC,oBACAC,aACAC,WACAC,SACAC,SACAC,eACAC,UACAC,YACAC,eAAe,SACfC,aACAC,eACGC,MAEH,MAAOC,EAAcC,GAAmBC,EAAAA,SAAsBZ,GAAY,IAE1Ea,EAAAA,WAAU,KACJb,GACFW,EAAgBX,EAClB,GACC,CAACA,EAAUU,IAEd,MAUMI,EAAsBC,IAC1B,IAAIC,EAA+BN,EAEjCM,EADEN,EAAaO,SAASF,GACNL,EAAaQ,QAC5BC,GAAgBA,IAAgBJ,IAGjB,IAAIL,EAAcK,GAGtCJ,EAAgBK,GAChBlB,IAAoBkB,EAAgB,EAGhCI,EAAmBA,CAACL,EAAgBM,IACxCC,EAAAA,IAACC,EAAAA,SACC,CAAA3B,KAAMmB,EACNlB,QAASA,EACTE,WAAYA,EACZC,SAAUU,EAAaO,SAASF,GAChCS,SAAUV,EACVO,MAAOA,EACPjB,QAASA,EACTI,UAAWA,GAAaiB,QAAQlB,GAChCmB,QAASnB,IAIb,OACEoB,EAAAA,KAACC,EAAAA,4BACa,QACZC,UAAU,SACV1B,aAAcA,EACdE,UAAWA,KACPI,YAEHR,GAAUqB,MAACQ,MAAG,CAACC,MAAM,OAAQC,SAAA/B,IAC9B0B,EAAAM,KAACL,sBAA4C,UAAjBtB,EAAwB0B,SAAA,CAClDV,MAACY,YAAS,CACRrC,QAASA,EACTE,WAAYA,EACZC,SAAUU,EAAayB,SAAWvC,EAAKuC,OACvCX,SApDsBY,KAC5B,IAAIpB,EAA+B,GAC/BN,EAAayB,SAAWvC,EAAKuC,SAC/BnB,EAAkB,IAAIpB,IAGxBe,EAAgBK,GAChBlB,IAAoBkB,EAAgB,EA8C9BZ,QAASA,IAEXkB,EAAAe,IAAA,QAAA,CAAAL,SACGpC,EAAK0C,KAAI,CAACvB,EAAKM,IACVN,EAAIwB,aAEJjB,EAAAA,IAACM,EAAAA,8BAEa,aAAYI,SAExBV,EAACe,IAAAT,cAAkB,CAAAY,OAAQ,SAAST,MAAM,OACvCC,SAAAjB,EAAIwB,aAAaxB,EAAKM,EAAOD,MAJb,cAAAC,KASlBD,EAAiBL,EAAKM,UAIlCnB,GAAUoB,EAACe,IAAAP,MAAI,CAAAC,MAAM,OAAMC,SAAE9B,MACV"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("./pagination.styles.js"),a=require("../../layout/box/box.comp.js"),n=require("../../buttons/button/button.comp.js"),o=require("../../icons/icon/icon.comp.js"),i=require("../../typography/text/text.comp.js");const s=()=>e.jsx(a.Box,{padding:1,borderRadius:"8px",children:e.jsx(i.Text,{color:"grey_3",children:"..."})});exports.Pagination=({current:c=1,onChange:x,total:l,showAll:u})=>{const[d,p]=t.useState(c),[g,j]=t.useState([]);t.useEffect((()=>{const t=d<=3,r=d>=l-2;j(u||l<=5?Array.from({length:l},((e,t)=>t+1)):t?[1,2,3,4,e.jsx(s,{}),l]:r?[1,e.jsx(s,{}),l-3,l-2,l-1,l]:[1,e.jsx(s,{}),d-1,d,d+1,e.jsx(s,{}),l])}),[d,l]),t.useEffect((()=>{p(c)}),[c]);const b=e=>{p(e),x?.(e)},h=1===d,y=d===l;return e.jsxs(a.Box,{alignItems:"center","data-testid":"pagination",children:[e.jsx(n.Button,{disabled:h,variant:"text",width:"40px",onClick:()=>b(d-1),"data-testid":"previous-button","aria-label":"Página anterior",children:e.jsx(o.Icon,{name:"arrow_left_s",color:h?"grey_4":"secondary",size:24})}),g.map(((t,n)=>"number"==typeof t?e.jsx(r.PageButton,{type:"button",onClick:()=>b(t),$current:d===t,"data-testid":`page-${t}`,"aria-label":`Página ${t}`,"aria-current":d===t?"page":void 0,children:e.jsx(i.Text,{color:d===t?"grey_1":"grey_3",children:t})},`page-${n}`):e.jsx(a.Box,{children:t},`page-spacer-${n}`))),e.jsx(n.Button,{disabled:y,variant:"text",width:"40px",onClick:()=>b(d+1),"data-testid":"next-button","aria-label":"Próxima página",children:e.jsx(o.Icon,{name:"arrow_right_s",color:y?"grey_4":"secondary",size:24})})]})};
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("./pagination.styles.js"),a=require("../../forms/select/select.comp.js"),n=require("../../layout/box/box.comp.js"),i=require("../../typography/text/text.comp.js"),s=require("../../buttons/button/button.comp.js"),o=require("../../icons/icon/icon.comp.js");const l=[10,50,100],c=()=>e.jsx(n.Box,{padding:1,borderRadius:"8px",children:e.jsx(i.Text,{color:"grey_3",children:"..."})}),x=({total:a,current:l,onChange:x,showAll:d})=>{const[u,p]=t.useState(l),[g,h]=t.useState([]);t.useEffect((()=>{const t=u<=3,r=u>=a-2;h(d||a<=5?Array.from({length:a},((e,t)=>t+1)):t?[1,2,3,4,e.jsx(c,{}),a]:r?[1,e.jsx(c,{}),a-3,a-2,a-1,a]:[1,e.jsx(c,{}),u-1,u,u+1,e.jsx(c,{}),a])}),[u,a,d]),t.useEffect((()=>{p(l)}),[l]);const j=e=>{p(e),x(e)},m=1===u,b=u===a;return e.jsxs(n.Box,{alignItems:"center","data-testid":"pagination",children:[e.jsx(s.Button,{disabled:m,variant:"text",width:"40px",onClick:()=>j(u-1),"data-testid":"previous-button","aria-label":"Página anterior",children:e.jsx(o.Icon,{name:"arrow_left_s",color:m?"grey_4":"secondary",size:24})}),g.map(((t,a)=>"number"==typeof t?e.jsx(r.PageButton,{type:"button",onClick:()=>j(t),$current:u===t,"data-testid":`page-${t}`,"aria-label":`Página ${t}`,"aria-current":u===t?"page":void 0,children:e.jsx(i.Text,{color:u===t?"grey_1":"grey_3",children:t})},`page-${a}`):e.jsx(n.Box,{children:t},`page-spacer-${a}`))),e.jsx(s.Button,{disabled:b,variant:"text",width:"40px",onClick:()=>j(u+1),"data-testid":"next-button","aria-label":"Próxima página",children:e.jsx(o.Icon,{name:"arrow_right_s",color:b?"grey_4":"secondary",size:24})})]})};exports.Pagination=({total:s,totalItems:o,current:c=1,onChange:d,showAll:u,itemsPerPage:p=10,itemsPerPageOptions:g=l,onChangeItemsPerPage:h,viewText:j="Visualizar",itemsText:m="itens",ofText:b="de"})=>{const[f,y]=t.useState(c),[w,v]=t.useState(p);t.useEffect((()=>{y(c)}),[c]),t.useEffect((()=>{v(p)}),[p]);const C=t.useMemo((()=>g.map((e=>({label:`${e} ${m}`,value:String(e)})))),[g,m]),P=e=>{y(e),d?.(e)};if(void 0===o)return e.jsx(x,{total:Math.max(1,s??1),current:f,onChange:P,showAll:u});return e.jsxs(n.Box,{width:"100%",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",position:"relative","data-testid":"pagination-footer",children:[e.jsxs(r.SideBox,{gap:1,alignItems:"center",minWidth:"180px",children:[e.jsx(i.Text,{color:"grey_3",size:"small",children:j}),e.jsx(a.Select,{options:C,value:String(w),onChange:e=>{const t=parseInt(e.target.value);Number.isNaN(t)||(v(t),h?.(t))},width:"120px",padding:"4px 8px",variant:"text","aria-label":j})]}),e.jsx(r.CenterBox,{children:e.jsx(x,{total:Math.max(1,Math.ceil(o/w)),current:f,onChange:P,showAll:u})}),e.jsx(r.SideBox,{minWidth:"180px",justifyContent:"flex-end",children:e.jsxs(i.Text,{children:[e.jsx("b",{children:Math.min(o,f*w)})," ",b," ",o]})})]})};
2
2
  //# sourceMappingURL=pagination.comp.js.map