@1doc/1ds-vue 2.7.2 → 2.9.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 (45) hide show
  1. package/CHANGELOG.md +1289 -0
  2. package/dist/index.css +1 -1
  3. package/dist/index.d.ts +1218 -32
  4. package/dist/index.mjs +11156 -7808
  5. package/dist/index.umd.js +4 -4
  6. package/package.json +5 -4
  7. package/src/index.ts +26 -0
  8. package/src/teste/accordion-conteudo-livre.test.mjs +44 -0
  9. package/src/teste/atributos.test.mjs +91 -0
  10. package/src/teste/attachmentcard-ia.test.mjs +48 -0
  11. package/src/teste/avatargroup-overlap.test.mjs +45 -0
  12. package/src/teste/badge-tag.test.mjs +45 -0
  13. package/src/teste/box-item-flex.test.mjs +84 -0
  14. package/src/teste/box-layout.test.mjs +57 -0
  15. package/src/teste/button.test.mjs +34 -0
  16. package/src/teste/calendar.test.mjs +179 -0
  17. package/src/teste/chips-xs.test.mjs +33 -0
  18. package/src/teste/coachmark.test.mjs +119 -0
  19. package/src/teste/color-picker.test.mjs +79 -0
  20. package/src/teste/datatable-documento.test.mjs +106 -0
  21. package/src/teste/datatable-slots.test.mjs +105 -0
  22. package/src/teste/dom.mjs +168 -0
  23. package/src/teste/fileinput-trigger.test.mjs +36 -0
  24. package/src/teste/icon-picker.test.mjs +98 -0
  25. package/src/teste/input-mascara-afins.test.mjs +64 -0
  26. package/src/teste/kbd-code-block.test.mjs +76 -0
  27. package/src/teste/list.test.mjs +162 -0
  28. package/src/teste/modal-variantes.test.mjs +79 -0
  29. package/src/teste/org-chart.test.mjs +131 -0
  30. package/src/teste/otp-input.test.mjs +130 -0
  31. package/src/teste/popover-maxheight.test.mjs +26 -0
  32. package/src/teste/renderizar.mjs +64 -0
  33. package/src/teste/rich-text-editor.test.mjs +210 -0
  34. package/src/teste/select-placement-filtro.test.mjs +49 -0
  35. package/src/teste/stack-box-raiz-unica.test.mjs +134 -0
  36. package/src/teste/stack.test.mjs +80 -0
  37. package/src/teste/statcard-rotulo-topo.test.mjs +34 -0
  38. package/src/teste/tabs-contador-fechavel.test.mjs +60 -0
  39. package/src/teste/tooltip-dark.test.mjs +28 -0
  40. package/src/utils/calendario.ts +78 -0
  41. package/src/utils/chart.ts +7 -2
  42. package/src/utils/html-seguro.ts +94 -0
  43. package/src/utils/id.ts +24 -0
  44. package/src/utils/paleta-de-cores.ts +34 -0
  45. package/src/utils/texto.ts +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1doc/1ds-vue",
3
- "version": "2.7.2",
3
+ "version": "2.9.0",
4
4
  "main": "dist/index.umd.js",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -30,8 +30,8 @@
30
30
  "vite": "^7.3.1",
31
31
  "vue": "^3.0.0",
32
32
  "vue-tsc": "^2.0.0",
33
- "@1doc/1ds-tokens": "0.4.1",
34
- "@1doc/1ds-core": "2.7.3"
33
+ "@1doc/1ds-tokens": "0.5.0",
34
+ "@1doc/1ds-core": "2.9.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@1doc/1ds-tokens": ">=0.1.0",
@@ -41,6 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "scripts": {
44
- "build": "vue-tsc --noEmit && vite build && node ../../scripts/get-vue-types.mjs"
44
+ "build": "vue-tsc --noEmit && vite build && node ../../scripts/get-vue-types.mjs",
45
+ "test": "node --test \"src/teste/*.test.mjs\""
45
46
  }
46
47
  }
package/src/index.ts CHANGED
@@ -5,6 +5,8 @@ export * from "./utils/theme";
5
5
  export * from "./utils/toast";
6
6
  // Densidade global (modo touch ≥44px via data-density)
7
7
  export * from "./utils/density";
8
+ // Paleta de cor categórica (primitivos) do ColorPicker
9
+ export * from "./utils/paleta-de-cores";
8
10
  // FontAwesome
