@1doc/1ds-vue 2.9.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 +434 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +119 -8
- package/dist/index.mjs +9512 -8153
- package/dist/index.umd.js +4 -4
- package/package.json +3 -3
- package/src/teste/accordion-titulo-neutro.test.mjs +32 -0
- package/src/teste/appsubheader-regiao.test.mjs +18 -0
- package/src/teste/attachmentcard-lista.test.mjs +39 -0
- package/src/teste/attachmentcard-sm.test.mjs +28 -0
- package/src/teste/badge-neutro-colado.test.mjs +30 -0
- package/src/teste/badge-tag.test.mjs +8 -0
- package/src/teste/calendar-slots-cabecalho.test.mjs +46 -0
- package/src/teste/coachmark-sem-veu.test.mjs +70 -0
- package/src/teste/color-picker-xs.test.mjs +28 -0
- package/src/teste/datatable-arvore-variantes.test.mjs +194 -0
- package/src/teste/descriptionlist-compacta.test.mjs +32 -0
- package/src/teste/dom.mjs +2 -0
- package/src/teste/empty-state-titulo-rico.test.mjs +39 -0
- package/src/teste/input-agrupado.test.mjs +44 -0
- package/src/teste/list-item-standalone.test.mjs +75 -0
- package/src/teste/list.test.mjs +2 -1
- 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/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/statcard-secundaria-tom.test.mjs +41 -0
- package/src/teste/toast-acao-detalhes.test.mjs +48 -0
- package/src/utils/html-seguro.ts +105 -2
- package/src/utils/toast.ts +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1doc/1ds-vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.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-
|
|
34
|
-
"@1doc/1ds-
|
|
33
|
+
"@1doc/1ds-core": "2.10.0",
|
|
34
|
+
"@1doc/1ds-tokens": "0.5.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@1doc/1ds-tokens": ">=0.1.0",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Accordion titleVariant 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("Accordion/Accordion.vue", props);
|
|
9
|
+
montados.push(m);
|
|
10
|
+
return m;
|
|
11
|
+
};
|
|
12
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
13
|
+
|
|
14
|
+
const ITENS = [
|
|
15
|
+
{ id: "a", title: "Prazos", content: "Dez dias úteis." },
|
|
16
|
+
{ id: "b", title: "Anexos", content: "Até 10 MB." },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
test("neutral liga a classe do título neutro; default e ausente não", async () => {
|
|
20
|
+
const n = await abrir({ items: ITENS, titleVariant: "neutral" });
|
|
21
|
+
assert.ok(n.raiz.querySelector(".umds-accordion").classList.contains("umds-accordion--title-neutral"));
|
|
22
|
+
const d = await abrir({ items: ITENS, titleVariant: "default" });
|
|
23
|
+
assert.ok(!d.raiz.querySelector(".umds-accordion").classList.contains("umds-accordion--title-neutral"));
|
|
24
|
+
const a = await abrir({ items: ITENS });
|
|
25
|
+
assert.ok(!a.raiz.querySelector(".umds-accordion").classList.contains("umds-accordion--title-neutral"));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("combina com a variant do accordion", async () => {
|
|
29
|
+
const m = await abrir({ items: ITENS, variant: "separated", titleVariant: "neutral" });
|
|
30
|
+
const c = m.raiz.querySelector(".umds-accordion").classList;
|
|
31
|
+
assert.ok(c.contains("umds-accordion--separated") && c.contains("umds-accordion--title-neutral"));
|
|
32
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AppSubheader: a região do contexto só rola na horizontal. O jsdom não tem layout: a
|
|
3
|
+
* geometria real é conferida pela story "Só a página atual" (play, no navegador); aqui, a regra de CSS.
|
|
4
|
+
*/
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { resolve } from "node:path";
|
|
9
|
+
|
|
10
|
+
const css = readFileSync(resolve(process.cwd(), "../core/src/components/AppSubheader/AppSubheader.css"), "utf8");
|
|
11
|
+
|
|
12
|
+
test("o contexto rola só na horizontal (overflow-x auto, overflow-y hidden) e ocupa a altura da barra (align-self stretch)", () => {
|
|
13
|
+
const inicio = css.indexOf(".umds-app-subheader__contexto {");
|
|
14
|
+
const regras = css.slice(inicio, css.indexOf("}", inicio));
|
|
15
|
+
assert.match(regras, /overflow-x:\s*auto/);
|
|
16
|
+
assert.match(regras, /overflow-y:\s*hidden/);
|
|
17
|
+
assert.match(regras, /align-self:\s*stretch/);
|
|
18
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** AttachmentCard: o <dl> do painel é válido (axe definition-list), no Vue (DOM do jsdom; o painel vai por Teleport). */
|
|
2
|
+
import { test, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { montar, documento, clicar, proximoTick } from "./dom.mjs";
|
|
5
|
+
|
|
6
|
+
let montado;
|
|
7
|
+
after(() => montado && montado.desmontar());
|
|
8
|
+
|
|
9
|
+
test("o dl só tem div com dt e dd; o botão de copiar mora dentro do dd", async () => {
|
|
10
|
+
montado = await montar("AttachmentCard/AttachmentCard.vue", {
|
|
11
|
+
fileName: "cnh.pdf",
|
|
12
|
+
documentType: "CNH",
|
|
13
|
+
status: "positive",
|
|
14
|
+
statusLabel: "Pré-aprovado",
|
|
15
|
+
statusDetails: {
|
|
16
|
+
description: "Documento legível.",
|
|
17
|
+
fields: [
|
|
18
|
+
{ label: "Nome completo", value: "Marcos Vinícius Tavares", copyable: true },
|
|
19
|
+
{ label: "CPF", value: "123.456.789-09" },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const selo = [...montado.raiz.querySelectorAll("button")].find((b) => b.textContent.includes("Pré-aprovado"));
|
|
24
|
+
await clicar(selo);
|
|
25
|
+
await proximoTick();
|
|
26
|
+
const dl = documento.querySelector(".umds-attachment-card__campos");
|
|
27
|
+
assert.equal(dl.tagName, "DL");
|
|
28
|
+
assert.equal(dl.children.length, 2);
|
|
29
|
+
for (const grupo of dl.children) {
|
|
30
|
+
assert.equal(grupo.tagName, "DIV");
|
|
31
|
+
assert.deepEqual([...grupo.children].map((f) => f.tagName), ["DT", "DD"]);
|
|
32
|
+
}
|
|
33
|
+
const dd = documento.querySelector(".umds-attachment-card__campo-valor");
|
|
34
|
+
assert.match(dd.querySelector(".umds-attachment-card__campo-valor-texto").textContent, /Marcos/);
|
|
35
|
+
assert.equal(dd.querySelector("button").getAttribute("aria-label"), "Copiar Nome completo");
|
|
36
|
+
for (const grupo of documento.querySelectorAll(".umds-attachment-card__campo")) {
|
|
37
|
+
assert.equal([...grupo.children].some((f) => f.tagName === "BUTTON"), false);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** AttachmentCard size="sm" 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("AttachmentCard/AttachmentCard.vue", props);
|
|
9
|
+
montados.push(m);
|
|
10
|
+
return m;
|
|
11
|
+
};
|
|
12
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
13
|
+
|
|
14
|
+
test("md (padrão): preview de 48px e o ícone do rodapé no sm do Icon", async () => {
|
|
15
|
+
const m = await abrir({ fileName: "Protocolo 104-2026.pdf" });
|
|
16
|
+
assert.ok(!m.raiz.querySelector(".umds-attachment-card").classList.contains("umds-attachment-card--sm"));
|
|
17
|
+
assert.match(m.raiz.querySelector(".umds-attachment-card__preview .umds-icon").getAttribute("style"), /width:\s*48px/);
|
|
18
|
+
const rodape = m.raiz.querySelector(".umds-attachment-card__rodape-icone .umds-icon");
|
|
19
|
+
assert.ok(rodape.classList.contains("umds-icon--sm"));
|
|
20
|
+
assert.doesNotMatch(rodape.getAttribute("style") || "", /width/);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("sm: preview de 40px e ícone do rodapé de 12px", async () => {
|
|
24
|
+
const m = await abrir({ fileName: "Protocolo 104-2026.pdf", size: "sm" });
|
|
25
|
+
assert.ok(m.raiz.querySelector(".umds-attachment-card").classList.contains("umds-attachment-card--sm"));
|
|
26
|
+
assert.match(m.raiz.querySelector(".umds-attachment-card__preview .umds-icon").getAttribute("style"), /width:\s*40px/);
|
|
27
|
+
assert.match(m.raiz.querySelector(".umds-attachment-card__rodape-icone .umds-icon").getAttribute("style"), /width:\s*12px/);
|
|
28
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Badge attached neutral no Vue: as classes no DOM e a regra de CSS na fonte (o jsdom não tem cascata de arquivo). */
|
|
2
|
+
import { test, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { montar } from "./dom.mjs";
|
|
7
|
+
import { h } from "vue";
|
|
8
|
+
|
|
9
|
+
const montados = [];
|
|
10
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
11
|
+
|
|
12
|
+
const css = readFileSync(resolve(process.cwd(), "../core/src/components/Badge/Badge.css"), "utf8");
|
|
13
|
+
const bloco = (seletor) => {
|
|
14
|
+
const inicio = css.indexOf(seletor + " {");
|
|
15
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
test("o neutro colado e sólido leva as três classes que a regra de CSS escolhe", async () => {
|
|
19
|
+
const m = await montar("Badge/Badge.vue", { attached: true, variant: "neutral", appearance: "solid" }, { default: () => h("span", "Tarefa manual") });
|
|
20
|
+
montados.push(m);
|
|
21
|
+
const c = m.raiz.querySelector(".umds-badge").classList;
|
|
22
|
+
assert.ok(c.contains("umds-badge--attached") && c.contains("umds-badge--neutral") && c.contains("umds-badge--solid"));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("CSS: cinza claro com texto escuro no lugar do cinza escuro do solid, que fora do attached não muda", () => {
|
|
26
|
+
const regras = bloco(".umds-badge--attached.umds-badge--neutral.umds-badge--solid");
|
|
27
|
+
assert.match(regras, /background-color:\s*var\(--umds-semantic-color-neutral-light-medium\)/);
|
|
28
|
+
assert.match(regras, /color:\s*var\(--umds-semantic-color-neutral-dark-pure\)/);
|
|
29
|
+
assert.match(bloco(".umds-badge--solid.umds-badge--neutral"), /background-color:\s*var\(--umds-semantic-color-neutral-dark-pure\)/);
|
|
30
|
+
});
|
|
@@ -43,3 +43,11 @@ test("Tag sem pill não escreve a classe; padrão segue outlined", async () => {
|
|
|
43
43
|
test("Tag variant new escreve a classe", async () => {
|
|
44
44
|
assert.match(await renderizar(Tag, { label: "Dado simulado", variant: "new" }), /umds-tag--new/);
|
|
45
45
|
});
|
|
46
|
+
|
|
47
|
+
test("Badge attachedSide right escreve o modificador do canto direito; o padrão não", async () => {
|
|
48
|
+
const direita = await renderizar(Badge, { attached: true, attachedSide: "right" }, { default: "A" });
|
|
49
|
+
assert.match(direita, /umds-badge--attached-right/);
|
|
50
|
+
assert.doesNotMatch(await renderizar(Badge, { attached: true, attachedSide: "left" }, { default: "B" }), /umds-badge--attached-right/);
|
|
51
|
+
assert.doesNotMatch(await renderizar(Badge, { attached: true }, { default: "C" }), /umds-badge--attached-right/);
|
|
52
|
+
assert.doesNotMatch(await renderizar(Badge, { attachedSide: "right" }, { default: "D" }), /umds-badge--attached/);
|
|
53
|
+
});
|
|
@@ -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,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,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
|
+
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataTable: cabeçalho escuro, zebra, destaque, vazio e linhas hierárquicas (treeData) no Vue.
|
|
3
|
+
*/
|
|
4
|
+
import { test, after } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { montar, proximoTick, clicar, teclar } from "./dom.mjs";
|
|
7
|
+
|
|
8
|
+
const montados = [];
|
|
9
|
+
const abrir = async (props, slots) => {
|
|
10
|
+
const m = await montar("DataTable/DataTable.vue", props, slots);
|
|
11
|
+
montados.push(m);
|
|
12
|
+
return m;
|
|
13
|
+
};
|
|
14
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
15
|
+
|
|
16
|
+
const COLUNAS = [
|
|
17
|
+
{ key: "nome", label: "Nome" },
|
|
18
|
+
{ key: "sigla", label: "Sigla" },
|
|
19
|
+
];
|
|
20
|
+
const DADOS = [
|
|
21
|
+
{ id: "a", nome: "Ana", sigla: "SADM" },
|
|
22
|
+
{ id: "b", nome: "Bruno", sigla: "SOBR" },
|
|
23
|
+
{ id: "c", nome: "Carla", sigla: "SEFIN" },
|
|
24
|
+
];
|
|
25
|
+
const ARVORE = [
|
|
26
|
+
{
|
|
27
|
+
id: "gab",
|
|
28
|
+
nome: "Gabinete",
|
|
29
|
+
sigla: "GAB",
|
|
30
|
+
children: [
|
|
31
|
+
{ id: "sadm", nome: "Administração", sigla: "SADM", children: [{ id: "rh", nome: "Recursos Humanos", sigla: "RH" }] },
|
|
32
|
+
{ id: "sobr", nome: "Obras", sigla: "SOBR" },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{ id: "sefin", nome: "Finanças", sigla: "SEFIN" },
|
|
36
|
+
];
|
|
37
|
+
const linhas = (m) => [...m.raiz.querySelectorAll("tbody tr")];
|
|
38
|
+
const nomes = (m) => linhas(m).map((l) => l.querySelectorAll("td")[0].textContent.trim());
|
|
39
|
+
|
|
40
|
+
test("headerVariant dark, headerUppercase, striped e hideHeader ligam as classes", async () => {
|
|
41
|
+
const m = await abrir({
|
|
42
|
+
columns: COLUNAS,
|
|
43
|
+
data: DADOS,
|
|
44
|
+
headerVariant: "dark",
|
|
45
|
+
headerUppercase: true,
|
|
46
|
+
striped: true,
|
|
47
|
+
hideHeader: true,
|
|
48
|
+
});
|
|
49
|
+
const raiz = m.raiz.querySelector(".umds-datatable");
|
|
50
|
+
for (const c of ["header-dark", "header-uppercase", "striped", "header-hidden"]) {
|
|
51
|
+
assert.ok(raiz.classList.contains(`umds-datatable--${c}`), c);
|
|
52
|
+
}
|
|
53
|
+
assert.equal(m.raiz.querySelectorAll("thead th").length, 2, "as colunas continuam no DOM");
|
|
54
|
+
assert.deepEqual(
|
|
55
|
+
linhas(m).map((l) => l.classList.contains("umds-datatable__row--striped")),
|
|
56
|
+
[false, true, false],
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("sem as props novas a tabela é a de sempre", async () => {
|
|
61
|
+
const m = await abrir({ columns: COLUNAS, data: DADOS });
|
|
62
|
+
const raiz = m.raiz.querySelector(".umds-datatable");
|
|
63
|
+
assert.doesNotMatch(raiz.className, /header-dark|header-uppercase|striped|header-hidden|tree/);
|
|
64
|
+
assert.equal(m.raiz.querySelector("table").getAttribute("role"), null);
|
|
65
|
+
assert.equal(m.raiz.querySelector("[aria-level]"), null);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("selectedRowKeys e isRowSelected destacam sem checkbox", async () => {
|
|
69
|
+
const m = await abrir({ columns: COLUNAS, data: DADOS, rowKey: "id", selectedRowKeys: ["b"] });
|
|
70
|
+
const l = linhas(m);
|
|
71
|
+
assert.ok(l[1].classList.contains("umds-datatable__row--selected"));
|
|
72
|
+
assert.ok(l[1].classList.contains("umds-datatable__row--highlighted"));
|
|
73
|
+
assert.equal(l[1].getAttribute("aria-selected"), "true");
|
|
74
|
+
assert.equal(l[0].getAttribute("aria-selected"), null);
|
|
75
|
+
assert.equal(m.raiz.querySelectorAll('[role="checkbox"], input[type="checkbox"]').length, 0);
|
|
76
|
+
|
|
77
|
+
const f = await abrir({ columns: COLUNAS, data: DADOS, isRowSelected: (row) => row.sigla === "SEFIN" });
|
|
78
|
+
assert.ok(linhas(f)[2].classList.contains("umds-datatable__row--selected"));
|
|
79
|
+
assert.ok(!linhas(f)[0].classList.contains("umds-datatable__row--selected"));
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("emptyIcon e emptyDescription; o padrão continua o inbox", async () => {
|
|
83
|
+
const padrao = await abrir({ columns: COLUNAS, data: [] });
|
|
84
|
+
assert.equal(padrao.raiz.querySelector(".umds-datatable__empty-icon svg").getAttribute("data-icon"), "inbox");
|
|
85
|
+
assert.equal(padrao.raiz.querySelector(".umds-datatable__empty-desc"), null);
|
|
86
|
+
|
|
87
|
+
const { faBoxOpen } = await import("@fortawesome/free-solid-svg-icons");
|
|
88
|
+
const m = await abrir({
|
|
89
|
+
columns: COLUNAS,
|
|
90
|
+
data: [],
|
|
91
|
+
emptyMessage: "Nada por aqui",
|
|
92
|
+
emptyDescription: "Ajuste o filtro de setor.",
|
|
93
|
+
emptyIcon: faBoxOpen,
|
|
94
|
+
});
|
|
95
|
+
assert.equal(m.raiz.querySelector(".umds-datatable__empty-icon svg").getAttribute("data-icon"), "box-open");
|
|
96
|
+
assert.match(m.raiz.querySelector(".umds-datatable__empty-desc").textContent, /Ajuste o filtro/);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("treeData: treegrid, só as raízes, aria de árvore", async () => {
|
|
100
|
+
const m = await abrir({ columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id" });
|
|
101
|
+
assert.equal(m.raiz.querySelector("table").getAttribute("role"), "treegrid");
|
|
102
|
+
assert.deepEqual(nomes(m), ["Gabinete", "Finanças"]);
|
|
103
|
+
const [gab, fin] = linhas(m);
|
|
104
|
+
assert.equal(gab.getAttribute("aria-level"), "1");
|
|
105
|
+
assert.equal(gab.getAttribute("aria-posinset"), "1");
|
|
106
|
+
assert.equal(gab.getAttribute("aria-setsize"), "2");
|
|
107
|
+
assert.equal(gab.getAttribute("aria-expanded"), "false");
|
|
108
|
+
assert.equal(fin.getAttribute("aria-expanded"), null);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("treeData: o botão expande e recolhe, com nome acessível e onExpand", async () => {
|
|
112
|
+
const chamadas = [];
|
|
113
|
+
const m = await abrir({
|
|
114
|
+
columns: COLUNAS,
|
|
115
|
+
data: ARVORE,
|
|
116
|
+
treeData: true,
|
|
117
|
+
rowKey: "id",
|
|
118
|
+
onExpand: (...a) => chamadas.push(a),
|
|
119
|
+
});
|
|
120
|
+
const botao = m.raiz.querySelector(".umds-datatable__tree-toggle");
|
|
121
|
+
assert.equal(botao.getAttribute("aria-label"), "Expandir");
|
|
122
|
+
await clicar(botao);
|
|
123
|
+
assert.deepEqual(nomes(m), ["Gabinete", "Administração", "Obras", "Finanças"]);
|
|
124
|
+
assert.deepEqual(chamadas[0], [["gab"], ARVORE[0], true]);
|
|
125
|
+
assert.equal(linhas(m)[1].getAttribute("aria-level"), "2");
|
|
126
|
+
await clicar(m.raiz.querySelector(".umds-datatable__tree-toggle"));
|
|
127
|
+
assert.deepEqual(nomes(m), ["Gabinete", "Finanças"]);
|
|
128
|
+
assert.deepEqual(chamadas[1], [[], ARVORE[0], false]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("treeData: defaultExpandAll abre tudo e desenha os fios", async () => {
|
|
132
|
+
const m = await abrir({ columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", defaultExpandAll: true });
|
|
133
|
+
assert.deepEqual(nomes(m), ["Gabinete", "Administração", "Recursos Humanos", "Obras", "Finanças"]);
|
|
134
|
+
const guias = (l) =>
|
|
135
|
+
[...l.querySelectorAll(".umds-datatable__guide")].map((g) => g.className.replace("umds-datatable__guide umds-datatable__guide--", ""));
|
|
136
|
+
const [gab, sadm, rh, sobr] = linhas(m);
|
|
137
|
+
assert.deepEqual(guias(gab), []);
|
|
138
|
+
assert.deepEqual(guias(sadm), ["tee"]);
|
|
139
|
+
assert.deepEqual(guias(rh), ["line", "elbow"]);
|
|
140
|
+
assert.deepEqual(guias(sobr), ["elbow"]);
|
|
141
|
+
assert.match(rh.querySelector(".umds-datatable__tree-content").getAttribute("style"), /calc\(2 \*/);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("treeData: expandedKeys controla, e expandLabel/collapseLabel traduzem", async () => {
|
|
145
|
+
const m = await abrir({
|
|
146
|
+
columns: COLUNAS,
|
|
147
|
+
data: ARVORE,
|
|
148
|
+
treeData: true,
|
|
149
|
+
rowKey: "id",
|
|
150
|
+
expandedKeys: ["gab"],
|
|
151
|
+
expandLabel: "Expand",
|
|
152
|
+
collapseLabel: "Collapse",
|
|
153
|
+
});
|
|
154
|
+
assert.deepEqual(nomes(m), ["Gabinete", "Administração", "Obras", "Finanças"]);
|
|
155
|
+
const rotulos = [...m.raiz.querySelectorAll(".umds-datatable__tree-toggle")].map((b) => b.getAttribute("aria-label"));
|
|
156
|
+
assert.deepEqual(rotulos, ["Collapse", "Expand"]);
|
|
157
|
+
await clicar(m.raiz.querySelector(".umds-datatable__tree-toggle"));
|
|
158
|
+
assert.deepEqual(nomes(m), ["Gabinete", "Administração", "Obras", "Finanças"], "controlado: não muda sozinho");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("treeData: teclado ↓ → ← Home End", async () => {
|
|
162
|
+
const m = await abrir({ columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id" });
|
|
163
|
+
const gab = linhas(m)[0];
|
|
164
|
+
gab.focus();
|
|
165
|
+
await proximoTick();
|
|
166
|
+
assert.equal(gab.getAttribute("tabindex"), "0");
|
|
167
|
+
assert.equal(linhas(m)[1].getAttribute("tabindex"), "-1");
|
|
168
|
+
|
|
169
|
+
await teclar(gab, "ArrowRight");
|
|
170
|
+
assert.deepEqual(nomes(m), ["Gabinete", "Administração", "Obras", "Finanças"]);
|
|
171
|
+
await teclar(gab, "ArrowRight");
|
|
172
|
+
assert.equal(m.raiz.ownerDocument.activeElement, linhas(m)[1]);
|
|
173
|
+
await teclar(linhas(m)[1], "ArrowDown");
|
|
174
|
+
assert.equal(m.raiz.ownerDocument.activeElement, linhas(m)[2]);
|
|
175
|
+
await teclar(linhas(m)[2], "ArrowLeft");
|
|
176
|
+
assert.equal(m.raiz.ownerDocument.activeElement, linhas(m)[0]);
|
|
177
|
+
await teclar(linhas(m)[0], "End");
|
|
178
|
+
assert.equal(m.raiz.ownerDocument.activeElement, linhas(m)[3]);
|
|
179
|
+
await teclar(linhas(m)[3], "Home");
|
|
180
|
+
assert.equal(m.raiz.ownerDocument.activeElement, linhas(m)[0]);
|
|
181
|
+
await teclar(linhas(m)[0], "ArrowLeft");
|
|
182
|
+
assert.deepEqual(nomes(m), ["Gabinete", "Finanças"]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("treeData: o botão não aciona o onRowClick, e o slot de célula vale na coluna da árvore", async () => {
|
|
186
|
+
let cliques = 0;
|
|
187
|
+
const m = await abrir(
|
|
188
|
+
{ columns: COLUNAS, data: ARVORE, treeData: true, rowKey: "id", onRowClick: () => cliques++ },
|
|
189
|
+
{ "cell-nome": ({ row }) => `** ${row.nome}` },
|
|
190
|
+
);
|
|
191
|
+
assert.deepEqual(nomes(m), ["** Gabinete", "** Finanças"]);
|
|
192
|
+
await clicar(m.raiz.querySelector(".umds-datatable__tree-toggle"));
|
|
193
|
+
assert.equal(cliques, 0);
|
|
194
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** DescriptionList density 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("DescriptionList/DescriptionList.vue", props);
|
|
9
|
+
montados.push(m);
|
|
10
|
+
return m;
|
|
11
|
+
};
|
|
12
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
13
|
+
|
|
14
|
+
const ITENS = [{ label: "Dotação", value: "02.031.0001" }];
|
|
15
|
+
|
|
16
|
+
test("compact escreve a classe; default e ausente não", async () => {
|
|
17
|
+
const c = await abrir({ items: ITENS, density: "compact" });
|
|
18
|
+
assert.ok(c.raiz.querySelector("dl").classList.contains("umds-description-list--compact"));
|
|
19
|
+
const d = await abrir({ items: ITENS, density: "default" });
|
|
20
|
+
assert.ok(!d.raiz.querySelector("dl").classList.contains("umds-description-list--compact"));
|
|
21
|
+
const a = await abrir({ items: ITENS });
|
|
22
|
+
assert.ok(!a.raiz.querySelector("dl").classList.contains("umds-description-list--compact"));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("compact vale nos dois desenhos", async () => {
|
|
26
|
+
const s = await abrir({ items: ITENS, density: "compact", layout: "stacked", bordered: true });
|
|
27
|
+
const cs = s.raiz.querySelector("dl").classList;
|
|
28
|
+
assert.ok(cs.contains("umds-description-list--stacked") && cs.contains("umds-description-list--compact"));
|
|
29
|
+
const i = await abrir({ items: ITENS, density: "compact", fit: true });
|
|
30
|
+
const ci = i.raiz.querySelector("dl").classList;
|
|
31
|
+
assert.ok(ci.contains("umds-description-list--inline") && ci.contains("umds-description-list--compact"));
|
|
32
|
+
});
|
package/src/teste/dom.mjs
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** EmptyState com título rico (slot title) 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
|
+
import { h } from "vue";
|
|
6
|
+
|
|
7
|
+
const montados = [];
|
|
8
|
+
const abrir = async (props, slots) => {
|
|
9
|
+
const m = await montar("EmptyState/EmptyState.vue", props, slots);
|
|
10
|
+
montados.push(m);
|
|
11
|
+
return m;
|
|
12
|
+
};
|
|
13
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
14
|
+
|
|
15
|
+
test("título em texto continua igual", async () => {
|
|
16
|
+
const m = await abrir({ title: "Nenhuma mensagem", description: "Tudo em dia." });
|
|
17
|
+
assert.equal(m.raiz.querySelector(".umds-empty-state__title").textContent.trim(), "Nenhuma mensagem");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("o slot title traz conteúdo rico e vale sobre a prop", async () => {
|
|
21
|
+
const m = await abrir(
|
|
22
|
+
{ title: "texto de reserva" },
|
|
23
|
+
{ title: () => [h("span", { "data-termo": "1" }, "Nenhum processo para "), h("a", { href: "#limpar" }, "Limpar filtro")] },
|
|
24
|
+
);
|
|
25
|
+
const titulo = m.raiz.querySelector(".umds-empty-state__title");
|
|
26
|
+
assert.ok(titulo.querySelector("[data-termo]"));
|
|
27
|
+
assert.equal(titulo.querySelector("a").getAttribute("href"), "#limpar");
|
|
28
|
+
assert.doesNotMatch(titulo.textContent, /texto de reserva/);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("só o slot, sem a prop title, também funciona", async () => {
|
|
32
|
+
const m = await abrir({}, { title: () => h("b", "Só o slot") });
|
|
33
|
+
assert.equal(m.raiz.querySelector(".umds-empty-state__title b").textContent, "Só o slot");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("o título é um div", async () => {
|
|
37
|
+
const m = await abrir({ title: "x" });
|
|
38
|
+
assert.equal(m.raiz.querySelector(".umds-empty-state__title").tagName, "DIV");
|
|
39
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Input grouped no Vue (DOM do jsdom). */
|
|
2
|
+
import { test, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { montar } from "./dom.mjs";
|
|
7
|
+
|
|
8
|
+
const montados = [];
|
|
9
|
+
const abrir = async (props) => {
|
|
10
|
+
const m = await montar("Input/Input.vue", props);
|
|
11
|
+
montados.push(m);
|
|
12
|
+
return m;
|
|
13
|
+
};
|
|
14
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
15
|
+
|
|
16
|
+
test("grouped liga a classe própria e a do borderless; sem a prop, nenhuma", async () => {
|
|
17
|
+
const g = await abrir({ ariaLabel: "Adicionar setor", grouped: true });
|
|
18
|
+
const raiz = g.raiz.querySelector(".umds-input");
|
|
19
|
+
assert.ok(raiz.classList.contains("umds-input--grouped"));
|
|
20
|
+
assert.ok(raiz.classList.contains("umds-input--borderless"));
|
|
21
|
+
const n = await abrir({ ariaLabel: "Adicionar setor" });
|
|
22
|
+
const normal = n.raiz.querySelector(".umds-input");
|
|
23
|
+
assert.ok(!normal.classList.contains("umds-input--grouped"));
|
|
24
|
+
assert.ok(!normal.classList.contains("umds-input--borderless"));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("borderless sozinho não ganha a classe do grupo", async () => {
|
|
28
|
+
const m = await abrir({ ariaLabel: "x", borderless: true });
|
|
29
|
+
const raiz = m.raiz.querySelector(".umds-input");
|
|
30
|
+
assert.ok(raiz.classList.contains("umds-input--borderless"));
|
|
31
|
+
assert.ok(!raiz.classList.contains("umds-input--grouped"));
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("CSS: o campo agrupado não impõe altura nem padding nem anel de foco próprio", () => {
|
|
35
|
+
const css = readFileSync(resolve(process.cwd(), "../core/src/components/Input/Input.css"), "utf8");
|
|
36
|
+
const bloco = (seletor) => {
|
|
37
|
+
const inicio = css.indexOf(seletor + " {");
|
|
38
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
39
|
+
};
|
|
40
|
+
assert.match(bloco(".umds-input--grouped .umds-input__container"), /height:\s*auto/);
|
|
41
|
+
const foco = bloco(".umds-input--grouped .umds-input__container:focus-within:not(.umds-input__container--disabled):not(.umds-input__container--readonly)");
|
|
42
|
+
assert.match(foco, /outline:\s*none/);
|
|
43
|
+
assert.match(foco, /box-shadow:\s*none/);
|
|
44
|
+
});
|