@1doc/1ds-vue 2.8.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1549 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1128 -29
- package/dist/index.mjs +12299 -7939
- package/dist/index.umd.js +4 -4
- package/package.json +5 -4
- package/src/index.ts +26 -0
- package/src/teste/accordion-conteudo-livre.test.mjs +44 -0
- package/src/teste/accordion-titulo-neutro.test.mjs +32 -0
- package/src/teste/appsubheader-regiao.test.mjs +18 -0
- package/src/teste/atributos.test.mjs +91 -0
- package/src/teste/attachmentcard-ia.test.mjs +48 -0
- package/src/teste/attachmentcard-lista.test.mjs +39 -0
- package/src/teste/attachmentcard-sm.test.mjs +28 -0
- package/src/teste/avatargroup-overlap.test.mjs +45 -0
- package/src/teste/badge-neutro-colado.test.mjs +30 -0
- package/src/teste/badge-tag.test.mjs +53 -0
- package/src/teste/box-item-flex.test.mjs +84 -0
- package/src/teste/box-layout.test.mjs +57 -0
- package/src/teste/button.test.mjs +34 -0
- package/src/teste/calendar-slots-cabecalho.test.mjs +46 -0
- package/src/teste/calendar.test.mjs +179 -0
- package/src/teste/chips-xs.test.mjs +33 -0
- package/src/teste/coachmark-sem-veu.test.mjs +70 -0
- package/src/teste/coachmark.test.mjs +119 -0
- package/src/teste/color-picker-xs.test.mjs +28 -0
- package/src/teste/color-picker.test.mjs +79 -0
- package/src/teste/datatable-arvore-variantes.test.mjs +194 -0
- package/src/teste/datatable-documento.test.mjs +106 -0
- package/src/teste/datatable-slots.test.mjs +105 -0
- package/src/teste/descriptionlist-compacta.test.mjs +32 -0
- package/src/teste/dom.mjs +170 -0
- package/src/teste/empty-state-titulo-rico.test.mjs +39 -0
- package/src/teste/fileinput-trigger.test.mjs +36 -0
- package/src/teste/icon-picker.test.mjs +98 -0
- package/src/teste/input-agrupado.test.mjs +44 -0
- package/src/teste/input-mascara-afins.test.mjs +64 -0
- package/src/teste/kbd-code-block.test.mjs +76 -0
- package/src/teste/list-item-standalone.test.mjs +75 -0
- package/src/teste/list.test.mjs +163 -0
- package/src/teste/modal-variantes.test.mjs +79 -0
- package/src/teste/org-chart.test.mjs +131 -0
- package/src/teste/otp-input.test.mjs +130 -0
- package/src/teste/popover-maxheight.test.mjs +26 -0
- package/src/teste/renderizar.mjs +64 -0
- package/src/teste/rich-text-editor-alinha-imagem-tabela.test.mjs +164 -0
- package/src/teste/rich-text-editor-estilo-de-texto.test.mjs +87 -0
- package/src/teste/rich-text-editor.test.mjs +210 -0
- package/src/teste/segmented-contador.test.mjs +39 -0
- package/src/teste/select-aberto-controlado-flutuante.test.mjs +120 -0
- package/src/teste/select-filtro-cor-tamanho.test.mjs +62 -0
- package/src/teste/select-placement-filtro.test.mjs +49 -0
- package/src/teste/stack-box-raiz-unica.test.mjs +134 -0
- package/src/teste/stack.test.mjs +80 -0
- package/src/teste/statcard-rotulo-topo.test.mjs +34 -0
- package/src/teste/statcard-secundaria-tom.test.mjs +41 -0
- package/src/teste/tabs-contador-fechavel.test.mjs +60 -0
- package/src/teste/toast-acao-detalhes.test.mjs +48 -0
- package/src/teste/tooltip-dark.test.mjs +28 -0
- package/src/utils/calendario.ts +78 -0
- package/src/utils/html-seguro.ts +197 -0
- package/src/utils/paleta-de-cores.ts +34 -0
- package/src/utils/texto.ts +5 -0
- package/src/utils/toast.ts +12 -2
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",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"build": "vue-tsc --noEmit && vite build && node ../../scripts/get-vue-types.mjs"
|
|
44
|
+
"build": "vue-tsc --noEmit && vite build && node ../../scripts/get-vue-types.mjs",
|
|
45
|
+
"test": "node --test \"src/teste/*.test.mjs\""
|
|
45
46
|
}
|
|
46
47
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from "./utils/theme";
|
|
|
5
5
|
export * from "./utils/toast";
|
|
6
6
|
// Densidade global (modo touch ≥44px via data-density)
|
|
7
7
|
export * from "./utils/density";
|
|
8
|
+
// Paleta de cor categórica (primitivos) do ColorPicker
|
|
9
|
+
export * from "./utils/paleta-de-cores";
|
|
8
10
|
// FontAwesome
|
|
9
11
|
export { library } from "@fortawesome/fontawesome-svg-core";
|
|
10
12
|
|
|
@@ -12,6 +14,9 @@ export { library } from "@fortawesome/fontawesome-svg-core";
|
|
|
12
14
|
export { default as Accordion } from "./components/Accordion/Accordion.vue";
|
|
13
15
|
export { default as AILabel } from "./components/AILabel/AILabel.vue";
|
|
14
16
|
export { default as AIContent } from "./components/AIContent/AIContent.vue";
|
|
17
|
+
export { default as Calendar } from "./components/Calendar/Calendar.vue";
|
|
18
|
+
export { default as Coachmark } from "./components/Coachmark/Coachmark.vue";
|
|
19
|
+
export { default as CodeBlock } from "./components/CodeBlock/CodeBlock.vue";
|
|
15
20
|
export { default as ConfirmAIAction } from "./components/ConfirmAIAction/ConfirmAIAction.vue";
|
|
16
21
|
export { default as Alert } from "./components/Alert/Alert.vue";
|
|
17
22
|
export { default as AppHeader } from "./components/AppHeader/AppHeader.vue";
|
|
@@ -33,11 +38,13 @@ export { default as Button } from "./components/Button/Button.vue";
|
|
|
33
38
|
export { default as Card } from "./components/Card/Card.vue";
|
|
34
39
|
export { default as Checkbox } from "./components/Checkbox/Checkbox.vue";
|
|
35
40
|
export { default as Chips } from "./components/Chips/Chips.vue";
|
|
41
|
+
export { default as ColorPicker } from "./components/ColorPicker/ColorPicker.vue";
|
|
36
42
|
export { default as Combobox } from "./components/Combobox/Combobox.vue";
|
|
37
43
|
export { default as ConfirmDialog } from "./components/ConfirmDialog/ConfirmDialog.vue";
|
|
38
44
|
export { default as Container } from "./components/Container/Container.vue";
|
|
39
45
|
export { default as DataTable } from "./components/DataTable/DataTable.vue";
|
|
40
46
|
export { default as DatePicker } from "./components/DatePicker/DatePicker.vue";
|
|
47
|
+
export { default as DescriptionList } from "./components/DescriptionList/DescriptionList.vue";
|
|
41
48
|
export { default as Divider } from "./components/Divider/Divider.vue";
|
|
42
49
|
export { default as DonutChart } from "./components/Chart/DonutChart.vue";
|
|
43
50
|
export { default as Drawer } from "./components/Drawer/Drawer.vue";
|
|
@@ -46,15 +53,21 @@ export { default as EmptyState } from "./components/EmptyState/EmptyState.vue";
|
|
|
46
53
|
export { default as FileInput } from "./components/FileInput/FileInput.vue";
|
|
47
54
|
export { default as Grid } from "./components/Grid/Grid.vue";
|
|
48
55
|
export { default as Icon } from "./components/Icon/Icon.vue";
|
|
56
|
+
export { default as IconPicker } from "./components/IconPicker/IconPicker.vue";
|
|
49
57
|
export { default as Input } from "./components/Input/Input.vue";
|
|
50
58
|
export { default as Kanban } from "./components/Kanban/Kanban.vue";
|
|
51
59
|
export { default as KanbanCard } from "./components/Kanban/KanbanCard.vue";
|
|
52
60
|
export { default as KanbanColumn } from "./components/Kanban/KanbanColumn.vue";
|
|
61
|
+
export { default as Kbd } from "./components/Kbd/Kbd.vue";
|
|
53
62
|
export { default as Link } from "./components/Link/Link.vue";
|
|
54
63
|
export { default as LineChart } from "./components/Chart/LineChart.vue";
|
|
64
|
+
export { default as List } from "./components/List/List.vue";
|
|
65
|
+
export { default as ListItem } from "./components/List/ListItem.vue";
|
|
55
66
|
export { default as Logo } from "./components/Logo/Logo.vue";
|
|
56
67
|
export { default as Modal } from "./components/Modal/Modal.vue";
|
|
57
68
|
export { default as MultiSelect } from "./components/MultiSelect/MultiSelect.vue";
|
|
69
|
+
export { default as OrgChart } from "./components/OrgChart/OrgChart.vue";
|
|
70
|
+
export { default as OtpInput } from "./components/OtpInput/OtpInput.vue";
|
|
58
71
|
export { default as PageHeader } from "./components/PageHeader/PageHeader.vue";
|
|
59
72
|
export { default as Pagination } from "./components/Pagination/Pagination.vue";
|
|
60
73
|
export { default as PhoneInput } from "./components/PhoneInput/PhoneInput.vue";
|
|
@@ -62,6 +75,7 @@ export { default as Podium } from "./components/Podium/Podium.vue";
|
|
|
62
75
|
export { default as ProgressBar } from "./components/ProgressBar/ProgressBar.vue";
|
|
63
76
|
export { default as Radio } from "./components/Radio/Radio.vue";
|
|
64
77
|
export { default as RadioGroup } from "./components/Radio/RadioGroup.vue";
|
|
78
|
+
export { default as RichTextEditor } from "./components/RichTextEditor/RichTextEditor.vue";
|
|
65
79
|
export { default as SegmentedControl } from "./components/SegmentedControl/SegmentedControl.vue";
|
|
66
80
|
export { default as Select } from "./components/Select/Select.vue";
|
|
67
81
|
export { default as SidePanel } from "./components/SidePanel/SidePanel.vue";
|
|
@@ -94,6 +108,9 @@ export { default as Tree } from "./components/Tree/Tree.vue";
|
|
|
94
108
|
export type * from "./components/Accordion/Accordion.vue";
|
|
95
109
|
export type * from "./components/AILabel/AILabel.vue";
|
|
96
110
|
export type * from "./components/AIContent/AIContent.vue";
|
|
111
|
+
export type * from "./components/Calendar/Calendar.vue";
|
|
112
|
+
export type * from "./components/Coachmark/Coachmark.vue";
|
|
113
|
+
export type * from "./components/CodeBlock/CodeBlock.vue";
|
|
97
114
|
export type * from "./components/ConfirmAIAction/ConfirmAIAction.vue";
|
|
98
115
|
export type * from "./components/Alert/Alert.vue";
|
|
99
116
|
export type * from "./components/AppHeader/AppHeader.vue";
|
|
@@ -115,11 +132,13 @@ export type * from "./components/Button/Button.vue";
|
|
|
115
132
|
export type * from "./components/Card/Card.vue";
|
|
116
133
|
export type * from "./components/Checkbox/Checkbox.vue";
|
|
117
134
|
export type * from "./components/Chips/Chips.vue";
|
|
135
|
+
export type * from "./components/ColorPicker/ColorPicker.vue";
|
|
118
136
|
export type * from "./components/Combobox/Combobox.vue";
|
|
119
137
|
export type * from "./components/ConfirmDialog/ConfirmDialog.vue";
|
|
120
138
|
export type * from "./components/Container/Container.vue";
|
|
121
139
|
export type * from "./components/DataTable/DataTable.vue";
|
|
122
140
|
export type * from "./components/DatePicker/DatePicker.vue";
|
|
141
|
+
export type * from "./components/DescriptionList/DescriptionList.vue";
|
|
123
142
|
export type * from "./components/Divider/Divider.vue";
|
|
124
143
|
export type * from "./components/Chart/DonutChart.vue";
|
|
125
144
|
export type * from "./components/Drawer/Drawer.vue";
|
|
@@ -128,15 +147,21 @@ export type * from "./components/EmptyState/EmptyState.vue";
|
|
|
128
147
|
export type * from "./components/FileInput/FileInput.vue";
|
|
129
148
|
export type * from "./components/Grid/Grid.vue";
|
|
130
149
|
export type * from "./components/Icon/Icon.vue";
|
|
150
|
+
export type * from "./components/IconPicker/IconPicker.vue";
|
|
131
151
|
export type * from "./components/Input/Input.vue";
|
|
132
152
|
export type * from "./components/Kanban/Kanban.vue";
|
|
133
153
|
export type * from "./components/Kanban/KanbanCard.vue";
|
|
134
154
|
export type * from "./components/Kanban/KanbanColumn.vue";
|
|
155
|
+
export type * from "./components/Kbd/Kbd.vue";
|
|
135
156
|
export type * from "./components/Link/Link.vue";
|
|
136
157
|
export type * from "./components/Chart/LineChart.vue";
|
|
158
|
+
export type * from "./components/List/List.vue";
|
|
159
|
+
export type * from "./components/List/ListItem.vue";
|
|
137
160
|
export type * from "./components/Logo/Logo.vue";
|
|
138
161
|
export type * from "./components/Modal/Modal.vue";
|
|
139
162
|
export type * from "./components/MultiSelect/MultiSelect.vue";
|
|
163
|
+
export type * from "./components/OrgChart/OrgChart.vue";
|
|
164
|
+
export type * from "./components/OtpInput/OtpInput.vue";
|
|
140
165
|
export type * from "./components/PageHeader/PageHeader.vue";
|
|
141
166
|
export type * from "./components/Pagination/Pagination.vue";
|
|
142
167
|
export type * from "./components/PhoneInput/PhoneInput.vue";
|
|
@@ -144,6 +169,7 @@ export type * from "./components/Podium/Podium.vue";
|
|
|
144
169
|
export type * from "./components/ProgressBar/ProgressBar.vue";
|
|
145
170
|
export type * from "./components/Radio/Radio.vue";
|
|
146
171
|
export type * from "./components/Radio/RadioGroup.vue";
|
|
172
|
+
export type * from "./components/RichTextEditor/RichTextEditor.vue";
|
|
147
173
|
export type * from "./components/SegmentedControl/SegmentedControl.vue";
|
|
148
174
|
export type * from "./components/Select/Select.vue";
|
|
149
175
|
export type * from "./components/SidePanel/SidePanel.vue";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Accordion no Vue GERADO: o slot `content-<id>` por item vale sobre o texto, e sem slot o texto aparece como sempre. */
|
|
2
|
+
import { test, before, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { h } from "vue";
|
|
5
|
+
import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
|
|
6
|
+
|
|
7
|
+
let Accordion;
|
|
8
|
+
|
|
9
|
+
before(async () => {
|
|
10
|
+
await abrir();
|
|
11
|
+
Accordion = await carregar("Accordion/Accordion.vue");
|
|
12
|
+
});
|
|
13
|
+
after(fechar);
|
|
14
|
+
|
|
15
|
+
const itens = [
|
|
16
|
+
{ id: "secao1", title: "Seção 01", content: "texto-um" },
|
|
17
|
+
{ id: "secao2", title: "Seção 02", content: "texto-dois" },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
test("sem slot, o content de texto aparece como sempre", async () => {
|
|
21
|
+
const html = await renderizar(Accordion, { items: itens });
|
|
22
|
+
assert.match(html, /texto-um/);
|
|
23
|
+
assert.match(html, /texto-dois/);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("o slot content-<id> vale sobre o texto só daquele item", async () => {
|
|
27
|
+
const html = await renderizar(
|
|
28
|
+
Accordion,
|
|
29
|
+
{ items: itens },
|
|
30
|
+
{ "content-secao1": () => h("input", { id: "campo-livre" }) },
|
|
31
|
+
);
|
|
32
|
+
assert.match(html, /<input id="campo-livre"/);
|
|
33
|
+
assert.doesNotMatch(html, /texto-um/);
|
|
34
|
+
assert.match(html, /texto-dois/);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("o slot recebe o item no escopo", async () => {
|
|
38
|
+
const html = await renderizar(
|
|
39
|
+
Accordion,
|
|
40
|
+
{ items: itens },
|
|
41
|
+
{ "content-secao2": ({ item }) => `para-${item.id}-${item.title}` },
|
|
42
|
+
);
|
|
43
|
+
assert.match(html, /para-secao2-Seção 02/);
|
|
44
|
+
});
|
|
@@ -0,0 +1,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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defeitos do Vue GERADO pelo Mitosis, que o React não tinha:
|
|
3
|
+
*
|
|
4
|
+
* - Text, Grid e Logo descartavam `title`, `style` e `aria-*` (o laço
|
|
5
|
+
* `for (k in props)` compilava para `props.props`);
|
|
6
|
+
* - o DataTable escrevia a classe `umds-datatable__row--selected.value`;
|
|
7
|
+
* - o Button escrevia `autofocus="false"` no DOM.
|
|
8
|
+
*
|
|
9
|
+
* Roda com `pnpm --filter @1doc/1ds-vue test` (node:test, sem dependência
|
|
10
|
+
* nova) e precisa de `pnpm --filter @1doc/1ds-core build` antes, porque os
|
|
11
|
+
* `.vue` de `src/components` são gerados.
|
|
12
|
+
*/
|
|
13
|
+
import { test, before, after } from "node:test";
|
|
14
|
+
import assert from "node:assert/strict";
|
|
15
|
+
import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
|
|
16
|
+
|
|
17
|
+
let Text, Grid, Logo, Button, DataTable;
|
|
18
|
+
|
|
19
|
+
before(async () => {
|
|
20
|
+
await abrir();
|
|
21
|
+
Text = await carregar("Text/Text.vue");
|
|
22
|
+
Grid = await carregar("Grid/Grid.vue");
|
|
23
|
+
Logo = await carregar("Logo/Logo.vue");
|
|
24
|
+
Button = await carregar("Button/Button.vue");
|
|
25
|
+
DataTable = await carregar("DataTable/DataTable.vue");
|
|
26
|
+
});
|
|
27
|
+
after(fechar);
|
|
28
|
+
|
|
29
|
+
test("Text repassa title, style e aria-*", async () => {
|
|
30
|
+
const html = await renderizar(
|
|
31
|
+
Text,
|
|
32
|
+
{ title: "Dica", style: "margin-top: 4px", "aria-live": "polite", "data-x": "1" },
|
|
33
|
+
{ default: "Olá" },
|
|
34
|
+
);
|
|
35
|
+
assert.match(html, /title="Dica"/);
|
|
36
|
+
assert.match(html, /margin-top:\s*4px/);
|
|
37
|
+
assert.match(html, /aria-live="polite"/);
|
|
38
|
+
assert.match(html, /data-x="1"/);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("Text mantém o estilo próprio (maxLines) junto com o do consumidor", async () => {
|
|
42
|
+
const html = await renderizar(
|
|
43
|
+
Text,
|
|
44
|
+
{ maxLines: 2, style: "margin-top: 4px" },
|
|
45
|
+
{ default: "Olá" },
|
|
46
|
+
);
|
|
47
|
+
assert.match(html, /--umds-text-max-lines:\s*2/);
|
|
48
|
+
assert.match(html, /margin-top:\s*4px/);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("Grid repassa title, style e aria-*", async () => {
|
|
52
|
+
const html = await renderizar(
|
|
53
|
+
Grid,
|
|
54
|
+
{ container: true, spacing: "xxxs", title: "Dica", style: "margin-top: 4px", "aria-label": "Área" },
|
|
55
|
+
{ default: "x" },
|
|
56
|
+
);
|
|
57
|
+
assert.match(html, /title="Dica"/);
|
|
58
|
+
assert.match(html, /margin-top:\s*4px/);
|
|
59
|
+
assert.match(html, /aria-label="Área"/);
|
|
60
|
+
assert.match(html, /--umds-grid-gap/);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("Logo repassa title, style e aria-*", async () => {
|
|
64
|
+
const html = await renderizar(Logo, { title: "Dica", style: "width: 80px", "aria-hidden": "true" });
|
|
65
|
+
assert.match(html, /title="Dica"/);
|
|
66
|
+
assert.match(html, /width:\s*80px/);
|
|
67
|
+
assert.match(html, /aria-hidden="true"/);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("Button não escreve autofocus quando falso", async () => {
|
|
71
|
+
const html = await renderizar(Button, {}, { default: "Salvar" });
|
|
72
|
+
assert.doesNotMatch(html, /autofocus/i);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("Button com autoFocus escreve o atributo", async () => {
|
|
76
|
+
const html = await renderizar(Button, { autoFocus: true }, { default: "Salvar" });
|
|
77
|
+
assert.match(html, /autofocus/i);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("DataTable aplica a classe --selected sem '.value'", async () => {
|
|
81
|
+
const html = await renderizar(DataTable, {
|
|
82
|
+
columns: [{ key: "nome", label: "Nome" }],
|
|
83
|
+
data: [{ nome: "Cris Lima" }, { nome: "Ana Paula" }],
|
|
84
|
+
selectable: true,
|
|
85
|
+
selectedRows: [0],
|
|
86
|
+
});
|
|
87
|
+
assert.match(html, /umds-datatable__row--selected(?=[\s"])/);
|
|
88
|
+
assert.doesNotMatch(html, /\.value/);
|
|
89
|
+
// só a primeira linha está selecionada
|
|
90
|
+
assert.equal((html.match(/umds-datatable__row--selected/g) || []).length, 1);
|
|
91
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AttachmentCard no Vue GERADO: o selo de IA e o slot `panel`. O painel vive
|
|
3
|
+
* num Portal e só abre no navegador; o que o SSR mostra, e o que importa para o
|
|
4
|
+
* slot, é a decisão que o componente toma no SCRIPT: sem `statusDetails`, só o
|
|
5
|
+
* slot `panel` deve bastar para o selo virar botão.
|
|
6
|
+
*/
|
|
7
|
+
import { test, before, after } from "node:test";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
|
|
10
|
+
|
|
11
|
+
let AttachmentCard;
|
|
12
|
+
|
|
13
|
+
before(async () => {
|
|
14
|
+
await abrir();
|
|
15
|
+
AttachmentCard = await carregar("AttachmentCard/AttachmentCard.vue");
|
|
16
|
+
});
|
|
17
|
+
after(fechar);
|
|
18
|
+
|
|
19
|
+
const base = { fileName: "protocolo.pdf", documentType: "Protocolo", status: "ai", statusLabel: "Recursos IA" };
|
|
20
|
+
|
|
21
|
+
test("status ai escreve a classe do selo e usa a varinha por padrão", async () => {
|
|
22
|
+
const html = await renderizar(AttachmentCard, base);
|
|
23
|
+
assert.match(html, /umds-attachment-card__status--ai/);
|
|
24
|
+
assert.match(html, /umds-attachment-card__status[^>]*>(?:<!--[^>]*-->)*<span class="umds-icon/);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("só o slot panel faz o selo virar botão (sem statusDetails)", async () => {
|
|
28
|
+
const html = await renderizar(AttachmentCard, base, { panel: () => "conteudo livre" });
|
|
29
|
+
assert.match(html, /<button[^>]*aria-haspopup="dialog"/);
|
|
30
|
+
assert.match(html, /umds-attachment-card__status--interativo/);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("sem panel nem statusDetails o selo não é botão", async () => {
|
|
34
|
+
const html = await renderizar(AttachmentCard, base);
|
|
35
|
+
assert.doesNotMatch(html, /aria-haspopup/);
|
|
36
|
+
assert.doesNotMatch(html, /<button/);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("statusDetails continua fazendo o selo virar botão", async () => {
|
|
40
|
+
const html = await renderizar(AttachmentCard, { ...base, status: "positive", statusDetails: { description: "ok" } });
|
|
41
|
+
assert.match(html, /<button[^>]*aria-haspopup="dialog"/);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("declara panelWidth e closePanelOnAction", () => {
|
|
45
|
+
const props = Object.keys(AttachmentCard.props || {});
|
|
46
|
+
assert.ok(props.includes("panelWidth"));
|
|
47
|
+
assert.ok(props.includes("closePanelOnAction"));
|
|
48
|
+
});
|
|
@@ -0,0 +1,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,45 @@
|
|
|
1
|
+
/** AvatarGroup (overflowCount, overlap, ring) conferido no HTML que o Vue GERADO escreve. */
|
|
2
|
+
import { test, before, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
|
|
5
|
+
|
|
6
|
+
let AvatarGroup;
|
|
7
|
+
|
|
8
|
+
before(async () => {
|
|
9
|
+
await abrir();
|
|
10
|
+
AvatarGroup = await carregar("Avatar/AvatarGroup.vue");
|
|
11
|
+
});
|
|
12
|
+
after(fechar);
|
|
13
|
+
|
|
14
|
+
const pessoas = [
|
|
15
|
+
{ name: "Ana Souza" },
|
|
16
|
+
{ name: "Bruno Lima" },
|
|
17
|
+
{ name: "Carla Dias" },
|
|
18
|
+
{ name: "Diego Ferraz" },
|
|
19
|
+
{ name: "Eduarda Neves" },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
test("sem overflowCount, o +N é o que passou de max", async () => {
|
|
23
|
+
assert.match(await renderizar(AvatarGroup, { avatars: pessoas, max: 3 }), />\s*\+2\s*</);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("overflowCount vira o +N sem itens-fantasma", async () => {
|
|
27
|
+
const html = await renderizar(AvatarGroup, { avatars: pessoas.slice(0, 3), max: 3, overflowCount: 12 });
|
|
28
|
+
assert.match(html, />\s*\+12\s*</);
|
|
29
|
+
assert.match(html, /Mais 12 avatares/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("overflowCount soma com o que passou de max", async () => {
|
|
33
|
+
assert.match(await renderizar(AvatarGroup, { avatars: pessoas, max: 3, overflowCount: 10 }), />\s*\+12\s*</);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("sem excedente não há +N", async () => {
|
|
37
|
+
assert.doesNotMatch(await renderizar(AvatarGroup, { avatars: pessoas.slice(0, 2), max: 4 }), />\s*\+\d+\s*</);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("overlap e ring escrevem as variáveis do grupo; sem eles, nenhum style", async () => {
|
|
41
|
+
const html = await renderizar(AvatarGroup, { avatars: pessoas, overlap: 6, ring: 1 });
|
|
42
|
+
assert.match(html, /--umds-avatar-group-overlap:\s*6px/);
|
|
43
|
+
assert.match(html, /--umds-avatar-group-ring:\s*1px/);
|
|
44
|
+
assert.doesNotMatch(await renderizar(AvatarGroup, { avatars: pessoas }), /--umds-avatar-group/);
|
|
45
|
+
});
|
|
@@ -0,0 +1,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
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Badge (2xs, new, attached) e Tag (xs, soft, pill, new), conferidos no HTML que o Vue GERADO escreve. */
|
|
2
|
+
import { test, before, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
|
|
5
|
+
|
|
6
|
+
let Badge, Tag;
|
|
7
|
+
|
|
8
|
+
before(async () => {
|
|
9
|
+
await abrir();
|
|
10
|
+
Badge = await carregar("Badge/Badge.vue");
|
|
11
|
+
Tag = await carregar("Tag/Tag.vue");
|
|
12
|
+
});
|
|
13
|
+
after(fechar);
|
|
14
|
+
|
|
15
|
+
test("Badge size 2xs escreve a classe; sem size continua md", async () => {
|
|
16
|
+
assert.match(await renderizar(Badge, { size: "2xs" }, { default: "A" }), /umds-badge--2xs/);
|
|
17
|
+
assert.match(await renderizar(Badge, {}, { default: "B" }), /umds-badge--md/);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("Badge variant new e attached escrevem as classes", async () => {
|
|
21
|
+
const html = await renderizar(Badge, { variant: "new", attached: true }, { default: "Novidade" });
|
|
22
|
+
assert.match(html, /umds-badge--new/);
|
|
23
|
+
assert.match(html, /umds-badge--attached/);
|
|
24
|
+
assert.doesNotMatch(await renderizar(Badge, {}, { default: "x" }), /umds-badge--attached/);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("Tag size xs escreve a classe e sm continua", async () => {
|
|
28
|
+
assert.match(await renderizar(Tag, { label: "a", size: "xs" }), /umds-tag--xs/);
|
|
29
|
+
assert.match(await renderizar(Tag, { label: "b", size: "sm" }), /umds-tag--sm/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("Tag appearance soft, variant primary e pill escrevem as classes", async () => {
|
|
33
|
+
const html = await renderizar(Tag, { label: "SOBR", appearance: "soft", variant: "primary", pill: true });
|
|
34
|
+
for (const c of ["umds-tag--soft", "umds-tag--primary", "umds-tag--pill"]) assert.match(html, new RegExp(c));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("Tag sem pill não escreve a classe; padrão segue outlined", async () => {
|
|
38
|
+
const html = await renderizar(Tag, { label: "x" });
|
|
39
|
+
assert.doesNotMatch(html, /umds-tag--pill/);
|
|
40
|
+
assert.match(html, /umds-tag--outlined/);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("Tag variant new escreve a classe", async () => {
|
|
44
|
+
assert.match(await renderizar(Tag, { label: "Dado simulado", variant: "new" }), /umds-tag--new/);
|
|
45
|
+
});
|
|
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
|
+
});
|