9
11
  export { library } from "@fortawesome/fontawesome-svg-core";
10
12
 
@@ -12,6 +14,9 @@ export { library } from "@fortawesome/fontawesome-svg-core";
12
14
  export { default as Accordion } from "./components/Accordion/Accordion.vue";
13
15
  export { default as AILabel } from "./components/AILabel/AILabel.vue";
14
16
  export { default as AIContent } from "./components/AIContent/AIContent.vue";
17
+ export { default as Calendar } from "./components/Calendar/Calendar.vue";
18
+ export { default as Coachmark } from "./components/Coachmark/Coachmark.vue";
19
+ export { default as CodeBlock } from "./components/CodeBlock/CodeBlock.vue";
15
20
  export { default as ConfirmAIAction } from "./components/ConfirmAIAction/ConfirmAIAction.vue";
16
21
  export { default as Alert } from "./components/Alert/Alert.vue";
17
22
  export { default as AppHeader } from "./components/AppHeader/AppHeader.vue";
@@ -33,11 +38,13 @@ export { default as Button } from "./components/Button/Button.vue";
33
38
  export { default as Card } from "./components/Card/Card.vue";
34
39
  export { default as Checkbox } from "./components/Checkbox/Checkbox.vue";
35
40
  export { default as Chips } from "./components/Chips/Chips.vue";
41
+ export { default as ColorPicker } from "./components/ColorPicker/ColorPicker.vue";
36
42
  export { default as Combobox } from "./components/Combobox/Combobox.vue";
37
43
  export { default as ConfirmDialog } from "./components/ConfirmDialog/ConfirmDialog.vue";
38
44
  export { default as Container } from "./components/Container/Container.vue";
39
45
  export { default as DataTable } from "./components/DataTable/DataTable.vue";
40
46
  export { default as DatePicker } from "./components/DatePicker/DatePicker.vue";
47
+ export { default as DescriptionList } from "./components/DescriptionList/DescriptionList.vue";
41
48
  export { default as Divider } from "./components/Divider/Divider.vue";
42
49
  export { default as DonutChart } from "./components/Chart/DonutChart.vue";
43
50
  export { default as Drawer } from "./components/Drawer/Drawer.vue";
@@ -46,15 +53,21 @@ export { default as EmptyState } from "./components/EmptyState/EmptyState.vue";
46
53
  export { default as FileInput } from "./components/FileInput/FileInput.vue";
47
54
  export { default as Grid } from "./components/Grid/Grid.vue";
48
55
  export { default as Icon } from "./components/Icon/Icon.vue";
56
+ export { default as IconPicker } from "./components/IconPicker/IconPicker.vue";
49
57
  export { default as Input } from "./components/Input/Input.vue";
50
58
  export { default as Kanban } from "./components/Kanban/Kanban.vue";
51
59
  export { default as KanbanCard } from "./components/Kanban/KanbanCard.vue";
52
60
  export { default as KanbanColumn } from "./components/Kanban/KanbanColumn.vue";
61
+ export { default as Kbd } from "./components/Kbd/Kbd.vue";
53
62
  export { default as Link } from "./components/Link/Link.vue";
54
63
  export { default as LineChart } from "./components/Chart/LineChart.vue";
64
+ export { default as List } from "./components/List/List.vue";
65
+ export { default as ListItem } from "./components/List/ListItem.vue";
55
66
  export { default as Logo } from "./components/Logo/Logo.vue";
56
67
  export { default as Modal } from "./components/Modal/Modal.vue";
57
68
  export { default as MultiSelect } from "./components/MultiSelect/MultiSelect.vue";
69
+ export { default as OrgChart } from "./components/OrgChart/OrgChart.vue";
70
+ export { default as OtpInput } from "./components/OtpInput/OtpInput.vue";
58
71
  export { default as PageHeader } from "./components/PageHeader/PageHeader.vue";
59
72
  export { default as Pagination } from "./components/Pagination/Pagination.vue";
60
73
  export { default as PhoneInput } from "./components/PhoneInput/PhoneInput.vue";
@@ -62,6 +75,7 @@ export { default as Podium } from "./components/Podium/Podium.vue";
62
75
  export { default as ProgressBar } from "./components/ProgressBar/ProgressBar.vue";
