@1doc/1ds-react 2.13.0 → 2.15.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 +62 -59
- package/dist/components/AILabel/AILabel.css +1 -1
- package/dist/components/Alert/Alert.css +1 -1
- package/dist/components/AppShell/AppShell.css +4 -0
- package/dist/components/AttachmentCard/AttachmentCard.css +2 -2
- package/dist/components/Avatar/Avatar.d.ts +8 -3
- package/dist/components/Avatar/Avatar.js +28 -4
- package/dist/components/BottomNavigation/BottomNavigation.css +2 -2
- package/dist/components/BottomSheet/BottomSheet.css +2 -2
- package/dist/components/Box/Box.css +3 -3
- package/dist/components/Button/Button.css +6 -1
- package/dist/components/Button/Button.d.ts +11 -2
- package/dist/components/Button/Button.js +15 -3
- package/dist/components/Card/Card.css +5 -5
- package/dist/components/Chart/Chart.css +1 -1
- package/dist/components/Coachmark/Coachmark.css +1 -1
- package/dist/components/Combobox/Combobox.css +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.css +1 -1
- package/dist/components/Counter/Counter.css +43 -0
- package/dist/components/Counter/Counter.d.ts +57 -0
- package/dist/components/Counter/Counter.js +99 -0
- package/dist/components/DatePicker/DatePicker.css +1 -1
- package/dist/components/Drawer/Drawer.css +2 -2
- package/dist/components/Dropdown/Dropdown.css +3 -1
- package/dist/components/Dropdown/Dropdown.d.ts +17 -0
- package/dist/components/Dropdown/Dropdown.js +22 -2
- package/dist/components/EmptyState/EmptyState.css +12 -0
- package/dist/components/EmptyState/EmptyState.d.ts +3 -0
- package/dist/components/EmptyState/EmptyState.js +1 -0
- package/dist/components/Kanban/Kanban.css +2 -2
- package/dist/components/Kanban/KanbanCard.css +2 -2
- package/dist/components/List/List.css +83 -0
- package/dist/components/List/List.d.ts +3 -0
- package/dist/components/List/List.js +6 -2
- package/dist/components/List/ListItem.d.ts +19 -0
- package/dist/components/List/ListItem.js +5 -1
- package/dist/components/Modal/Modal.css +3 -4
- package/dist/components/MultiSelect/MultiSelect.css +1 -1
- package/dist/components/OrgChart/OrgChart.css +2 -2
- package/dist/components/PhoneInput/PhoneInput.css +2 -2
- package/dist/components/Popover/Popover.css +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.css +1 -1
- package/dist/components/Select/Select.css +1 -1
- package/dist/components/StatCard/StatCard.css +99 -5
- package/dist/components/StatCard/StatCard.d.ts +12 -6
- package/dist/components/StatCard/StatCard.js +6 -2
- package/dist/components/Switch/Switch.css +2 -2
- package/dist/components/Text/Text.d.ts +6 -0
- package/dist/components/TimePicker/TimePicker.css +1 -1
- package/dist/components/Toast/Toast.css +2 -2
- package/dist/components/Tooltip/Tooltip.css +23 -3
- package/dist/components/Tooltip/Tooltip.js +33 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/teste/PedidosMatheus.test.d.ts +1 -0
- package/dist/teste/PedidosMatheus.test.js +91 -0
- package/dist/teste/PedidosMatheus2.test.d.ts +1 -0
- package/dist/teste/PedidosMatheus2.test.js +82 -0
- package/dist/teste/SegmentedControlSuperficie.test.js +1 -1
- package/dist/teste/StatCardTamanhoSm.test.js +8 -0
- package/package.json +3 -3
- package/src/index.ts +2 -0
- package/src/teste/PedidosMatheus.test.tsx +129 -0
- package/src/teste/PedidosMatheus2.test.tsx +102 -0
- package/src/teste/SegmentedControlSuperficie.test.tsx +1 -1
- package/src/teste/StatCardTamanhoSm.test.tsx +9 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
+
import Avatar from "../components/Avatar/Avatar";
|
|
4
|
+
import Dropdown from "../components/Dropdown/Dropdown";
|
|
5
|
+
import EmptyState from "../components/EmptyState/EmptyState";
|
|
6
|
+
import List from "../components/List/List";
|
|
7
|
+
import ListItem from "../components/List/ListItem";
|
|
8
|
+
import { lerArquivo } from "./lerArquivo";
|
|
9
|
+
|
|
10
|
+
describe("Avatar · fallback e name", () => {
|
|
11
|
+
it("a foto que falha volta para as iniciais do name", () => {
|
|
12
|
+
const onError = vi.fn();
|
|
13
|
+
const { container } = render(<Avatar src="/quebrada.png" name="Cris Lima" onError={onError} />);
|
|
14
|
+
fireEvent.error(container.querySelector("img")!);
|
|
15
|
+
expect(container.querySelector("img")).toBeNull();
|
|
16
|
+
expect(container.textContent).toBe("CL");
|
|
17
|
+
expect(container.firstElementChild).toHaveClass("umds-avatar--letter");
|
|
18
|
+
expect(onError).toHaveBeenCalledTimes(1);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("sem name, a falha mostra o children", () => {
|
|
22
|
+
const { container } = render(<Avatar src="/quebrada.png">ML</Avatar>);
|
|
23
|
+
fireEvent.error(container.querySelector("img")!);
|
|
24
|
+
expect(container.textContent).toBe("ML");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("um src novo tenta a foto de novo", () => {
|
|
28
|
+
const { container, rerender } = render(<Avatar src="/quebrada.png" name="Cris Lima" />);
|
|
29
|
+
fireEvent.error(container.querySelector("img")!);
|
|
30
|
+
rerender(<Avatar src="/boa.png" name="Cris Lima" />);
|
|
31
|
+
expect(container.querySelector("img")).toHaveAttribute("src", "/boa.png");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("name gera as iniciais (primeiro e último nome) e o nome acessível", () => {
|
|
35
|
+
const { container } = render(<Avatar name="Matheus de Souza" />);
|
|
36
|
+
expect(container.textContent).toBe("MS");
|
|
37
|
+
expect(container.firstElementChild).toHaveAttribute("aria-label", "Matheus de Souza");
|
|
38
|
+
expect(container.firstElementChild).toHaveAttribute("role", "img");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("Dropdown · onSelect no item", () => {
|
|
43
|
+
it("chama a ação do item com os campos próprios, e depois o onSelect do Dropdown", async () => {
|
|
44
|
+
const ordem: string[] = [];
|
|
45
|
+
const doItem = vi.fn((item) => ordem.push("item:" + item.command));
|
|
46
|
+
const doMenu = vi.fn(() => ordem.push("menu"));
|
|
47
|
+
render(
|
|
48
|
+
<Dropdown ariaLabel="Ações" onSelect={doMenu} items={[{ key: "a", label: "Assinar", command: "assinar", onSelect: doItem }]}>
|
|
49
|
+
<button type="button">Abrir</button>
|
|
50
|
+
</Dropdown>,
|
|
51
|
+
);
|
|
52
|
+
fireEvent.click(screen.getByRole("button", { name: "Abrir" }));
|
|
53
|
+
fireEvent.click(await screen.findByRole("menuitem", { name: "Assinar" }));
|
|
54
|
+
expect(ordem).toEqual(["item:assinar", "menu"]);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("ListItem · variant e li", () => {
|
|
59
|
+
it("variant primary marca a classe sem aria-current", () => {
|
|
60
|
+
render(<ul><ListItem variant="primary" href="#c" title="Circular" /></ul>);
|
|
61
|
+
const link = screen.getByRole("link", { name: "Circular" });
|
|
62
|
+
expect(link).toHaveClass("umds-list-item--primary");
|
|
63
|
+
expect(link).not.toHaveAttribute("aria-current");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("liClassName e liStyle vão para o li", () => {
|
|
67
|
+
const { container } = render(
|
|
68
|
+
<ul><ListItem title="Memorando" liClassName="entra" liStyle={{ "--ordem": 2 } as any} onClick={() => {}} /></ul>,
|
|
69
|
+
);
|
|
70
|
+
const li = container.querySelector("li")!;
|
|
71
|
+
expect(li).toHaveClass("umds-list__item");
|
|
72
|
+
expect(li).toHaveClass("entra");
|
|
73
|
+
expect(li.style.getPropertyValue("--ordem")).toBe("2");
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("EmptyState · fill e List · emptyFill", () => {
|
|
78
|
+
it("fill escreve a classe; List repassa emptyFill", () => {
|
|
79
|
+
const { container } = render(
|
|
80
|
+
<>
|
|
81
|
+
<EmptyState title="Vazio" fill />
|
|
82
|
+
<List ariaLabel="Docs" isEmpty emptyFill />
|
|
83
|
+
</>,
|
|
84
|
+
);
|
|
85
|
+
expect(container.querySelector(".umds-empty-state--fill")).not.toBeNull();
|
|
86
|
+
expect(container.querySelector(".umds-list--empty-fill .umds-empty-state--fill")).not.toBeNull();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("AppShell e StatCard · CSS", () => {
|
|
91
|
+
it("o AppShell dá a cor de texto do tema a quem herda", async () => {
|
|
92
|
+
const css = (await lerArquivo("../core/src/components/AppShell/AppShell.css")).replace(/\r\n/g, "\n");
|
|
93
|
+
const bloco = css.slice(css.indexOf(".umds-app-shell {"), css.indexOf("}", css.indexOf(".umds-app-shell {")));
|
|
94
|
+
expect(bloco).toContain("color: var(--umds-semantic-color-neutral-dark-pure)");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("a StatCard com segunda medida empilha em largura pequena", async () => {
|
|
98
|
+
const css = (await lerArquivo("../core/src/components/StatCard/StatCard.css")).replace(/\r\n/g, "\n");
|
|
99
|
+
expect(css).toContain("container-type: inline-size");
|
|
100
|
+
expect(css).toMatch(/@container \(max-width: 240px\)/);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -37,7 +37,7 @@ describe("SegmentedControl · variant surface", () => {
|
|
|
37
37
|
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");
|
|
38
38
|
expect(escolhido).toMatch(/background-color:\s*var\(--umds-semantic-color-background-white\)/);
|
|
39
39
|
expect(escolhido).toMatch(/font-weight:\s*var\(--umds-primitive-font-weight-bold\)/);
|
|
40
|
-
expect(escolhido).toMatch(/box-shadow:\s*var\(--umds-semantic-shadow-md\)/);
|
|
40
|
+
expect(escolhido).toMatch(/box-shadow:\s*var\(--umds-semantic-shadow-bottom-md\)/);
|
|
41
41
|
expect(bloco(t, ".umds-segmented--surface .umds-segmented__track")).toMatch(/background-color:\s*var\(--umds-semantic-color-neutral-light-medium\)/);
|
|
42
42
|
expect(t).toMatch(/\.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\)/);
|
|
43
43
|
});
|
|
@@ -33,6 +33,15 @@ describe("StatCard · size", () => {
|
|
|
33
33
|
expect(container.firstElementChild).toHaveClass("umds-stat-card--sm", "umds-stat-card--rotulo-topo");
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
it("a segunda medida tem o mesmo tamanho e peso do número, no sm e no rótulo no topo", () => {
|
|
37
|
+
const sm = bloco(".umds-stat-card.umds-stat-card--sm .umds-stat-card__valor-secundario");
|
|
38
|
+
expect(sm).toMatch(/font-size:\s*1\.125rem/);
|
|
39
|
+
expect(sm).toMatch(/font-weight:\s*var\(--umds-primitive-font-weight-extrabold\)/);
|
|
40
|
+
const topo = bloco(".umds-stat-card--rotulo-topo .umds-stat-card__valor-secundario");
|
|
41
|
+
expect(topo).toMatch(/font-size:\s*var\(--umds-primitive-font-size-lg\)/);
|
|
42
|
+
expect(topo).toMatch(/font-weight:\s*var\(--umds-primitive-font-weight-extrabold\)/);
|
|
43
|
+
});
|
|
44
|
+
|
|
36
45
|
it("o número continua antes do rótulo no HTML", () => {
|
|
37
46
|
const { container } = render(<StatCard value={44} label="Não lidos" size="sm" />);
|
|
38
47
|
const valor = container.querySelector(".umds-stat-card__valor") as HTMLElement;
|