@multiplatform.one/components 7.88.8 → 7.88.10
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/components",
|
|
3
|
-
"version": "7.88.
|
|
3
|
+
"version": "7.88.10",
|
|
4
4
|
"description": "multiplatform.one ui components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@floating-ui/react": "^0.27.20",
|
|
61
|
-
"@multiplatform.one/forms": "^7.88.
|
|
62
|
-
"@multiplatform.one/i18n": "^7.88.
|
|
63
|
-
"@multiplatform.one/platform": "^7.88.
|
|
64
|
-
"@multiplatform.one/router": "^7.88.
|
|
65
|
-
"@multiplatform.one/theme": "^7.88.
|
|
61
|
+
"@multiplatform.one/forms": "^7.88.10",
|
|
62
|
+
"@multiplatform.one/i18n": "^7.88.10",
|
|
63
|
+
"@multiplatform.one/platform": "^7.88.10",
|
|
64
|
+
"@multiplatform.one/router": "^7.88.10",
|
|
65
|
+
"@multiplatform.one/theme": "^7.88.10",
|
|
66
66
|
"@phosphor-icons/react": "^2.1.10",
|
|
67
67
|
"@shopify/flash-list": "^2.3.1",
|
|
68
68
|
"@tamagui/colors": "2.7.6",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"tamagui": "2.7.6"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@multiplatform.one/config": "7.88.
|
|
93
|
-
"@multiplatform.one/storybook": "7.88.
|
|
94
|
-
"@multiplatform.one/test-utils": "7.88.
|
|
92
|
+
"@multiplatform.one/config": "7.88.10",
|
|
93
|
+
"@multiplatform.one/storybook": "7.88.10",
|
|
94
|
+
"@multiplatform.one/test-utils": "7.88.10",
|
|
95
95
|
"@tamagui/build": "2.7.6",
|
|
96
96
|
"@testing-library/jest-dom": "^7.0.1",
|
|
97
97
|
"@testing-library/react": "^16.3.3",
|
|
@@ -79,4 +79,66 @@ describe("useSheetFrameFocus", () => {
|
|
|
79
79
|
vi.stubGlobal("requestAnimationFrame", undefined);
|
|
80
80
|
expect(() => h.frames.flush()).not.toThrow();
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
describe("Tab trap", () => {
|
|
84
|
+
function trap(controls: number) {
|
|
85
|
+
const trigger = document.createElement("button");
|
|
86
|
+
const frame = document.createElement("div");
|
|
87
|
+
frame.tabIndex = -1;
|
|
88
|
+
const buttons = Array.from({ length: controls }, (_, n) => {
|
|
89
|
+
const button = document.createElement("button");
|
|
90
|
+
button.textContent = `control ${n}`;
|
|
91
|
+
Object.defineProperty(button, "offsetWidth", { configurable: true, value: 40 });
|
|
92
|
+
frame.append(button);
|
|
93
|
+
return button;
|
|
94
|
+
});
|
|
95
|
+
const hidden = document.createElement("button");
|
|
96
|
+
frame.append(hidden);
|
|
97
|
+
document.body.append(trigger, frame);
|
|
98
|
+
trigger.focus();
|
|
99
|
+
const frameRef = { current: frame as HTMLElement | null };
|
|
100
|
+
renderHook(() => useSheetFrameFocus(true, frameRef));
|
|
101
|
+
const tab = (shiftKey = false) => {
|
|
102
|
+
const event = new KeyboardEvent("keydown", { key: "Tab", shiftKey, cancelable: true });
|
|
103
|
+
frame.dispatchEvent(event);
|
|
104
|
+
return event.defaultPrevented;
|
|
105
|
+
};
|
|
106
|
+
return { frame, buttons, hidden, tab };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
it("wraps Tab from the last visible control to the first", () => {
|
|
110
|
+
const { buttons, tab } = trap(3);
|
|
111
|
+
buttons[2].focus();
|
|
112
|
+
expect(tab()).toBe(true);
|
|
113
|
+
expect(document.activeElement).toBe(buttons[0]);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("wraps Shift+Tab from the first control, or the frame itself, to the last", () => {
|
|
117
|
+
const { frame, buttons, tab } = trap(3);
|
|
118
|
+
buttons[0].focus();
|
|
119
|
+
expect(tab(true)).toBe(true);
|
|
120
|
+
expect(document.activeElement).toBe(buttons[2]);
|
|
121
|
+
frame.focus();
|
|
122
|
+
expect(tab(true)).toBe(true);
|
|
123
|
+
expect(document.activeElement).toBe(buttons[2]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("lets Tab move on its own between middle controls, and ignores other keys", () => {
|
|
127
|
+
const { frame, buttons, tab } = trap(3);
|
|
128
|
+
buttons[1].focus();
|
|
129
|
+
expect(tab()).toBe(false);
|
|
130
|
+
expect(tab(true)).toBe(false);
|
|
131
|
+
const enter = new KeyboardEvent("keydown", { key: "Enter", cancelable: true });
|
|
132
|
+
frame.dispatchEvent(enter);
|
|
133
|
+
expect(enter.defaultPrevented).toBe(false);
|
|
134
|
+
expect(document.activeElement).toBe(buttons[1]);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("holds focus in place when nothing in the frame is visible", () => {
|
|
138
|
+
const { hidden, tab } = trap(0);
|
|
139
|
+
hidden.focus();
|
|
140
|
+
expect(tab()).toBe(true);
|
|
141
|
+
expect(document.activeElement).toBe(hidden);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
82
144
|
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
2
|
+
import { act } from "@testing-library/react";
|
|
3
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { LogView, type LogEntry } from "./LogView";
|
|
5
|
+
|
|
6
|
+
const scrollToEnd = vi.hoisted(() => vi.fn());
|
|
7
|
+
|
|
8
|
+
vi.mock("tamagui", async (importOriginal) => {
|
|
9
|
+
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
10
|
+
const { createElement, forwardRef, useImperativeHandle } = await import("react");
|
|
11
|
+
return {
|
|
12
|
+
...actual,
|
|
13
|
+
ScrollView: forwardRef(function ScrollView({ children }: { children?: unknown }, ref) {
|
|
14
|
+
useImperativeHandle(ref, () => ({ scrollToEnd }));
|
|
15
|
+
return createElement("div", { "data-scroller": "" }, children as never);
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const entries: LogEntry[] = [
|
|
21
|
+
{ id: "a", time: "2026-11-03T09:15:02.123Z", message: "sync started", source: "worker-2" },
|
|
22
|
+
{ id: "b", time: new Date("2026-11-03T09:15:07.000Z"), level: "warn", message: "slow page" },
|
|
23
|
+
{ id: "c", time: "not-a-timestamp", level: "error", message: "push failed" },
|
|
24
|
+
{ time: "2026-11-03T09:15:09Z", level: "debug", message: "retrying" },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function setWidth(width: number) {
|
|
28
|
+
Object.defineProperty(window, "innerWidth", { configurable: true, value: width });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function rows(container: HTMLElement) {
|
|
32
|
+
return Array.from(container.querySelectorAll<HTMLElement>("[data-log-entry]"));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe("LogView (LC-215, LC-261)", () => {
|
|
36
|
+
const initialWidth = window.innerWidth;
|
|
37
|
+
afterEach(() => setWidth(initialWidth));
|
|
38
|
+
|
|
39
|
+
it("names the log for assistive tech and renders one row per entry", () => {
|
|
40
|
+
setWidth(1280);
|
|
41
|
+
const { getByRole, container } = renderWithProviders(
|
|
42
|
+
<LogView entries={entries} label="Sync worker log" />,
|
|
43
|
+
);
|
|
44
|
+
expect(getByRole("log").getAttribute("aria-label")).toBe("Sync worker log");
|
|
45
|
+
expect(rows(container)).toHaveLength(4);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("shows each entry's clock time, its source and its message", () => {
|
|
49
|
+
setWidth(1280);
|
|
50
|
+
const { container } = renderWithProviders(<LogView entries={entries} label="log" />);
|
|
51
|
+
const [first, second, third, fourth] = rows(container).map((row) => row.textContent);
|
|
52
|
+
expect(first).toContain("09:15:02");
|
|
53
|
+
expect(first).not.toContain(".123");
|
|
54
|
+
expect(first).toContain("worker-2");
|
|
55
|
+
expect(first).toContain("sync started");
|
|
56
|
+
expect(second).toContain("09:15:07");
|
|
57
|
+
expect(third).toContain("not-a-timestamp");
|
|
58
|
+
expect(fourth).toContain("retrying");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("marks only warnings and errors with a hidden glyph", () => {
|
|
62
|
+
setWidth(1280);
|
|
63
|
+
const { container } = renderWithProviders(<LogView entries={entries} label="log" />);
|
|
64
|
+
const marked = rows(container).map((row) => row.querySelector("svg") !== null);
|
|
65
|
+
expect(marked).toEqual([false, true, true, false]);
|
|
66
|
+
for (const row of rows(container)) {
|
|
67
|
+
expect(row.textContent).not.toMatch(/\b(warn|error|debug)\b/i);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("stacks the meta line over the message at compact width", () => {
|
|
72
|
+
setWidth(390);
|
|
73
|
+
const { container } = renderWithProviders(
|
|
74
|
+
<LogView entries={entries.slice(0, 1)} label="log" />,
|
|
75
|
+
);
|
|
76
|
+
const [row] = rows(container);
|
|
77
|
+
expect(row.children).toHaveLength(2);
|
|
78
|
+
expect(row.children[0].textContent).toBe("09:15:02worker-2");
|
|
79
|
+
expect(row.children[1].textContent).toBe("sync started");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("puts meta and message side by side at regular width", () => {
|
|
83
|
+
setWidth(1280);
|
|
84
|
+
const { container } = renderWithProviders(
|
|
85
|
+
<LogView entries={entries.slice(0, 1)} label="log" />,
|
|
86
|
+
);
|
|
87
|
+
const [row] = rows(container);
|
|
88
|
+
expect(row.children).toHaveLength(3);
|
|
89
|
+
expect(row.children[2].textContent).toBe("sync started");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("scrolls to the newest entry only while following", () => {
|
|
93
|
+
setWidth(1280);
|
|
94
|
+
scrollToEnd.mockClear();
|
|
95
|
+
const { rerender } = renderWithProviders(<LogView entries={entries.slice(0, 1)} label="log" />);
|
|
96
|
+
expect(scrollToEnd).toHaveBeenCalledTimes(1);
|
|
97
|
+
expect(scrollToEnd).toHaveBeenLastCalledWith({ animated: false });
|
|
98
|
+
act(() => {
|
|
99
|
+
rerender(<LogView entries={entries} label="log" follow={false} />);
|
|
100
|
+
});
|
|
101
|
+
expect(scrollToEnd).toHaveBeenCalledTimes(1);
|
|
102
|
+
act(() => {
|
|
103
|
+
rerender(<LogView entries={entries.slice(0, 2)} label="log" />);
|
|
104
|
+
});
|
|
105
|
+
expect(scrollToEnd).toHaveBeenCalledTimes(2);
|
|
106
|
+
});
|
|
107
|
+
});
|
package/src/views/ImageGrid.tsx
CHANGED
|
@@ -178,7 +178,7 @@ function autoColumns({
|
|
|
178
178
|
gutter: number;
|
|
179
179
|
variant: NonNullable<ImageGridProps<unknown>["variant"]>;
|
|
180
180
|
minTileWidth?: number;
|
|
181
|
-
tileSize?:
|
|
181
|
+
tileSize?: TileSizeRung;
|
|
182
182
|
}>): number {
|
|
183
183
|
if (minTileWidth !== undefined) {
|
|
184
184
|
return tileColumnsForWidth(span, { minWidth: minTileWidth, maxWidth: Infinity }, gutter);
|