63
76
  export { default as Radio } from "./components/Radio/Radio.vue";
64
77
  export { default as RadioGroup } from "./components/Radio/RadioGroup.vue";
78
+ export { default as RichTextEditor } from "./components/RichTextEditor/RichTextEditor.vue";
65
79
  export { default as SegmentedControl } from "./components/SegmentedControl/SegmentedControl.vue";
66
80
  export { default as Select } from "./components/Select/Select.vue";
67
81
  export { default as SidePanel } from "./components/SidePanel/SidePanel.vue";
@@ -94,6 +108,9 @@ export { default as Tree } from "./components/Tree/Tree.vue";
94
108
  export type * from "./components/Accordion/Accordion.vue";
95
109
  export type * from "./components/AILabel/AILabel.vue";
96
110
  export type * from "./components/AIContent/AIContent.vue";
111
+ export type * from "./components/Calendar/Calendar.vue";
112
+ export type * from "./components/Coachmark/Coachmark.vue";
113
+ export type * from "./components/CodeBlock/CodeBlock.vue";
97
114
  export type * from "./components/ConfirmAIAction/ConfirmAIAction.vue";
98
115
  export type * from "./components/Alert/Alert.vue";
99
116
  export type * from "./components/AppHeader/AppHeader.vue";
@@ -115,11 +132,13 @@ export type * from "./components/Button/Button.vue";
115
132
  export type * from "./components/Card/Card.vue";
116
133
  export type * from "./components/Checkbox/Checkbox.vue";
117
134
  export type * from "./components/Chips/Chips.vue";
135
+ export type * from "./components/ColorPicker/ColorPicker.vue";
118
136
  export type * from "./components/Combobox/Combobox.vue";
119
137
  export type * from "./components/ConfirmDialog/ConfirmDialog.vue";
120
138
  export type * from "./components/Container/Container.vue";
121
139
  export type * from "./components/DataTable/DataTable.vue";
122
140
  export type * from "./components/DatePicker/DatePicker.vue";
141
+ export type * from "./components/DescriptionList/DescriptionList.vue";
123
142
  export type * from "./components/Divider/Divider.vue";
124
143
  export type * from "./components/Chart/DonutChart.vue";
125
144
  export type * from "./components/Drawer/Drawer.vue";
@@ -128,15 +147,21 @@ export type * from "./components/EmptyState/EmptyState.vue";
128
147
  export type * from "./components/FileInput/FileInput.vue";
129
148
  export type * from "./components/Grid/Grid.vue";
130
149
  export type * from "./components/Icon/Icon.vue";
150
+ export type * from "./components/IconPicker/IconPicker.vue";
131
151
  export type * from "./components/Input/Input.vue";
132
152
  export type * from "./components/Kanban/Kanban.vue";
133
153
  export type * from "./components/Kanban/KanbanCard.vue";
134
154
  export type * from "./components/Kanban/KanbanColumn.vue";
155
+ export type * from "./components/Kbd/Kbd.vue";
135
156
  export type * from "./components/Link/Link.vue";
136
157
  export type * from "./components/Chart/LineChart.vue";
158
+ export type * from "./components/List/List.vue";
159
+ export type * from "./components/List/ListItem.vue";
137
160
  export type * from "./components/Logo/Logo.vue";
138
161
  export type * from "./components/Modal/Modal.vue";
139
162
  export type * from "./components/MultiSelect/MultiSelect.vue";
163
+ export type * from "./components/OrgChart/OrgChart.vue";
164
+ export type * from "./components/OtpInput/OtpInput.vue";
140
165
  export type * from "./components/PageHeader/PageHeader.vue";
141
166
  export type * from "./components/Pagination/Pagination.vue";
142
167
  export type * from "./components/PhoneInput/PhoneInput.vue";
@@ -144,6 +169,7 @@ export type * from "./components/Podium/Podium.vue";
144
169
  export type * from "./components/ProgressBar/ProgressBar.vue";
145
170
  export type * from "./components/Radio/Radio.vue";
146
171
  export type * from "./components/Radio/RadioGroup.vue";
172
+ export type * from "./components/RichTextEditor/RichTextEditor.vue";
147
173
  export type * from "./components/SegmentedControl/SegmentedControl.vue";
148
174
  export type * from "./components/Select/Select.vue";
149
175
  export type * from "./components/SidePanel/SidePanel.vue";
