@cosmicdrift/kumiko-renderer-web 0.258.0 → 0.258.1
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": "@cosmicdrift/kumiko-renderer-web",
|
|
3
|
-
"version": "0.258.
|
|
3
|
+
"version": "0.258.1",
|
|
4
4
|
"description": "Web-platform bindings for @cosmicdrift/kumiko-renderer. HTML default-primitives, browser history-based navigation, EventSource-backed live events, and a one-call createKumikoApp that mounts the whole stack via react-dom.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"./styles.css": "./src/styles.css"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@cosmicdrift/kumiko-dispatcher-live": "0.258.
|
|
20
|
-
"@cosmicdrift/kumiko-headless": "0.258.
|
|
21
|
-
"@cosmicdrift/kumiko-renderer": "0.258.
|
|
19
|
+
"@cosmicdrift/kumiko-dispatcher-live": "0.258.1",
|
|
20
|
+
"@cosmicdrift/kumiko-headless": "0.258.1",
|
|
21
|
+
"@cosmicdrift/kumiko-renderer": "0.258.1",
|
|
22
22
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
23
23
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
24
24
|
"@radix-ui/react-label": "^2.1.8",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"cmdk": "^1.1.1",
|
|
34
34
|
"lucide-react": "^1.14.0",
|
|
35
35
|
"qrcode": "^1.5.4",
|
|
36
|
+
"@types/qrcode": "^1.5.5",
|
|
36
37
|
"radix-ui": "^1.4.3",
|
|
37
38
|
"react": "^19.2.6",
|
|
38
39
|
"react-day-picker": "^10.0.0",
|
|
@@ -61,12 +62,11 @@
|
|
|
61
62
|
"@tailwindcss/cli": "^4.3.0",
|
|
62
63
|
"@testing-library/react": "^16.3.2",
|
|
63
64
|
"@testing-library/user-event": "^14.6.1",
|
|
64
|
-
"@types/qrcode": "^1.5.5",
|
|
65
65
|
"@types/react": "^19.2.14",
|
|
66
66
|
"@types/react-dom": "^19.2.3",
|
|
67
67
|
"jsdom": "^29.1.1",
|
|
68
68
|
"tailwindcss": "^4.3.0",
|
|
69
|
-
"@cosmicdrift/kumiko-locale-de": "0.258.
|
|
69
|
+
"@cosmicdrift/kumiko-locale-de": "0.258.1"
|
|
70
70
|
},
|
|
71
71
|
"repository": {
|
|
72
72
|
"type": "git",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, mock, test } from "bun:test";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { defaultPrimitives } from "../index";
|
|
4
|
+
|
|
5
|
+
const { DataTable } = defaultPrimitives;
|
|
6
|
+
|
|
7
|
+
interface InlinePadding {
|
|
8
|
+
readonly left: string | undefined;
|
|
9
|
+
readonly right: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// happy-dom doesn't compute Tailwind layout, so resolve the effective inline
|
|
13
|
+
// padding the way Tailwind's cascade does: p-* < px-* < pl-*/pr-*. Variant-
|
|
14
|
+
// prefixed utilities (e.g. `[&:has([role=checkbox])]:pr-0`) only apply
|
|
15
|
+
// conditionally and are skipped.
|
|
16
|
+
function resolveInlinePadding(element: HTMLElement): InlinePadding {
|
|
17
|
+
const tokens = element.className.split(/\s+/).filter((t) => t !== "" && !t.includes(":"));
|
|
18
|
+
const paddingFor = (prefix: string): string | undefined =>
|
|
19
|
+
tokens
|
|
20
|
+
.filter((t) => t.startsWith(`${prefix}-`))
|
|
21
|
+
.at(-1)
|
|
22
|
+
?.slice(prefix.length + 1);
|
|
23
|
+
const all = paddingFor("p");
|
|
24
|
+
const x = paddingFor("px") ?? all;
|
|
25
|
+
return { left: paddingFor("pl") ?? x, right: paddingFor("pr") ?? x };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const columns = [
|
|
29
|
+
{ field: "revision", label: "Revision", type: "number", sortable: false },
|
|
30
|
+
{ field: "title", label: "Title", type: "string", sortable: true },
|
|
31
|
+
] as const;
|
|
32
|
+
|
|
33
|
+
const rows = [{ id: "r1", values: { revision: 1, title: "First" } }];
|
|
34
|
+
|
|
35
|
+
describe("DataTable header cells align with body cells", () => {
|
|
36
|
+
test.each([
|
|
37
|
+
["without sort wiring", undefined],
|
|
38
|
+
["with sort wiring", mock()],
|
|
39
|
+
] as const)(
|
|
40
|
+
"%s: every column header has the same inline padding as its cells",
|
|
41
|
+
(_, onSortChange) => {
|
|
42
|
+
render(
|
|
43
|
+
<DataTable
|
|
44
|
+
columns={columns}
|
|
45
|
+
rows={rows}
|
|
46
|
+
testId="t"
|
|
47
|
+
{...(onSortChange !== undefined && { onSortChange })}
|
|
48
|
+
/>,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
for (const col of columns) {
|
|
52
|
+
const header = resolveInlinePadding(screen.getByTestId(`column-${col.field}`));
|
|
53
|
+
const cell = resolveInlinePadding(screen.getByTestId(`cell-r1-${col.field}`));
|
|
54
|
+
expect(header.left).toBeDefined();
|
|
55
|
+
expect(header).toEqual(cell);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
});
|
package/src/primitives/index.tsx
CHANGED
|
@@ -1877,7 +1877,7 @@ function SortableHeader({
|
|
|
1877
1877
|
data-testid={`column-${field}`}
|
|
1878
1878
|
data-sortable={sortable === true ? true : undefined}
|
|
1879
1879
|
data-highlighted={highlighted === true ? "true" : undefined}
|
|
1880
|
-
className={cn("
|
|
1880
|
+
className={cn("text-muted-foreground", highlighted === true && "bg-accent/40")}
|
|
1881
1881
|
>
|
|
1882
1882
|
{label}
|
|
1883
1883
|
</TableHead>
|
|
@@ -1893,7 +1893,7 @@ function SortableHeader({
|
|
|
1893
1893
|
data-sortable="true"
|
|
1894
1894
|
data-highlighted={highlighted === true ? "true" : undefined}
|
|
1895
1895
|
aria-sort={ariaSort}
|
|
1896
|
-
className={cn("
|
|
1896
|
+
className={cn("text-muted-foreground", highlighted === true && "bg-accent/40")}
|
|
1897
1897
|
>
|
|
1898
1898
|
<button
|
|
1899
1899
|
type="button"
|