@1doc/1ds-vue 2.10.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 +219 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +45 -2
- package/dist/index.mjs +6143 -6077
- package/dist/index.umd.js +4 -4
- package/package.json +3 -3
- package/src/teste/accordion-controlado.test.mjs +75 -0
- package/src/teste/badge-attached-tom-padding.test.mjs +49 -0
- package/src/teste/button-densidade.test.mjs +33 -0
- package/src/teste/calendar-compacto.test.mjs +37 -0
- package/src/teste/coachmark-um-passo.test.mjs +47 -0
- package/src/teste/datatable-compacta-tom.test.mjs +70 -0
- package/src/teste/input-ghost.test.mjs +37 -0
- package/src/teste/modal-proporcoes-1doc.test.mjs +38 -0
- package/src/teste/segmented-superficie.test.mjs +40 -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-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/token-primary-lighter.test.mjs +48 -0
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-
|
|
34
|
-
"@1doc/1ds-
|
|
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,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,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,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,70 @@
|
|
|
1
|
+
/** DataTable: rowTone e densidade compacta de 44px, 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("DataTable/DataTable.vue", props);
|
|
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: "situacao", label: "Situação" },
|
|
19
|
+
];
|
|
20
|
+
const DADOS = [
|
|
21
|
+
{ nome: "Ana Souza", situacao: "Ativa", tom: "positive" },
|
|
22
|
+
{ nome: "Carlos Lima", situacao: "Bloqueado", tom: "negative" },
|
|
23
|
+
{ nome: "Marina Alves", situacao: "Licença", tom: "info" },
|
|
24
|
+
{ nome: "Rafael Pereira", situacao: "Desligado", tom: "muted" },
|
|
25
|
+
{ nome: "Beatriz Lima", situacao: "Ativa" },
|
|
26
|
+
];
|
|
27
|
+
const linhas = (m) => [...m.raiz.querySelectorAll("tbody tr")];
|
|
28
|
+
|
|
29
|
+
test("rowTone com o nome de um campo da linha", async () => {
|
|
30
|
+
const l = linhas(await abrir({ columns: COLUNAS, data: DADOS, rowTone: "tom" }));
|
|
31
|
+
assert.ok(l[0].classList.contains("umds-datatable__row--positive"));
|
|
32
|
+
assert.ok(l[1].classList.contains("umds-datatable__row--negative"));
|
|
33
|
+
assert.ok(l[2].classList.contains("umds-datatable__row--info"));
|
|
34
|
+
assert.ok(l[3].classList.contains("umds-datatable__row--muted"));
|
|
35
|
+
assert.equal(l[4].className, "umds-datatable__row");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("rowTone com função (row, rowIndex)", async () => {
|
|
39
|
+
const l = linhas(
|
|
40
|
+
await abrir({ columns: COLUNAS, data: DADOS, rowTone: (row, i) => (row.situacao === "Bloqueado" || i === 4 ? "negative" : undefined) }),
|
|
41
|
+
);
|
|
42
|
+
assert.ok(l[1].classList.contains("umds-datatable__row--negative"));
|
|
43
|
+
assert.ok(l[4].classList.contains("umds-datatable__row--negative"));
|
|
44
|
+
assert.equal(l[0].className, "umds-datatable__row");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("tom desconhecido ou vazio não vira classe; sem rowTone nada muda", async () => {
|
|
48
|
+
const a = linhas(await abrir({ columns: COLUNAS, data: [{ nome: "A", situacao: "x", tom: "rosa" }, { nome: "B", situacao: "y", tom: "" }], rowTone: "tom" }));
|
|
49
|
+
for (const l of a) assert.equal(l.className, "umds-datatable__row");
|
|
50
|
+
const b = linhas(await abrir({ columns: COLUNAS, data: DADOS }));
|
|
51
|
+
for (const l of b) assert.equal(l.className, "umds-datatable__row");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("o tom convive com a linha selecionada e a zebra", async () => {
|
|
55
|
+
const l = linhas(await abrir({ columns: COLUNAS, data: DADOS, rowTone: "tom", striped: true, rowKey: "nome", selectedRowKeys: ["Carlos Lima"] }));
|
|
56
|
+
for (const c of ["negative", "selected", "striped"]) assert.ok(l[1].classList.contains("umds-datatable__row--" + c));
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const css = readFileSync(resolve(process.cwd(), "../core/src/components/DataTable/DataTable.css"), "utf8").replace(/\r\n/g, "\n");
|
|
60
|
+
const bloco = (seletor) => {
|
|
61
|
+
const inicio = css.indexOf(seletor + " {");
|
|
62
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
test("CSS: compacta de 44px sem o documento; selecionada vence o tom; tom vence a zebra", () => {
|
|
66
|
+
assert.match(bloco(".umds-datatable--compact:not(.umds-datatable--document) .umds-datatable__td"), /height:\s*var\(--umds-semantic-field-height\)/);
|
|
67
|
+
assert.ok(css.includes(".umds-datatable--compact:not(.umds-datatable--document) .umds-datatable__th,"));
|
|
68
|
+
assert.match(css, /\.umds-datatable__row--negative:not\(\.umds-datatable__row--selected\)\.umds-datatable__row--striped/);
|
|
69
|
+
assert.match(bloco(".umds-datatable__row--muted .umds-datatable__td"), /neutral-dark-down/);
|
|
70
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Input variant ghost 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("Input variant ghost escreve a classe; sem a prop e com default, não", async () => {
|
|
25
|
+
assert.ok((await raiz("Input/Input.vue", { ariaLabel: "a", variant: "ghost" }, ".umds-input")).classList.contains("umds-input--ghost"));
|
|
26
|
+
assert.ok(!(await raiz("Input/Input.vue", { ariaLabel: "b" }, ".umds-input")).classList.contains("umds-input--ghost"));
|
|
27
|
+
assert.ok(!(await raiz("Input/Input.vue", { ariaLabel: "c", variant: "default" }, ".umds-input")).classList.contains("umds-input--ghost"));
|
|
28
|
+
const c = (await raiz("Input/Input.vue", { ariaLabel: "d", variant: "ghost", errorMessage: "Obrigatório" }, ".umds-input")).classList;
|
|
29
|
+
assert.ok(c.contains("umds-input--ghost") && c.contains("umds-input--error"));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("Input CSS: só o repouso muda (fundo claro, borda clara), com baixa especificidade para o hover e o foco vencerem", () => {
|
|
33
|
+
const t = css("Input");
|
|
34
|
+
const ghost = bloco(t, ".umds-input--ghost:where(:not(.umds-input--error):not(.umds-input--disabled):not(.umds-input--readonly)) .umds-input__container");
|
|
35
|
+
assert.match(ghost, /background-color:\s*var\(--umds-semantic-color-background-light\)/);
|
|
36
|
+
assert.match(ghost, /border-color:\s*var\(--umds-semantic-color-neutral-light-medium\)/);
|
|
37
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Modal density 1doc 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("Modal density 1doc escreve a classe e convive com variant primary; sem a prop, não", async () => {
|
|
25
|
+
const c = (await raiz("Modal/Modal.vue", { open: true, inline: true, density: "1doc", variant: "primary", title: "Resolver tarefa" }, ".umds-modal")).classList;
|
|
26
|
+
assert.ok(c.contains("umds-modal--1doc") && c.contains("umds-modal--primary") && c.contains("umds-modal--base"));
|
|
27
|
+
assert.ok(!(await raiz("Modal/Modal.vue", { open: true, inline: true, title: "Padrão" }, ".umds-modal")).classList.contains("umds-modal--1doc"));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("Modal CSS: cabeçalho de 67px, rodapé de 65px (padding 12px 24px), raio de 12px; o padrão (8px) não muda", () => {
|
|
31
|
+
const t = css("Modal");
|
|
32
|
+
assert.match(bloco(t, ".umds-modal--1doc.umds-modal--base .umds-modal__header"), /min-height:\s*67px/);
|
|
33
|
+
const rodape = bloco(t, ".umds-modal--1doc.umds-modal--base .umds-modal__footer");
|
|
34
|
+
assert.match(rodape, /min-height:\s*65px/);
|
|
35
|
+
assert.match(rodape, /padding:\s*var\(--umds-primitive-spacing-mini\)\s+var\(--umds-primitive-spacing-xxs\)/);
|
|
36
|
+
assert.match(t, /\.umds-modal--1doc:not\(\.umds-modal--fullscreen\):not\(\.umds-modal--janela-fullscreen\):not\(\.umds-modal--sheet\) \{\n(?:\s*\/\*.*\*\/\n)?\s*border-radius:\s*12px/);
|
|
37
|
+
assert.match(bloco(t, ".umds-modal"), /border-radius:\s*var\(--umds-primitive-border-radius-sm\)/);
|
|
38
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** SegmentedControl variant surface 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("SegmentedControl variant surface escreve a classe; sem a prop e com default, não", async () => {
|
|
25
|
+
const opcoes = [{ label: "Individual", value: "individual", count: 12 }, { label: "Em lote", value: "lote" }];
|
|
26
|
+
assert.ok((await raiz("SegmentedControl/SegmentedControl.vue", { options: opcoes, variant: "surface", defaultValue: "individual" }, ".umds-segmented")).classList.contains("umds-segmented--surface"));
|
|
27
|
+
assert.ok(!(await raiz("SegmentedControl/SegmentedControl.vue", { options: opcoes, defaultValue: "individual" }, ".umds-segmented")).classList.contains("umds-segmented--surface"));
|
|
28
|
+
assert.ok(!(await raiz("SegmentedControl/SegmentedControl.vue", { options: opcoes, variant: "default", defaultValue: "individual" }, ".umds-segmented")).classList.contains("umds-segmented--surface"));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("SegmentedControl CSS: o escolhido é branco, em negrito e com sombra; o trilho é cinza claro; o azul do padrão segue", () => {
|
|
32
|
+
const t = css("SegmentedControl");
|
|
33
|
+
const escolhido = bloco(t, ".umds-segmented--surface .umds-segmented__input:checked + .umds-segmented__item,\n.umds-segmented--surface .umds-segmented__input:checked + .umds-segmented__item:hover");
|
|
34
|
+
assert.match(escolhido, /background-color:\s*var\(--umds-semantic-color-background-white\)/);
|
|
35
|
+
assert.match(escolhido, /font-weight:\s*var\(--umds-primitive-font-weight-bold\)/);
|
|
36
|
+
assert.match(escolhido, /box-shadow:\s*var\(--umds-semantic-shadow-md\)/);
|
|
37
|
+
assert.match(bloco(t, ".umds-segmented--surface .umds-segmented__track"), /background-color:\s*var\(--umds-semantic-color-neutral-light-medium\)/);
|
|
38
|
+
assert.match(t, /\.umds-segmented__input:checked \+ \.umds-segmented__item,\n\.umds-segmented__input:checked \+ \.umds-segmented__item:hover \{\n\s*background-color:\s*var\(--umds-semantic-color-primary-pure\)/);
|
|
39
|
+
assert.match(bloco(t, ".umds-segmented--surface .umds-segmented__count"), /background-color:\s*var\(--umds-semantic-color-background-white\)/);
|
|
40
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Select: o slot #item com escopo da opção, na lista e no gatilho, 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
|
+
import { h } from "vue";
|
|
6
|
+
|
|
7
|
+
const montados = [];
|
|
8
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
9
|
+
|
|
10
|
+
const OPCOES = [
|
|
11
|
+
{ label: "Urgente", value: "urgente", etiqueta: "Prazo hoje" },
|
|
12
|
+
{ label: "Rotina", value: "rotina", etiqueta: "Sem prazo" },
|
|
13
|
+
];
|
|
14
|
+
const abrir = async (props, slots = {}) => {
|
|
15
|
+
const m = await montar("Select/Select.vue", { ariaLabel: "Prioridade", options: OPCOES, ...props }, slots);
|
|
16
|
+
montados.push(m);
|
|
17
|
+
return m;
|
|
18
|
+
};
|
|
19
|
+
const gatilho = (m) => m.raiz.querySelector(".umds-select__trigger");
|
|
20
|
+
const slotItem = (escopos) => ({
|
|
21
|
+
item: (escopo) => {
|
|
22
|
+
escopos.push(escopo);
|
|
23
|
+
return h("span", { "data-testid": "item" }, escopo.optionData.label + " " + escopo.optionData.etiqueta);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("a lista passa a opção ao slot (optionData e o apelido option)", async () => {
|
|
28
|
+
const escopos = [];
|
|
29
|
+
const m = await abrir({}, slotItem(escopos));
|
|
30
|
+
await clicar(gatilho(m));
|
|
31
|
+
const itens = [...m.raiz.querySelectorAll('[data-testid="item"]')].map((n) => n.textContent);
|
|
32
|
+
assert.deepEqual(itens, ["Urgente Prazo hoje", "Rotina Sem prazo"]);
|
|
33
|
+
const daLista = escopos.find((e) => e.optionData.value === "rotina");
|
|
34
|
+
assert.equal(daLista.optionData, OPCOES[1]);
|
|
35
|
+
assert.equal(daLista.option, OPCOES[1]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("o gatilho com a opção escolhida mostra o conteúdo do slot, não o texto", async () => {
|
|
39
|
+
const m = await abrir({ value: "urgente" }, slotItem([]));
|
|
40
|
+
await proximoTick();
|
|
41
|
+
const dentro = gatilho(m).querySelector(".umds-select__trigger-item");
|
|
42
|
+
assert.ok(dentro);
|
|
43
|
+
assert.match(dentro.textContent, /Urgente Prazo hoje/);
|
|
44
|
+
assert.equal(gatilho(m).querySelector(".umds-select__placeholder"), null);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("sem valor o gatilho mostra o placeholder, e escolher na lista passa o item ao gatilho", async () => {
|
|
48
|
+
const m = await abrir({ placeholder: "Escolha" }, slotItem([]));
|
|
49
|
+
assert.match(gatilho(m).textContent, /Escolha/);
|
|
50
|
+
assert.equal(gatilho(m).querySelector(".umds-select__trigger-item"), null);
|
|
51
|
+
await clicar(gatilho(m));
|
|
52
|
+
await clicar(m.raiz.querySelectorAll('[role="option"]')[1]);
|
|
53
|
+
await proximoTick();
|
|
54
|
+
assert.match(gatilho(m).querySelector(".umds-select__trigger-item").textContent, /Rotina Sem prazo/);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("seleção múltipla segue com o texto no gatilho", async () => {
|
|
58
|
+
const m = await abrir({ multiple: true, value: ["urgente"] }, slotItem([]));
|
|
59
|
+
assert.equal(gatilho(m).querySelector(".umds-select__trigger-item"), null);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("sem o slot nada muda: o gatilho mostra o rótulo e a lista o texto da opção", async () => {
|
|
63
|
+
const m = await abrir({ value: "urgente" });
|
|
64
|
+
assert.equal(gatilho(m).querySelector(".umds-select__trigger-item"), null);
|
|
65
|
+
assert.match(gatilho(m).textContent, /Urgente/);
|
|
66
|
+
await clicar(gatilho(m));
|
|
67
|
+
assert.match(m.raiz.querySelector('[role="option"]').textContent, /Urgente/);
|
|
68
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** Select filtro: largura mínima da lista configurável e lista que não passa da janela, 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, clicar, janela, proximoTick } from "./dom.mjs";
|
|
7
|
+
|
|
8
|
+
const montados = [];
|
|
9
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
10
|
+
|
|
11
|
+
const OPCOES = [
|
|
12
|
+
{ label: "Urgente", value: "urgente" },
|
|
13
|
+
{ label: "Revisão", value: "revisao" },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const abrir = async (props) => {
|
|
17
|
+
const m = await montar("Select/Select.vue", { ariaLabel: "x", options: OPCOES, ...props });
|
|
18
|
+
montados.push(m);
|
|
19
|
+
await clicar(m.raiz.querySelector(".umds-select__trigger"));
|
|
20
|
+
return m;
|
|
21
|
+
};
|
|
22
|
+
const lista = (m) => m.raiz.querySelector(".umds-select__dropdown");
|
|
23
|
+
|
|
24
|
+
/** jsdom não tem layout: só a lista "mede" o que o teste mandar. */
|
|
25
|
+
function medirLista(direita, larguraDaJanela) {
|
|
26
|
+
const original = janela.HTMLElement.prototype.getBoundingClientRect;
|
|
27
|
+
janela.HTMLElement.prototype.getBoundingClientRect = function () {
|
|
28
|
+
const eLista = this.classList.contains("umds-select__dropdown");
|
|
29
|
+
return { top: 0, bottom: 0, left: 0, right: eLista ? direita : 0, width: 0, height: 0, x: 0, y: 0 };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(janela, "innerWidth", { value: larguraDaJanela, configurable: true });
|
|
32
|
+
return () => (janela.HTMLElement.prototype.getBoundingClientRect = original);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
test("listMinWidth em número vira px; a lista nunca fica mais estreita que o gatilho", async () => {
|
|
36
|
+
const m = await abrir({ variant: "filter", listMinWidth: 220 });
|
|
37
|
+
assert.equal(lista(m).style.minWidth, "max(100%, 220px)");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("listMinWidth em medida CSS vale como veio", async () => {
|
|
41
|
+
const m = await abrir({ variant: "filter", listMinWidth: "18rem" });
|
|
42
|
+
assert.equal(lista(m).style.minWidth, "max(100%, 18rem)");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("listMinWidth 0 é um valor, não ausência", async () => {
|
|
46
|
+
const m = await abrir({ variant: "filter", listMinWidth: 0 });
|
|
47
|
+
assert.equal(lista(m).style.minWidth, "max(100%, 0px)");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("sem a prop o mínimo é o do CSS, sem estilo inline; o Select padrão ignora a prop", async () => {
|
|
51
|
+
assert.equal(lista(await abrir({ variant: "filter" })).style.minWidth, "");
|
|
52
|
+
assert.equal(lista(await abrir({ listMinWidth: 220 })).style.minWidth, "");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("a lista que estoura a borda direita se alinha ao fim do gatilho", async () => {
|
|
56
|
+
const restaurar = medirLista(1457, 1440);
|
|
57
|
+
try {
|
|
58
|
+
const m = await abrir({ variant: "filter" });
|
|
59
|
+
await proximoTick();
|
|
60
|
+
assert.ok(m.raiz.querySelector(".umds-select--list-end"));
|
|
61
|
+
} finally {
|
|
62
|
+
restaurar();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("a lista que cabe fica onde está, e o Select padrão não é movido", async () => {
|
|
67
|
+
const restaurar = medirLista(900, 1440);
|
|
68
|
+
try {
|
|
69
|
+
const m = await abrir({ variant: "filter" });
|
|
70
|
+
await proximoTick();
|
|
71
|
+
assert.equal(m.raiz.querySelector(".umds-select--list-end"), null);
|
|
72
|
+
} finally {
|
|
73
|
+
restaurar();
|
|
74
|
+
}
|
|
75
|
+
const restaurar2 = medirLista(1457, 1440);
|
|
76
|
+
try {
|
|
77
|
+
const m = await abrir({});
|
|
78
|
+
await proximoTick();
|
|
79
|
+
assert.equal(m.raiz.querySelector(".umds-select--list-end"), null);
|
|
80
|
+
} finally {
|
|
81
|
+
restaurar2();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("fechar desliga o alinhamento", async () => {
|
|
86
|
+
const restaurar = medirLista(1457, 1440);
|
|
87
|
+
try {
|
|
88
|
+
const m = await abrir({ variant: "filter" });
|
|
89
|
+
await proximoTick();
|
|
90
|
+
assert.ok(m.raiz.querySelector(".umds-select--list-end"));
|
|
91
|
+
await clicar(m.raiz.querySelector(".umds-select__trigger"));
|
|
92
|
+
await proximoTick();
|
|
93
|
+
assert.equal(m.raiz.querySelector(".umds-select--list-end"), null);
|
|
94
|
+
} finally {
|
|
95
|
+
restaurar();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const css = readFileSync(resolve(process.cwd(), "../core/src/components/Select/Select.css"), "utf8").replace(/\r\n/g, "\n");
|
|
100
|
+
const bloco = (seletor) => {
|
|
101
|
+
const inicio = css.indexOf(seletor + " {");
|
|
102
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
test("CSS: wrapper fit-content, busca fora da conta da largura e alinhamento pela direita", () => {
|
|
106
|
+
assert.match(bloco(".umds-select--filter"), /width:\s*fit-content/);
|
|
107
|
+
assert.match(bloco(".umds-select--filter .umds-select__search-container"), /contain:\s*inline-size/);
|
|
108
|
+
assert.match(bloco(".umds-select__search-input"), /min-width:\s*0/);
|
|
109
|
+
const fim = bloco(".umds-select--filter.umds-select--list-end .umds-select__dropdown");
|
|
110
|
+
assert.match(fim, /left:\s*auto/);
|
|
111
|
+
assert.match(fim, /right:\s*0/);
|
|
112
|
+
});
|