@1doc/1ds-vue 2.9.0 → 2.11.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 +653 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +164 -10
- package/dist/index.mjs +9734 -8309
- package/dist/index.umd.js +4 -4
- package/package.json +3 -3
- package/src/teste/accordion-controlado.test.mjs +75 -0
- 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-attached-tom-padding.test.mjs +49 -0
- package/src/teste/badge-neutro-colado.test.mjs +30 -0
- package/src/teste/badge-tag.test.mjs +8 -0
- package/src/teste/button-densidade.test.mjs +33 -0
- package/src/teste/calendar-compacto.test.mjs +37 -0
- package/src/teste/calendar-slots-cabecalho.test.mjs +46 -0
- package/src/teste/coachmark-sem-veu.test.mjs +70 -0
- package/src/teste/coachmark-um-passo.test.mjs +47 -0
- package/src/teste/color-picker-xs.test.mjs +28 -0
- package/src/teste/datatable-arvore-variantes.test.mjs +194 -0
- package/src/teste/datatable-compacta-tom.test.mjs +70 -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/input-ghost.test.mjs +37 -0
- package/src/teste/list-item-standalone.test.mjs +75 -0
- package/src/teste/list.test.mjs +2 -1
- package/src/teste/modal-proporcoes-1doc.test.mjs +38 -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/segmented-contador.test.mjs +39 -0
- package/src/teste/segmented-superficie.test.mjs +40 -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-item-com-escopo.test.mjs +68 -0
- package/src/teste/select-lista-filtro.test.mjs +112 -0
- package/src/teste/statcard-secundaria-tom.test.mjs +41 -0
- package/src/teste/statcard-tamanho-sm.test.mjs +34 -0
- package/src/teste/tabs-compacta-css.test.mjs +23 -0
- package/src/teste/tabs-compacta.test.mjs +27 -0
- package/src/teste/tag-positivo-tingido.test.mjs +56 -0
- package/src/teste/toast-acao-detalhes.test.mjs +48 -0
- package/src/teste/token-primary-lighter.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.11.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.
|
|
34
|
-
"@1doc/1ds-core": "2.
|
|
33
|
+
"@1doc/1ds-tokens": "0.6.0",
|
|
34
|
+
"@1doc/1ds-core": "2.11.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@1doc/1ds-tokens": ">=0.1.0",
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Accordion controlado (open e onOpenChange) no Vue (DOM do jsdom). */
|
|
2
|
+
import { test, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { montar, clicar, proximoTick } from "./dom.mjs";
|
|
5
|
+
|
|
6
|
+
const montados = [];
|
|
7
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
8
|
+
const abrir = async (props) => {
|
|
9
|
+
const m = await montar("Accordion/Accordion.vue", props);
|
|
10
|
+
montados.push(m);
|
|
11
|
+
await proximoTick();
|
|
12
|
+
return m;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const ITENS = [
|
|
16
|
+
{ id: "prazos", title: "Prazos", content: "Dez dias úteis.", defaultOpen: true },
|
|
17
|
+
{ id: "anexos", title: "Anexos", content: "Até 10 MB." },
|
|
18
|
+
{ id: "sigilo", title: "Sigilo", content: "Só o setor." },
|
|
19
|
+
];
|
|
20
|
+
const botao = (m, nome) => [...m.raiz.querySelectorAll("button")].find((b) => b.textContent.includes(nome));
|
|
21
|
+
const aberto = (m, nome) => botao(m, nome).getAttribute("aria-expanded") === "true";
|
|
22
|
+
|
|
23
|
+
test("não controlado: defaultOpen, clique abre e fecha, e onOpenChange avisa a nova lista", async () => {
|
|
24
|
+
const chamadas = [];
|
|
25
|
+
const m = await abrir({ items: ITENS, multiple: true, onOpenChange: (ids) => chamadas.push(ids) });
|
|
26
|
+
assert.equal(aberto(m, "Prazos"), true);
|
|
27
|
+
await clicar(botao(m, "Anexos"));
|
|
28
|
+
assert.equal(aberto(m, "Anexos"), true);
|
|
29
|
+
assert.deepEqual(chamadas.at(-1), ["prazos", "anexos"]);
|
|
30
|
+
await clicar(botao(m, "Prazos"));
|
|
31
|
+
assert.equal(aberto(m, "Prazos"), false);
|
|
32
|
+
assert.deepEqual(chamadas.at(-1), ["anexos"]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("sem multiple, abrir um fecha o outro", async () => {
|
|
36
|
+
const m = await abrir({ items: ITENS });
|
|
37
|
+
await clicar(botao(m, "Anexos"));
|
|
38
|
+
assert.equal(aberto(m, "Anexos"), true);
|
|
39
|
+
assert.equal(aberto(m, "Prazos"), false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("controlado: open manda e ignora defaultOpen", async () => {
|
|
43
|
+
const m = await abrir({ items: ITENS, open: ["sigilo"] });
|
|
44
|
+
assert.equal(aberto(m, "Sigilo"), true);
|
|
45
|
+
assert.equal(aberto(m, "Prazos"), false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("controlado: o clique só pede; sem o app mudar open, nada abre", async () => {
|
|
49
|
+
const chamadas = [];
|
|
50
|
+
const m = await abrir({ items: ITENS, multiple: true, open: ["prazos"], onOpenChange: (ids) => chamadas.push(ids) });
|
|
51
|
+
await clicar(botao(m, "Anexos"));
|
|
52
|
+
assert.deepEqual(chamadas.at(-1), ["prazos", "anexos"]);
|
|
53
|
+
assert.equal(aberto(m, "Anexos"), false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("controlado: o app muda open e o painel acompanha (inclusive open vazio)", async () => {
|
|
57
|
+
const { ref } = await import("vue");
|
|
58
|
+
const abertos = ref(["prazos"]);
|
|
59
|
+
const m = await abrir(() => ({ items: ITENS, multiple: true, open: abertos.value, onOpenChange: (ids) => (abertos.value = ids) }));
|
|
60
|
+
assert.equal(aberto(m, "Prazos"), true);
|
|
61
|
+
await clicar(botao(m, "Sigilo"));
|
|
62
|
+
assert.deepEqual(abertos.value, ["prazos", "sigilo"]);
|
|
63
|
+
assert.equal(aberto(m, "Sigilo"), true);
|
|
64
|
+
abertos.value = [];
|
|
65
|
+
await proximoTick();
|
|
66
|
+
assert.equal(aberto(m, "Prazos"), false);
|
|
67
|
+
assert.equal(aberto(m, "Sigilo"), false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("item desabilitado não pede nada", async () => {
|
|
71
|
+
const chamadas = [];
|
|
72
|
+
const m = await abrir({ items: [{ id: "x", title: "Bloqueado", content: "...", disabled: true }], open: [], onOpenChange: (ids) => chamadas.push(ids) });
|
|
73
|
+
await clicar(botao(m, "Bloqueado"));
|
|
74
|
+
assert.equal(chamadas.length, 0);
|
|
75
|
+
});
|
|
@@ -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,49 @@
|
|
|
1
|
+
/** Badge 2xs com padding de 8px e attached com 22px e tom escuro, no Vue (classes no DOM e regras de CSS na fonte). */
|
|
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
|
+
const abrir = async (props) => {
|
|
12
|
+
const m = await montar("Badge/Badge.vue", props, { default: () => h("span", "Tarefa manual") });
|
|
13
|
+
montados.push(m);
|
|
14
|
+
return m.raiz.querySelector(".umds-badge");
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const css = readFileSync(resolve(process.cwd(), "../core/src/components/Badge/Badge.css"), "utf8").replace(/\r\n/g, "\n");
|
|
18
|
+
const bloco = (seletor) => {
|
|
19
|
+
const inicio = css.indexOf(seletor + " {");
|
|
20
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
test("2xs: padding de 2px em cima e embaixo e 8px dos lados; xs e md não mudam", () => {
|
|
24
|
+
assert.match(bloco(".umds-badge--2xs"), /padding:\s*var\(--umds-primitive-spacing-micro\)\s+var\(--umds-primitive-spacing-nano\)/);
|
|
25
|
+
assert.match(bloco(".umds-badge--xs"), /padding:\s*var\(--umds-primitive-spacing-micro\)\s+var\(--umds-primitive-spacing-quarck\)/);
|
|
26
|
+
assert.match(bloco(".umds-badge--md"), /padding:\s*var\(--umds-primitive-spacing-quarck\)\s+var\(--umds-primitive-spacing-nano\)/);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("attached: altura mínima de 22px (24 - 2)", async () => {
|
|
30
|
+
assert.match(
|
|
31
|
+
bloco(".umds-badge--attached"),
|
|
32
|
+
/min-height:\s*calc\(var\(--umds-primitive-spacing-xxs\)\s*-\s*var\(--umds-primitive-spacing-micro\)\)/,
|
|
33
|
+
);
|
|
34
|
+
const c = (await abrir({ attached: true, size: "xs", variant: "neutral", appearance: "solid" })).classList;
|
|
35
|
+
assert.ok(c.contains("umds-badge--attached") && c.contains("umds-badge--xs"));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("attachedTone dark escreve a classe; sem ela, com light e sem attached, não", async () => {
|
|
39
|
+
assert.ok((await abrir({ attached: true, attachedTone: "dark", variant: "neutral", appearance: "solid" })).classList.contains("umds-badge--attached-dark"));
|
|
40
|
+
assert.ok(!(await abrir({ attached: true, variant: "neutral", appearance: "solid" })).classList.contains("umds-badge--attached-dark"));
|
|
41
|
+
assert.ok(!(await abrir({ attached: true, attachedTone: "light", variant: "neutral", appearance: "solid" })).classList.contains("umds-badge--attached-dark"));
|
|
42
|
+
assert.ok(!(await abrir({ attachedTone: "dark", variant: "neutral", appearance: "solid" })).classList.contains("umds-badge--attached-dark"));
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("CSS: o escuro é neutral-dark-down com texto branco, só no neutro sólido colado", () => {
|
|
46
|
+
const regra = bloco(".umds-badge--attached.umds-badge--neutral.umds-badge--solid.umds-badge--attached-dark");
|
|
47
|
+
assert.match(regra, /background-color:\s*var\(--umds-semantic-color-neutral-dark-down\)/);
|
|
48
|
+
assert.match(regra, /color:\s*var\(--umds-semantic-color-neutral-light-pure\)/);
|
|
49
|
+
});
|
|
@@ -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,33 @@
|
|
|
1
|
+
/** Button density="comfortable" 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
|
+
import { h } from "vue";
|
|
8
|
+
|
|
9
|
+
const montados = [];
|
|
10
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
11
|
+
const abrir = async (props) => {
|
|
12
|
+
const m = await montar("Button/Button.vue", props, { default: () => h("span", "Personalizar") });
|
|
13
|
+
montados.push(m);
|
|
14
|
+
return m.raiz.querySelector("button");
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const css = readFileSync(resolve(process.cwd(), "../core/src/components/Button/Button.css"), "utf8").replace(/\r\n/g, "\n");
|
|
18
|
+
const bloco = (seletor) => {
|
|
19
|
+
const inicio = css.indexOf(seletor + " {");
|
|
20
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
test("comfortable escreve a classe; sem a prop e com default o botão é o de antes", async () => {
|
|
24
|
+
assert.ok((await abrir({ size: "sm", density: "comfortable" })).classList.contains("umds-button--comfortable"));
|
|
25
|
+
assert.ok(!(await abrir({ size: "sm" })).classList.contains("umds-button--comfortable"));
|
|
26
|
+
assert.ok(!(await abrir({ size: "sm", density: "default" })).classList.contains("umds-button--comfortable"));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("CSS: o sm confortável tem 12px de padding lateral; o sm de antes segue em 8px; os outros tamanhos não mudam", () => {
|
|
30
|
+
assert.match(bloco(".umds-button--sm.umds-button--comfortable:not(.umds-button--icon)"), /padding:\s*0\s+var\(--umds-primitive-spacing-mini\)/);
|
|
31
|
+
assert.match(bloco(".umds-button--sm"), /padding:\s*0\s+var\(--umds-primitive-spacing-nano\)/);
|
|
32
|
+
assert.match(bloco(".umds-button--md"), /padding:\s*0\s+var\(--umds-primitive-spacing-xxxs\)/);
|
|
33
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Calendar density compact no Vue (classes no DOM e regras de CSS na fonte). */
|
|
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
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
10
|
+
const raiz = async (caminho, props, seletor) => {
|
|
11
|
+
const m = await montar(caminho, props);
|
|
12
|
+
montados.push(m);
|
|
13
|
+
return m.raiz.querySelector(seletor);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const css = (componente) =>
|
|
17
|
+
readFileSync(resolve(process.cwd(), `../core/src/components/${componente}/${componente}.css`), "utf8").replace(/\r\n/g, "\n");
|
|
18
|
+
const bloco = (texto, seletor) => {
|
|
19
|
+
const inicio = texto.indexOf(seletor + " {");
|
|
20
|
+
assert.ok(inicio >= 0, seletor);
|
|
21
|
+
return texto.slice(inicio, texto.indexOf("}", inicio));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
test("Calendar density compact escreve a classe na raiz; sem a prop, não", async () => {
|
|
25
|
+
const c = (await raiz("Calendar/Calendar.vue", { today: "2026-05-15", defaultDate: "2026-05-15", density: "compact" }, ".umds-calendar")).classList;
|
|
26
|
+
assert.ok(c.contains("umds-calendar--compact") && c.contains("umds-calendar--month"));
|
|
27
|
+
assert.ok(!(await raiz("Calendar/Calendar.vue", { today: "2026-05-15", defaultDate: "2026-05-15" }, ".umds-calendar")).classList.contains("umds-calendar--compact"));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("Calendar CSS: evento de 20px (16 + 4), 4px de padding lateral e linha de 16px; reticências só quando passa da largura", () => {
|
|
31
|
+
const t = css("Calendar");
|
|
32
|
+
const compacto = bloco(t, ".umds-calendar--compact .umds-calendar__event");
|
|
33
|
+
assert.match(compacto, /min-height:\s*calc\(var\(--umds-primitive-spacing-xxxs\)\s*\+\s*var\(--umds-primitive-spacing-quarck\)\)/);
|
|
34
|
+
assert.match(compacto, /padding:\s*var\(--umds-primitive-spacing-micro\)\s+var\(--umds-primitive-spacing-quarck\)/);
|
|
35
|
+
assert.match(compacto, /line-height:\s*var\(--umds-primitive-spacing-xxxs\)/);
|
|
36
|
+
assert.match(bloco(t, ".umds-calendar__event-title"), /text-overflow:\s*ellipsis/);
|
|
37
|
+
});
|
|
@@ -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,47 @@
|
|
|
1
|
+
/** Coachmark: com um passo só, sem o contador "1 de 1", no Vue (DOM do jsdom). */
|
|
2
|
+
import { test, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { montar, documento, proximoTick } from "./dom.mjs";
|
|
5
|
+
|
|
6
|
+
const montados = [];
|
|
7
|
+
const abrir = async (steps, props = {}) => {
|
|
8
|
+
const alvo = documento.createElement("button");
|
|
9
|
+
alvo.id = "alvo-vue-um";
|
|
10
|
+
documento.body.append(alvo);
|
|
11
|
+
const m = await montar("Coachmark/Coachmark.vue", { open: true, steps, ...props });
|
|
12
|
+
montados.push({ m, alvo });
|
|
13
|
+
await proximoTick();
|
|
14
|
+
await new Promise((r) => setTimeout(r, 40));
|
|
15
|
+
return m;
|
|
16
|
+
};
|
|
17
|
+
after(() => montados.forEach(({ m, alvo }) => (m.desmontar(), alvo.remove())));
|
|
18
|
+
|
|
19
|
+
const UM = [{ target: "#alvo-vue-um", title: "Novo: arrastar", content: "Arraste a linha." }];
|
|
20
|
+
const DOIS = [...UM, { title: "Pronto", content: "Sem alvo." }];
|
|
21
|
+
|
|
22
|
+
test("com um passo só não há contador, nem visível nem na região aria-live", async () => {
|
|
23
|
+
const m = await abrir(UM);
|
|
24
|
+
const cartao = documento.querySelector('[role="dialog"]');
|
|
25
|
+
assert.ok(!cartao.textContent.includes("1 de 1"));
|
|
26
|
+
assert.equal(documento.querySelector(".umds-coachmark__sr").textContent.trim(), "Novo: arrastar");
|
|
27
|
+
m.desmontar();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("com um passo e modal={false} também não", async () => {
|
|
31
|
+
const m = await abrir(UM, { modal: false });
|
|
32
|
+
assert.ok(!documento.querySelector('[role="dialog"]').textContent.includes("1 de 1"));
|
|
33
|
+
m.desmontar();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("com dois passos o contador aparece e o leitor de tela o ouve", async () => {
|
|
37
|
+
const m = await abrir(DOIS);
|
|
38
|
+
assert.ok(documento.querySelector('[role="dialog"]').textContent.includes("1 de 2"));
|
|
39
|
+
assert.equal(documento.querySelector(".umds-coachmark__sr").textContent.trim(), "1 de 2: Novo: arrastar");
|
|
40
|
+
m.desmontar();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("counterLabel segue valendo com mais de um passo", async () => {
|
|
44
|
+
const m = await abrir(DOIS, { counterLabel: "Step {current} of {total}" });
|
|
45
|
+
assert.ok(documento.querySelector('[role="dialog"]').textContent.includes("Step 1 of 2"));
|
|
46
|
+
m.desmontar();
|
|
47
|
+
});
|
|
@@ -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
|
+
});
|