@1doc/1ds-vue 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.
- package/CHANGELOG.md +1549 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1128 -29
- package/dist/index.mjs +12299 -7939
- package/dist/index.umd.js +4 -4
- package/package.json +5 -4
- package/src/index.ts +26 -0
- package/src/teste/accordion-conteudo-livre.test.mjs +44 -0
- package/src/teste/accordion-titulo-neutro.test.mjs +32 -0
- package/src/teste/appsubheader-regiao.test.mjs +18 -0
- package/src/teste/atributos.test.mjs +91 -0
- package/src/teste/attachmentcard-ia.test.mjs +48 -0
- package/src/teste/attachmentcard-lista.test.mjs +39 -0
- package/src/teste/attachmentcard-sm.test.mjs +28 -0
- package/src/teste/avatargroup-overlap.test.mjs +45 -0
- package/src/teste/badge-neutro-colado.test.mjs +30 -0
- package/src/teste/badge-tag.test.mjs +53 -0
- package/src/teste/box-item-flex.test.mjs +84 -0
- package/src/teste/box-layout.test.mjs +57 -0
- package/src/teste/button.test.mjs +34 -0
- package/src/teste/calendar-slots-cabecalho.test.mjs +46 -0
- package/src/teste/calendar.test.mjs +179 -0
- package/src/teste/chips-xs.test.mjs +33 -0
- package/src/teste/coachmark-sem-veu.test.mjs +70 -0
- package/src/teste/coachmark.test.mjs +119 -0
- package/src/teste/color-picker-xs.test.mjs +28 -0
- package/src/teste/color-picker.test.mjs +79 -0
- package/src/teste/datatable-arvore-variantes.test.mjs +194 -0
- package/src/teste/datatable-documento.test.mjs +106 -0
- package/src/teste/datatable-slots.test.mjs +105 -0
- package/src/teste/descriptionlist-compacta.test.mjs +32 -0
- package/src/teste/dom.mjs +170 -0
- package/src/teste/empty-state-titulo-rico.test.mjs +39 -0
- package/src/teste/fileinput-trigger.test.mjs +36 -0
- package/src/teste/icon-picker.test.mjs +98 -0
- package/src/teste/input-agrupado.test.mjs +44 -0
- package/src/teste/input-mascara-afins.test.mjs +64 -0
- package/src/teste/kbd-code-block.test.mjs +76 -0
- package/src/teste/list-item-standalone.test.mjs +75 -0
- package/src/teste/list.test.mjs +163 -0
- package/src/teste/modal-variantes.test.mjs +79 -0
- package/src/teste/org-chart.test.mjs +131 -0
- package/src/teste/otp-input.test.mjs +130 -0
- package/src/teste/popover-maxheight.test.mjs +26 -0
- package/src/teste/renderizar.mjs +64 -0
- package/src/teste/rich-text-editor-alinha-imagem-tabela.test.mjs +164 -0
- package/src/teste/rich-text-editor-estilo-de-texto.test.mjs +87 -0
- package/src/teste/rich-text-editor.test.mjs +210 -0
- package/src/teste/segmented-contador.test.mjs +39 -0
- package/src/teste/select-aberto-controlado-flutuante.test.mjs +120 -0
- package/src/teste/select-filtro-cor-tamanho.test.mjs +62 -0
- package/src/teste/select-placement-filtro.test.mjs +49 -0
- package/src/teste/stack-box-raiz-unica.test.mjs +134 -0
- package/src/teste/stack.test.mjs +80 -0
- package/src/teste/statcard-rotulo-topo.test.mjs +34 -0
- package/src/teste/statcard-secundaria-tom.test.mjs +41 -0
- package/src/teste/tabs-contador-fechavel.test.mjs +60 -0
- package/src/teste/toast-acao-detalhes.test.mjs +48 -0
- package/src/teste/tooltip-dark.test.mjs +28 -0
- package/src/utils/calendario.ts +78 -0
- package/src/utils/html-seguro.ts +197 -0
- package/src/utils/paleta-de-cores.ts +34 -0
- package/src/utils/texto.ts +5 -0
- package/src/utils/toast.ts +12 -2
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calendar: os slots do cabeçalho do Vue se chamam `#header-start` e `#header-end` (com hífen).
|
|
3
|
+
* O Vue lê o nome do slot como está, então `#headerStart` não chega: o teste prova os dois
|
|
4
|
+
* lados e o que a documentação diz.
|
|
5
|
+
*/
|
|
6
|
+
import { test, after } from "node:test";
|
|
7
|
+
import assert from "node:assert/strict";
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import { resolve } from "node:path";
|
|
10
|
+
import { montar } from "./dom.mjs";
|
|
11
|
+
import { h } from "vue";
|
|
12
|
+
|
|
13
|
+
const montados = [];
|
|
14
|
+
const abrir = async (slots) => {
|
|
15
|
+
const m = await montar("Calendar/Calendar.vue", { events: [], defaultDate: "2026-10-08" }, slots);
|
|
16
|
+
montados.push(m);
|
|
17
|
+
return m;
|
|
18
|
+
};
|
|
19
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
20
|
+
|
|
21
|
+
test("#header-start e #header-end chegam ao cabeçalho", async () => {
|
|
22
|
+
const m = await abrir({
|
|
23
|
+
"header-start": () => h("span", { "data-teste": "inicio" }, "Todos os documentos"),
|
|
24
|
+
"header-end": () => h("span", { "data-teste": "fim" }, "Legenda"),
|
|
25
|
+
});
|
|
26
|
+
assert.ok(m.raiz.querySelector('[data-teste="inicio"]'));
|
|
27
|
+
assert.ok(m.raiz.querySelector('[data-teste="fim"]'));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("#headerStart e #headerEnd (camelCase) NÃO chegam: a documentação não pode mandar usá-los", async () => {
|
|
31
|
+
const m = await abrir({
|
|
32
|
+
headerStart: () => h("span", { "data-teste": "inicio" }, "x"),
|
|
33
|
+
headerEnd: () => h("span", { "data-teste": "fim" }, "y"),
|
|
34
|
+
});
|
|
35
|
+
assert.equal(m.raiz.querySelector('[data-teste="inicio"]'), null);
|
|
36
|
+
assert.equal(m.raiz.querySelector('[data-teste="fim"]'), null);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("a documentação do componente fala header-start e header-end", () => {
|
|
40
|
+
const fonte = readFileSync(resolve(process.cwd(), "../core/src/components/Calendar/Calendar.lite.tsx"), "utf8");
|
|
41
|
+
assert.match(fonte, /@slot header-start/);
|
|
42
|
+
assert.match(fonte, /@slot header-end/);
|
|
43
|
+
assert.doesNotMatch(fonte, /@slot headerStart/);
|
|
44
|
+
assert.doesNotMatch(fonte, /@slot headerEnd/);
|
|
45
|
+
assert.match(fonte, /#header-start/);
|
|
46
|
+
});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calendar no Vue, montado num DOM (jsdom): grade, eventos, +N, teclado e visões.
|
|
3
|
+
*/
|
|
4
|
+
import { test, after } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { montar, documento, teclar, clicar, proximoTick } from "./dom.mjs";
|
|
7
|
+
|
|
8
|
+
const HOJE = "2026-05-15";
|
|
9
|
+
const EVENTOS = [
|
|
10
|
+
{ id: "a", date: "2026-05-04", title: "Proc. Administrativo 002/2020", color: "--umds-primitive-blue-pure" },
|
|
11
|
+
{ id: "b", date: "2026-05-11", title: "Protocolo 005/2020", color: "--umds-primitive-green-pure", time: "09:00" },
|
|
12
|
+
{ id: "c", date: "2026-05-11", title: "Ofício 001/2020", color: "--umds-primitive-red-pure", time: "08:00" },
|
|
13
|
+
...[1, 2, 3, 4, 5].map((n) => ({ id: "d" + n, date: "2026-05-20", title: "Reunião " + n })),
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const montados = [];
|
|
17
|
+
const abrir = async (props = {}, slots = {}) => {
|
|
18
|
+
const m = await montar("Calendar/Calendar.vue", { today: HOJE, defaultDate: HOJE, ...props }, slots);
|
|
19
|
+
montados.push(m);
|
|
20
|
+
return m;
|
|
21
|
+
};
|
|
22
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
23
|
+
|
|
24
|
+
const celula = (m, iso) => m.raiz.querySelector(`[data-date="${iso}"]`);
|
|
25
|
+
const titulo = (m) => m.raiz.querySelector(".umds-calendar__title").textContent.trim();
|
|
26
|
+
const botao = (m, nome) => [...m.raiz.querySelectorAll("button")].find((b) => (b.getAttribute("aria-label") || b.textContent.trim()) === nome);
|
|
27
|
+
|
|
28
|
+
test("é uma grade nomeada pelo mês, com sete cabeçalhos; maio de 2026 tem seis semanas", async () => {
|
|
29
|
+
const m = await abrir();
|
|
30
|
+
const grade = m.raiz.querySelector('[role="grid"]');
|
|
31
|
+
assert.equal(grade.getAttribute("aria-label"), "Maio 2026");
|
|
32
|
+
assert.equal(m.raiz.querySelectorAll('[role="columnheader"]').length, 7);
|
|
33
|
+
assert.equal(m.raiz.querySelectorAll('[role="columnheader"]')[0].getAttribute("aria-label"), "Domingo");
|
|
34
|
+
assert.equal(m.raiz.querySelectorAll('[role="gridcell"]').length, 42);
|
|
35
|
+
assert.equal(titulo(m), "Maio 2026");
|
|
36
|
+
assert.ok(celula(m, "2026-04-26").classList.contains("umds-calendar__cell--outside"));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("hoje tem aria-current; cada dia tem nome com a contagem de eventos", async () => {
|
|
40
|
+
const m = await abrir({ events: EVENTOS });
|
|
41
|
+
assert.equal(celula(m, HOJE).getAttribute("aria-current"), "date");
|
|
42
|
+
assert.equal(celula(m, "2026-05-11").getAttribute("aria-label"), "segunda-feira, 11 de maio de 2026, 2 eventos");
|
|
43
|
+
assert.equal(celula(m, "2026-05-12").getAttribute("aria-label"), "terça-feira, 12 de maio de 2026, sem eventos");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("os eventos caem no dia, em ordem de horário, com a cor do dado", async () => {
|
|
47
|
+
const m = await abrir({ events: EVENTOS });
|
|
48
|
+
const chips = celula(m, "2026-05-11").querySelectorAll(".umds-calendar__event");
|
|
49
|
+
assert.equal(chips.length, 2);
|
|
50
|
+
assert.ok(chips[0].textContent.includes("08:00") && chips[0].textContent.includes("Ofício 001/2020"));
|
|
51
|
+
assert.match(chips[0].getAttribute("style"), /border-left-color:\s*var\(--umds-primitive-red-pure\)/);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("passou de maxVisible: três eventos e um +N que avisa com os escondidos", async () => {
|
|
55
|
+
const vistos = [];
|
|
56
|
+
const m = await abrir({ events: EVENTOS, onMoreClick: (iso, escondidos) => vistos.push([iso, escondidos.map((e) => e.id)]) });
|
|
57
|
+
const dia = celula(m, "2026-05-20");
|
|
58
|
+
assert.equal(dia.querySelectorAll(".umds-calendar__event").length, 3);
|
|
59
|
+
const mais = dia.querySelector(".umds-calendar__more");
|
|
60
|
+
assert.equal(mais.textContent.trim(), "+2");
|
|
61
|
+
assert.equal(mais.getAttribute("aria-label"), "2 eventos a mais em 20 de maio");
|
|
62
|
+
await clicar(mais);
|
|
63
|
+
assert.deepEqual(vistos, [["2026-05-20", ["d4", "d5"]]]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("clicar no evento avisa com o evento e não clica no dia; clicar no dia avisa com o ISO", async () => {
|
|
67
|
+
const eventos = [];
|
|
68
|
+
const dias = [];
|
|
69
|
+
const m = await abrir({ events: EVENTOS, onEventClick: (e) => eventos.push(e.id), onDayClick: (d) => dias.push(d) });
|
|
70
|
+
await clicar(celula(m, "2026-05-04").querySelector(".umds-calendar__event"));
|
|
71
|
+
assert.deepEqual(eventos, ["a"]);
|
|
72
|
+
assert.deepEqual(dias, []);
|
|
73
|
+
await clicar(celula(m, "2026-05-12"));
|
|
74
|
+
assert.deepEqual(dias, ["2026-05-12"]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("anterior, próximo e hoje navegam e avisam em onDateChange", async () => {
|
|
78
|
+
const datas = [];
|
|
79
|
+
const m = await abrir({ onDateChange: (d) => datas.push(d) });
|
|
80
|
+
await clicar(botao(m, "Próximo"));
|
|
81
|
+
assert.equal(titulo(m), "Junho 2026");
|
|
82
|
+
await clicar(botao(m, "Anterior"));
|
|
83
|
+
await clicar(botao(m, "Anterior"));
|
|
84
|
+
assert.equal(titulo(m), "Abril 2026");
|
|
85
|
+
await clicar(botao(m, "Hoje"));
|
|
86
|
+
assert.equal(titulo(m), "Maio 2026");
|
|
87
|
+
assert.deepEqual(datas, ["2026-06-15", "2026-05-15", "2026-04-15", HOJE]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("só o dia de hoje entra na ordem de Tab, com os eventos dele", async () => {
|
|
91
|
+
const m = await abrir({ today: "2026-05-11", defaultDate: "2026-05-11", events: EVENTOS });
|
|
92
|
+
const comTab = [...m.raiz.querySelectorAll('[role="gridcell"]')].filter((c) => c.getAttribute("tabindex") === "0");
|
|
93
|
+
assert.equal(comTab.length, 1);
|
|
94
|
+
assert.equal(comTab[0].getAttribute("data-date"), "2026-05-11");
|
|
95
|
+
const chips = [...m.raiz.querySelectorAll(".umds-calendar__event")].filter((c) => c.getAttribute("tabindex") === "0");
|
|
96
|
+
assert.equal(chips.length, 2);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("setas movem o foco; Home, End e Enter", async () => {
|
|
100
|
+
const dias = [];
|
|
101
|
+
const m = await abrir({ onDayClick: (d) => dias.push(d) });
|
|
102
|
+
celula(m, HOJE).focus();
|
|
103
|
+
await teclar(celula(m, HOJE), "ArrowRight");
|
|
104
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-16"));
|
|
105
|
+
await teclar(documento.activeElement, "ArrowDown");
|
|
106
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-23"));
|
|
107
|
+
await teclar(documento.activeElement, "ArrowLeft");
|
|
108
|
+
await teclar(documento.activeElement, "ArrowUp");
|
|
109
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-15"));
|
|
110
|
+
await teclar(documento.activeElement, "Home");
|
|
111
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-10"));
|
|
112
|
+
await teclar(documento.activeElement, "End");
|
|
113
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-16"));
|
|
114
|
+
await teclar(documento.activeElement, "Enter");
|
|
115
|
+
assert.deepEqual(dias, ["2026-05-16"]);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("a seta que sai do mês troca de mês e leva o foco; PageDown troca de mês", async () => {
|
|
119
|
+
const m = await abrir({ defaultDate: "2026-05-30" });
|
|
120
|
+
celula(m, "2026-05-30").focus();
|
|
121
|
+
await teclar(celula(m, "2026-05-30"), "ArrowRight");
|
|
122
|
+
await teclar(documento.activeElement, "ArrowRight");
|
|
123
|
+
assert.equal(titulo(m), "Junho 2026");
|
|
124
|
+
assert.equal(documento.activeElement, celula(m, "2026-06-01"));
|
|
125
|
+
await teclar(documento.activeElement, "PageDown");
|
|
126
|
+
assert.equal(titulo(m), "Julho 2026");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("a visão de semana: sete dias, todos os eventos; onViewChange avisa", async () => {
|
|
130
|
+
const visoes = [];
|
|
131
|
+
const m = await abrir({ today: "2026-05-20", defaultDate: "2026-05-20", events: EVENTOS, onViewChange: (v) => visoes.push(v) });
|
|
132
|
+
const semana = [...m.raiz.querySelectorAll('input[type="radio"]')].find((r) => r.value === "week");
|
|
133
|
+
semana.click();
|
|
134
|
+
await proximoTick();
|
|
135
|
+
assert.deepEqual(visoes, ["week"]);
|
|
136
|
+
assert.equal(m.raiz.querySelectorAll('[role="gridcell"]').length, 7);
|
|
137
|
+
assert.equal(celula(m, "2026-05-20").querySelectorAll(".umds-calendar__event").length, 5);
|
|
138
|
+
assert.equal(m.raiz.querySelector(".umds-calendar__more"), null);
|
|
139
|
+
assert.ok(m.raiz.querySelector(".umds-calendar--week"));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("weekStartsOn=1 e locale en-US com textos por prop", async () => {
|
|
143
|
+
const m = await abrir({
|
|
144
|
+
weekStartsOn: 1,
|
|
145
|
+
locale: "en-US",
|
|
146
|
+
previousLabel: "Previous",
|
|
147
|
+
nextLabel: "Next",
|
|
148
|
+
todayLabel: "Today",
|
|
149
|
+
viewLabel: "View",
|
|
150
|
+
});
|
|
151
|
+
assert.equal(m.raiz.querySelectorAll('[role="columnheader"]')[0].getAttribute("aria-label"), "Monday");
|
|
152
|
+
assert.equal(titulo(m), "May 2026");
|
|
153
|
+
assert.ok(botao(m, "Previous") && botao(m, "Next") && botao(m, "Today"));
|
|
154
|
+
assert.equal(m.raiz.querySelector('[role="group"]').getAttribute("aria-label"), "View");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("os slots header-start e header-end entram no cabeçalho; hideViewSwitcher esconde o seletor", async () => {
|
|
158
|
+
const m = await abrir(
|
|
159
|
+
{ hideViewSwitcher: true },
|
|
160
|
+
{ "header-start": () => "Filtro de escopo", "header-end": () => "Legenda" },
|
|
161
|
+
);
|
|
162
|
+
const start = m.raiz.querySelector(".umds-calendar__toolbar-start").textContent;
|
|
163
|
+
const end = m.raiz.querySelector(".umds-calendar__toolbar-end").textContent;
|
|
164
|
+
assert.ok(start.includes("Filtro de escopo"));
|
|
165
|
+
assert.ok(end.includes("Legenda"));
|
|
166
|
+
assert.equal(m.raiz.querySelectorAll('input[type="radio"]').length, 0);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("controlado: date de fora manda; selectedDate marca o dia", async () => {
|
|
170
|
+
const { ref } = await import("vue");
|
|
171
|
+
const data = ref("2026-08-10");
|
|
172
|
+
const m = await montar("Calendar/Calendar.vue", () => ({ today: HOJE, date: data.value, selectedDate: "2026-08-12" }));
|
|
173
|
+
montados.push(m);
|
|
174
|
+
assert.equal(titulo(m), "Agosto 2026");
|
|
175
|
+
assert.equal(celula(m, "2026-08-12").getAttribute("aria-selected"), "true");
|
|
176
|
+
data.value = "2026-09-01";
|
|
177
|
+
await proximoTick();
|
|
178
|
+
assert.equal(titulo(m), "Setembro 2026");
|
|
179
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Chips: size xs e circularRemove, 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 Chips;
|
|
7
|
+
|
|
8
|
+
before(async () => {
|
|
9
|
+
await abrir();
|
|
10
|
+
Chips = await carregar("Chips/Chips.vue");
|
|
11
|
+
});
|
|
12
|
+
after(fechar);
|
|
13
|
+
|
|
14
|
+
test("size xs escreve a classe; sem size continua md", async () => {
|
|
15
|
+
assert.match(await renderizar(Chips, { label: "a", size: "xs" }), /umds-chip--xs/);
|
|
16
|
+
assert.match(await renderizar(Chips, { label: "b" }), /umds-chip--md/);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("circularRemove com removable escreve a classe do círculo", async () => {
|
|
20
|
+
const html = await renderizar(Chips, { label: "Marcador", removable: true, circularRemove: true });
|
|
21
|
+
assert.match(html, /umds-chip--remove-circle/);
|
|
22
|
+
assert.match(html, /aria-label="Remover Marcador"/);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("circularRemove sem removable não escreve a classe", async () => {
|
|
26
|
+
const html = await renderizar(Chips, { label: "Marcador", circularRemove: true });
|
|
27
|
+
assert.doesNotMatch(html, /umds-chip--remove-circle/);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("sem circularRemove o chip removível é o de antes", async () => {
|
|
31
|
+
const html = await renderizar(Chips, { label: "x", removable: true });
|
|
32
|
+
assert.doesNotMatch(html, /umds-chip--remove-circle/);
|
|
33
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Coachmark modal={false} no Vue (DOM do jsdom). */
|
|
2
|
+
import { test, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { montar, documento, janela, proximoTick } from "./dom.mjs";
|
|
5
|
+
|
|
6
|
+
const montados = [];
|
|
7
|
+
const abrir = async (props) => {
|
|
8
|
+
const alvo = documento.createElement("button");
|
|
9
|
+
alvo.id = "alvo-vue";
|
|
10
|
+
documento.body.append(alvo);
|
|
11
|
+
const m = await montar("Coachmark/Coachmark.vue", {
|
|
12
|
+
open: true,
|
|
13
|
+
steps: [{ target: "#alvo-vue", title: "Novo: arrastar", content: "Arraste a linha." }],
|
|
14
|
+
...props,
|
|
15
|
+
});
|
|
16
|
+
montados.push({ m, alvo });
|
|
17
|
+
await proximoTick();
|
|
18
|
+
await new Promise((r) => setTimeout(r, 40));
|
|
19
|
+
return m;
|
|
20
|
+
};
|
|
21
|
+
after(() => montados.forEach(({ m, alvo }) => (m.desmontar(), alvo.remove())));
|
|
22
|
+
|
|
23
|
+
const cartao = () => documento.querySelector('[role="dialog"]');
|
|
24
|
+
|
|
25
|
+
test("modal={false}: sem véu nem recorte, diálogo não modal, raiz que deixa o ponteiro passar", async () => {
|
|
26
|
+
const m = await abrir({ modal: false });
|
|
27
|
+
assert.equal(documento.querySelector(".umds-coachmark__veil"), null);
|
|
28
|
+
assert.equal(documento.querySelector(".umds-coachmark__cutout"), null);
|
|
29
|
+
assert.ok(documento.querySelector(".umds-coachmark").classList.contains("umds-coachmark--modeless"));
|
|
30
|
+
assert.equal(cartao().getAttribute("aria-modal"), "false");
|
|
31
|
+
m.desmontar();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("sem a prop modal o tour é modal (Vue não vira false)", async () => {
|
|
35
|
+
const m = await abrir({});
|
|
36
|
+
assert.ok(documento.querySelector(".umds-coachmark__veil"));
|
|
37
|
+
assert.equal(cartao().getAttribute("aria-modal"), "true");
|
|
38
|
+
assert.ok(!documento.querySelector(".umds-coachmark").classList.contains("umds-coachmark--modeless"));
|
|
39
|
+
m.desmontar();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("sem véu o Tab não fica preso; com véu fica", async () => {
|
|
43
|
+
const livre = await abrir({ modal: false });
|
|
44
|
+
const concluir = [...documento.querySelectorAll(".umds-coachmark button")].find((b) => b.textContent.trim() === "Concluir");
|
|
45
|
+
concluir.focus();
|
|
46
|
+
const e1 = new janela.KeyboardEvent("keydown", { key: "Tab", bubbles: true, cancelable: true });
|
|
47
|
+
concluir.dispatchEvent(e1);
|
|
48
|
+
assert.equal(e1.defaultPrevented, false);
|
|
49
|
+
livre.desmontar();
|
|
50
|
+
|
|
51
|
+
const preso = await abrir({});
|
|
52
|
+
const concluir2 = [...documento.querySelectorAll(".umds-coachmark button")].find((b) => b.textContent.trim() === "Concluir");
|
|
53
|
+
concluir2.focus();
|
|
54
|
+
const e2 = new janela.KeyboardEvent("keydown", { key: "Tab", bubbles: true, cancelable: true });
|
|
55
|
+
concluir2.dispatchEvent(e2);
|
|
56
|
+
assert.equal(e2.defaultPrevented, true);
|
|
57
|
+
preso.desmontar();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("o Esc fecha de qualquer lugar da página, uma vez só, e o ouvinte sai ao desmontar", async () => {
|
|
61
|
+
const motivos = [];
|
|
62
|
+
const m = await abrir({ modal: false, onClose: (r) => motivos.push(r) });
|
|
63
|
+
documento.dispatchEvent(new janela.KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
|
|
64
|
+
assert.deepEqual(motivos, ["escape"]);
|
|
65
|
+
cartao().dispatchEvent(new janela.KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
|
|
66
|
+
assert.deepEqual(motivos, ["escape", "escape"], "um por tecla, não dois");
|
|
67
|
+
m.desmontar();
|
|
68
|
+
documento.dispatchEvent(new janela.KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
|
|
69
|
+
assert.equal(motivos.length, 2);
|
|
70
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coachmark no Vue, montado num DOM (jsdom): o cartão vai por Teleport para o
|
|
3
|
+
* body, o foco entra nele e as teclas e os botões movem o tour.
|
|
4
|
+
*/
|
|
5
|
+
import { test, after, beforeEach } from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { montar, documento, teclar, clicar, proximoTick } from "./dom.mjs";
|
|
8
|
+
|
|
9
|
+
const PASSOS = [
|
|
10
|
+
{ target: "#alvo-a", title: "Cada item é uma aba", content: "Fluxos e formulários abrem em abas." },
|
|
11
|
+
{ target: "#alvo-b", title: "Salvo sozinho", content: "Tudo fica neste navegador." },
|
|
12
|
+
{ title: "Pronto", content: "Sem alvo: o cartão fica no centro." },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const montados = [];
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
documento.body.innerHTML = '<button id="alvo-a">A</button><button id="alvo-b">B</button>';
|
|
18
|
+
});
|
|
19
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
20
|
+
|
|
21
|
+
const abrir = async (props = {}) => {
|
|
22
|
+
const m = await montar("Coachmark/Coachmark.vue", { open: true, steps: PASSOS, ...props });
|
|
23
|
+
montados.push(m);
|
|
24
|
+
// O Teleport e o primeiro posicionamento acontecem em ticks seguintes.
|
|
25
|
+
await proximoTick();
|
|
26
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
27
|
+
return m;
|
|
28
|
+
};
|
|
29
|
+
const cartao = () => documento.querySelector('[role="dialog"]');
|
|
30
|
+
const botao = (nome) => [...documento.querySelectorAll("button")].find((b) => b.textContent.trim() === nome);
|
|
31
|
+
|
|
32
|
+
test("aberto é um diálogo modal nomeado pelo título, com contador", async () => {
|
|
33
|
+
await abrir();
|
|
34
|
+
const c = cartao();
|
|
35
|
+
assert.ok(c);
|
|
36
|
+
assert.equal(c.getAttribute("aria-modal"), "true");
|
|
37
|
+
const titulo = documento.getElementById(c.getAttribute("aria-labelledby"));
|
|
38
|
+
assert.equal(titulo.textContent.trim(), "Cada item é uma aba");
|
|
39
|
+
assert.ok(c.textContent.includes("1 de 3"));
|
|
40
|
+
assert.ok(botao("Próximo"));
|
|
41
|
+
assert.equal(botao("Anterior"), undefined);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("fechado não desenha nada", async () => {
|
|
45
|
+
const m = await abrir({ open: false });
|
|
46
|
+
assert.equal(cartao(), null);
|
|
47
|
+
m.desmontar();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("o foco entra no cartão", async () => {
|
|
51
|
+
await abrir();
|
|
52
|
+
assert.equal(documento.activeElement, cartao());
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("Próximo e Anterior trocam de passo e avisam em onStepChange", async () => {
|
|
56
|
+
const vistos = [];
|
|
57
|
+
await abrir({ onStepChange: (i) => vistos.push(i) });
|
|
58
|
+
await clicar(botao("Próximo"));
|
|
59
|
+
assert.deepEqual(vistos, [1]);
|
|
60
|
+
assert.ok(cartao().textContent.includes("Salvo sozinho"));
|
|
61
|
+
await clicar(botao("Anterior"));
|
|
62
|
+
assert.deepEqual(vistos, [1, 0]);
|
|
63
|
+
assert.ok(cartao().textContent.includes("Cada item é uma aba"));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("setas avançam e voltam; Esc sai com 'escape'", async () => {
|
|
67
|
+
const motivos = [];
|
|
68
|
+
await abrir({ onClose: (m) => motivos.push(m) });
|
|
69
|
+
await teclar(cartao(), "ArrowRight");
|
|
70
|
+
assert.ok(cartao().textContent.includes("Salvo sozinho"));
|
|
71
|
+
await teclar(cartao(), "ArrowLeft");
|
|
72
|
+
assert.ok(cartao().textContent.includes("Cada item é uma aba"));
|
|
73
|
+
await teclar(cartao(), "Escape");
|
|
74
|
+
assert.deepEqual(motivos, ["escape"]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("último passo: Concluir fecha com 'finish'; Sair do tour fecha com 'skip'", async () => {
|
|
78
|
+
const motivos = [];
|
|
79
|
+
await abrir({ step: 2, onClose: (m) => motivos.push(m) });
|
|
80
|
+
assert.equal(botao("Próximo"), undefined);
|
|
81
|
+
await clicar(botao("Concluir"));
|
|
82
|
+
await clicar(botao("Sair do tour"));
|
|
83
|
+
assert.deepEqual(motivos, ["finish", "skip"]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("hideSkip esconde o Sair do tour", async () => {
|
|
87
|
+
await abrir({ hideSkip: true });
|
|
88
|
+
assert.equal(botao("Sair do tour"), undefined);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("os textos vêm por prop", async () => {
|
|
92
|
+
await abrir({ step: 1, nextLabel: "Next", previousLabel: "Back", skipLabel: "Skip tour", counterLabel: "{current} of {total}" });
|
|
93
|
+
assert.ok(botao("Next") && botao("Back") && botao("Skip tour"));
|
|
94
|
+
assert.ok(cartao().textContent.includes("2 of 3"));
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("o foco fica preso no cartão: Tab no último vai ao primeiro", async () => {
|
|
98
|
+
await abrir();
|
|
99
|
+
const sair = botao("Sair do tour");
|
|
100
|
+
const proximo = botao("Próximo");
|
|
101
|
+
proximo.focus();
|
|
102
|
+
const evento = await teclar(proximo, "Tab");
|
|
103
|
+
assert.equal(evento.defaultPrevented, true);
|
|
104
|
+
assert.equal(documento.activeElement, sair);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("com alvo desenha o recorte; passo sem alvo, não", async () => {
|
|
108
|
+
await abrir();
|
|
109
|
+
assert.ok(documento.querySelector(".umds-coachmark__cutout"));
|
|
110
|
+
await abrir({ step: 2 });
|
|
111
|
+
assert.equal(documento.querySelector(".umds-coachmark--no-target") !== null, true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("o alvo pode ser um elemento ou um ref do Vue", async () => {
|
|
115
|
+
const { ref } = await import("vue");
|
|
116
|
+
const el = ref(documento.getElementById("alvo-b"));
|
|
117
|
+
await abrir({ steps: [{ target: el, title: "Por ref" }] });
|
|
118
|
+
assert.ok(documento.querySelector(".umds-coachmark__cutout"));
|
|
119
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** ColorPicker size xs no Vue (DOM do jsdom). */
|
|
2
|
+
import { test, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { montar } from "./dom.mjs";
|
|
5
|
+
|
|
6
|
+
const montados = [];
|
|
7
|
+
const abrir = async (props) => {
|
|
8
|
+
const m = await montar("ColorPicker/ColorPicker.vue", props);
|
|
9
|
+
montados.push(m);
|
|
10
|
+
return m;
|
|
11
|
+
};
|
|
12
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
13
|
+
|
|
14
|
+
test("xs escreve a classe do tamanho; sm e md seguem como eram", async () => {
|
|
15
|
+
const xs = await abrir({ ariaLabel: "Cor", size: "xs" });
|
|
16
|
+
assert.ok(xs.raiz.querySelector(".umds-color-picker").classList.contains("umds-color-picker--xs"));
|
|
17
|
+
const sm = await abrir({ ariaLabel: "Cor", size: "sm" });
|
|
18
|
+
const c = sm.raiz.querySelector(".umds-color-picker").classList;
|
|
19
|
+
assert.ok(c.contains("umds-color-picker--sm") && !c.contains("umds-color-picker--xs"));
|
|
20
|
+
const md = await abrir({ ariaLabel: "Cor" });
|
|
21
|
+
assert.ok(md.raiz.querySelector(".umds-color-picker").classList.contains("umds-color-picker--md"));
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("no xs a amostra escolhida mantém a marcação e o aria-checked", async () => {
|
|
25
|
+
const m = await abrir({ ariaLabel: "Cor", size: "xs", defaultValue: "--umds-primitive-red-pure" });
|
|
26
|
+
assert.equal(m.raiz.querySelectorAll(".umds-color-picker__swatch--selected").length, 1);
|
|
27
|
+
assert.equal(m.raiz.querySelector('[role="radio"][aria-checked="true"]').getAttribute("aria-label"), "Vermelho");
|
|
28
|
+
});
|