rift-ds 1.32.0 → 1.33.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.
Files changed (96) hide show
  1. package/README.md +4 -4
  2. package/behaviors/clipboard.d.ts +7 -0
  3. package/behaviors/clipboard.js +35 -0
  4. package/behaviors/headingSlug.d.ts +8 -0
  5. package/behaviors/headingSlug.js +4 -0
  6. package/behaviors/shell.css +64 -0
  7. package/behaviors/syncedChoice.d.ts +2 -0
  8. package/behaviors/syncedChoice.js +48 -0
  9. package/behaviors/useLayer.d.ts +15 -2
  10. package/behaviors/useLayer.js +3 -2
  11. package/bin/templates/blocks/app/guide/PageFeedback.tsx +55 -0
  12. package/bin/templates/blocks/app/guide/page.module.css +94 -0
  13. package/bin/templates/blocks/app/guide/page.tsx +168 -0
  14. package/bin/templates/blocks/components/blocks/AppShell.module.css +3 -1
  15. package/bin/templates/blocks/components/blocks/AppShell.tsx +8 -0
  16. package/bin/templates/blocks/components/blocks/DocsShell.module.css +18 -0
  17. package/bin/templates/blocks/components/blocks/DocsShell.tsx +179 -0
  18. package/bin/templates/blocks/registry.json +13 -0
  19. package/code/highlight.d.ts +4 -0
  20. package/code/highlight.js +34 -0
  21. package/code/index.d.ts +16 -0
  22. package/code/index.js +23 -0
  23. package/components/AnchorNav/AnchorNav.d.ts +29 -3
  24. package/components/AnchorNav/AnchorNav.js +69 -5
  25. package/components/AppLayout/AppLayout.css +8 -4
  26. package/components/AppLayout/AppLayout.d.ts +13 -3
  27. package/components/AppLayout/AppLayout.js +2 -0
  28. package/components/ArtifactPanel/ArtifactPanel.css +46 -0
  29. package/components/ArtifactPanel/ArtifactPanel.d.ts +14 -4
  30. package/components/ArtifactPanel/ArtifactPanel.js +8 -5
  31. package/components/BackToTop/BackToTop.css +28 -0
  32. package/components/BackToTop/BackToTop.d.ts +28 -0
  33. package/components/BackToTop/BackToTop.js +47 -0
  34. package/components/BentoTile/BentoTile.css +3 -0
  35. package/components/CodeBlock/CodeBlock.css +63 -24
  36. package/components/CodeBlock/CodeBlock.d.ts +62 -6
  37. package/components/CodeBlock/CodeBlock.js +90 -48
  38. package/components/CopyButton/CopyButton.d.ts +42 -0
  39. package/components/CopyButton/CopyButton.js +72 -0
  40. package/components/DescriptionList/DescriptionListCopy.d.ts +2 -2
  41. package/components/DescriptionList/DescriptionListCopy.js +7 -35
  42. package/components/Figure/Figure.css +26 -0
  43. package/components/Figure/Figure.d.ts +10 -1
  44. package/components/Figure/Figure.js +15 -3
  45. package/components/Heading/Heading.css +43 -0
  46. package/components/Heading/Heading.d.ts +14 -3
  47. package/components/Heading/Heading.js +22 -4
  48. package/components/HoverCard/HoverCard.js +1 -0
  49. package/components/Link/Link.css +38 -0
  50. package/components/Link/Link.d.ts +3 -3
  51. package/components/Link/Link.js +1 -1
  52. package/components/Menubar/Menubar.css +82 -0
  53. package/components/Menubar/Menubar.d.ts +40 -0
  54. package/components/Menubar/Menubar.js +97 -0
  55. package/components/NavList/NavList.css +197 -0
  56. package/components/NavList/NavList.d.ts +54 -6
  57. package/components/NavList/NavList.js +136 -8
  58. package/components/Pagination/Pagination.css +80 -0
  59. package/components/Pagination/Pagination.d.ts +29 -3
  60. package/components/Pagination/Pagination.js +49 -5
  61. package/components/Rating/Rating.css +26 -0
  62. package/components/Rating/Rating.d.ts +18 -5
  63. package/components/Rating/Rating.js +16 -7
  64. package/components/SectionTitle/SectionTitle.css +36 -0
  65. package/components/SectionTitle/SectionTitle.d.ts +10 -1
  66. package/components/SectionTitle/SectionTitle.js +7 -2
  67. package/components/ShaderScene/ShaderScene.d.ts +2 -1
  68. package/components/ShaderScene/ShaderScene.js +20 -2
  69. package/components/SiteFooter/SiteFooter.css +157 -0
  70. package/components/SiteFooter/SiteFooter.d.ts +53 -0
  71. package/components/SiteFooter/SiteFooter.js +61 -0
  72. package/components/SiteHeader/SiteHeader.css +106 -4
  73. package/components/SiteHeader/SiteHeader.d.ts +25 -2
  74. package/components/SiteHeader/SiteHeader.js +46 -8
  75. package/components/SiteLayout/SiteLayout.css +361 -0
  76. package/components/SiteLayout/SiteLayout.d.ts +103 -0
  77. package/components/SiteLayout/SiteLayout.js +68 -0
  78. package/components/Table/Table.css +14 -0
  79. package/components/Table/Table.d.ts +2 -0
  80. package/components/Table/Table.js +1 -1
  81. package/components/Tooltip/Tooltip.js +1 -0
  82. package/components/keyboard-patterns.json.d.ts +57 -0
  83. package/components/keyboard-patterns.json.js +1 -1
  84. package/components/registry.json +89 -19
  85. package/components/registry.json.d.ts +89 -19
  86. package/components/registry.json.js +1 -1
  87. package/index.d.ts +5 -0
  88. package/index.js +14 -1
  89. package/package.json +14 -2
  90. package/tokens/breakpoints.js +3 -3
  91. package/tokens/registry.json +5 -0
  92. package/tokens/registry.json.d.ts +5 -0
  93. package/tokens/registry.json.js +1 -1
  94. package/tokens/tokens-dark.css +12 -0
  95. package/tokens/tokens-light.css +12 -0
  96. package/tokens/values.json.js +1 -1
