@1doc/1ds-react 2.8.0 → 2.10.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.
Files changed (287) hide show
  1. package/CHANGELOG.md +1540 -0
  2. package/dist/components/AILabel/AILabel.js +1 -1
  3. package/dist/components/Accordion/Accordion.css +13 -0
  4. package/dist/components/Accordion/Accordion.d.ts +9 -2
  5. package/dist/components/Accordion/Accordion.js +1 -0
  6. package/dist/components/AppSubheader/AppSubheader.css +10 -1
  7. package/dist/components/AttachmentCard/AttachmentCard.css +26 -8
  8. package/dist/components/AttachmentCard/AttachmentCard.d.ts +22 -2
  9. package/dist/components/AttachmentCard/AttachmentCard.js +47 -3
  10. package/dist/components/Avatar/Avatar.css +7 -2
  11. package/dist/components/Avatar/AvatarGroup.d.ts +17 -0
  12. package/dist/components/Avatar/AvatarGroup.js +22 -8
  13. package/dist/components/Badge/Badge.css +67 -2
  14. package/dist/components/Badge/Badge.d.ts +23 -4
  15. package/dist/components/Badge/Badge.js +4 -0
  16. package/dist/components/Box/Box.css +83 -0
  17. package/dist/components/Box/Box.d.ts +82 -2
  18. package/dist/components/Box/Box.js +42 -2
  19. package/dist/components/Button/Button.css +29 -0
  20. package/dist/components/Button/Button.d.ts +4 -4
  21. package/dist/components/Button/Button.js +4 -1
  22. package/dist/components/Calendar/Calendar.css +245 -0
  23. package/dist/components/Calendar/Calendar.d.ts +126 -0
  24. package/dist/components/Calendar/Calendar.js +320 -0
  25. package/dist/components/Chips/Chips.css +38 -0
  26. package/dist/components/Chips/Chips.d.ts +5 -2
  27. package/dist/components/Chips/Chips.js +2 -1
  28. package/dist/components/Coachmark/Coachmark.css +128 -0
  29. package/dist/components/Coachmark/Coachmark.d.ts +87 -0
  30. package/dist/components/Coachmark/Coachmark.js +362 -0
  31. package/dist/components/CodeBlock/CodeBlock.css +96 -0
  32. package/dist/components/CodeBlock/CodeBlock.d.ts +47 -0
  33. package/dist/components/CodeBlock/CodeBlock.js +103 -0
  34. package/dist/components/ColorPicker/ColorPicker.css +140 -0
  35. package/dist/components/ColorPicker/ColorPicker.d.ts +73 -0
  36. package/dist/components/ColorPicker/ColorPicker.js +219 -0
  37. package/dist/components/Combobox/Combobox.css +8 -0
  38. package/dist/components/DataTable/DataTable.css +254 -0
  39. package/dist/components/DataTable/DataTable.d.ts +81 -5
  40. package/dist/components/DataTable/DataTable.js +335 -19
  41. package/dist/components/DatePicker/DatePicker.css +8 -0
  42. package/dist/components/DatePicker/DatePicker.js +10 -1
  43. package/dist/components/DescriptionList/DescriptionList.css +127 -0
  44. package/dist/components/DescriptionList/DescriptionList.d.ts +62 -0
  45. package/dist/components/DescriptionList/DescriptionList.js +52 -0
  46. package/dist/components/EmptyState/EmptyState.d.ts +4 -2
  47. package/dist/components/EmptyState/EmptyState.js +2 -2
  48. package/dist/components/FileInput/FileInput.css +16 -0
  49. package/dist/components/FileInput/FileInput.d.ts +4 -2
  50. package/dist/components/FileInput/FileInput.js +8 -2
  51. package/dist/components/Grid/Grid.js +5 -5
  52. package/dist/components/IconPicker/IconPicker.css +107 -0
  53. package/dist/components/IconPicker/IconPicker.d.ts +74 -0
  54. package/dist/components/IconPicker/IconPicker.js +194 -0
  55. package/dist/components/Input/Input.css +59 -0
  56. package/dist/components/Input/Input.d.ts +17 -1
  57. package/dist/components/Input/Input.js +67 -5
  58. package/dist/components/Kanban/Kanban.css +4 -0
  59. package/dist/components/Kbd/Kbd.css +66 -0
  60. package/dist/components/Kbd/Kbd.d.ts +32 -0
  61. package/dist/components/Kbd/Kbd.js +40 -0
  62. package/dist/components/List/List.css +136 -0
  63. package/dist/components/List/List.d.ts +82 -0
  64. package/dist/components/List/List.js +53 -0
  65. package/dist/components/List/ListItem.d.ts +97 -0
  66. package/dist/components/List/ListItem.js +82 -0
  67. package/dist/components/Modal/Modal.css +80 -0
  68. package/dist/components/Modal/Modal.d.ts +33 -6
  69. package/dist/components/Modal/Modal.js +101 -6
  70. package/dist/components/MultiSelect/MultiSelect.css +8 -0
  71. package/dist/components/MultiSelect/MultiSelect.js +10 -1
  72. package/dist/components/OrgChart/OrgChart.css +149 -0
  73. package/dist/components/OrgChart/OrgChart.d.ts +83 -0
  74. package/dist/components/OrgChart/OrgChart.js +297 -0
  75. package/dist/components/OtpInput/OtpInput.css +93 -0
  76. package/dist/components/OtpInput/OtpInput.d.ts +60 -0
  77. package/dist/components/OtpInput/OtpInput.js +215 -0
  78. package/dist/components/PhoneInput/PhoneInput.css +8 -0
  79. package/dist/components/Popover/Popover.d.ts +7 -0
  80. package/dist/components/Popover/Popover.js +11 -1
  81. package/dist/components/RichTextEditor/RichTextEditor.css +250 -0
  82. package/dist/components/RichTextEditor/RichTextEditor.d.ts +97 -0
  83. package/dist/components/RichTextEditor/RichTextEditor.js +951 -0
  84. package/dist/components/SegmentedControl/SegmentedControl.css +24 -0
  85. package/dist/components/SegmentedControl/SegmentedControl.d.ts +2 -0
  86. package/dist/components/SegmentedControl/SegmentedControl.js +10 -2
  87. package/dist/components/Select/Select.css +164 -0
  88. package/dist/components/Select/Select.d.ts +34 -0
  89. package/dist/components/Select/Select.js +258 -28
  90. package/dist/components/Stack/Stack.css +49 -0
  91. package/dist/components/Stack/Stack.d.ts +65 -7
  92. package/dist/components/Stack/Stack.js +30 -2
  93. package/dist/components/StatCard/StatCard.css +138 -0
  94. package/dist/components/StatCard/StatCard.d.ts +26 -0
  95. package/dist/components/StatCard/StatCard.js +13 -1
  96. package/dist/components/Tabs/Tab.d.ts +15 -0
  97. package/dist/components/Tabs/Tab.js +30 -1
  98. package/dist/components/Tabs/Tabs.css +132 -0
  99. package/dist/components/Tabs/Tabs.d.ts +7 -0
  100. package/dist/components/Tabs/Tabs.js +13 -2
  101. package/dist/components/Tag/Tag.css +85 -2
  102. package/dist/components/Tag/Tag.d.ts +13 -6
  103. package/dist/components/Tag/Tag.js +1 -0
  104. package/dist/components/Text/Text.js +2 -2
  105. package/dist/components/Textarea/Textarea.css +8 -0
  106. package/dist/components/TimePicker/TimePicker.css +8 -0
  107. package/dist/components/Toast/Toast.css +32 -0
  108. package/dist/components/Toast/Toast.d.ts +18 -0
  109. package/dist/components/Toast/Toast.js +14 -1
  110. package/dist/components/Toast/ToastStack.js +8 -1
  111. package/dist/components/Tooltip/Tooltip.css +25 -0
  112. package/dist/components/Tooltip/Tooltip.d.ts +11 -0
  113. package/dist/components/Tooltip/Tooltip.js +18 -3
  114. package/dist/index.d.ts +25 -0
  115. package/dist/index.js +14 -0
  116. package/dist/teste/AILabel.test.d.ts +1 -0
  117. package/dist/teste/AILabel.test.js +33 -0
  118. package/dist/teste/AccordionConteudoLivre.test.d.ts +1 -0
  119. package/dist/teste/AccordionConteudoLivre.test.js +29 -0
  120. package/dist/teste/AccordionTituloNeutro.test.d.ts +1 -0
  121. package/dist/teste/AccordionTituloNeutro.test.js +23 -0
  122. package/dist/teste/AppSubheaderRegiao.test.d.ts +1 -0
  123. package/dist/teste/AppSubheaderRegiao.test.js +13 -0
  124. package/dist/teste/AtributosRepassados.test.d.ts +1 -0
  125. package/dist/teste/AtributosRepassados.test.js +52 -0
  126. package/dist/teste/AttachmentCardIA.test.d.ts +1 -0
  127. package/dist/teste/AttachmentCardIA.test.js +89 -0
  128. package/dist/teste/AttachmentCardLista.test.d.ts +1 -0
  129. package/dist/teste/AttachmentCardLista.test.js +49 -0
  130. package/dist/teste/AttachmentCardSm.test.d.ts +1 -0
  131. package/dist/teste/AttachmentCardSm.test.js +26 -0
  132. package/dist/teste/AvatarGroupOverlap.test.d.ts +1 -0
  133. package/dist/teste/AvatarGroupOverlap.test.js +56 -0
  134. package/dist/teste/BadgeNeutroColado.test.d.ts +1 -0
  135. package/dist/teste/BadgeNeutroColado.test.js +11 -0
  136. package/dist/teste/BadgeTag.test.d.ts +1 -0
  137. package/dist/teste/BadgeTag.test.js +55 -0
  138. package/dist/teste/BoxItemFlex.test.d.ts +1 -0
  139. package/dist/teste/BoxItemFlex.test.js +54 -0
  140. package/dist/teste/BoxLayout.test.d.ts +1 -0
  141. package/dist/teste/BoxLayout.test.js +35 -0
  142. package/dist/teste/Button.test.d.ts +1 -0
  143. package/dist/teste/Button.test.js +27 -0
  144. package/dist/teste/Calendar.test.d.ts +1 -0
  145. package/dist/teste/Calendar.test.js +221 -0
  146. package/dist/teste/CalendarCabecalho.test.d.ts +1 -0
  147. package/dist/teste/CalendarCabecalho.test.js +11 -0
  148. package/dist/teste/ChipsXs.test.d.ts +1 -0
  149. package/dist/teste/ChipsXs.test.js +31 -0
  150. package/dist/teste/Coachmark.test.d.ts +1 -0
  151. package/dist/teste/Coachmark.test.js +149 -0
  152. package/dist/teste/CoachmarkSemVeu.test.d.ts +1 -0
  153. package/dist/teste/CoachmarkSemVeu.test.js +85 -0
  154. package/dist/teste/ColorPicker.test.d.ts +1 -0
  155. package/dist/teste/ColorPicker.test.js +132 -0
  156. package/dist/teste/ColorPickerXs.test.d.ts +1 -0
  157. package/dist/teste/ColorPickerXs.test.js +21 -0
  158. package/dist/teste/DataTableArvoreEVariantes.test.d.ts +1 -0
  159. package/dist/teste/DataTableArvoreEVariantes.test.js +190 -0
  160. package/dist/teste/DataTableCelulaLivre.test.d.ts +1 -0
  161. package/dist/teste/DataTableCelulaLivre.test.js +76 -0
  162. package/dist/teste/DataTableDocumento.test.d.ts +1 -0
  163. package/dist/teste/DataTableDocumento.test.js +92 -0
  164. package/dist/teste/DatePicker.test.js +23 -0
  165. package/dist/teste/DescriptionListCompacta.test.d.ts +1 -0
  166. package/dist/teste/DescriptionListCompacta.test.js +22 -0
  167. package/dist/teste/EmptyStateTituloRico.test.d.ts +1 -0
  168. package/dist/teste/EmptyStateTituloRico.test.js +23 -0
  169. package/dist/teste/FileInputTrigger.test.d.ts +1 -0
  170. package/dist/teste/FileInputTrigger.test.js +53 -0
  171. package/dist/teste/IconPicker.test.d.ts +1 -0
  172. package/dist/teste/IconPicker.test.js +130 -0
  173. package/dist/teste/InputAgrupado.test.d.ts +1 -0
  174. package/dist/teste/InputAgrupado.test.js +24 -0
  175. package/dist/teste/InputMascaraEAfins.test.d.ts +1 -0
  176. package/dist/teste/InputMascaraEAfins.test.js +99 -0
  177. package/dist/teste/KbdCodeBlock.test.d.ts +1 -0
  178. package/dist/teste/KbdCodeBlock.test.js +95 -0
  179. package/dist/teste/List.test.d.ts +1 -0
  180. package/dist/teste/List.test.js +153 -0
  181. package/dist/teste/ListItemTooltipStandalone.test.d.ts +1 -0
  182. package/dist/teste/ListItemTooltipStandalone.test.js +39 -0
  183. package/dist/teste/ModalVariantes.test.d.ts +1 -0
  184. package/dist/teste/ModalVariantes.test.js +151 -0
  185. package/dist/teste/NomeAcessivelSsr.test.d.ts +1 -0
  186. package/dist/teste/NomeAcessivelSsr.test.js +88 -0
  187. package/dist/teste/OrgChart.test.d.ts +1 -0
  188. package/dist/teste/OrgChart.test.js +162 -0
  189. package/dist/teste/OtpInput.test.d.ts +1 -0
  190. package/dist/teste/OtpInput.test.js +143 -0
  191. package/dist/teste/PopoverMaxHeight.test.d.ts +1 -0
  192. package/dist/teste/PopoverMaxHeight.test.js +38 -0
  193. package/dist/teste/RichTextEditor.test.d.ts +1 -0
  194. package/dist/teste/RichTextEditor.test.js +287 -0
  195. package/dist/teste/RichTextEditorAlinhaImagemTabela.test.d.ts +1 -0
  196. package/dist/teste/RichTextEditorAlinhaImagemTabela.test.js +212 -0
  197. package/dist/teste/RichTextEditorEstiloDeTexto.test.d.ts +1 -0
  198. package/dist/teste/RichTextEditorEstiloDeTexto.test.js +120 -0
  199. package/dist/teste/SegmentedControlContador.test.d.ts +1 -0
  200. package/dist/teste/SegmentedControlContador.test.js +39 -0
  201. package/dist/teste/SelectAbertoControladoEFlutuante.test.d.ts +1 -0
  202. package/dist/teste/SelectAbertoControladoEFlutuante.test.js +145 -0
  203. package/dist/teste/SelectFiltroCorETamanho.test.d.ts +1 -0
  204. package/dist/teste/SelectFiltroCorETamanho.test.js +77 -0
  205. package/dist/teste/SelectPlacementFiltro.test.d.ts +1 -0
  206. package/dist/teste/SelectPlacementFiltro.test.js +88 -0
  207. package/dist/teste/Stack.test.d.ts +1 -0
  208. package/dist/teste/Stack.test.js +57 -0
  209. package/dist/teste/StatCardRotuloTopo.test.d.ts +1 -0
  210. package/dist/teste/StatCardRotuloTopo.test.js +34 -0
  211. package/dist/teste/StatCardSecundariaETom.test.d.ts +1 -0
  212. package/dist/teste/StatCardSecundariaETom.test.js +45 -0
  213. package/dist/teste/TabsContadorFechavel.test.d.ts +1 -0
  214. package/dist/teste/TabsContadorFechavel.test.js +79 -0
  215. package/dist/teste/ToastAcaoEDetalhes.test.d.ts +1 -0
  216. package/dist/teste/ToastAcaoEDetalhes.test.js +94 -0
  217. package/dist/teste/TooltipDark.test.d.ts +1 -0
  218. package/dist/teste/TooltipDark.test.js +31 -0
  219. package/dist/utils/calendario.d.ts +28 -0
  220. package/dist/utils/calendario.js +73 -0
  221. package/dist/utils/html-seguro.d.ts +45 -0
  222. package/dist/utils/html-seguro.js +208 -0
  223. package/dist/utils/paleta-de-cores.d.ts +26 -0
  224. package/dist/utils/paleta-de-cores.js +10 -0
  225. package/dist/utils/texto.d.ts +5 -0
  226. package/dist/utils/texto.js +5 -0
  227. package/dist/utils/toast.d.ts +10 -1
  228. package/dist/utils/toast.js +2 -1
  229. package/package.json +3 -3
  230. package/src/index.ts +26 -0
  231. package/src/teste/AILabel.test.tsx +41 -0
  232. package/src/teste/AccordionConteudoLivre.test.tsx +39 -0
  233. package/src/teste/AccordionTituloNeutro.test.tsx +25 -0
  234. package/src/teste/AppSubheaderRegiao.test.tsx +17 -0
  235. package/src/teste/AtributosRepassados.test.tsx +73 -0
  236. package/src/teste/AttachmentCardIA.test.tsx +126 -0
  237. package/src/teste/AttachmentCardLista.test.tsx +53 -0
  238. package/src/teste/AttachmentCardSm.test.tsx +29 -0
  239. package/src/teste/AvatarGroupOverlap.test.tsx +74 -0
  240. package/src/teste/BadgeNeutroColado.test.tsx +15 -0
  241. package/src/teste/BadgeTag.test.tsx +85 -0
  242. package/src/teste/BoxItemFlex.test.tsx +81 -0
  243. package/src/teste/BoxLayout.test.tsx +50 -0
  244. package/src/teste/Button.test.tsx +39 -0
  245. package/src/teste/Calendar.test.tsx +282 -0
  246. package/src/teste/CalendarCabecalho.test.tsx +11 -0
  247. package/src/teste/ChipsXs.test.tsx +41 -0
  248. package/src/teste/Coachmark.test.tsx +198 -0
  249. package/src/teste/CoachmarkSemVeu.test.tsx +101 -0
  250. package/src/teste/ColorPicker.test.tsx +153 -0
  251. package/src/teste/ColorPickerXs.test.tsx +22 -0
  252. package/src/teste/DataTableArvoreEVariantes.test.tsx +240 -0
  253. package/src/teste/DataTableCelulaLivre.test.tsx +103 -0
  254. package/src/teste/DataTableDocumento.test.tsx +102 -0
  255. package/src/teste/DatePicker.test.tsx +38 -0
  256. package/src/teste/DescriptionListCompacta.test.tsx +24 -0
  257. package/src/teste/EmptyStateTituloRico.test.tsx +34 -0
  258. package/src/teste/FileInputTrigger.test.tsx +89 -0
  259. package/src/teste/IconPicker.test.tsx +145 -0
  260. package/src/teste/InputAgrupado.test.tsx +26 -0
  261. package/src/teste/InputMascaraEAfins.test.tsx +124 -0
  262. package/src/teste/KbdCodeBlock.test.tsx +106 -0
  263. package/src/teste/List.test.tsx +269 -0
  264. package/src/teste/ListItemTooltipStandalone.test.tsx +64 -0
  265. package/src/teste/ModalVariantes.test.tsx +173 -0
  266. package/src/teste/NomeAcessivelSsr.test.tsx +110 -0
  267. package/src/teste/OrgChart.test.tsx +183 -0
  268. package/src/teste/OtpInput.test.tsx +163 -0
  269. package/src/teste/PopoverMaxHeight.test.tsx +47 -0
  270. package/src/teste/RichTextEditor.test.tsx +329 -0
  271. package/src/teste/RichTextEditorAlinhaImagemTabela.test.tsx +238 -0
  272. package/src/teste/RichTextEditorEstiloDeTexto.test.tsx +137 -0
  273. package/src/teste/SegmentedControlContador.test.tsx +43 -0
  274. package/src/teste/SelectAbertoControladoEFlutuante.test.tsx +180 -0
  275. package/src/teste/SelectFiltroCorETamanho.test.tsx +90 -0
  276. package/src/teste/SelectPlacementFiltro.test.tsx +110 -0
  277. package/src/teste/Stack.test.tsx +80 -0
  278. package/src/teste/StatCardRotuloTopo.test.tsx +44 -0
  279. package/src/teste/StatCardSecundariaETom.test.tsx +51 -0
  280. package/src/teste/TabsContadorFechavel.test.tsx +144 -0
  281. package/src/teste/ToastAcaoEDetalhes.test.tsx +109 -0
  282. package/src/teste/TooltipDark.test.tsx +51 -0
  283. package/src/utils/calendario.ts +78 -0
  284. package/src/utils/html-seguro.ts +197 -0
  285. package/src/utils/paleta-de-cores.ts +34 -0
  286. package/src/utils/texto.ts +5 -0
  287. package/src/utils/toast.ts +12 -2