@@ -0,0 +1,44 @@
1
+ /** Accordion no Vue GERADO: o slot `content-<id>` por item vale sobre o texto, e sem slot o texto aparece como sempre. */
2
+ import { test, before, after } from "node:test";
3
+ import assert from "node:assert/strict";
4
+ import { h } from "vue";
5
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
6
+
7
+ let Accordion;
8
+
9
+ before(async () => {
10
+ await abrir();
11
+ Accordion = await carregar("Accordion/Accordion.vue");
12
+ });
13
+ after(fechar);
14
+
15
+ const itens = [
16
+ { id: "secao1", title: "Seção 01", content: "texto-um" },
17
+ { id: "secao2", title: "Seção 02", content: "texto-dois" },
18
+ ];
19
+
20
+ test("sem slot, o content de texto aparece como sempre", async () => {
21
+ const html = await renderizar(Accordion, { items: itens });
22
+ assert.match(html, /texto-um/);
23
+ assert.match(html, /texto-dois/);
24
+ });
25
+
26
+ test("o slot content-<id> vale sobre o texto só daquele item", async () => {
27
+ const html = await renderizar(
28
+ Accordion,
29
+ { items: itens },
30
+ { "content-secao1": () => h("input", { id: "campo-livre" }) },
31
+ );
32
+ assert.match(html, /<input id="campo-livre"/);
33
+ assert.doesNotMatch(html, /texto-um/);
34
+ assert.match(html, /texto-dois/);
35
+ });
36
+
37
+ test("o slot recebe o item no escopo", async () => {
38
+ const html = await renderizar(
39
+ Accordion,
40
+ { items: itens },
41
+ { "content-secao2": ({ item }) => `para-${item.id}-${item.title}` },
42
+ );
43
+ assert.match(html, /para-secao2-Seção 02/);
44
+ });
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Defeitos do Vue GERADO pelo Mitosis, que o React não tinha:
3
+ *
4
+ * - Text, Grid e Logo descartavam `title`, `style` e `aria-*` (o laço
5
+ * `for (k in props)` compilava para `props.props`);
6
+ * - o DataTable escrevia a classe `umds-datatable__row--selected.value`;
7
+ * - o Button escrevia `autofocus="false"` no DOM.
8
+ *
9
+ * Roda com `pnpm --filter @1doc/1ds-vue test` (node:test, sem dependência
10
+ * nova) e precisa de `pnpm --filter @1doc/1ds-core build` antes, porque os
11
+ * `.vue` de `src/components` são gerados.
12
+ */
13
+ import { test, before, after } from "node:test";
14
+ import assert from "node:assert/strict";
15
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
16
+
17
+ let Text, Grid, Logo, Button, DataTable;
18
+
19
+ before(async () => {
20
+ await abrir();
21
+ Text = await carregar("Text/Text.vue");
22
+ Grid = await carregar("Grid/Grid.vue");
23
+ Logo = await carregar("Logo/Logo.vue");
24
+ Button = await carregar("Button/Button.vue");
25
+ DataTable = await carregar("DataTable/DataTable.vue");
26
+ });
27
+ after(fechar);
28
+
29
+ test("Text repassa title, style e aria-*", async () => {
30
+ const html = await renderizar(
31
+ Text,
32
+ { title: "Dica", style: "margin-top: 4px", "aria-live": "polite", "data-x": "1" },
33
+ { default: "Olá" },
34
+ );
35
+ assert.match(html, /title="Dica"/);
36
+ assert.match(html, /margin-top:\s*4px/);
37
+ assert.match(html, /aria-live="polite"/);
38
+ assert.match(html, /data-x="1"/);
39
+ });
40
+
41
+ test("Text mantém o estilo próprio (maxLines) junto com o do consumidor", async () => {
42
+ const html = await renderizar(
43
+ Text,
44
+ { maxLines: 2, style: "margin-top: 4px" },
45
+ { default: "Olá" },
46
+ );
47
+ assert.match(html, /--umds-text-max-lines:\s*2/);
48
+ assert.match(html, /margin-top:\s*4px/);
49
+ });
50
+
51
+ test("Grid repassa title, style e aria-*", async () => {
52
+ const html = await renderizar(
53
+ Grid,
54
+ { container: true, spacing: "xxxs", title: "Dica", style: "margin-top: 4px", "aria-label": "Área" },
55
+ { default: "x" },
56
+ );
57
+ assert.match(html, /title="Dica"/);
58
+ assert.match(html, /margin-top:\s*4px/);
59
+ assert.match(html, /aria-label="Área"/);
60
+ assert.match(html, /--umds-grid-gap/);
61
+ });
62
+
63
+ test("Logo repassa title, style e aria-*", async () => {
64
+ const html = await renderizar(Logo, { title: "Dica", style: "width: 80px", "aria-hidden": "true" });
65
+ assert.match(html, /title="Dica"/);
66
+ assert.match(html, /width:\s*80px/);
67
+ assert.match(html, /aria-hidden="true"/);
68
+ });
69
+
70
+ test("Button não escreve autofocus quando falso", async () => {
71
+ const html = await renderizar(Button, {}, { default: "Salvar" });
72
+ assert.doesNotMatch(html, /autofocus/i);
73
+ });
74
+
75
+ test("Button com autoFocus escreve o atributo", async () => {
76
+ const html = await renderizar(Button, { autoFocus: true }, { default: "Salvar" });
77
+ assert.match(html, /autofocus/i);
78
+ });
79
+
80
+ test("DataTable aplica a classe --selected sem '.value'", async () => {
81
+ const html = await renderizar(DataTable, {
82
+ columns: [{ key: "nome", label: "Nome" }],
83
+ data: [{ nome: "Cris Lima" }, { nome: "Ana Paula" }],
84
+ selectable: true,
85
+ selectedRows: [0],
86
+ });
87
+ assert.match(html, /umds-datatable__row--selected(?=[\s"])/);
88
+ assert.doesNotMatch(html, /\.value/);
89
+ // só a primeira linha está selecionada
90
+ assert.equal((html.match(/umds-datatable__row--selected/g) || []).length, 1);
91
+ });
@@ -0,0 +1,48 @@
1
+ /**
2
+ * AttachmentCard no Vue GERADO: o selo de IA e o slot `panel`. O painel vive
3
+ * num Portal e só abre no navegador; o que o SSR mostra, e o que importa para o
4
+ * slot, é a decisão que o componente toma no SCRIPT: sem `statusDetails`, só o
5
+ * slot `panel` deve bastar para o selo virar botão.
6
+ */
7
+ import { test, before, after } from "node:test";
8
+ import assert from "node:assert/strict";
9
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
10
+
11
+ let AttachmentCard;
12
+
13
+ before(async () => {
14
+ await abrir();
15
+ AttachmentCard = await carregar("AttachmentCard/AttachmentCard.vue");
16
+ });
17
+ after(fechar);
18
+
19
+ const base = { fileName: "protocolo.pdf", documentType: "Protocolo", status: "ai", statusLabel: "Recursos IA" };
20
+
21
+ test("status ai escreve a classe do selo e usa a varinha por padrão", async () => {
22
+ const html = await renderizar(AttachmentCard, base);
23
+ assert.match(html, /umds-attachment-card__status--ai/);
24
+ assert.match(html, /umds-attachment-card__status[^>]*>(?:<!--[^>]*-->)*<span class="umds-icon/);
25
+ });
26
+
27
+ test("só o slot panel faz o selo virar botão (sem statusDetails)", async () => {
28
+ const html = await renderizar(AttachmentCard, base, { panel: () => "conteudo livre" });
29
+ assert.match(html, /<button[^>]*aria-haspopup="dialog"/);
30
+ assert.match(html, /umds-attachment-card__status--interativo/);
31
+ });
32
+
33
+ test("sem panel nem statusDetails o selo não é botão", async () => {
34
+ const html = await renderizar(AttachmentCard, base);
35
+ assert.doesNotMatch(html, /aria-haspopup/);
36
+ assert.doesNotMatch(html, /<button/);
37
+ });
38
+
39
+ test("statusDetails continua fazendo o selo virar botão", async () => {
40
+ const html = await renderizar(AttachmentCard, { ...base, status: "positive", statusDetails: { description: "ok" } });
41
+ assert.match(html, /<button[^>]*aria-haspopup="dialog"/);
42
+ });
43
+
44
+ test("declara panelWidth e closePanelOnAction", () => {
45
+ const props = Object.keys(AttachmentCard.props || {});
46
+ assert.ok(props.includes("panelWidth"));
47
+ assert.ok(props.includes("closePanelOnAction"));
48
+ });
@@ -0,0 +1,45 @@
1
+ /** AvatarGroup (overflowCount, overlap, ring) conferido no HTML que o Vue GERADO escreve. */
2
+ import { test, before, after } from "node:test";
3
+ import assert from "node:assert/strict";
4
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
5
+
6
+ let AvatarGroup;
7
+
8
+ before(async () => {
9
+ await abrir();
10
+ AvatarGroup = await carregar("Avatar/AvatarGroup.vue");
11
+ });
12
+ after(fechar);
13
+
14
+ const pessoas = [
15
+ { name: "Ana Souza" },
16
+ { name: "Bruno Lima" },
17
+ { name: "Carla Dias" },
18
+ { name: "Diego Ferraz" },
19
+ { name: "Eduarda Neves" },
20
+ ];
21
+
22
+ test("sem overflowCount, o +N é o que passou de max", async () => {
23
+ assert.match(await renderizar(AvatarGroup, { avatars: pessoas, max: 3 }), />\s*\+2\s*</);
24
+ });
25
+
26
+ test("overflowCount vira o +N sem itens-fantasma", async () => {
27
+ const html = await renderizar(AvatarGroup, { avatars: pessoas.slice(0, 3), max: 3, overflowCount: 12 });
28
+ assert.match(html, />\s*\+12\s*</);
29
+ assert.match(html, /Mais 12 avatares/);
30
+ });
31
+
32
+ test("overflowCount soma com o que passou de max", async () => {
33
+ assert.match(await renderizar(AvatarGroup, { avatars: pessoas, max: 3, overflowCount: 10 }), />\s*\+12\s*</);
34
+ });
35
+
36
+ test("sem excedente não há +N", async () => {
37
+ assert.doesNotMatch(await renderizar(AvatarGroup, { avatars: pessoas.slice(0, 2), max: 4 }), />\s*\+\d+\s*</);
38
+ });
39
+
40
+ test("overlap e ring escrevem as variáveis do grupo; sem eles, nenhum style", async () => {
41
+ const html = await renderizar(AvatarGroup, { avatars: pessoas, overlap: 6, ring: 1 });
42
+ assert.match(html, /--umds-avatar-group-overlap:\s*6px/);
43
+ assert.match(html, /--umds-avatar-group-ring:\s*1px/);
44
+ assert.doesNotMatch(await renderizar(AvatarGroup, { avatars: pessoas }), /--umds-avatar-group/);
45
+ });
@@ -0,0 +1,45 @@
1
+ /** Badge (2xs, new, attached) e Tag (xs, soft, pill, new), conferidos no HTML que o Vue GERADO escreve. */
2
+ import { test, before, after } from "node:test";
3
+ import assert from "node:assert/strict";
4
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
5
+
6
+ let Badge, Tag;
7
+
8
+ before(async () => {
9
+ await abrir();
10
+ Badge = await carregar("Badge/Badge.vue");
11
+ Tag = await carregar("Tag/Tag.vue");
12
+ });
13
+ after(fechar);
14
+
15
+ test("Badge size 2xs escreve a classe; sem size continua md", async () => {
16
+ assert.match(await renderizar(Badge, { size: "2xs" }, { default: "A" }), /umds-badge--2xs/);
17
+ assert.match(await renderizar(Badge, {}, { default: "B" }), /umds-badge--md/);
18
+ });
19
+
20
+ test("Badge variant new e attached escrevem as classes", async () => {
21
+ const html = await renderizar(Badge, { variant: "new", attached: true }, { default: "Novidade" });
22
+ assert.match(html, /umds-badge--new/);
23
+ assert.match(html, /umds-badge--attached/);
24
+ assert.doesNotMatch(await renderizar(Badge, {}, { default: "x" }), /umds-badge--attached/);
25
+ });
26
+
27
+ test("Tag size xs escreve a classe e sm continua", async () => {
28
+ assert.match(await renderizar(Tag, { label: "a", size: "xs" }), /umds-tag--xs/);
29
+ assert.match(await renderizar(Tag, { label: "b", size: "sm" }), /umds-tag--sm/);
30
+ });
31
+
32
+ test("Tag appearance soft, variant primary e pill escrevem as classes", async () => {
33
+ const html = await renderizar(Tag, { label: "SOBR", appearance: "soft", variant: "primary", pill: true });
34
+ for (const c of ["umds-tag--soft", "umds-tag--primary", "umds-tag--pill"]) assert.match(html, new RegExp(c));
35
+ });
36
+
37
+ test("Tag sem pill não escreve a classe; padrão segue outlined", async () => {
38
+ const html = await renderizar(Tag, { label: "x" });
39
+ assert.doesNotMatch(html, /umds-tag--pill/);
40
+ assert.match(html, /umds-tag--outlined/);
41
+ });
42
+
43
+ test("Tag variant new escreve a classe", async () => {
44
+ assert.match(await renderizar(Tag, { label: "Dado simulado", variant: "new" }), /umds-tag--new/);
45
+ });
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Box como item flex (grow, shrink, basis, minWidth, overflow*, fullHeight)
3
+ * e com `as`, conferidos no HTML que o Vue GERADO escreve.
4
+ */
5
+ import { test, before, after } from "node:test";
6
+ import assert from "node:assert/strict";
7
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
8
+
9
+ let Box;
10
+
11
+ before(async () => {
12
+ await abrir();
13
+ Box = await carregar("Box/Box.vue");
14
+ });
15
+ after(fechar);
16
+
17
+ /** Componente de raiz múltipla: o HTML abre com marcadores de fragmento do Vue. */
18
+ const ABRE = "^(?:<!--\\[-->|<!---->)*";
19
+
20
+ const TAGS = ["div", "span", "ul", "ol", "li", "section", "nav", "header", "footer", "form"];
21
+
22
+ test("Box sem `as` continua um div", async () => {
23
+ const html = await renderizar(Box, { padding: "md" }, { default: "x" });
24
+ assert.match(html, new RegExp(`${ABRE}<div class="umds-box`));
25
+ });
26
+
27
+ for (const tag of TAGS) {
28
+ test(`Box as="${tag}" renderiza <${tag}> e só ele`, async () => {
29
+ const html = await renderizar(Box, { as: tag }, { default: "x" });
30
+ assert.match(html, new RegExp(`${ABRE}<${tag}[ >]`));
31
+ for (const outra of TAGS.filter((t) => t !== tag)) assert.doesNotMatch(html, new RegExp(`<${outra}[ >]`));
32
+ });
33
+ }
34
+
35
+ test("Box ul/ol mantém a semântica de lista (role=list)", async () => {
36
+ assert.match(await renderizar(Box, { as: "ul" }, { default: "x" }), /<ul[^>]*role="list"/);
37
+ assert.match(await renderizar(Box, { as: "ol" }, { default: "x" }), /<ol[^>]*role="list"/);
38
+ });
39
+
40
+ test("Box as=nav repassa aria-label", async () => {
41
+ const html = await renderizar(Box, { as: "nav", "aria-label": "Atalhos" }, { default: "x" });
42
+ assert.match(html, /<nav[^>]*aria-label="Atalhos"/);
43
+ });
44
+
45
+ test("Box escreve as classes de item flex", async () => {
46
+ const html = await renderizar(
47
+ Box,
48
+ {
49
+ grow: true,
50
+ shrink: "0",
51
+ basis: "50",
52
+ minWidth: "auto",
53
+ overflow: "hidden",
54
+ overflowX: "auto",
55
+ overflowY: "scroll",
56
+ fullHeight: true,
57
+ fullWidth: true,
58
+ },
59
+ { default: "x" },
60
+ );
61
+ for (const c of [
62
+ "umds-box--grow",
63
+ "umds-box--shrink-0",
64
+ "umds-box--basis-50",
65
+ "umds-box--min-w-auto",
66
+ "umds-box--overflow-hidden",
67
+ "umds-box--overflow-x-auto",
68
+ "umds-box--overflow-y-scroll",
69
+ "umds-box--full-height",
70
+ "umds-box--full",
71
+ ]) {
72
+ assert.match(html, new RegExp(c));
73
+ }
74
+ });
75
+
76
+ test("Box sem as props de item não escreve nenhuma classe delas", async () => {
77
+ const html = await renderizar(Box, { padding: "md" }, { default: "x" });
78
+ assert.doesNotMatch(html, /grow|shrink|basis|min-w|overflow|full-height/);
79
+ });
80
+
81
+ test("Box repassa a classe do consumidor (raiz múltipla não herda `class` sozinha)", async () => {
82
+ const html = await renderizar(Box, { padding: "md", class: "minha-classe" }, { default: "x" });
83
+ assert.match(html, /class="[^"]*umds-box[^"]*minha-classe|class="[^"]*minha-classe[^"]*umds-box/);
84
+ });
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Box de layout (direction, gap, align, justify, wrap) e atributos repassados,
3
+ * conferidos no HTML que o Vue GERADO escreve.
4
+ */
5
+ import { test, before, after } from "node:test";
6
+ import assert from "node:assert/strict";
7
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
8
+
9
+ let Box;
10
+
11
+ before(async () => {
12
+ await abrir();
13
+ Box = await carregar("Box/Box.vue");
14
+ });
15
+ after(fechar);
16
+
17
+ test("Box sem props de layout não vira flex", async () => {
18
+ const html = await renderizar(Box, { padding: "md", bordered: true }, { default: "x" });
19
+ assert.doesNotMatch(html, /umds-box--flex/);
20
+ });
21
+
22
+ test("Box com direction/gap/align/justify/wrap vira flex", async () => {
23
+ const html = await renderizar(
24
+ Box,
25
+ { direction: "horizontal", gap: "xxxs", align: "center", justify: "between", wrap: true, padding: "md" },
26
+ { default: "x" },
27
+ );
28
+ for (const c of [
29
+ "umds-box--flex",
30
+ "umds-box--horizontal",
31
+ "umds-box--gap-xxxs",
32
+ "umds-box--align-center",
33
+ "umds-box--justify-between",
34
+ "umds-box--wrap",
35
+ "umds-box--p-md",
36
+ ]) {
37
+ assert.ok(html.includes(c), `faltou ${c} em ${html}`);
38
+ }
39
+ });
40
+
41
+ test("Box só com gap vira flex vertical", async () => {
42
+ const html = await renderizar(Box, { gap: "xs" }, { default: "x" });
43
+ assert.match(html, /umds-box--flex/);
44
+ assert.match(html, /umds-box--vertical/);
45
+ });
46
+
47
+ test("Box repassa id, role, aria-label e style", async () => {
48
+ const html = await renderizar(
49
+ Box,
50
+ { id: "r", role: "region", "aria-label": "Resumo", style: "margin-top: 4px" },
51
+ { default: "x" },
52
+ );
53
+ assert.match(html, /id="r"/);
54
+ assert.match(html, /role="region"/);
55
+ assert.match(html, /aria-label="Resumo"/);
56
+ assert.match(html, /margin-top:\s*4px/);
57
+ });
@@ -0,0 +1,34 @@
1
+ /** Button: variante neutral-text e tamanho xs, conferidos no HTML que o Vue GERADO escreve. */
2
+ import { test, before, after } from "node:test";
3
+ import assert from "node:assert/strict";
4
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
5
+
6
+ let Button;
7
+
8
+ before(async () => {
9
+ await abrir();
10
+ Button = await carregar("Button/Button.vue");
11
+ });
12
+ after(fechar);
13
+
14
+ test("variant neutral-text escreve a classe da variante", async () => {
15
+ const html = await renderizar(Button, { variant: "neutral-text" }, { default: "Simular" });
16
+ assert.match(html, /class="[^"]*umds-button--neutral-text/);
17
+ });
18
+
19
+ test("neutral continua sendo o contornado cinza", async () => {
20
+ const html = await renderizar(Button, { variant: "neutral" }, { default: "Ordenar" });
21
+ assert.match(html, /umds-button--neutral[ "]/);
22
+ assert.doesNotMatch(html, /neutral-text/);
23
+ });
24
+
25
+ test("size xs escreve a classe e sem size continua md", async () => {
26
+ assert.match(await renderizar(Button, { size: "xs" }, { default: "Resolver" }), /umds-button--xs/);
27
+ assert.match(await renderizar(Button, {}, { default: "Padrão" }), /umds-button--md/);
28
+ });
29
+
30
+ test("no xs o ícone usa o tamanho sm do Icon", async () => {
31
+ const html = await renderizar(Button, { size: "xs", startIcon: ["fas", "plus"] }, { default: "Novo" });
32
+ assert.match(html, /umds-icon--sm/);
33
+ assert.doesNotMatch(html, /umds-icon--xs/);
34
+ });