@@ -8,6 +8,14 @@
8
8
  ============================================ */
9
9
 
10
10
  .ds-nav-list {
11
+ /* How far a row's text sits in from the row's own edge (the rows are
12
+ compact tertiary Buttons, the headings share their inset). A host that
13
+ lines the list's text up with something above it, a header's brand,
14
+ hangs the list out by this much, so the fills sit in the gutter and the
15
+ words sit on the line (SiteLayout's sidebar does). Compact rows inset
16
+ their text --padding-300; default rows (a default Button) --padding-500,
17
+ set below. */
18
+ --ds-nav-list-text-inset: var(--padding-300);
11
19
  display: flex;
12
20
  flex-direction: column;
13
21
  gap: var(--gap-050);
@@ -153,3 +161,192 @@
153
161
  .ds-nav-list__item > .ds-nav-list__sublist {
154
162
  margin-top: var(--gap-050);
155
163
  }
164
+
165
+ /* ============================================
166
+ COMPACT
167
+ Every row on the 32px compact control height, for a
168
+ long sidebar: the 40px reservation and toggle step down
169
+ to match, so a hundred rows read as one quiet column.
170
+ ============================================ */
171
+
172
+ /* Default size: the top-level rows are default Buttons, so their text sits
173
+ --padding-500 in; the hang and the section headings follow it, so the
174
+ headings sit on the rows' leading line at either size. */
175
+ .ds-nav-list:not(.ds-nav-list--compact) {
176
+ --ds-nav-list-text-inset: var(--padding-500);
177
+ }
178
+
179
+ .ds-nav-list:not(.ds-nav-list--compact) .ds-nav-list__heading {
180
+ padding-inline-start: var(--padding-500);
181
+ }
182
+
183
+ .ds-nav-list--compact .ds-nav-list__item {
184
+ min-height: var(--control-height-compact);
185
+ }
186
+
187
+ .ds-nav-list--compact .ds-nav-list__toggle {
188
+ width: var(--control-height-compact);
189
+ height: var(--control-height-compact);
190
+ }
191
+
192
+ .ds-nav-list--compact .ds-nav-list__sublist {
193
+ padding-inline-start: var(--padding-400);
194
+ }
195
+
196
+ .ds-nav-list__badge {
197
+ margin-inline-start: auto;
198
+ }
199
+
200
+ /* ============================================
201
+ SECTIONS
202
+ A heading over its rows: the rails' group heading
203
+ (caption face, tertiary text, mixed case), seated on
204
+ the rows' leading line. A collapsible heading is a
205
+ full-width quiet button with the chevron at its end.
206
+ ============================================ */
207
+
208
+ .ds-nav-list__section {
209
+ display: flex;
210
+ flex-direction: column;
211
+ }
212
+
213
+ .ds-nav-list__section + .ds-nav-list__section,
214
+ .ds-nav-list__item + .ds-nav-list__section {
215
+ margin-block-start: var(--gap-500);
216
+ }
217
+
218
+ .ds-nav-list__heading {
219
+ display: flex;
220
+ align-items: center;
221
+ gap: var(--gap-200);
222
+ box-sizing: border-box;
223
+ min-height: var(--control-height-compact);
224
+ padding-inline: var(--padding-300);
225
+ font-family: var(--font-paragraph-sm-family);
226
+ font-size: var(--font-paragraph-sm-size);
227
+ line-height: var(--font-paragraph-sm-line-height);
228
+ color: var(--color-text-tertiary);
229
+ }
230
+
231
+ .ds-nav-list--compact .ds-nav-list__heading {
232
+ padding-inline: var(--padding-300);
233
+ }
234
+
235
+ .ds-nav-list__heading--toggle {
236
+ width: 100%;
237
+ margin: 0;
238
+ padding-inline-end: var(--padding-200);
239
+ border: none;
240
+ border-radius: var(--radius-pill);
241
+ background: none;
242
+ text-align: start;
243
+ cursor: pointer;
244
+ transition: background-color var(--motion-duration-base) var(--motion-ease-standard), color var(--motion-duration-base) var(--motion-ease-standard);
245
+ }
246
+
247
+ .ds-nav-list__heading--toggle:hover {
248
+ background-color: var(--color-action-passive-bg-hover);
249
+ color: var(--color-text-secondary);
250
+ }
251
+
252
+ .ds-nav-list__heading--toggle:focus-visible {
253
+ outline: 2px solid var(--color-action-primary-bg);
254
+ outline-offset: -2px;
255
+ }
256
+
257
+ .ds-nav-list__heading-text {
258
+ flex: 1 1 auto;
259
+ min-width: 0;
260
+ }
261
+
262
+ .ds-nav-list__heading--toggle[aria-expanded='true'] .ds-nav-list__chevron {
263
+ transform: rotate(180deg);
264
+ }
265
+
266
+ .ds-nav-list__section-list {
267
+ display: flex;
268
+ flex-direction: column;
269
+ gap: var(--gap-050);
270
+ overflow: hidden;
271
+ min-height: 0;
272
+ margin: 0;
273
+ padding: 0;
274
+ list-style: none;
275
+ }
276
+
277
+ /* ============================================
278
+ SCROLLABLE
279
+ The list as its own scroll area: it takes its parent's
280
+ height, keeps its scroll to itself at both ends, and
281
+ keeps a still gutter so rows do not shift when the
282
+ scrollbar comes and goes.
283
+ ============================================ */
284
+
285
+ .ds-nav-list--scrollable {
286
+ /* How far the content fades in or out at an end with more to scroll. */
287
+ --ds-nav-list-fade: var(--gap-1000);
288
+ --ds-nav-list-fade-start: 0px;
289
+ --ds-nav-list-fade-end: 0px;
290
+ flex-wrap: nowrap;
291
+ height: 100%;
292
+ min-height: 0;
293
+ overflow-y: auto;
294
+ overscroll-behavior: contain;
295
+ /* Room at both ends for the fade, a hook so a host can line the first
296
+ row up with something beside it (SiteLayout's sidebar pulls the list up
297
+ by it, so the first row starts level with the page's first line). */
298
+ --ds-nav-list-block-inset: var(--padding-200);
299
+ padding-block: var(--ds-nav-list-block-inset);
300
+ /* The scrollbar stays out of sight until the list scrolls. */
301
+ scrollbar-width: none;
302
+ /* The ends fade only when there is more past them, so a list at its top
303
+ shows its first row crisp. ds-allow(color): mask alpha keywords
304
+ (black/transparent), not palette colours */
305
+ -webkit-mask-image: linear-gradient(
306
+ to bottom,
307
+ transparent,
308
+ black var(--ds-nav-list-fade-start),
309
+ black calc(100% - var(--ds-nav-list-fade-end)),
310
+ transparent
311
+ );
312
+ mask-image: linear-gradient(
313
+ to bottom,
314
+ transparent,
315
+ black var(--ds-nav-list-fade-start),
316
+ black calc(100% - var(--ds-nav-list-fade-end)),
317
+ transparent
318
+ );
319
+ }
320
+
321
+ /* A fixed-height column scrolls its rows rather than squeezing them: a
322
+ flex child would otherwise shrink to fit and the rows would overlap. */
323
+ .ds-nav-list--scrollable > * {
324
+ flex-shrink: 0;
325
+ }
326
+
327
+ .ds-nav-list--scrollable[data-fade-start] {
328
+ --ds-nav-list-fade-start: var(--ds-nav-list-fade);
329
+ }
330
+
331
+ .ds-nav-list--scrollable[data-fade-end] {
332
+ --ds-nav-list-fade-end: var(--ds-nav-list-fade);
333
+ }
334
+
335
+ .ds-nav-list--scrollable::-webkit-scrollbar {
336
+ width: 0;
337
+ }
338
+
339
+ /* While it scrolls: a thin thumb on no track, gone again once it settles. */
340
+ .ds-nav-list--scrollable[data-scrolling] {
341
+ scrollbar-width: thin;
342
+ scrollbar-color: var(--color-bg-container-border) transparent;
343
+ }
344
+
345
+ .ds-nav-list--scrollable[data-scrolling]::-webkit-scrollbar {
346
+ width: var(--padding-150);
347
+ }
348
+
349
+ .ds-nav-list--scrollable[data-scrolling]::-webkit-scrollbar-thumb {
350
+ border-radius: var(--radius-pill);
351
+ background: var(--color-bg-container-border);
352
+ }
@@ -12,6 +12,7 @@ export interface NavListItem {
12
12
  /**
13
13
  * When false, an item with children renders no toggle and its children stay
14
14
  * visible — a permanent group rather than a collapsible section.
15
+ * @default true
15
16
  */
16
17
  collapsible?: boolean;
17
18
  /**
@@ -20,26 +21,73 @@ export interface NavListItem {
20
21
  * stay current on their child routes.
21
22
  */
22
23
  current?: boolean;
24
+ /** A short tag after the label, such as "New" or "Beta", drawn as a neutral Badge. */
25
+ badge?: string;
23
26
  }
27
+ /**
28
+ * A titled section of rows: a heading over its items, the way a long
29
+ * documentation sidebar groups its pages. Sections sit only at the top
30
+ * level; their items nest like any others.
31
+ */
32
+ export interface NavListSection {
33
+ /** Marks the entry as a section rather than a row. */
34
+ type: 'section';
35
+ /** The section's heading. */
36
+ label: string;
37
+ /** The section's rows. */
38
+ items: NavListItem[];
39
+ /**
40
+ * Stable identity for its expansion state. Defaults to the label. In
41
+ * `expandedIds`, `defaultExpandedIds` and `onExpandedChange` a section
42
+ * appears as `section:<id>`, so its id never collides with a row's.
43
+ */
44
+ id?: string;
45
+ /**
46
+ * Let the reader fold the section under its heading. Unlike a row with
47
+ * `items`, which folds unless told not to, a section is a plain label
48
+ * unless told to fold.
49
+ * @default false
50
+ */
51
+ collapsible?: boolean;
52
+ }
53
+ /** A top-level entry: a row, or a section of rows. */
54
+ export type NavListEntry = NavListItem | NavListSection;
24
55
  /** Props owned by NavList itself — everything else falls through to the list element. */
25
56
  type NavListOwnProps = {
26
- /** Navigation tree to render. */
27
- items: NavListItem[];
57
+ /** Navigation tree to render: rows, and at the top level, sections of rows. */
58
+ items: NavListEntry[];
59
+ /**
60
+ * Row density. `default` is the drawer's 40px top row; `compact` sets
61
+ * every row on the 32px compact control height, for a long sidebar of
62
+ * pages (a documentation site's hundred entries).
63
+ */
64
+ size?: 'default' | 'compact';
65
+ /**
66
+ * Make the list its own scroll area: it fills the height its parent
67
+ * gives it, scrolls inside without carrying the page along at its ends,
68
+ * and brings the current row into view when it first renders. Put it in
69
+ * a column with a fixed or sticky height.
70
+ */
71
+ scrollable?: boolean;
28
72
  /** href of the current page — the exactly matching row gets `aria-current="page"` and the active treatment. */
29
73
  currentHref?: string;
30
74
  /** Controlled list of expanded item ids. */
31
75
  expandedIds?: string[];
32
- /** Initially expanded item ids (uncontrolled). */
76
+ /**
77
+ * Initially expanded item ids (uncontrolled). The branch and the
78
+ * collapsible section that hold the current page start open as well, so a
79
+ * reader landing deep in a long tree sees where they are.
80
+ */
33
81
  defaultExpandedIds?: string[];
34
82
  /** Fires with the full new list of expanded ids whenever a toggle is pressed, in both controlled and uncontrolled modes. */
35
83
  onExpandedChange?: (expandedIds: string[]) => void;
36
- /** Allow several sections expanded at once. Default false — expanding one collapses the rest. */
84
+ /** Allow several branches expanded at once. Default false: expanding one collapses its siblings, never the section or the rows it sits in. */
37
85
  multiple?: boolean;
38
86
  /** Fires when any link is clicked, alongside native navigation — e.g. to close the drawer that contains the list. */
39
87
  onNavigate?: (item: NavListItem, event: React.MouseEvent<HTMLElement>) => void;
40
- /** Accessible name of a collapsed section's chevron toggle, given the row's label. Defaults to "Expand <label>". */
88
+ /** Accessible name of a collapsed row's or section's toggle, given its label. Defaults to "Expand <label>". */
41
89
  expandLabel?: (label: string) => string;
42
- /** Accessible name of an expanded section's chevron toggle, given the row's label. Defaults to "Collapse <label>". */
90
+ /** Accessible name of an expanded row's or section's toggle, given its label. Defaults to "Collapse <label>". */
43
91
  collapseLabel?: (label: string) => string;
44
92
  /**
45
93
  * The component its links render with, such as Next.js's `Link`, so they
@@ -1,13 +1,18 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import React, { useId, useState } from "react";
3
+ import React, { useId, useState, useRef, useEffect } from "react";
4
4
  import { Button } from "../Button/Button.js";
5
+ import { Badge } from "../Badge/Badge.js";
6
+ import { MOTION_SCROLL_SETTLE_MS } from "../../tokens/motion.js";
5
7
  import "./NavList.css";
6
8
  import "../../fonts/material-symbols.css";
9
+ const isSection = (entry) => entry.type === "section";
7
10
  const MAX_DEPTH = 3;
8
11
  const NavList = React.forwardRef(
9
12
  ({
10
13
  items,
14
+ size = "default",
15
+ scrollable = false,
11
16
  currentHref,
12
17
  expandedIds,
13
18
  defaultExpandedIds,
@@ -22,13 +27,90 @@ const NavList = React.forwardRef(
22
27
  }, ref) => {
23
28
  const baseClass = "ds-nav-list";
24
29
  const uid = useId();
25
- const [internalExpanded, setInternalExpanded] = useState(
26
- defaultExpandedIds ?? []
27
- );
28
- const expanded = expandedIds ?? internalExpanded;
29
30
  const itemId = (item) => item.id ?? item.href;
31
+ const sectionId = (section) => `section:${section.id ?? section.label}`;
32
+ const [internalExpanded, setInternalExpanded] = useState(() => {
33
+ const open = new Set(defaultExpandedIds ?? []);
34
+ const holdsCurrent = (item) => (item.current ?? (currentHref !== void 0 && item.href === currentHref)) || Boolean(item.items?.some(holdsCurrent));
35
+ const walk = (list) => {
36
+ for (const item of list) {
37
+ if (item.items?.some(holdsCurrent)) open.add(itemId(item));
38
+ if (item.items) walk(item.items);
39
+ }
40
+ };
41
+ for (const entry of items) {
42
+ if (isSection(entry)) {
43
+ if (entry.collapsible && entry.items.some(holdsCurrent)) open.add(sectionId(entry));
44
+ walk(entry.items);
45
+ } else {
46
+ walk([entry]);
47
+ }
48
+ }
49
+ return [...open];
50
+ });
51
+ const expanded = expandedIds ?? internalExpanded;
52
+ const rootRef = useRef(null);
53
+ const setRootRef = (node) => {
54
+ rootRef.current = node;
55
+ if (typeof ref === "function") ref(node);
56
+ else if (ref) ref.current = node;
57
+ };
58
+ useEffect(() => {
59
+ const root = rootRef.current;
60
+ if (!scrollable || !root) return;
61
+ let settle;
62
+ const edges = () => {
63
+ const max = root.scrollHeight - root.clientHeight;
64
+ root.toggleAttribute("data-fade-start", root.scrollTop > 1);
65
+ root.toggleAttribute("data-fade-end", root.scrollTop < max - 1);
66
+ };
67
+ const onScroll = () => {
68
+ edges();
69
+ root.setAttribute("data-scrolling", "");
70
+ clearTimeout(settle);
71
+ settle = setTimeout(() => root.removeAttribute("data-scrolling"), MOTION_SCROLL_SETTLE_MS);
72
+ };
73
+ edges();
74
+ root.addEventListener("scroll", onScroll, { passive: true });
75
+ const resize = new ResizeObserver(edges);
76
+ resize.observe(root);
77
+ return () => {
78
+ clearTimeout(settle);
79
+ root.removeEventListener("scroll", onScroll);
80
+ resize.disconnect();
81
+ };
82
+ }, [scrollable]);
83
+ useEffect(() => {
84
+ const root = rootRef.current;
85
+ if (!scrollable || !root) return;
86
+ const row = root.querySelector('[aria-current="page"]');
87
+ if (!row) return;
88
+ const top = row.getBoundingClientRect().top - root.getBoundingClientRect().top;
89
+ if (top < 0 || top > root.clientHeight - row.offsetHeight) {
90
+ root.scrollTop += top - root.clientHeight / 3;
91
+ }
92
+ }, []);
93
+ const ancestorsOf = /* @__PURE__ */ new Map();
94
+ const mapAncestors = (list, chain) => {
95
+ for (const item of list) {
96
+ if (!item.items) continue;
97
+ ancestorsOf.set(itemId(item), chain);
98
+ mapAncestors(item.items, [...chain, itemId(item)]);
99
+ }
100
+ };
101
+ for (const entry of items) {
102
+ if (isSection(entry)) {
103
+ ancestorsOf.set(sectionId(entry), []);
104
+ mapAncestors(entry.items, [sectionId(entry)]);
105
+ } else {
106
+ mapAncestors([entry], []);
107
+ }
108
+ }
30
109
  const toggle = (id) => {
31
- const next = expanded.includes(id) ? expanded.filter((entry) => entry !== id) : multiple ? [...expanded, id] : [id];
110
+ const parentOf = (entry) => (ancestorsOf.get(entry) ?? []).join("\0");
111
+ const isSection2 = (entry) => entry.startsWith("section:");
112
+ const sibling = (entry) => parentOf(entry) === parentOf(id) && isSection2(entry) === isSection2(id);
113
+ const next = expanded.includes(id) ? expanded.filter((entry) => entry !== id) : multiple ? [...expanded, id] : [...expanded.filter((entry) => !sibling(entry)), id];
32
114
  if (expandedIds === void 0) setInternalExpanded(next);
33
115
  onExpandedChange?.(next);
34
116
  };
@@ -43,8 +125,9 @@ const NavList = React.forwardRef(
43
125
  Button,
44
126
  {
45
127
  variant: "tertiary",
46
- size: level === 1 ? "default" : "compact",
128
+ size: level === 1 && size === "default" ? "default" : "compact",
47
129
  label: item.label,
130
+ iconRight: item.badge ? /* @__PURE__ */ jsx(Badge, { className: `${baseClass}__badge`, label: item.badge, variant: "neutral" }) : void 0,
48
131
  href: item.href,
49
132
  linkComponent,
50
133
  ariaCurrent: isCurrent,
@@ -95,7 +178,52 @@ const NavList = React.forwardRef(
95
178
  )
96
179
  ] }, id);
97
180
  });
