@tangle-network/ui 11.51.12 → 11.51.14
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 +13 -1
- package/dist/chat/chat-message.js +1 -1
- package/dist/chat/user-message.js +1 -1
- package/dist/hooks.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -6
- package/dist/primitives/expandable-panel.d.ts +19 -0
- package/dist/primitives/expandable-panel.js +69 -0
- package/dist/primitives.d.ts +2 -1
- package/dist/primitives.js +2 -1
- package/dist/run/run-row-shell.d.ts +0 -13
- package/dist/run/run-row-shell.js +3 -15
- package/dist/run/status-meta.d.ts +0 -2
- package/dist/run/status-meta.js +1 -7
- package/dist/run.d.ts +3 -4
- package/dist/run.js +3 -4
- package/dist/utils/format.d.ts +0 -4
- package/dist/utils/format.js +1 -12
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/src/chat/chat-message.tsx +1 -1
- package/src/chat/message-author.test.tsx +6 -6
- package/src/chat/speaker.stories.tsx +1 -1
- package/src/chat/synthetic-text.test.tsx +2 -2
- package/src/chat/user-message.tsx +1 -1
- package/src/primitives/control-presentation.test.tsx +0 -92
- package/src/primitives/expandable-panel.stories.tsx +36 -0
- package/src/primitives/expandable-panel.test.tsx +49 -0
- package/src/primitives/expandable-panel.tsx +108 -0
- package/src/primitives/index.ts +3 -0
- package/src/run/index.ts +0 -3
- package/src/run/run-row-shell.tsx +4 -20
- package/src/run/status-meta.tsx +0 -3
- package/src/utils/format.ts +0 -13
- package/dist/run/run-item-primitives.d.ts +0 -3
- package/dist/run/run-item-primitives.js +0 -12
- package/src/primitives/switch.test.tsx +0 -39
- package/src/primitives/toolbar.test.tsx +0 -103
- package/src/run/run-item-primitives.tsx +0 -12
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { render, screen } from "@testing-library/react";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { FilterField, Toolbar } from "./toolbar";
|
|
4
|
-
|
|
5
|
-
describe("Toolbar", () => {
|
|
6
|
-
it("renders each slot it is given", () => {
|
|
7
|
-
render(
|
|
8
|
-
<Toolbar
|
|
9
|
-
actions={<button type="button">Export</button>}
|
|
10
|
-
filters={<span>Product</span>}
|
|
11
|
-
search={<input aria-label="Search" type="search" />}
|
|
12
|
-
/>,
|
|
13
|
-
);
|
|
14
|
-
expect(screen.getByLabelText("Search")).toBeInTheDocument();
|
|
15
|
-
expect(screen.getByText("Product")).toBeInTheDocument();
|
|
16
|
-
expect(screen.getByRole("button", { name: "Export" })).toBeInTheDocument();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("omits a slot's wrapper entirely when it is not given", () => {
|
|
20
|
-
const { container } = render(
|
|
21
|
-
<Toolbar search={<input aria-label="Search" type="search" />} />,
|
|
22
|
-
);
|
|
23
|
-
const row = container.firstElementChild as HTMLElement;
|
|
24
|
-
expect(row.children).toHaveLength(1);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Filters keep their content width while it fits and shrink (scrolling) only
|
|
28
|
-
// once search reaches its 16rem floor; an even split clipped a third filter at
|
|
29
|
-
// 1440px, and no floor left search 89px wide in an 832px toolbar.
|
|
30
|
-
it("keeps filters at content width above a search floor, actions at content width", () => {
|
|
31
|
-
const { container } = render(
|
|
32
|
-
<Toolbar
|
|
33
|
-
actions={<button type="button">Export</button>}
|
|
34
|
-
filters={<span>Product</span>}
|
|
35
|
-
search={<input aria-label="Search" type="search" />}
|
|
36
|
-
/>,
|
|
37
|
-
);
|
|
38
|
-
const [searchSlot, filterSlot, actionsSlot] = Array.from(
|
|
39
|
-
(container.firstElementChild as HTMLElement).children,
|
|
40
|
-
) as HTMLElement[];
|
|
41
|
-
const search = searchSlot.className.split(" ");
|
|
42
|
-
const filters = filterSlot.className.split(" ");
|
|
43
|
-
expect(search).toEqual(expect.arrayContaining(["lg:flex-1", "lg:min-w-64", "lg:max-w-sm", "min-w-0"]));
|
|
44
|
-
expect(filters).toEqual(expect.arrayContaining(["lg:flex-initial", "min-w-0", "lg:overflow-x-auto"]));
|
|
45
|
-
expect(filters).not.toContain("lg:flex-1");
|
|
46
|
-
expect(actionsSlot.className).toContain("shrink-0");
|
|
47
|
-
expect(actionsSlot.className).not.toContain("flex-1");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("wraps the filters on a phone and scrolls one line from lg up", () => {
|
|
51
|
-
const { container } = render(<Toolbar filters={<span>Product</span>} />);
|
|
52
|
-
const filterSlot = (container.firstElementChild as HTMLElement)
|
|
53
|
-
.children[0] as HTMLElement;
|
|
54
|
-
const classes = filterSlot.className.split(" ");
|
|
55
|
-
expect(classes).toContain("flex-wrap");
|
|
56
|
-
expect(classes).not.toContain("overflow-x-auto");
|
|
57
|
-
expect(classes).toContain("lg:flex-nowrap");
|
|
58
|
-
expect(classes).toContain("lg:overflow-x-auto");
|
|
59
|
-
expect(classes).toContain("min-w-0");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// A free child would render as a bare flex item with none of the slots'
|
|
63
|
-
// guards, so it would size off its content and push the row into overflow.
|
|
64
|
-
it("renders nothing for a stray child", () => {
|
|
65
|
-
const { container } = render(
|
|
66
|
-
// @ts-expect-error children is deliberately not part of the API
|
|
67
|
-
<Toolbar>
|
|
68
|
-
<span>stray</span>
|
|
69
|
-
</Toolbar>,
|
|
70
|
-
);
|
|
71
|
-
expect(screen.queryByText("stray")).toBeNull();
|
|
72
|
-
expect((container.firstElementChild as HTMLElement).children).toHaveLength(
|
|
73
|
-
0,
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe("FilterField", () => {
|
|
79
|
-
it("labels the control visibly rather than by placeholder", () => {
|
|
80
|
-
render(
|
|
81
|
-
<FilterField htmlFor="product" label="Product">
|
|
82
|
-
<select id="product">
|
|
83
|
-
<option>All products</option>
|
|
84
|
-
</select>
|
|
85
|
-
</FilterField>,
|
|
86
|
-
);
|
|
87
|
-
expect(screen.getByText("Product")).toBeInTheDocument();
|
|
88
|
-
expect(screen.getByLabelText("Product")).toBe(
|
|
89
|
-
screen.getByRole("combobox"),
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("sets its label on the 14px step of the shared scale, never smaller", () => {
|
|
94
|
-
render(
|
|
95
|
-
<FilterField htmlFor="status" label="Status">
|
|
96
|
-
<select id="status" />
|
|
97
|
-
</FilterField>,
|
|
98
|
-
);
|
|
99
|
-
const label = screen.getByText("Status");
|
|
100
|
-
expect(label.className).toMatch(/\btext-sm\b/);
|
|
101
|
-
expect(label.className).not.toMatch(/\btext-xs\b|text-\[/);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useLiveTime } from "../hooks/use-live-time";
|
|
2
|
-
import { formatDuration } from "../utils/format";
|
|
3
|
-
|
|
4
|
-
export function LiveDuration({ startTime }: { startTime: number }) {
|
|
5
|
-
const elapsed = useLiveTime(100) - startTime;
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<span className="text-xs font-mono text-neutral-400 dark:text-neutral-500 tabular-nums">
|
|
9
|
-
{formatDuration(elapsed)}
|
|
10
|
-
</span>
|
|
11
|
-
);
|
|
12
|
-
}
|