@dogsbay/ui 0.2.0-beta.12 → 0.2.0-beta.120
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 +37 -12
- package/src/alert/CollapsibleAlert.astro +19 -3
- package/src/api-layout/ApiLayout.astro +28 -4
- package/src/api-layout/ExampleBlock.astro +3 -2
- package/src/api-symbol/api-symbol.css +14 -11
- package/src/badge/Badge.astro +3 -10
- package/src/badge/variants.ts +37 -0
- package/src/code-block/CodeBlock.astro +38 -8
- package/src/code-rich/CodeRich.astro +93 -15
- package/src/code-rich/code-rich.css +21 -2
- package/src/code-rich/markers.ts +66 -0
- package/src/content-renderer/ContentRenderer.astro +47 -6
- package/src/content-renderer/InlineRenderer.astro +24 -1
- package/src/docs-layout/DocsLayout.astro +36 -4
- package/src/files/FileTree.astro +16 -0
- package/src/files/index.ts +2 -0
- package/src/files/markup.ts +34 -0
- package/src/image/Image.astro +23 -2
- package/src/kbd/Kbd.astro +2 -3
- package/src/kbd/variants.ts +3 -0
- package/src/link-card/LinkCard.astro +8 -2
- package/src/property-list/PropertyList.astro +3 -2
- package/src/sidebar/SidebarNavMark.astro +85 -0
- package/src/sidebar/SidebarNavTree.astro +111 -7
- package/src/sidebar/sidebar.ts +2 -2
- package/src/table/Table.astro +16 -2
- package/src/table/TableCell.astro +1 -1
- package/src/table/TableHead.astro +1 -1
- package/src/toc/TableOfContents.astro +10 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import SidebarNavMark from "./SidebarNavMark.astro";
|
|
2
3
|
/**
|
|
3
4
|
* Recursive sidebar navigation tree.
|
|
4
5
|
* Renders a data-driven tree with native <details>/<summary> for zero-JS expand/collapse.
|
|
@@ -8,11 +9,18 @@
|
|
|
8
9
|
* <SidebarNavTree items={navItems} currentPath={Astro.url.pathname} />
|
|
9
10
|
*/
|
|
10
11
|
|
|
12
|
+
interface NavMark {
|
|
13
|
+
kind: "added" | "changed" | "removed" | "moved";
|
|
14
|
+
label?: string;
|
|
15
|
+
subtree?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
interface NavItem {
|
|
12
19
|
label: string;
|
|
13
20
|
href?: string;
|
|
14
21
|
icon?: string; // Raw SVG string (rendered via set:html)
|
|
15
22
|
children?: NavItem[];
|
|
23
|
+
mark?: NavMark;
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
interface Props {
|
|
@@ -24,6 +32,13 @@ interface Props {
|
|
|
24
32
|
|
|
25
33
|
const { items, currentPath, level = 0, class: className } = Astro.props;
|
|
26
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Markers are rendered by SidebarNavMark, which owns the accessibility
|
|
37
|
+
* contract (distinct glyph so colour is never the sole channel,
|
|
38
|
+
* visually-hidden text so the row announces "MySQL, changed",
|
|
39
|
+
* forced-colors survival). See that component.
|
|
40
|
+
*/
|
|
41
|
+
|
|
27
42
|
const normalizedPath = currentPath.replace(/\/$/, "") || "/";
|
|
28
43
|
|
|
29
44
|
function isActive(href: string) {
|
|
@@ -54,24 +69,78 @@ const paddingLeft = `${8 + level * 12}px`;
|
|
|
54
69
|
const active = item.href ? isActive(item.href) : false;
|
|
55
70
|
const hasChildren = item.children && item.children.length > 0;
|
|
56
71
|
const shouldOpen = hasChildren && hasActiveDescendant(item);
|
|
72
|
+
const open = shouldOpen || active;
|
|
73
|
+
// A branch that is ALSO a page (has an href) is a section landing
|
|
74
|
+
// page; it uses the button-driven disclosure below and needs a
|
|
75
|
+
// stable id linking its toggle button to its submenu.
|
|
76
|
+
const submenuId = item.href
|
|
77
|
+
? `nav-sub-${item.href.replace(/[^a-z0-9]+/gi, "-")}-${level}`
|
|
78
|
+
: undefined;
|
|
57
79
|
|
|
58
80
|
return (
|
|
59
81
|
<li data-sidebar="nav-tree-item">
|
|
60
|
-
{hasChildren ? (
|
|
82
|
+
{hasChildren && item.href ? (
|
|
83
|
+
/*
|
|
84
|
+
Section landing page: APG "disclosure navigation" pattern — a
|
|
85
|
+
real link (navigates) + a SEPARATE toggle <button> (expands),
|
|
86
|
+
as siblings. Nesting a focusable <a> inside the interactive
|
|
87
|
+
<summary> is an axe `nested-interactive` violation, and native
|
|
88
|
+
<details> can't show a header link when collapsed without that
|
|
89
|
+
nesting. Progressive enhancement: the submenu's server state
|
|
90
|
+
(hidden unless open) is correct with no JS — the link still
|
|
91
|
+
works and the active section is expanded — and the inline
|
|
92
|
+
script wires the toggle button when JS is available.
|
|
93
|
+
*/
|
|
94
|
+
<Fragment>
|
|
95
|
+
<div
|
|
96
|
+
class:list={[
|
|
97
|
+
"flex w-full min-w-0 items-center gap-2 rounded-md text-sm text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
98
|
+
level === 0 ? "h-8" : "h-7",
|
|
99
|
+
active && "bg-sidebar-accent font-medium text-sidebar-accent-foreground",
|
|
100
|
+
]}
|
|
101
|
+
style={`padding-left: ${paddingLeft};`}
|
|
102
|
+
>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
data-nav-toggle
|
|
106
|
+
aria-controls={submenuId}
|
|
107
|
+
aria-expanded={open ? "true" : "false"}
|
|
108
|
+
aria-label={`Toggle ${item.label} section`}
|
|
109
|
+
class="shrink-0 rounded outline-none ring-sidebar-ring focus-visible:ring-2"
|
|
110
|
+
>
|
|
111
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4 shrink-0 transition-transform duration-200" data-chevron aria-hidden="true"><polyline points="9 18 15 12 9 6" /></svg>
|
|
112
|
+
</button>
|
|
113
|
+
{item.icon && <span class="shrink-0 [&>svg]:size-4" set:html={item.icon} />}
|
|
114
|
+
<a
|
|
115
|
+
href={item.href}
|
|
116
|
+
class="min-w-0 flex-1 truncate text-inherit no-underline outline-none ring-sidebar-ring focus-visible:ring-2"
|
|
117
|
+
data-nav-href={item.href}
|
|
118
|
+
data-active={active || undefined}
|
|
119
|
+
data-nav-mark-row={item.mark?.subtree ? undefined : item.mark?.kind}
|
|
120
|
+
>{item.label}</a>
|
|
121
|
+
{item.mark && (
|
|
122
|
+
<SidebarNavMark kind={item.mark.kind} label={item.mark.label} subtree={item.mark.subtree} />
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
<div id={submenuId} data-nav-submenu hidden={!open}>
|
|
126
|
+
<Astro.self items={item.children!} currentPath={currentPath} level={level + 1} />
|
|
127
|
+
</div>
|
|
128
|
+
</Fragment>
|
|
129
|
+
) : hasChildren ? (
|
|
61
130
|
<details open={shouldOpen || active}>
|
|
62
131
|
<summary
|
|
63
132
|
class:list={[
|
|
64
133
|
"flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md text-sm text-sidebar-foreground outline-none [list-style:none] ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&::-webkit-details-marker]:hidden",
|
|
65
134
|
level === 0 ? "h-8" : "h-7",
|
|
66
|
-
active && "bg-sidebar-accent font-medium text-sidebar-accent-foreground",
|
|
67
135
|
]}
|
|
68
136
|
style={`padding-left: ${paddingLeft};`}
|
|
69
|
-
data-nav-href={item.href || undefined}
|
|
70
|
-
data-active={active || undefined}
|
|
71
137
|
>
|
|
72
138
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4 shrink-0 transition-transform duration-200" data-chevron aria-hidden="true"><polyline points="9 18 15 12 9 6" /></svg>
|
|
73
139
|
{item.icon && <span class="shrink-0 [&>svg]:size-4" set:html={item.icon} />}
|
|
74
|
-
<span class="truncate">{item.label}</span>
|
|
140
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
141
|
+
{item.mark && (
|
|
142
|
+
<SidebarNavMark kind={item.mark.kind} label={item.mark.label} subtree={item.mark.subtree} />
|
|
143
|
+
)}
|
|
75
144
|
</summary>
|
|
76
145
|
<Astro.self items={item.children!} currentPath={currentPath} level={level + 1} />
|
|
77
146
|
</details>
|
|
@@ -86,12 +155,22 @@ const paddingLeft = `${8 + level * 12}px`;
|
|
|
86
155
|
style={`padding-left: ${paddingLeft};`}
|
|
87
156
|
data-active={active || undefined}
|
|
88
157
|
data-nav-href={item.href}
|
|
158
|
+
{/*
|
|
159
|
+
A SUBTREE mark is a claim about descendants, never about
|
|
160
|
+
this row — striking through a surviving group because one
|
|
161
|
+
child was deleted tells the reader the whole section is
|
|
162
|
+
gone (code review, 2026-07-13).
|
|
163
|
+
*/}
|
|
164
|
+
data-nav-mark-row={item.mark?.subtree ? undefined : item.mark?.kind}
|
|
89
165
|
>
|
|
90
166
|
{/* Spacer to align with chevron in branch items */}
|
|
91
167
|
<span class="size-4 shrink-0" />
|
|
92
168
|
{/* Icon (level 0 only) */}
|
|
93
169
|
{item.icon && <span class="shrink-0 [&>svg]:size-4" set:html={item.icon} />}
|
|
94
|
-
<span class="truncate">{item.label}</span>
|
|
170
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
171
|
+
{item.mark && (
|
|
172
|
+
<SidebarNavMark kind={item.mark.kind} label={item.mark.label} subtree={item.mark.subtree} />
|
|
173
|
+
)}
|
|
95
174
|
</a>
|
|
96
175
|
)}
|
|
97
176
|
</li>
|
|
@@ -100,7 +179,32 @@ const paddingLeft = `${8 + level * 12}px`;
|
|
|
100
179
|
</ul>
|
|
101
180
|
|
|
102
181
|
<style is:global>
|
|
103
|
-
details[open] > summary [data-chevron]
|
|
182
|
+
details[open] > summary [data-chevron],
|
|
183
|
+
[data-nav-toggle][aria-expanded="true"] [data-chevron] {
|
|
104
184
|
transform: rotate(90deg);
|
|
105
185
|
}
|
|
106
186
|
</style>
|
|
187
|
+
|
|
188
|
+
<script>
|
|
189
|
+
// Wire the section-landing disclosure toggles (APG disclosure-nav).
|
|
190
|
+
// The link navigates on its own; this button just expands/collapses
|
|
191
|
+
// the sibling submenu. Server-rendered state is already correct, so
|
|
192
|
+
// with no JS the link still works and the active section is open.
|
|
193
|
+
// Idempotent + re-run after view transitions.
|
|
194
|
+
function wireNavToggles() {
|
|
195
|
+
document
|
|
196
|
+
.querySelectorAll<HTMLButtonElement>("[data-nav-toggle]:not([data-wired])")
|
|
197
|
+
.forEach((btn) => {
|
|
198
|
+
btn.dataset.wired = "1";
|
|
199
|
+
const id = btn.getAttribute("aria-controls");
|
|
200
|
+
const submenu = id ? document.getElementById(id) : null;
|
|
201
|
+
btn.addEventListener("click", () => {
|
|
202
|
+
const isOpen = btn.getAttribute("aria-expanded") === "true";
|
|
203
|
+
btn.setAttribute("aria-expanded", String(!isOpen));
|
|
204
|
+
if (submenu) submenu.hidden = isOpen;
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
wireNavToggles();
|
|
209
|
+
document.addEventListener("astro:page-load", wireNavToggles);
|
|
210
|
+
</script>
|
package/src/sidebar/sidebar.ts
CHANGED
|
@@ -202,7 +202,7 @@ function openMobile(provider: HTMLElement) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// Lock scroll
|
|
205
|
-
ScrollLock.
|
|
205
|
+
ScrollLock.activate();
|
|
206
206
|
|
|
207
207
|
// Focus first focusable element in sidebar
|
|
208
208
|
requestAnimationFrame(() => {
|
|
@@ -237,7 +237,7 @@ function closeMobile(provider: HTMLElement) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
// Unlock scroll
|
|
240
|
-
ScrollLock.
|
|
240
|
+
ScrollLock.deactivate();
|
|
241
241
|
|
|
242
242
|
// Return focus to trigger
|
|
243
243
|
const trigger = instance.provider.querySelector(
|
package/src/table/Table.astro
CHANGED
|
@@ -6,19 +6,33 @@ const tableContainer = tv({
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
const table = tv({
|
|
9
|
-
base: "w-full caption-
|
|
9
|
+
base: "w-full caption-top text-sm",
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
interface Props {
|
|
13
13
|
class?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional table caption, rendered as a `<caption>`: the table's title,
|
|
16
|
+
* above it and left-aligned.
|
|
17
|
+
* For a caption with markup, use the `caption` slot instead.
|
|
18
|
+
*/
|
|
19
|
+
caption?: string;
|
|
14
20
|
[key: string]: unknown;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
const { class: className, ...rest } = Astro.props;
|
|
23
|
+
const { class: className, caption, ...rest } = Astro.props;
|
|
24
|
+
|
|
25
|
+
// A table's caption is its title: above the table, left-aligned, in the body color
|
|
26
|
+
const captionClass = "mb-2 text-left text-sm font-medium text-foreground";
|
|
18
27
|
---
|
|
19
28
|
|
|
20
29
|
<div class={tableContainer()}>
|
|
21
30
|
<table class={table({ class: className })} {...rest}>
|
|
31
|
+
{Astro.slots.has("caption") ? (
|
|
32
|
+
<caption class={captionClass}><slot name="caption" /></caption>
|
|
33
|
+
) : (
|
|
34
|
+
caption && <caption class={captionClass}>{caption}</caption>
|
|
35
|
+
)}
|
|
22
36
|
<slot />
|
|
23
37
|
</table>
|
|
24
38
|
</div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { tv } from "tailwind-variants";
|
|
3
3
|
|
|
4
4
|
const tableHead = tv({
|
|
5
|
-
base: "
|
|
5
|
+
base: "px-2 py-2 text-left align-bottom font-semibold text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
@@ -99,40 +99,40 @@ const filtered = headings.filter(
|
|
|
99
99
|
line-height: 1.4;
|
|
100
100
|
}
|
|
101
101
|
.toc-kind-class {
|
|
102
|
-
background-color: oklch(0.
|
|
103
|
-
color: oklch(0.
|
|
102
|
+
background-color: oklch(0.44 0.18 265 / 0.15);
|
|
103
|
+
color: oklch(0.44 0.18 265);
|
|
104
104
|
}
|
|
105
105
|
:global(.dark) .toc-kind-class {
|
|
106
106
|
background-color: oklch(0.7 0.15 265 / 0.2);
|
|
107
107
|
color: oklch(0.7 0.15 265);
|
|
108
108
|
}
|
|
109
109
|
.toc-kind-meth {
|
|
110
|
-
background-color: oklch(0.
|
|
111
|
-
color: oklch(0.
|
|
110
|
+
background-color: oklch(0.44 0.15 155 / 0.15);
|
|
111
|
+
color: oklch(0.44 0.15 155);
|
|
112
112
|
}
|
|
113
113
|
:global(.dark) .toc-kind-meth {
|
|
114
114
|
background-color: oklch(0.7 0.15 155 / 0.2);
|
|
115
115
|
color: oklch(0.7 0.15 155);
|
|
116
116
|
}
|
|
117
117
|
.toc-kind-attr {
|
|
118
|
-
background-color: oklch(0.
|
|
119
|
-
color: oklch(0.
|
|
118
|
+
background-color: oklch(0.44 0.15 55 / 0.15);
|
|
119
|
+
color: oklch(0.44 0.15 55);
|
|
120
120
|
}
|
|
121
121
|
:global(.dark) .toc-kind-attr {
|
|
122
122
|
background-color: oklch(0.75 0.15 55 / 0.2);
|
|
123
123
|
color: oklch(0.75 0.15 55);
|
|
124
124
|
}
|
|
125
125
|
.toc-kind-func {
|
|
126
|
-
background-color: oklch(0.
|
|
127
|
-
color: oklch(0.
|
|
126
|
+
background-color: oklch(0.44 0.18 330 / 0.15);
|
|
127
|
+
color: oklch(0.44 0.18 330);
|
|
128
128
|
}
|
|
129
129
|
:global(.dark) .toc-kind-func {
|
|
130
130
|
background-color: oklch(0.7 0.15 330 / 0.2);
|
|
131
131
|
color: oklch(0.7 0.15 330);
|
|
132
132
|
}
|
|
133
133
|
.toc-kind-module {
|
|
134
|
-
background-color: oklch(0.
|
|
135
|
-
color: oklch(0.
|
|
134
|
+
background-color: oklch(0.44 0.12 200 / 0.15);
|
|
135
|
+
color: oklch(0.44 0.12 200);
|
|
136
136
|
}
|
|
137
137
|
:global(.dark) .toc-kind-module {
|
|
138
138
|
background-color: oklch(0.65 0.12 200 / 0.2);
|