98
- return /* @__PURE__ */ jsx("ul", { ...rest, ref, className: `${baseClass} ${className}`.trim(), children: renderItems(1, items) });
181
+ const renderSection = (section) => {
182
+ const id = sectionId(section);
183
+ const panelId = `${uid}-${id}`;
184
+ const isOpen = !section.collapsible || expanded.includes(id);
185
+ return /* @__PURE__ */ jsxs("li", { className: `${baseClass}__section`, children: [
186
+ section.collapsible ? /* @__PURE__ */ jsxs(
187
+ "button",
188
+ {
189
+ type: "button",
190
+ className: `${baseClass}__heading ${baseClass}__heading--toggle`,
191
+ "aria-expanded": isOpen,
192
+ "aria-controls": panelId,
193
+ "aria-label": isOpen ? collapseLabel(section.label) : expandLabel(section.label),
194
+ onClick: () => toggle(id),
195
+ children: [
196
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__heading-text`, children: section.label }),
197
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__chevron material-symbols-rounded`, "aria-hidden": "true", children: "expand_more" })
198
+ ]
199
+ }
200
+ ) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__heading`, id: `${panelId}-heading`, children: section.label }),
201
+ /* @__PURE__ */ jsx(
202
+ "div",
203
+ {
204
+ id: panelId,
205
+ className: `${baseClass}__panel ${isOpen ? `${baseClass}__panel--open` : ""}`,
206
+ inert: !isOpen,
207
+ children: /* @__PURE__ */ jsx(
208
+ "ul",
209
+ {
210
+ className: `${baseClass}__section-list`,
211
+ "aria-labelledby": section.collapsible ? void 0 : `${panelId}-heading`,
212
+ "aria-label": section.collapsible ? section.label : void 0,
213
+ children: renderItems(1, section.items)
214
+ }
215
+ )
216
+ }
217
+ )
218
+ ] }, id);
219
+ };
220
+ const classes = [
221
+ baseClass,
222
+ size === "compact" ? `${baseClass}--compact` : "",
223
+ scrollable ? `${baseClass}--scrollable` : "",
224
+ className
225
+ ].filter(Boolean).join(" ");
226
+ return /* @__PURE__ */ jsx("ul", { ...rest, ref: setRootRef, className: classes, children: items.map((entry) => isSection(entry) ? renderSection(entry) : renderItems(1, [entry])) });
99
227
  }
100
228
  );
101
229
  NavList.displayName = "NavList";
@@ -126,3 +126,83 @@
126
126
  color: var(--color-text-secondary);
127
127
  white-space: nowrap;
128
128
  }
129
+
130
+ /* ============================================
131
+ ADJACENT (variant="adjacent")
132
+ The page before and after this one in a sequence, as two
133
+ cards on the container family's surface: an eyebrow with
134
+ its chevron over the page's title. Previous holds the start
135
+ edge and next the end, each half the row, so a missing side
136
+ leaves its half empty rather than stretching the other.
137
+ ============================================ */
138
+
139
+ .ds-pagination--adjacent {
140
+ display: grid;
141
+ grid-template-columns: 1fr 1fr;
142
+ gap: var(--gap-400);
143
+ width: 100%;
144
+ }
145
+
146
+ .ds-pagination__adjacent {
147
+ display: flex;
148
+ flex-direction: column;
149
+ gap: var(--gap-100);
150
+ min-width: 0;
151
+ padding: var(--padding-400) var(--padding-500);
152
+ border: var(--border-025) solid var(--color-bg-container-border);
153
+ border-radius: var(--radius-300);
154
+ background-color: var(--color-bg-container-primary);
155
+ color: var(--color-text-primary);
156
+ text-decoration: none;
157
+ transition: background-color var(--motion-duration-base) var(--motion-ease-standard), border-color var(--motion-duration-base) var(--motion-ease-standard);
158
+ }
159
+
160
+ .ds-pagination__adjacent:hover {
161
+ background-color: var(--color-bg-container-secondary);
162
+ }
163
+
164
+ .ds-pagination__adjacent:focus-visible {
165
+ outline: 2px solid var(--color-action-primary-bg);
166
+ outline-offset: 2px;
167
+ }
168
+
169
+ .ds-pagination__adjacent--next {
170
+ grid-column: 2;
171
+ align-items: flex-end;
172
+ text-align: end;
173
+ }
174
+
175
+ .ds-pagination__adjacent-eyebrow {
176
+ display: inline-flex;
177
+ align-items: center;
178
+ gap: var(--gap-050);
179
+ font-family: var(--font-caption-family);
180
+ font-size: var(--font-caption-size);
181
+ line-height: var(--font-caption-line-height);
182
+ color: var(--color-text-tertiary);
183
+ }
184
+
185
+ .ds-pagination__adjacent-eyebrow .ds-pagination__icon {
186
+ --icon-size: var(--icon-size-500);
187
+ }
188
+
189
+ .ds-pagination__adjacent-title {
190
+ max-width: 100%;
191
+ overflow: hidden;
192
+ text-overflow: ellipsis;
193
+ white-space: nowrap;
194
+ font-family: var(--font-title-body-family);
195
+ font-size: var(--font-title-body-size);
196
+ font-weight: var(--font-title-body-weight);
197
+ line-height: var(--font-title-body-line-height);
198
+ }
199
+
200
+ @media (max-width: 480px) {
201
+ .ds-pagination--adjacent {
202
+ grid-template-columns: 1fr;
203
+ }
204
+
205
+ .ds-pagination__adjacent--next {
206
+ grid-column: 1;
207
+ }
208
+ }
@@ -1,6 +1,31 @@
1
1
  import { default as React } from 'react';
2
+ import { LinkComponent } from '../../behaviors/LinkProvider';
3
+ /** A neighbouring page the `adjacent` form links to. */
4
+ export interface PaginationLink {
5
+ /** Where the link goes. */
6
+ href: string;
7
+ /** The page's title, shown under the Previous or Next eyebrow. */
8
+ label: string;
9
+ }
2
10
  /** Props owned by Pagination itself — everything else falls through to the nav landmark. */
3
11
  type PaginationOwnProps = {
12
+ /**
13
+ * The pager's form. `numbered` (the default) steps through numbered pages
14
+ * of one list. `adjacent` links to the page before and after this one in
15
+ * a sequence (a guide's chapters, a set of articles) as two cards naming
16
+ * them, and takes `previous` and `next` instead of page numbers.
17
+ */
18
+ variant?: 'numbered' | 'adjacent';
19
+ /** The page before this one, for the `adjacent` form. Leave it out on the first page. */
20
+ previous?: PaginationLink;
21
+ /** The page after this one, for the `adjacent` form. Leave it out on the last page. */
22
+ next?: PaginationLink;
23
+ /** The eyebrow over the previous page's title in the `adjacent` form. */
24
+ previousText?: string;
25
+ /** The eyebrow over the next page's title in the `adjacent` form. */
26
+ nextText?: string;
27
+ /** The component that renders the `adjacent` form's links, such as Next.js's `Link`. Defaults to the nearest LinkProvider's, else a plain `<a>`. */
28
+ linkComponent?: LinkComponent;
4
29
  /**
5
30
  * Current page (1-based), for a controlled pager. Leave it undefined to let
6
31
  * the component keep its own page, seeded from `defaultPage`.
@@ -8,8 +33,8 @@ type PaginationOwnProps = {
8
33
  page?: number;
9
34
  /** Page shown on first render when the pager is uncontrolled (1-based) */
10
35
  defaultPage?: number;
11
- /** Total number of pages */
12
- pageCount: number;
36
+ /** Total number of pages. Required for the `numbered` form; the `adjacent` form ignores it. */
37
+ pageCount?: number;
13
38
  /** Called with the page the user requests */
14
39
  onPageChange?: (page: number) => void;
15
40
  /** Pages shown on each side of the current page */
@@ -40,7 +65,8 @@ export interface PaginationProps extends PaginationOwnProps, Omit<React.Componen
40
65
  /**
41
66
  * Pagination component — page navigation for long datasets.
42
67
  * Numbered pages with ellipses for large ranges, or a compact
43
- * prev/next readout. Pairs with Table.
68
+ * prev/next readout. Pairs with Table. The `adjacent` form instead links
69
+ * to the previous and next page of a sequence, as two titled cards.
44
70
  *
45
71
  * Forwards a ref to the `<nav>` landmark and spreads unrecognised props onto
46
72
  * it. The landmark is named "Pagination" unless a native `aria-label` or