@@ -0,0 +1,132 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { describe, expect, it, vi } from "vitest";
3
+ import { useState } from "react";
4
+ import { render, screen } from "@testing-library/react";
5
+ import userEvent from "@testing-library/user-event";
6
+ import ColorPicker from "../components/ColorPicker/ColorPicker";
7
+ import { COLOR_PALETTE } from "../utils/paleta-de-cores";
8
+ describe("ColorPicker", () => {
9
+ it("é um radiogroup com uma amostra por primitivo de cor, cada uma com nome", () => {
10
+ render(_jsx(ColorPicker, { ariaLabel: "Cor do marcador" }));
11
+ const grupo = screen.getByRole("radiogroup", { name: "Cor do marcador" });
12
+ expect(grupo.querySelectorAll('[role="radio"]')).toHaveLength(COLOR_PALETTE.length);
13
+ expect(COLOR_PALETTE).toHaveLength(31);
14
+ expect(screen.getByRole("radio", { name: "Azul escuro" })).toBeInTheDocument();
15
+ expect(screen.getByRole("radio", { name: "Cinza muito claro" })).toBeInTheDocument();
16
+ });
17
+ it("pinta cada amostra com a variável do token", () => {
18
+ render(_jsx(ColorPicker, { ariaLabel: "Cor" }));
19
+ const azul = screen.getByRole("radio", { name: "Azul" });
20
+ expect(azul.style.backgroundColor).toBe("var(--umds-primitive-blue-pure)");
21
+ });
22
+ it("clicar escolhe e entrega o NOME do token em onChange", async () => {
23
+ const usuario = userEvent.setup();
24
+ const aoMudar = vi.fn();
25
+ render(_jsx(ColorPicker, { ariaLabel: "Cor", onChange: aoMudar }));
26
+ await usuario.click(screen.getByRole("radio", { name: "Verde" }));
27
+ expect(aoMudar).toHaveBeenCalledWith("--umds-primitive-green-pure");
28
+ expect(screen.getByRole("radio", { name: "Verde" })).toHaveAttribute("aria-checked", "true");
29
+ });
30
+ it("não escolhido tem aria-checked false e só a escolhida mostra a marcação", () => {
31
+ const { container } = render(_jsx(ColorPicker, { ariaLabel: "Cor", defaultValue: "--umds-primitive-red-pure" }));
32
+ expect(screen.getByRole("radio", { name: "Vermelho" })).toHaveAttribute("aria-checked", "true");
33
+ expect(screen.getByRole("radio", { name: "Azul" })).toHaveAttribute("aria-checked", "false");
34
+ expect(container.querySelectorAll(".umds-color-picker__swatch svg")).toHaveLength(1);
35
+ });
36
+ it("Tab entra na amostra escolhida (roving tabindex)", () => {
37
+ render(_jsx(ColorPicker, { ariaLabel: "Cor", value: "--umds-primitive-orange-pure" }));
38
+ const radios = screen.getAllByRole("radio");
39
+ const comTab = radios.filter((r) => r.getAttribute("tabindex") === "0");
40
+ expect(comTab).toHaveLength(1);
41
+ expect(comTab[0]).toHaveAccessibleName("Laranja");
42
+ });
43
+ it("sem valor, Tab entra na primeira amostra", () => {
44
+ render(_jsx(ColorPicker, { ariaLabel: "Cor" }));
45
+ expect(screen.getAllByRole("radio")[0]).toHaveAttribute("tabindex", "0");
46
+ });
47
+ it("setas movem a escolha e o foco; Home e End vão às pontas; dá a volta", async () => {
48
+ const usuario = userEvent.setup();
49
+ const aoMudar = vi.fn();
50
+ render(_jsx(ColorPicker, { ariaLabel: "Cor", families: ["blue"], defaultValue: "--umds-primitive-blue-dark", onChange: aoMudar }));
51
+ const radios = screen.getAllByRole("radio");
52
+ radios[0].focus();
53
+ await usuario.keyboard("{ArrowRight}");
54
+ expect(aoMudar).toHaveBeenLastCalledWith("--umds-primitive-blue-pure");
55
+ expect(radios[1]).toHaveFocus();
56
+ await usuario.keyboard("{ArrowLeft}{ArrowLeft}");
57
+ expect(aoMudar).toHaveBeenLastCalledWith("--umds-primitive-blue-light");
58
+ expect(radios[3]).toHaveFocus();
59
+ await usuario.keyboard("{Home}");
60
+ expect(radios[0]).toHaveFocus();
61
+ await usuario.keyboard("{End}");
62
+ expect(radios[3]).toHaveFocus();
63
+ await usuario.keyboard("{ArrowDown}");
64
+ expect(radios[0]).toHaveFocus();
65
+ });
66
+ it("pula amostra desabilitada no teclado", async () => {
67
+ const usuario = userEvent.setup();
68
+ const aoMudar = vi.fn();
69
+ render(_jsx(ColorPicker, { ariaLabel: "Cor", defaultValue: "a", onChange: aoMudar, swatches: [
70
+ { value: "a", label: "A" },
71
+ { value: "b", label: "B", disabled: true },
72
+ { value: "c", label: "C" },
73
+ ] }));
74
+ screen.getByRole("radio", { name: "A" }).focus();
75
+ await usuario.keyboard("{ArrowRight}");
76
+ expect(aoMudar).toHaveBeenLastCalledWith("c");
77
+ });
78
+ it("families recorta a paleta", () => {
79
+ render(_jsx(ColorPicker, { ariaLabel: "Cor", families: ["blue", "gray"] }));
80
+ expect(screen.getAllByRole("radio")).toHaveLength(11);
81
+ });
82
+ it("swatches substitui a paleta (nomes traduzidos)", () => {
83
+ render(_jsx(ColorPicker, { ariaLabel: "Color", swatches: [{ value: "--umds-primitive-blue-pure", label: "Blue" }] }));
84
+ expect(screen.getAllByRole("radio")).toHaveLength(1);
85
+ expect(screen.getByRole("radio", { name: "Blue" })).toBeInTheDocument();
86
+ });
87
+ it("disabled desabilita todas as amostras", () => {
88
+ render(_jsx(ColorPicker, { ariaLabel: "Cor", disabled: true }));
89
+ for (const r of screen.getAllByRole("radio"))
90
+ expect(r).toBeDisabled();
91
+ });
92
+ it("label visível nomeia o grupo", () => {
93
+ render(_jsx(ColorPicker, { label: "Cor de fundo", id: "cp" }));
94
+ expect(screen.getByRole("radiogroup", { name: "Cor de fundo" })).toBeInTheDocument();
95
+ });
96
+ it("cor livre vem desligada: sem campo de hexadecimal", () => {
97
+ render(_jsx(ColorPicker, { ariaLabel: "Cor" }));
98
+ expect(screen.queryByLabelText(/hexadecimal/i)).toBeNull();
99
+ });
100
+ it("allowCustom: hexadecimal completo vira #RRGGBB em maiúsculas; incompleto não emite", async () => {
101
+ const usuario = userEvent.setup();
102
+ const aoMudar = vi.fn();
103
+ render(_jsx(ColorPicker, { ariaLabel: "Cor", allowCustom: true, onChange: aoMudar }));
104
+ const campo = screen.getByLabelText("Cor livre (hexadecimal)");
105
+ await usuario.type(campo, "0058d");
106
+ expect(aoMudar).not.toHaveBeenCalled();
107
+ await usuario.type(campo, "b");
108
+ expect(aoMudar).toHaveBeenCalledTimes(1);
109
+ expect(aoMudar).toHaveBeenCalledWith("#0058DB");
110
+ });
111
+ it("allowCustom: hexadecimal inválido mostra a mensagem ao sair do campo", async () => {
112
+ const usuario = userEvent.setup();
113
+ render(_jsx(ColorPicker, { ariaLabel: "Cor", allowCustom: true, customErrorMessage: "Formato inv\u00E1lido" }));
114
+ const campo = screen.getByLabelText("Cor livre (hexadecimal)");
115
+ await usuario.type(campo, "xyz");
116
+ expect(screen.queryByText("Formato inválido")).toBeNull();
117
+ await usuario.tab();
118
+ expect(screen.getByText("Formato inválido")).toBeInTheDocument();
119
+ });
120
+ it("controlado: reflete o value e escolher uma amostra limpa o campo livre", async () => {
121
+ const usuario = userEvent.setup();
122
+ function Controlado() {
123
+ const [valor, setValor] = useState("#336699");
124
+ return _jsx(ColorPicker, { ariaLabel: "Cor", allowCustom: true, value: valor, onChange: setValor });
125
+ }
126
+ render(_jsx(Controlado, {}));
127
+ const campo = screen.getByLabelText("Cor livre (hexadecimal)");
128
+ expect(campo.value).toBe("#336699");
129
+ await usuario.click(screen.getByRole("radio", { name: "Azul" }));
130
+ expect(campo.value).toBe("");
131
+ });
132
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { describe, expect, it } from "vitest";
3
+ import { render, screen } from "@testing-library/react";
4
+ import ColorPicker from "../components/ColorPicker/ColorPicker";
5
+ describe("ColorPicker · size xs", () => {
6
+ it("xs escreve a classe do tamanho; sm e md seguem como eram", () => {
7
+ const { container, rerender } = render(_jsx(ColorPicker, { ariaLabel: "Cor", size: "xs" }));
8
+ const raiz = () => container.firstElementChild;
9
+ expect(raiz()).toHaveClass("umds-color-picker--xs");
10
+ rerender(_jsx(ColorPicker, { ariaLabel: "Cor", size: "sm" }));
11
+ expect(raiz()).toHaveClass("umds-color-picker--sm");
12
+ expect(raiz()).not.toHaveClass("umds-color-picker--xs");
13
+ rerender(_jsx(ColorPicker, { ariaLabel: "Cor" }));
14
+ expect(raiz()).toHaveClass("umds-color-picker--md");
15
+ });
16
+ it("no xs a amostra escolhida mantém a marcação e o aria-checked", () => {
17
+ const { container } = render(_jsx(ColorPicker, { ariaLabel: "Cor", size: "xs", defaultValue: "--umds-primitive-red-pure" }));
18
+ expect(screen.getByRole("radio", { name: "Vermelho" })).toHaveAttribute("aria-checked", "true");
19
+ expect(container.querySelectorAll(".umds-color-picker__swatch--selected")).toHaveLength(1);
20
+ });
21
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,190 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { describe, expect, it, vi } from "vitest";
3
+ import { render, screen, fireEvent } from "@testing-library/react";
4
+ import { faBoxOpen } from "@fortawesome/free-solid-svg-icons";
5
+ import DataTable from "../components/DataTable/DataTable";
6
+ const COLUNAS = [
7
+ { key: "nome", label: "Nome" },
8
+ { key: "sigla", label: "Sigla" },
9
+ ];
10
+ const DADOS = [
11
+ { id: "a", nome: "Ana", sigla: "SADM" },
12
+ { id: "b", nome: "Bruno", sigla: "SOBR" },
13
+ { id: "c", nome: "Carla", sigla: "SEFIN" },
14
+ ];
15
+ describe("DataTable: cabeçalho, zebra e destaque", () => {
16
+ it("headerVariant dark e headerUppercase ligam as classes; sem as props, nada muda", () => {
17
+ const { container, rerender } = render(_jsx(DataTable, { columns: COLUNAS, data: DADOS }));
18
+ const raiz = () => container.querySelector(".umds-datatable");
19
+ expect(raiz().className).not.toMatch(/header-dark|header-uppercase|striped|header-hidden/);
20
+ rerender(_jsx(DataTable, { columns: COLUNAS, data: DADOS, headerVariant: "dark", headerUppercase: true, striped: true, hideHeader: true }));
21
+ expect(raiz()).toHaveClass("umds-datatable--header-dark");
22
+ expect(raiz()).toHaveClass("umds-datatable--header-uppercase");
23
+ expect(raiz()).toHaveClass("umds-datatable--striped");
24
+ expect(raiz()).toHaveClass("umds-datatable--header-hidden");
25
+ });
26
+ it("hideHeader não remove o cabeçalho: as colunas continuam nomeadas", () => {
27
+ render(_jsx(DataTable, { columns: COLUNAS, data: DADOS, hideHeader: true }));
28
+ expect(screen.getAllByRole("columnheader")).toHaveLength(2);
29
+ });
30
+ it("striped marca as linhas ímpares", () => {
31
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: DADOS, striped: true }));
32
+ const linhas = [...container.querySelectorAll("tbody tr")];
33
+ expect(linhas.map((l) => l.classList.contains("umds-datatable__row--striped"))).toEqual([false, true, false]);
34
+ });
35
+ it("selectedRowKeys destaca a linha sem checkbox e marca aria-selected", () => {
36
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: DADOS, rowKey: "id", selectedRowKeys: ["b"] }));
37
+ const linhas = [...container.querySelectorAll("tbody tr")];
38
+ expect(linhas[1]).toHaveClass("umds-datatable__row--selected");
39
+ expect(linhas[1]).toHaveClass("umds-datatable__row--highlighted");
40
+ expect(linhas[1]).toHaveAttribute("aria-selected", "true");
41
+ expect(linhas[0]).not.toHaveClass("umds-datatable__row--selected");
42
+ expect(linhas[0]).not.toHaveAttribute("aria-selected");
43
+ expect(screen.queryByRole("checkbox")).toBeNull();
44
+ });
45
+ it("isRowSelected destaca por função", () => {
46
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: DADOS, isRowSelected: (row) => row.sigla === "SEFIN" }));
47
+ const linhas = [...container.querySelectorAll("tbody tr")];
48
+ expect(linhas[2]).toHaveClass("umds-datatable__row--selected");
49
+ expect(linhas[0]).not.toHaveClass("umds-datatable__row--selected");
50
+ });
51
+ it("emptyIcon e emptyDescription entram no estado vazio", () => {
52
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: [], emptyMessage: "Nada por aqui", emptyDescription: "Ajuste o filtro de setor.", emptyIcon: faBoxOpen }));
53
+ expect(screen.getByText("Nada por aqui")).toBeInTheDocument();
54
+ expect(screen.getByText("Ajuste o filtro de setor.")).toBeInTheDocument();
55
+ expect(container.querySelector(".umds-datatable__empty-icon svg")).toHaveAttribute("data-icon", "box-open");
56
+ });
57
+ it("o ícone padrão do estado vazio continua o inbox", () => {
58
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: [] }));
59
+ expect(container.querySelector(".umds-datatable__empty-icon svg")).toHaveAttribute("data-icon", "inbox");
60
+ expect(container.querySelector(".umds-datatable__empty-desc")).toBeNull();
61
+ });
62
+ it("compact na tabela de documento soma as duas classes", () => {
63
+ const { container } = render(_jsx(DataTable, { variant: "document", density: "compact", columns: COLUNAS, data: DADOS }));
64
+ const raiz = container.querySelector(".umds-datatable");
65
+ expect(raiz).toHaveClass("umds-datatable--document");
66
+ expect(raiz).toHaveClass("umds-datatable--compact");
67
+ });
68
+ });
69
+ const ARVORE = [
70
+ {
71
+ id: "gab",
72
+ nome: "Gabinete",
73
+ sigla: "GAB",
74
+ children: [
75
+ { id: "sadm", nome: "Administração", sigla: "SADM", children: [{ id: "rh", nome: "Recursos Humanos", sigla: "RH" }] },
76
+ { id: "sobr", nome: "Obras", sigla: "SOBR" },
77
+ ],
78
+ },
79
+ { id: "sefin", nome: "Finanças", sigla: "SEFIN" },
80
+ ];
81
+ const linhas = (c) => [...c.querySelectorAll("tbody tr")];
82
+ const nomes = (c) => linhas(c).map((l) => l.querySelectorAll("td")[0].textContent);
83
+ describe("DataTable treeData", () => {
84
+ it("vira treegrid; fechada, mostra só as raízes, com aria-level, posinset, setsize e expanded", () => {
85
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id" }));
86
+ expect(screen.getByRole("treegrid")).toBeInTheDocument();
87
+ expect(nomes(container)).toEqual(["Gabinete", "Finanças"]);
88
+ const [gab, fin] = linhas(container);
89
+ expect(gab).toHaveAttribute("aria-level", "1");
90
+ expect(gab).toHaveAttribute("aria-posinset", "1");
91
+ expect(gab).toHaveAttribute("aria-setsize", "2");
92
+ expect(gab).toHaveAttribute("aria-expanded", "false");
93
+ expect(fin).not.toHaveAttribute("aria-expanded");
94
+ });
95
+ it("o botão expande e recolhe, com nome acessível e onExpand", () => {
96
+ const aoExpandir = vi.fn();
97
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", onExpand: aoExpandir }));
98
+ fireEvent.click(screen.getByRole("button", { name: "Expandir" }));
99
+ expect(nomes(container)).toEqual(["Gabinete", "Administração", "Obras", "Finanças"]);
100
+ expect(aoExpandir).toHaveBeenCalledWith(["gab"], ARVORE[0], true);
101
+ const filha = linhas(container)[1];
102
+ expect(filha).toHaveAttribute("aria-level", "2");
103
+ expect(filha).toHaveAttribute("aria-expanded", "false");
104
+ fireEvent.click(screen.getAllByRole("button", { name: "Recolher" })[0]);
105
+ expect(nomes(container)).toEqual(["Gabinete", "Finanças"]);
106
+ expect(aoExpandir).toHaveBeenLastCalledWith([], ARVORE[0], false);
107
+ });
108
+ it("expandLabel e collapseLabel traduzem os botões", () => {
109
+ render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", defaultExpandedKeys: ["gab"], expandLabel: "Expand", collapseLabel: "Collapse" }));
110
+ expect(screen.getByRole("button", { name: "Collapse" })).toBeInTheDocument();
111
+ expect(screen.getByRole("button", { name: "Expand" })).toBeInTheDocument();
112
+ });
113
+ it("defaultExpandAll abre tudo, e o primeiro recolher parte da árvore aberta", () => {
114
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", defaultExpandAll: true }));
115
+ expect(nomes(container)).toEqual(["Gabinete", "Administração", "Recursos Humanos", "Obras", "Finanças"]);
116
+ expect(linhas(container)[2]).toHaveAttribute("aria-level", "3");
117
+ fireEvent.click(screen.getAllByRole("button", { name: "Recolher" })[1]);
118
+ expect(nomes(container)).toEqual(["Gabinete", "Administração", "Obras", "Finanças"]);
119
+ });
120
+ it("expandedKeys controla: o clique avisa, mas só muda quando o pai muda a prop", () => {
121
+ const aoExpandir = vi.fn();
122
+ const { container, rerender } = render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", expandedKeys: [], onExpand: aoExpandir }));
123
+ fireEvent.click(screen.getByRole("button", { name: "Expandir" }));
124
+ expect(aoExpandir).toHaveBeenCalledWith(["gab"], ARVORE[0], true);
125
+ expect(nomes(container)).toEqual(["Gabinete", "Finanças"]);
126
+ rerender(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", expandedKeys: ["gab"], onExpand: aoExpandir }));
127
+ expect(nomes(container)).toEqual(["Gabinete", "Administração", "Obras", "Finanças"]);
128
+ });
129
+ it("sem rowKey, a chave é o caminho de índices", () => {
130
+ const aoExpandir = vi.fn();
131
+ render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, onExpand: aoExpandir }));
132
+ fireEvent.click(screen.getByRole("button", { name: "Expandir" }));
133
+ expect(aoExpandir.mock.calls[0][0]).toEqual(["0"]);
134
+ });
135
+ it("desenha os fios: tee para quem tem irmã depois, elbow para a última, line para o que continua", () => {
136
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", defaultExpandAll: true }));
137
+ const guias = (l) => [...l.querySelectorAll(".umds-datatable__guide")].map((g) => g.className.replace("umds-datatable__guide umds-datatable__guide--", ""));
138
+ const [gab, sadm, rh, sobr] = linhas(container);
139
+ expect(guias(gab)).toEqual([]);
140
+ expect(guias(sadm)).toEqual(["tee"]);
141
+ expect(guias(rh)).toEqual(["line", "elbow"]);
142
+ expect(guias(sobr)).toEqual(["elbow"]);
143
+ });
144
+ it("o recuo cresce por nível", () => {
145
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", defaultExpandAll: true }));
146
+ const recuo = (l) => l.querySelector(".umds-datatable__tree-content").style.paddingLeft;
147
+ expect(recuo(linhas(container)[0])).toContain("calc(0 *");
148
+ expect(recuo(linhas(container)[2])).toContain("calc(2 *");
149
+ });
150
+ it("teclado: ↓ ↑ andam, → expande e desce, ← recolhe e sobe, Home e End", () => {
151
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id" }));
152
+ const gab = linhas(container)[0];
153
+ gab.focus();
154
+ expect(gab).toHaveAttribute("tabindex", "0");
155
+ expect(linhas(container)[1]).toHaveAttribute("tabindex", "-1");
156
+ fireEvent.keyDown(gab, { key: "ArrowRight" });
157
+ expect(nomes(container)).toEqual(["Gabinete", "Administração", "Obras", "Finanças"]);
158
+ expect(document.activeElement).toBe(gab);
159
+ fireEvent.keyDown(gab, { key: "ArrowRight" });
160
+ expect(document.activeElement).toBe(linhas(container)[1]);
161
+ fireEvent.keyDown(document.activeElement, { key: "ArrowDown" });
162
+ expect(document.activeElement).toBe(linhas(container)[2]);
163
+ expect(linhas(container)[2]).toHaveAttribute("tabindex", "0");
164
+ fireEvent.keyDown(document.activeElement, { key: "ArrowLeft" });
165
+ expect(document.activeElement).toBe(linhas(container)[0]);
166
+ fireEvent.keyDown(document.activeElement, { key: "End" });
167
+ expect(document.activeElement).toBe(linhas(container)[3]);
168
+ fireEvent.keyDown(document.activeElement, { key: "Home" });
169
+ expect(document.activeElement).toBe(linhas(container)[0]);
170
+ fireEvent.keyDown(document.activeElement, { key: "ArrowLeft" });
171
+ expect(nomes(container)).toEqual(["Gabinete", "Finanças"]);
172
+ });
173
+ it("clicar no botão não aciona o onRowClick da linha", () => {
174
+ const aoClicar = vi.fn();
175
+ render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", onRowClick: aoClicar }));
176
+ fireEvent.click(screen.getByRole("button", { name: "Expandir" }));
177
+ expect(aoClicar).not.toHaveBeenCalled();
178
+ });
179
+ it("sem treeData, a tabela é a de sempre: sem role, sem aria-level", () => {
180
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: ARVORE }));
181
+ expect(screen.queryByRole("treegrid")).toBeNull();
182
+ expect(container.querySelector("[aria-level]")).toBeNull();
183
+ expect(container.querySelector(".umds-datatable__tree-toggle")).toBeNull();
184
+ });
185
+ it("childrenKey troca o campo das filhas", () => {
186
+ const dados = [{ id: 1, nome: "Pai", sigla: "P", itens: [{ id: 2, nome: "Filho", sigla: "F" }] }];
187
+ const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: dados, treeData: true, childrenKey: "itens", rowKey: "id", defaultExpandAll: true }));
188
+ expect(nomes(container)).toEqual(["Pai", "Filho"]);
189
+ });
190
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { describe, expect, it } from "vitest";
3
+ import { render, screen, within } from "@testing-library/react";
4
+ import DataTable from "../components/DataTable/DataTable";
5
+ /**
6
+ * Célula livre (`render` devolvendo nó) e linha de grupo (`rowGroup`).
7
+ * No Vue o equivalente é o slot `#cell-<key>`: ver `datatable-slots.test.mjs`.
8
+ */
9
+ const USUARIOS = [
10
+ { id: 1, nome: "Lucas Andrade", setor: "SADM", perfil: "Administrador" },
11
+ { id: 2, nome: "Marina Souza", setor: "SADM", perfil: "Nível 1" },
12
+ { id: 3, nome: "Rafael Pereira", setor: "SOBR", perfil: "Nível 2" },
13
+ ];
14
+ describe("DataTable · célula livre", () => {
15
+ it("render devolvendo elemento desenha o nó, não texto", () => {
16
+ const colunas = [
17
+ { key: "nome", label: "Usuário", render: (row) => _jsx("strong", { "data-testid": "nome", children: row.nome }) },
18
+ { key: "perfil", label: "Perfil" },
19
+ ];
20
+ render(_jsx(DataTable, { columns: colunas, data: USUARIOS }));
21
+ const nos = screen.getAllByTestId("nome");
22
+ expect(nos).toHaveLength(3);
23
+ expect(nos[0].tagName).toBe("STRONG");
24
+ expect(nos[0]).toHaveTextContent("Lucas Andrade");
25
+ });
26
+ it("render recebe a linha e o índice", () => {
27
+ const colunas = [
28
+ { key: "nome", label: "Usuário", render: (row, i) => `${i + 1}. ${row.nome}` },
29
+ ];
30
+ render(_jsx(DataTable, { columns: colunas, data: USUARIOS }));
31
+ expect(screen.getByText("2. Marina Souza")).toBeInTheDocument();
32
+ });
33
+ it("DataTableColumn é exportado e tipa a coluna com render de nó", () => {
34
+ const coluna = {
35
+ key: "acoes",
36
+ label: "Ações",
37
+ render: () => _jsx("button", { type: "button", children: "Editar" }),
38
+ };
39
+ render(_jsx(DataTable, { columns: [coluna], data: USUARIOS }));
40
+ expect(screen.getAllByRole("button", { name: "Editar" })).toHaveLength(3);
41
+ });
42
+ });
43
+ describe("DataTable · linha de grupo (rowGroup)", () => {
44
+ const colunas = [
45
+ { key: "nome", label: "Usuário" },
46
+ { key: "perfil", label: "Perfil" },
47
+ ];
48
+ it("sem rowGroup não desenha linha de grupo", () => {
49
+ const { container } = render(_jsx(DataTable, { columns: colunas, data: USUARIOS }));
50
+ expect(container.querySelector("th[scope='rowgroup']")).toBeNull();
51
+ });
52
+ it("rowGroup por campo abre um grupo por valor consecutivo", () => {
53
+ const { container } = render(_jsx(DataTable, { columns: colunas, data: USUARIOS, rowGroup: "setor" }));
54
+ const grupos = container.querySelectorAll("th[scope='rowgroup']");
55
+ expect(Array.from(grupos).map((g) => g.textContent)).toEqual(["SADM", "SOBR"]);
56
+ // a linha de grupo atravessa as colunas todas
57
+ expect(grupos[0]).toHaveAttribute("colspan", "2");
58
+ });
59
+ it("rowGroup por função e colspan com selectable", () => {
60
+ const { container } = render(_jsx(DataTable, { columns: colunas, data: USUARIOS, selectable: true, rowGroup: (row) => (row.id === 3 ? undefined : "Equipe A") }));
61
+ const grupos = container.querySelectorAll("th[scope='rowgroup']");
62
+ expect(grupos).toHaveLength(1);
63
+ expect(grupos[0]).toHaveTextContent("Equipe A");
64
+ expect(grupos[0]).toHaveAttribute("colspan", "3");
65
+ });
66
+ it("renderRowGroup devolve nó", () => {
67
+ render(_jsx(DataTable, { columns: colunas, data: USUARIOS, rowGroup: "setor", renderRowGroup: (rotulo) => _jsxs("em", { "data-testid": "grupo", children: [rotulo, "!"] }) }));
68
+ expect(screen.getAllByTestId("grupo").map((n) => n.textContent)).toEqual(["SADM!", "SOBR!"]);
69
+ });
70
+ it("a linha de grupo não entra na seleção por índice", async () => {
71
+ const { container } = render(_jsx(DataTable, { columns: colunas, data: USUARIOS, rowGroup: "setor", selectable: true, selectedRows: [2] }));
72
+ const selecionadas = container.querySelectorAll(".umds-datatable__row--selected");
73
+ expect(selecionadas).toHaveLength(1);
74
+ expect(within(selecionadas[0]).getByText("Rafael Pereira")).toBeInTheDocument();
75
+ });
76
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,92 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { describe, expect, it, vi } from "vitest";
3
+ import { render, screen } from "@testing-library/react";
4
+ import userEvent from "@testing-library/user-event";
5
+ import DataTable from "../components/DataTable/DataTable";
6
+ import DescriptionList from "../components/DescriptionList/DescriptionList";
7
+ const COLUNAS = [
8
+ { key: "descricao", label: "Descrição", sortable: true },
9
+ { key: "quantidade", label: "Quantidade", align: "right" },
10
+ ];
11
+ const DADOS = [
12
+ { descricao: "Diesel S10", quantidade: "5.760" },
13
+ { descricao: "Gasolina comum", quantidade: "1.200" },
14
+ ];
15
+ describe("DataTable variant=document", () => {
16
+ it("é a tabela de documento: classe própria, cabeçalho e linhas", () => {
17
+ const { container } = render(_jsx(DataTable, { variant: "document", columns: COLUNAS, data: DADOS }));
18
+ expect(container.querySelector(".umds-datatable--document")).not.toBeNull();
19
+ expect(screen.getAllByRole("columnheader")).toHaveLength(2);
20
+ expect(screen.getByText("Diesel S10")).toBeInTheDocument();
21
+ });
22
+ it("não ordena: sem botão de ordenar, sem aria-sort", () => {
23
+ render(_jsx(DataTable, { variant: "document", columns: COLUNAS, data: DADOS, sortKey: "descricao", sortDirection: "asc" }));
24
+ expect(screen.queryByRole("button")).toBeNull();
25
+ for (const th of screen.getAllByRole("columnheader"))
26
+ expect(th).not.toHaveAttribute("aria-sort");
27
+ });
28
+ it("não seleciona: selectable é ignorado", () => {
29
+ render(_jsx(DataTable, { variant: "document", selectable: true, columns: COLUNAS, data: DADOS }));
30
+ expect(screen.queryByRole("checkbox")).toBeNull();
31
+ expect(screen.getAllByRole("columnheader")).toHaveLength(2);
32
+ });
33
+ it("linha não é clicável nem entra na ordem de Tab", async () => {
34
+ const usuario = userEvent.setup();
35
+ const aoClicar = vi.fn();
36
+ const { container } = render(_jsx(DataTable, { variant: "document", columns: COLUNAS, data: DADOS, onRowClick: aoClicar }));
37
+ const linha = container.querySelector("tbody tr");
38
+ expect(linha).not.toHaveAttribute("tabindex");
39
+ expect(linha).not.toHaveClass("umds-datatable__row--clickable");
40
+ await usuario.click(linha);
41
+ expect(aoClicar).not.toHaveBeenCalled();
42
+ });
43
+ it("a tabela de interface continua igual (ordena, seleciona, clica)", async () => {
44
+ const usuario = userEvent.setup();
45
+ const aoOrdenar = vi.fn();
46
+ render(_jsx(DataTable, { columns: COLUNAS, data: DADOS, selectable: true, onSort: aoOrdenar }));
47
+ expect(screen.getAllByRole("checkbox").length).toBeGreaterThan(0);
48
+ await usuario.click(screen.getByRole("button", { name: /Descrição/ }));
49
+ expect(aoOrdenar).toHaveBeenCalledWith("descricao", "asc");
50
+ });
51
+ });
52
+ describe("DescriptionList", () => {
53
+ const ITENS = [
54
+ { label: "Dotação", value: "02.031.0001" },
55
+ { label: "Empenho", value: "2026NE000184" },
56
+ { label: "Fonte", value: "" },
57
+ ];
58
+ it("é um dl com um dt e um dd por par", () => {
59
+ const { container } = render(_jsx(DescriptionList, { items: ITENS, ariaLabel: "Dados de empenho" }));
60
+ const dl = container.querySelector("dl");
61
+ expect(dl).toHaveAttribute("aria-label", "Dados de empenho");
62
+ expect(dl.querySelectorAll("dt")).toHaveLength(3);
63
+ expect(dl.querySelectorAll("dd")).toHaveLength(3);
64
+ expect(dl.querySelector("dt")).toHaveTextContent("Dotação");
65
+ expect(dl.querySelector("dd")).toHaveTextContent("02.031.0001");
66
+ });
67
+ it("valor vazio mostra o traço, ou o texto de emptyValue", () => {
68
+ const { container, rerender } = render(_jsx(DescriptionList, { items: ITENS }));
69
+ expect(container.querySelectorAll("dd")[2]).toHaveTextContent("—");
70
+ rerender(_jsx(DescriptionList, { items: ITENS, emptyValue: "N\u00E3o informado" }));
71
+ expect(container.querySelectorAll("dd")[2]).toHaveTextContent("Não informado");
72
+ });
73
+ it("inline é o padrão; fit encolhe", () => {
74
+ const { container, rerender } = render(_jsx(DescriptionList, { items: ITENS }));
75
+ const dl = container.querySelector("dl");
76
+ expect(dl).toHaveClass("umds-description-list--inline");
77
+ expect(dl).not.toHaveClass("umds-description-list--fit");
78
+ rerender(_jsx(DescriptionList, { items: ITENS, fit: true }));
79
+ expect(container.querySelector("dl")).toHaveClass("umds-description-list--fit");
80
+ });
81
+ it("stacked ganha as colunas e a caixa do valor", () => {
82
+ const { container } = render(_jsx(DescriptionList, { items: ITENS, layout: "stacked", columns: 3, bordered: true }));
83
+ const dl = container.querySelector("dl");
84
+ expect(dl).toHaveClass("umds-description-list--stacked");
85
+ expect(dl).toHaveClass("umds-description-list--cols-3");
86
+ expect(dl).toHaveClass("umds-description-list--bordered");
87
+ });
88
+ it("sem itens, não desenha par nenhum", () => {
89
+ const { container } = render(_jsx(DescriptionList, {}));
90
+ expect(container.querySelectorAll("dt")).toHaveLength(0);
91
+ });
92
+ });
@@ -69,3 +69,26 @@ describe("DatePicker · teclado", () => {
69
69
  expect(screen.getByRole("combobox")).toHaveTextContent(/15\/\d{2}\/\d{4}/);
70
70
  });
71
71
  });
72
+ /**
73
+ * A story "Com valor" mostrava "Selecione o período" com `value="2025-12-31"`.
74
+ * Não era a story: no modo single o componente só lia `range`, e `value` e
75
+ * `defaultValue` eram declarados e nunca chegavam ao campo.
76
+ */
77
+ describe("DatePicker · valor no modo single", () => {
78
+ it("`value` aparece no campo, no formato pedido", () => {
79
+ render(_jsx(DatePicker, { label: "Vencimento", value: "2025-12-31", format: "DD/MM/YYYY" }));
80
+ expect(screen.getByRole("combobox")).toHaveTextContent("31/12/2025");
81
+ });
82
+ it("`defaultValue` semeia o campo no modo não-controlado", () => {
83
+ render(_jsx(DatePicker, { label: "Vencimento", defaultValue: "2025-06-15" }));
84
+ expect(screen.getByRole("combobox")).toHaveTextContent("15/06/2025");
85
+ });
86
+ it("`value` vazio no modo controlado mostra o placeholder", () => {
87
+ render(_jsx(DatePicker, { label: "Vencimento", value: "", placeholder: "DD/MM/AAAA" }));
88
+ expect(screen.getByRole("combobox")).toHaveTextContent("DD/MM/AAAA");
89
+ });
90
+ it("o modo range continua lendo `range`, não `value`", () => {
91
+ render(_jsx(DatePicker, { mode: "range", label: "Per\u00EDodo", value: "2025-01-01", range: { from: "2025-03-01", to: "2025-03-10" } }));
92
+ expect(screen.getByRole("combobox")).toHaveTextContent("01/03/2025 – 10/03/2025");
93
+ });
94
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { describe, expect, it } from "vitest";
3
+ import { render } from "@testing-library/react";
4
+ import DescriptionList from "../components/DescriptionList/DescriptionList";
5
+ const ITENS = [{ label: "Dotação", value: "02.031.0001" }];
6
+ describe("DescriptionList · density", () => {
7
+ it("compact escreve a classe; o padrão não", () => {
8
+ const { container, rerender } = render(_jsx(DescriptionList, { items: ITENS, density: "compact" }));
9
+ const dl = () => container.querySelector("dl");
10
+ expect(dl()).toHaveClass("umds-description-list--compact");
11
+ rerender(_jsx(DescriptionList, { items: ITENS, density: "default" }));
12
+ expect(dl()).not.toHaveClass("umds-description-list--compact");
13
+ rerender(_jsx(DescriptionList, { items: ITENS }));
14
+ expect(dl()).not.toHaveClass("umds-description-list--compact");
15
+ });
16
+ it("compact vale nos dois desenhos", () => {
17
+ const { container, rerender } = render(_jsx(DescriptionList, { items: ITENS, density: "compact", layout: "stacked", bordered: true }));
18
+ expect(container.querySelector("dl")).toHaveClass("umds-description-list--stacked", "umds-description-list--compact");
19
+ rerender(_jsx(DescriptionList, { items: ITENS, density: "compact", fit: true }));
20
+ expect(container.querySelector("dl")).toHaveClass("umds-description-list--inline", "umds-description-list--compact");
21
+ });
22
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { describe, expect, it } from "vitest";
3
+ import { render, screen } from "@testing-library/react";
4
+ import { faInbox } from "@fortawesome/free-solid-svg-icons";
5
+ import EmptyState from "../components/EmptyState/EmptyState";
6
+ describe("EmptyState · título rico", () => {
7
+ it("título em texto continua igual", () => {
8
+ const { container } = render(_jsx(EmptyState, { icon: faInbox, title: "Nenhuma mensagem", description: "Tudo em dia." }));
9
+ expect(container.querySelector(".umds-empty-state__title")).toHaveTextContent("Nenhuma mensagem");
10
+ expect(screen.getByText("Tudo em dia.")).toBeInTheDocument();
11
+ });
12
+ it("título aceita conteúdo rico: negrito, link", () => {
13
+ const { container } = render(_jsx(EmptyState, { title: _jsxs(_Fragment, { children: ["Nenhum processo para ", _jsx("strong", { "data-testid": "termo", children: "SOBR" }), " ", _jsx("a", { href: "#limpar", children: "Limpar filtro" })] }) }));
14
+ const titulo = container.querySelector(".umds-empty-state__title");
15
+ expect(titulo).toContainElement(screen.getByTestId("termo"));
16
+ expect(titulo.querySelector("a")).toHaveAttribute("href", "#limpar");
17
+ });
18
+ it("o título é um div (conteúdo de bloco não vira HTML inválido dentro de p)", () => {
19
+ const { container } = render(_jsx(EmptyState, { title: _jsx("div", { "data-testid": "bloco", children: "Bloco" }) }));
20
+ expect(container.querySelector(".umds-empty-state__title").tagName).toBe("DIV");
21
+ expect(screen.getByTestId("bloco").parentElement).toHaveClass("umds-empty-state__title");
22
+ });
23
+ });
@@ -0,0 +1 @@
1
+ export {};