rift-ds 1.31.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 (170) hide show
  1. package/README.md +4 -4
  2. package/behaviors/chat-card.css +4 -1
  3. package/behaviors/clipboard.d.ts +7 -0
  4. package/behaviors/clipboard.js +35 -0
  5. package/behaviors/deferComponent.d.ts +43 -0
  6. package/behaviors/deferComponent.js +35 -0
  7. package/behaviors/headingSlug.d.ts +8 -0
  8. package/behaviors/headingSlug.js +4 -0
  9. package/behaviors/shell.css +64 -0
  10. package/behaviors/syncedChoice.d.ts +2 -0
  11. package/behaviors/syncedChoice.js +48 -0
  12. package/behaviors/useLayer.d.ts +15 -2
  13. package/behaviors/useLayer.js +3 -2
  14. package/bin/templates/blocks/app/guide/PageFeedback.tsx +55 -0
  15. package/bin/templates/blocks/app/guide/page.module.css +94 -0
  16. package/bin/templates/blocks/app/guide/page.tsx +168 -0
  17. package/bin/templates/blocks/components/blocks/AppShell.module.css +13 -2
  18. package/bin/templates/blocks/components/blocks/AppShell.tsx +8 -0
  19. package/bin/templates/blocks/components/blocks/DocsShell.module.css +18 -0
  20. package/bin/templates/blocks/components/blocks/DocsShell.tsx +179 -0
  21. package/bin/templates/blocks/registry.json +13 -0
  22. package/chat/ChatLauncher.d.ts +9 -1
  23. package/chat/ChatLauncher.js +51 -33
  24. package/chat/ChatWidget.css +13 -4
  25. package/chat/ChatWidget.js +15 -15
  26. package/chat/deferredChatWidget.d.ts +10 -0
  27. package/chat/deferredChatWidget.js +10 -0
  28. package/chat/index.d.ts +1 -0
  29. package/chat/index.js +2 -0
  30. package/chat/registry.json.d.ts +2 -1
  31. package/chat/registry.json.js +1 -1
  32. package/code/highlight.d.ts +4 -0
  33. package/code/highlight.js +34 -0
  34. package/code/index.d.ts +16 -0
  35. package/code/index.js +23 -0
  36. package/components/Accordion/Accordion.css +8 -0
  37. package/components/AgentPlan/AgentPlan.css +8 -0
  38. package/components/AgentRail/AgentRail.css +3 -3
  39. package/components/AiButton/AiButton.css +19 -0
  40. package/components/AiButton/AiButton.d.ts +10 -1
  41. package/components/AiButton/AiButton.js +6 -1
  42. package/components/AnchorNav/AnchorNav.d.ts +29 -3
  43. package/components/AnchorNav/AnchorNav.js +69 -5
  44. package/components/AppLayout/AppLayout.css +8 -4
  45. package/components/AppLayout/AppLayout.d.ts +13 -3
  46. package/components/AppLayout/AppLayout.js +2 -0
  47. package/components/ArtifactPanel/ArtifactPanel.css +46 -0
  48. package/components/ArtifactPanel/ArtifactPanel.d.ts +14 -4
  49. package/components/ArtifactPanel/ArtifactPanel.js +13 -10
  50. package/components/Attachment/AttachmentViewer.js +7 -7
  51. package/components/BackToTop/BackToTop.css +28 -0
  52. package/components/BackToTop/BackToTop.d.ts +28 -0
  53. package/components/BackToTop/BackToTop.js +47 -0
  54. package/components/BentoTile/BentoTile.css +4 -1
  55. package/components/BentoTile/BentoTile.js +5 -5
  56. package/components/Button/Button.css +28 -1
  57. package/components/Button/Button.d.ts +7 -2
  58. package/components/Button/Button.js +7 -3
  59. package/components/ChatHeader/ChatHeader.d.ts +1 -1
  60. package/components/ChatThread/ChatThread.css +1 -1
  61. package/components/Chip/Chip.css +26 -0
  62. package/components/CircularButton/CircularButton.d.ts +16 -96
  63. package/components/CircularButton/CircularButton.js +11 -94
  64. package/components/CodeBlock/CodeBlock.css +63 -24
  65. package/components/CodeBlock/CodeBlock.d.ts +62 -6
  66. package/components/CodeBlock/CodeBlock.js +90 -48
  67. package/components/Combobox/Combobox.css +12 -0
  68. package/components/CommandPalette/CommandPalette.css +1 -1
  69. package/components/CommandPalette/CommandPalette.js +3 -3
  70. package/components/CommandPaletteTrigger/CommandPaletteTrigger.css +9 -0
  71. package/components/CommandPaletteTrigger/CommandPaletteTrigger.d.ts +10 -2
  72. package/components/CommandPaletteTrigger/CommandPaletteTrigger.js +7 -2
  73. package/components/Composer/Composer.css +3 -3
  74. package/components/Composer/Composer.js +9 -9
  75. package/components/ContextMenu/ContextMenu.css +24 -0
  76. package/components/CopyButton/CopyButton.d.ts +42 -0
  77. package/components/CopyButton/CopyButton.js +72 -0
  78. package/components/DataTable/DataTable.css +2 -2
  79. package/components/DataTable/DataTable.js +15 -15
  80. package/components/DateInput/DateInput.css +20 -0
  81. package/components/DescriptionList/DescriptionListCopy.d.ts +2 -2
  82. package/components/DescriptionList/DescriptionListCopy.js +7 -35
  83. package/components/Dialog/Dialog.css +1 -1
  84. package/components/Dialog/Dialog.js +3 -3
  85. package/components/DocumentChip/DocumentChip.css +12 -0
  86. package/components/DocumentViewer/DocumentViewer.js +10 -10
  87. package/components/Drawer/Drawer.css +1 -1
  88. package/components/Drawer/Drawer.js +3 -3
  89. package/components/Dropdown/Dropdown.css +30 -0
  90. package/components/DropdownMenu/DropdownMenu.css +24 -0
  91. package/components/Figure/Figure.css +26 -0
  92. package/components/Figure/Figure.d.ts +10 -1
  93. package/components/Figure/Figure.js +15 -3
  94. package/components/FileInput/FileInput.css +9 -0
  95. package/components/FilterBar/FilterBar.css +12 -0
  96. package/components/Heading/Heading.css +43 -0
  97. package/components/Heading/Heading.d.ts +14 -3
  98. package/components/Heading/Heading.js +22 -4
  99. package/components/HoverCard/HoverCard.js +1 -0
  100. package/components/{CircularButton/CircularButton.css → IconButton/IconButton.css} +91 -81
  101. package/components/IconButton/IconButton.d.ts +108 -0
  102. package/components/IconButton/IconButton.js +101 -0
  103. package/components/Input/Input.css +53 -0
  104. package/components/Input/Input.js +3 -3
  105. package/components/Link/Link.css +38 -0
  106. package/components/Link/Link.d.ts +3 -3
  107. package/components/Link/Link.js +1 -1
  108. package/components/MaskedInput/MaskedInput.js +3 -3
  109. package/components/Menubar/Menubar.css +82 -0
  110. package/components/Menubar/Menubar.d.ts +40 -0
  111. package/components/Menubar/Menubar.js +97 -0
  112. package/components/ModelPicker/ModelPicker.css +12 -1
  113. package/components/NavList/NavList.css +198 -1
  114. package/components/NavList/NavList.d.ts +54 -6
  115. package/components/NavList/NavList.js +136 -8
  116. package/components/Pagination/Pagination.css +81 -1
  117. package/components/Pagination/Pagination.d.ts +29 -3
  118. package/components/Pagination/Pagination.js +49 -5
  119. package/components/QuestionCard/QuestionCard.js +3 -3
  120. package/components/RadioButton/RadioButton.css +14 -12
  121. package/components/Rating/Rating.css +26 -0
  122. package/components/Rating/Rating.d.ts +18 -5
  123. package/components/Rating/Rating.js +16 -7
  124. package/components/RichDropdown/RichDropdown.css +7 -0
  125. package/components/SectionTitle/SectionTitle.css +36 -0
  126. package/components/SectionTitle/SectionTitle.d.ts +10 -1
  127. package/components/SectionTitle/SectionTitle.js +7 -2
  128. package/components/SegmentedControl/SegmentedControl.css +16 -5
  129. package/components/SegmentedControl/SegmentedControl.js +7 -4
  130. package/components/ShaderScene/ShaderScene.d.ts +2 -1
  131. package/components/ShaderScene/ShaderScene.js +20 -2
  132. package/components/SiteFooter/SiteFooter.css +157 -0
  133. package/components/SiteFooter/SiteFooter.d.ts +53 -0
  134. package/components/SiteFooter/SiteFooter.js +61 -0
  135. package/components/SiteHeader/SiteHeader.css +118 -9
  136. package/components/SiteHeader/SiteHeader.d.ts +25 -2
  137. package/components/SiteHeader/SiteHeader.js +49 -11
  138. package/components/SiteLayout/SiteLayout.css +361 -0
  139. package/components/SiteLayout/SiteLayout.d.ts +103 -0
  140. package/components/SiteLayout/SiteLayout.js +68 -0
  141. package/components/SourceTrail/SourceTrail.css +8 -0
  142. package/components/SplitButton/SplitButton.css +14 -14
  143. package/components/SplitButton/SplitButton.js +3 -3
  144. package/components/Table/Table.css +14 -0
  145. package/components/Table/Table.d.ts +2 -0
  146. package/components/Table/Table.js +1 -1
  147. package/components/TableToolbar/TableToolbar.css +2 -2
  148. package/components/TableToolbar/TableToolbar.js +36 -37
  149. package/components/ThreadPanel/ThreadPanel.css +8 -0
  150. package/components/ThreadTabs/ThreadTabs.css +7 -0
  151. package/components/TimePicker/TimePicker.css +12 -0
  152. package/components/ToolCall/ToolCall.css +8 -0
  153. package/components/Tooltip/Tooltip.js +4 -2
  154. package/components/WorldMap/WorldMap.js +5 -5
  155. package/components/keyboard-patterns.json.d.ts +57 -0
  156. package/components/keyboard-patterns.json.js +1 -1
  157. package/components/registry.d.ts +3 -1
  158. package/components/registry.json +107 -28
  159. package/components/registry.json.d.ts +107 -28
  160. package/components/registry.json.js +1 -1
  161. package/index.d.ts +6 -0
  162. package/index.js +16 -1
  163. package/package.json +19 -3
  164. package/tokens/breakpoints.js +3 -3
  165. package/tokens/registry.json +5 -0
  166. package/tokens/registry.json.d.ts +5 -0
  167. package/tokens/registry.json.js +1 -1
  168. package/tokens/tokens-dark.css +12 -0
  169. package/tokens/tokens-light.css +12 -0
  170. package/tokens/values.json.js +1 -1
@@ -0,0 +1,168 @@
1
+ /**
2
+ * The docs block: one documentation page in the docs shell, showing every
3
+ * piece a docs page needs. Keep the shell, replace this article with
4
+ * yours, and give each page its own `currentHref` and breadcrumb.
5
+ *
6
+ * Code here is monochrome. To colour it, install shiki and pass
7
+ * `lines={await highlight(code, 'tsx')}` (from `rift-ds/code/highlight`)
8
+ * to each CodeBlock, in a Server Component such as this page, so the page
9
+ * ships no highlighter.
10
+ */
11
+
12
+ import { Alert } from 'rift-ds/components/Alert/Alert';
13
+ import { ArtifactPanel } from 'rift-ds/components/ArtifactPanel/ArtifactPanel';
14
+ import { Button } from 'rift-ds/components/Button/Button';
15
+ import { CodeBlock } from 'rift-ds/components/CodeBlock/CodeBlock';
16
+ import { Figure } from 'rift-ds/components/Figure/Figure';
17
+ import { Heading } from 'rift-ds/components/Heading/Heading';
18
+ import { Instructions } from 'rift-ds/components/Instructions/Instructions';
19
+ import { Link } from 'rift-ds/components/Link/Link';
20
+ import { Pagination } from 'rift-ds/components/Pagination/Pagination';
21
+ import { Prose } from 'rift-ds/components/Prose/Prose';
22
+ import { Table } from 'rift-ds/components/Table/Table';
23
+ import { TreeView } from 'rift-ds/components/TreeView/TreeView';
24
+ import { packageManagerTabs } from 'rift-ds/code';
25
+ import { DocsShell } from '../../components/blocks/DocsShell';
26
+ import { PageFeedback } from './PageFeedback';
27
+ import styles from './page.module.css';
28
+
29
+ const USAGE = `import { Button } from 'rift-ds/components/Button/Button';
30
+
31
+ export function SaveBar() {
32
+ return <Button variant="primary">Save changes</Button>;
33
+ }`;
34
+
35
+ export default function GuidePage() {
36
+ return (
37
+ <DocsShell currentHref="#installation" breadcrumb={[{ label: 'Docs', href: '#docs' }, { label: 'Installation' }]}>
38
+ <header className={styles.intro}>
39
+ <Heading level={1} tier="display-2">
40
+ Installation
41
+ </Heading>
42
+ <p className={styles.lead}>
43
+ Add Acme to a React app, set up its theme, and render your first component.
44
+ </p>
45
+ </header>
46
+
47
+ <section className={styles.section}>
48
+ <Heading level={2} anchor>
49
+ Install the package
50
+ </Heading>
51
+ <Prose>
52
+ <p>Install it with the package manager your app uses. Your pick is remembered on every page.</p>
53
+ </Prose>
54
+ <CodeBlock tabs={packageManagerTabs({ install: 'acme-ui' })} syncKey="package-manager" />
55
+ <Alert
56
+ variant="info"
57
+ title="React 19 or later"
58
+ description="Acme relies on React 19's ref as a prop. Upgrade React first if your app is on 18."
59
+ />
60
+ </section>
61
+
62
+ <section className={styles.section}>
63
+ <Heading level={2} anchor>
64
+ Set up the theme
65
+ </Heading>
66
+ <Instructions
67
+ steps={[
68
+ { label: 'Import the stylesheet', description: 'Once, in your root layout, before your own CSS.' },
69
+ { label: 'Load the font', description: 'Through your framework’s font loader, or a link in the head.' },
70
+ { label: 'Set the colour mode', description: 'Render the colour mode script in the head so the first paint is right.' },
71
+ ]}
72
+ />
73
+ <CodeBlock
74
+ tabs={packageManagerTabs({ run: 'acme-ui init' })}
75
+ syncKey="package-manager"
76
+ />
77
+ </section>
78
+
79
+ <section className={styles.section}>
80
+ <Heading level={2} anchor>
81
+ Your first component
82
+ </Heading>
83
+ <ArtifactPanel layout="inline" viewLabel="Button example" code={USAGE} language="tsx">
84
+ <Button variant="primary">Save changes</Button>
85
+ </ArtifactPanel>
86
+ <Heading level={3} anchor>
87
+ Props
88
+ </Heading>
89
+ <Table
90
+ bordered
91
+ size="compact"
92
+ caption="Button props"
93
+ captionHidden
94
+ columns={[
95
+ { key: 'prop', header: 'Prop', mono: true, width: '24%', rowHeader: true },
96
+ { key: 'type', header: 'Type', mono: true, width: '36%' },
97
+ { key: 'description', header: 'Description' },
98
+ ]}
99
+ rows={[
100
+ { id: 'variant', cells: { prop: 'variant', type: "'primary' | 'secondary' | 'tertiary'", description: 'How much the button stands out.' } },
101
+ { id: 'size', cells: { prop: 'size', type: "'default' | 'compact'", description: 'The control height.' } },
102
+ { id: 'disabled', cells: { prop: 'disabled', type: 'boolean', description: 'Holds the button still.' } },
103
+ ]}
104
+ />
105
+ </section>
106
+
107
+ <section className={styles.section}>
108
+ <Heading level={2} anchor>
109
+ Writing labels
110
+ </Heading>
111
+ <div className={styles.pair}>
112
+ <Figure variant="positive" caption="Say what happens when it is pressed.">
113
+ <div className={styles.specimen}>
114
+ <Button variant="primary">Save changes</Button>
115
+ </div>
116
+ </Figure>
117
+ <Figure variant="error" caption="Leave the reader guessing what the button does.">
118
+ <div className={styles.specimen}>
119
+ <Button variant="primary">Click here</Button>
120
+ </div>
121
+ </Figure>
122
+ </div>
123
+ </section>
124
+
125
+ <section className={styles.section}>
126
+ <Heading level={2} anchor>
127
+ Project structure
128
+ </Heading>
129
+ <TreeView
130
+ aria-label="Project files"
131
+ defaultExpandedIds={['app', 'components']}
132
+ nodes={[
133
+ {
134
+ id: 'app',
135
+ label: 'app',
136
+ icon: 'folder',
137
+ children: [
138
+ { id: 'layout', label: 'layout.tsx', icon: 'description' },
139
+ { id: 'page', label: 'page.tsx', icon: 'description' },
140
+ ],
141
+ },
142
+ {
143
+ id: 'components',
144
+ label: 'components',
145
+ icon: 'folder',
146
+ children: [{ id: 'save-bar', label: 'SaveBar.tsx', icon: 'description' }],
147
+ },
148
+ ]}
149
+ />
150
+ </section>
151
+
152
+ <footer className={styles.pageFooter}>
153
+ <div className={styles.meta}>
154
+ <Link variant="standalone" size="compact" href="#edit" iconLeft="edit">
155
+ Edit this page
156
+ </Link>
157
+ <span className={styles.updated}>Last updated 12 Nov 2026</span>
158
+ </div>
159
+ <PageFeedback />
160
+ <Pagination
161
+ variant="adjacent"
162
+ previous={{ href: '#introduction', label: 'Introduction' }}
163
+ next={{ href: '#theming', label: 'Theming' }}
164
+ />
165
+ </footer>
166
+ </DocsShell>
167
+ );
168
+ }
@@ -72,7 +72,9 @@
72
72
  .content {
73
73
  position: relative;
74
74
  width: 100%;
75
- max-width: 1440px;
75
+ /* The shell recipe's width axis (CONTENT_WIDTH in AppShell.tsx): 1440px
76
+ contained, or the whole column when full, in any mode. */
77
+ max-width: var(--ds-shell-content-max, var(--ds-shell-contained-width));
76
78
  min-width: 0;
77
79
  display: flex;
78
80
  flex-direction: column;
@@ -150,6 +152,13 @@
150
152
  display: none;
151
153
  }
152
154
 
155
+ /* An icon-only control wears a tooltip, which wraps it: the wrapper leaves
156
+ the row with the control, or it would hold a gap open. */
157
+ .topBarActions :global(.ds-tooltip):has(> .searchIcon),
158
+ .topBarActions :global(.ds-tooltip):has(> .aiIcon) {
159
+ display: none;
160
+ }
161
+
153
162
  .topBarActions {
154
163
  display: flex;
155
164
  align-items: center;
@@ -221,7 +230,9 @@
221
230
  }
222
231
 
223
232
  .searchIcon,
224
- .aiIcon {
233
+ .aiIcon,
234
+ .topBarActions :global(.ds-tooltip):has(> .searchIcon),
235
+ .topBarActions :global(.ds-tooltip):has(> .aiIcon) {
225
236
  display: inline-flex;
226
237
  }
227
238
 
@@ -41,6 +41,13 @@ import styles from './AppShell.module.css';
41
41
  */
42
42
  const SHELL_LAYOUT: AppSidebarLayout = 'floating';
43
43
 
44
+ /**
45
+ * How wide the page runs, apart from the mode: `contained` centres the
46
+ * content column at 1440px, `full` runs it the whole width the mode leaves.
47
+ * Any mode takes either.
48
+ */
49
+ const CONTENT_WIDTH: 'contained' | 'full' = 'contained';
50
+
44
51
  /** The product's name, shown beside the logo in the sidebar. */
45
52
  const PRODUCT_NAME = 'Acme';
46
53
 
@@ -101,6 +108,7 @@ export function AppShell({ activeKey, breadcrumb, title, actions, children }: Ap
101
108
  <div
102
109
  className={styles.shell}
103
110
  data-ds-shell={SHELL_LAYOUT}
111
+ data-ds-width={CONTENT_WIDTH}
104
112
  >
105
113
  <AppSidebar
106
114
  sections={NAV_SECTIONS}
@@ -0,0 +1,18 @@
1
+ /*
2
+ * The docs shell's own touches. SiteLayout owns the columns, the sticky
3
+ * sidebar, the widths, the reading measure and the fold; every value here
4
+ * is a rift-ds token.
5
+ */
6
+
7
+ .brand {
8
+ font-family: var(--font-title-body-family);
9
+ font-size: var(--font-title-body-size);
10
+ font-weight: var(--font-title-body-weight);
11
+ color: var(--color-text-primary);
12
+ }
13
+
14
+ .article {
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: var(--gap-500);
18
+ }
@@ -0,0 +1,179 @@
1
+ 'use client';
2
+ /**
3
+ * The documentation shell the docs block sits in: rift-ds's SiteLayout
4
+ * holding a site header (search and colour mode), a long sidebar of pages,
5
+ * the article with its breadcrumb, an on-this-page rail read from the
6
+ * article's headings, and a sitemap footer. This file is yours: rename the
7
+ * product, replace the navigation and the footer with your own, and wire
8
+ * the search to your command palette.
9
+ *
10
+ * Two settings below lay it out: PAGE_WIDTH (the columns contained at
11
+ * 1440px or full width) and SIDEBAR_DOCK, which moves the header, the
12
+ * sidebar and the footer as one frame: docked to the window's edge, the
13
+ * header and the footer run full width with it; beside the content, all
14
+ * three follow the page. SiteLayout's readingWidth holds the article to a
15
+ * reading measure while the page is contained.
16
+ *
17
+ * Responsive by construction: below 1152px the on-this-page rail gives
18
+ * way, and below 960px the sidebar leaves the page and the header's menu
19
+ * carries its pages (each section's drawerItems), so there is one menu.
20
+ */
21
+
22
+ import type { ReactNode } from 'react';
23
+ import { AnchorNav } from 'rift-ds/components/AnchorNav/AnchorNav';
24
+ import { BackToTop } from 'rift-ds/components/BackToTop/BackToTop';
25
+ import { Breadcrumb, type BreadcrumbItem } from 'rift-ds/components/Breadcrumb/Breadcrumb';
26
+ import { CommandPaletteTrigger } from 'rift-ds/components/CommandPaletteTrigger/CommandPaletteTrigger';
27
+ import { NavList, type NavListEntry } from 'rift-ds/components/NavList/NavList';
28
+ import { SiteFooter, type SiteFooterColumn } from 'rift-ds/components/SiteFooter/SiteFooter';
29
+ import { SiteHeader, type SiteHeaderSection } from 'rift-ds/components/SiteHeader/SiteHeader';
30
+ import { SiteLayout } from 'rift-ds/components/SiteLayout/SiteLayout';
31
+ import { ThemeToggle } from 'rift-ds/components/ThemeToggle/ThemeToggle';
32
+ import styles from './DocsShell.module.css';
33
+
34
+ /** How wide the page's columns run: centred at 1440px, or the full window. */
35
+ const PAGE_WIDTH: 'contained' | 'full' = 'full';
36
+
37
+ /** Where the sidebar sits, the header and the footer moving with it: docked to the window's start edge, or beside the content in the page's row. */
38
+ const SIDEBAR_DOCK: 'edge' | 'content' = 'edge';
39
+
40
+ /** The product's name, shown in the header and the footer. */
41
+ const PRODUCT_NAME = 'Acme';
42
+
43
+
44
+ /** Every page of the docs, in sections; a long list scrolls inside the sidebar. */
45
+ const COMPONENT_PAGES = [
46
+ 'Accordion', 'Alert', 'Avatar', 'Badge', 'Breadcrumb', 'Button', 'Calendar', 'Card', 'Checkbox', 'Code block',
47
+ 'Combobox', 'Dialog', 'Drawer', 'Dropdown menu', 'Field', 'Input', 'Menubar', 'Pagination', 'Popover', 'Select',
48
+ 'Slider', 'Switch', 'Table', 'Tabs', 'Toast', 'Tooltip',
49
+ ];
50
+ const NAV: NavListEntry[] = [
51
+ {
52
+ type: 'section',
53
+ label: 'Getting started',
54
+ items: [
55
+ { label: 'Introduction', href: '#introduction' },
56
+ { label: 'Installation', href: '#installation' },
57
+ {
58
+ label: 'Theming',
59
+ href: '#theming',
60
+ items: [
61
+ { label: 'Colours', href: '#theming-colours' },
62
+ { label: 'Dark mode', href: '#theming-dark-mode' },
63
+ ],
64
+ },
65
+ { label: 'CLI', href: '#cli', badge: 'New' },
66
+ ],
67
+ },
68
+ {
69
+ type: 'section',
70
+ label: 'Components',
71
+ items: COMPONENT_PAGES.map((label) => ({ label, href: `#${label.toLowerCase().replace(/ /g, '-')}` })),
72
+ },
73
+ {
74
+ type: 'section',
75
+ label: 'Guides',
76
+ collapsible: true,
77
+ items: [
78
+ { label: 'Forms', href: '#guide-forms' },
79
+ { label: 'Server rendering', href: '#guide-server-rendering' },
80
+ ],
81
+ },
82
+ ];
83
+
84
+ /**
85
+ * The header's top-level sections. Each lists its pages as drawerItems: on a
86
+ * phone the sidebar leaves the page and the header's one menu carries them.
87
+ */
88
+ const SECTIONS: SiteHeaderSection[] = [
89
+ {
90
+ id: 'docs',
91
+ label: 'Docs',
92
+ href: '#docs',
93
+ drawerItems: [
94
+ { label: 'Introduction', href: '#introduction' },
95
+ { label: 'Installation', href: '#installation' },
96
+ { label: 'Theming', href: '#theming' },
97
+ { label: 'CLI', href: '#cli' },
98
+ ],
99
+ },
100
+ {
101
+ id: 'components',
102
+ label: 'Components',
103
+ href: '#components',
104
+ drawerItems: COMPONENT_PAGES.map((label) => ({ label, href: `#${label.toLowerCase().replace(/ /g, '-')}` })),
105
+ },
106
+ { id: 'changelog', label: 'Changelog', href: '#changelog' },
107
+ ];
108
+
109
+ /** The footer's sitemap. */
110
+ const FOOTER_COLUMNS: SiteFooterColumn[] = [
111
+ { label: 'Docs', links: [{ label: 'Introduction', href: '#introduction' }, { label: 'Installation', href: '#installation' }] },
112
+ { label: 'Components', links: [{ label: 'Button', href: '#button' }, { label: 'Table', href: '#table' }] },
113
+ { label: 'Community', links: [{ label: 'Discussions', href: 'https://example.com/discussions', external: true }] },
114
+ ];
115
+
116
+ export interface DocsShellProps {
117
+ /** The href of this page, which the sidebar marks as current. */
118
+ currentHref: string;
119
+ /** The page's place in the docs, ending with the page itself. */
120
+ breadcrumb: BreadcrumbItem[];
121
+ /** The article: its h1, then its sections, each opened by an h2. */
122
+ children: ReactNode;
123
+ }
124
+
125
+ export function DocsShell({ currentHref, breadcrumb, children }: DocsShellProps) {
126
+ return (
127
+ <SiteLayout
128
+ width={PAGE_WIDTH}
129
+ readingWidth
130
+ sidebarDock={SIDEBAR_DOCK}
131
+ mainId="docs-article"
132
+ header={
133
+ <SiteHeader
134
+ brand={<span className={styles.brand}>{PRODUCT_NAME}</span>}
135
+ sections={SECTIONS}
136
+ currentHref="#docs"
137
+ foldBelow="tablet"
138
+ actions={
139
+ <>
140
+ {/* Wire it to your command palette: CommandPalette from rift-ds,
141
+ opened from here and from Cmd+K. */}
142
+ <CommandPaletteTrigger label="Search the docs" size="compact" />
143
+ <ThemeToggle showLabels={false} size="compact" />
144
+ </>
145
+ }
146
+ condensedActions={
147
+ <>
148
+ {/* The same two at their narrowest, for a phone: the bar uses
149
+ these before it folds. */}
150
+ <CommandPaletteTrigger label="Search the docs" size="compact" iconOnly />
151
+ <ThemeToggle size="compact" cycle />
152
+ </>
153
+ }
154
+ />
155
+ }
156
+ sidebar={
157
+ <NavList
158
+ items={NAV}
159
+ size="compact"
160
+ scrollable
161
+ currentHref={currentHref}
162
+ />
163
+ }
164
+ aside={<AnchorNav fromHeadings={{ root: '#docs-article' }} />}
165
+ footer={
166
+ <SiteFooter
167
+ brand={PRODUCT_NAME}
168
+ description="Components and guides for building the Acme app."
169
+ columns={FOOTER_COLUMNS}
170
+ legal={`© ${new Date().getFullYear()} ${PRODUCT_NAME}.`}
171
+ />
172
+ }
173
+ >
174
+ <Breadcrumb items={breadcrumb} />
175
+ <div className={styles.article}>{children}</div>
176
+ <BackToTop focusTarget="docs-article" />
177
+ </SiteLayout>
178
+ );
179
+ }
@@ -72,6 +72,19 @@
72
72
  "app/shader/page.tsx",
73
73
  "app/shader/page.module.css"
74
74
  ]
75
+ },
76
+ {
77
+ "name": "docs",
78
+ "label": "Docs",
79
+ "description": "A documentation page: a site header, a long sidebar of pages, an article with tabbed install commands and live examples, an on-this-page rail and a footer.",
80
+ "route": "/guide",
81
+ "files": [
82
+ "components/blocks/DocsShell.tsx",
83
+ "components/blocks/DocsShell.module.css",
84
+ "app/guide/page.tsx",
85
+ "app/guide/page.module.css",
86
+ "app/guide/PageFeedback.tsx"
87
+ ]
75
88
  }
76
89
  ]
77
90
  }
@@ -34,6 +34,8 @@ export interface ChatLauncherProps {
34
34
  * the chat from a control of its own, such as an AiButton in its top bar:
35
35
  * that control calls `setOpen(true)` from `useChatWidget()` and sets
36
36
  * `returnFocusRef.current` to itself, so closing the panel hands focus back.
37
+ * It also calls `preloadChatWidget` on hover and focus, as the floating
38
+ * button does.
37
39
  */
38
40
  fab?: boolean;
39
41
  /** The panel's DOM id, for a host control's `aria-controls`. */
@@ -48,6 +50,12 @@ export interface ChatLauncherProps {
48
50
  panelLabel?: string;
49
51
  /** The words of the floating button's summary panel, over AiButton's English defaults: the panel's name, given the summary's title ("Summary: <title>"), its dismiss button ("Dismiss summary") and its chips' group ("Suggested prompts"). */
50
52
  aiButtonLabels?: Pick<AiButtonProps, 'summaryRegionLabel' | 'dismissLabel' | 'suggestionsLabel'>;
53
+ /**
54
+ * Accessible name of the spinner the panel shows while the chat's code is
55
+ * still arriving: the panel was opened before the preload finished, or the
56
+ * visitor asked to save data and nothing was preloaded.
57
+ */
58
+ loadingLabel?: string;
51
59
  /** Everything the widget takes. The launcher sets the responsive ones itself. */
52
60
  widget?: Omit<ChatWidgetProps, 'fullscreenEnabled' | 'placementEnabled' | 'compact' | 'phone'>;
53
61
  /** Rendered inside the panel after the widget: for a host's extra chrome. */
@@ -89,4 +97,4 @@ export interface ChatLauncherProps {
89
97
  * edge gap on the docked side. The panel's geometry reads `--ds-chat-width`,
90
98
  * `--ds-chat-inset` and `--ds-chat-float-height`, defaulted on `:root`.
91
99
  */
92
- export declare function ChatLauncher({ label, icon, summary, hidden, panelId, hostAttribute, panelLabel, aiButtonLabels, widget, children, surface, fab, }: ChatLauncherProps): import("react").JSX.Element | null;
100
+ export declare function ChatLauncher({ label, icon, summary, hidden, panelId, hostAttribute, panelLabel, aiButtonLabels, loadingLabel, widget, children, surface, fab, }: ChatLauncherProps): import("react").JSX.Element | null;
@@ -1,11 +1,13 @@
1
1
  "use client";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
- import { useSyncExternalStore, useLayoutEffect, useRef, useEffect, useState } from "react";
3
+ import { useSyncExternalStore, useLayoutEffect, useRef, useEffect, useState, Suspense } from "react";
4
+ import { usePreloadWhenIdle } from "../behaviors/deferComponent.js";
4
5
  import { useScrollLock } from "../behaviors/useScrollLock.js";
5
6
  import { AiButton } from "../components/AiButton/AiButton.js";
6
- import { ChatWidget } from "./ChatWidget.js";
7
+ import { Spinner } from "../components/Spinner/Spinner.js";
7
8
  import { useChatAgentState } from "./agentState.js";
8
9
  import { useChatWidget } from "./context.js";
10
+ import { DeferredChatWidget } from "./deferredChatWidget.js";
9
11
  import { isFloatDragStart, FLOAT_EDGE_GAP, FLOAT_MAX_SCALE, dockWidthFromDrag, clampFloatPosition } from "./placement.js";
10
12
  import { useDockViewport, TAKEOVER_QUERY } from "./queries.js";
11
13
  import { keepFittingSuggestions } from "./suggestions.js";
@@ -43,6 +45,7 @@ function ChatLauncher({
43
45
  hostAttribute = "data-chat",
44
46
  panelLabel = "Chat",
45
47
  aiButtonLabels,
48
+ loadingLabel = "Loading chat",
46
49
  widget,
47
50
  children,
48
51
  surface = "raised",
@@ -50,6 +53,7 @@ function ChatLauncher({
50
53
  }) {
51
54
  const { open, setOpen, panelPhase, view, side, floating, returnFocusRef, send } = useChatWidget();
52
55
  const agentState = useChatAgentState();
56
+ usePreloadWhenIdle(DeferredChatWidget.preload);
53
57
  const launchSuggestion = (id) => {
54
58
  const chip = summary?.chips?.find((c) => c.id === id);
55
59
  if (!chip) return;
@@ -248,33 +252,41 @@ function ChatLauncher({
248
252
  if (hidden) return null;
249
253
  if (!renderPanel) {
250
254
  if (!fab) return null;
251
- return /* @__PURE__ */ jsx("div", { className: "ds-chat-launcher__fab", children: /* @__PURE__ */ jsx(
252
- AiButton,
255
+ return /* @__PURE__ */ jsx(
256
+ "div",
253
257
  {
254
- ...aiButtonLabels,
255
- label,
256
- icon,
257
- state: agentState,
258
- "aria-expanded": false,
259
- "aria-controls": panelId,
260
- summary: summary ? {
261
- overline: summary.overline,
262
- title: summary.title,
263
- caption: summary.caption,
264
- text: summary.text,
265
- suggestions: keepFittingSuggestions(
266
- summary.suggestions ?? summary.chips?.map(({ id, label: chipLabel }) => ({ id, label: chipLabel })) ?? [],
267
- (chip) => chip.label,
268
- "ChatLauncher summary chips"
269
- )
270
- } : void 0,
271
- onSummarySuggestion: launchSuggestion,
272
- onClick: (event) => {
273
- returnFocusRef.current = event.currentTarget;
274
- setOpen(true);
275
- }
258
+ className: "ds-chat-launcher__fab",
259
+ onPointerEnter: DeferredChatWidget.preload,
260
+ onFocusCapture: DeferredChatWidget.preload,
261
+ children: /* @__PURE__ */ jsx(
262
+ AiButton,
263
+ {
264
+ ...aiButtonLabels,
265
+ label,
266
+ icon,
267
+ state: agentState,
268
+ "aria-expanded": false,
269
+ "aria-controls": panelId,
270
+ summary: summary ? {
271
+ overline: summary.overline,
272
+ title: summary.title,
273
+ caption: summary.caption,
274
+ text: summary.text,
275
+ suggestions: keepFittingSuggestions(
276
+ summary.suggestions ?? summary.chips?.map(({ id, label: chipLabel }) => ({ id, label: chipLabel })) ?? [],
277
+ (chip) => chip.label,
278
+ "ChatLauncher summary chips"
279
+ )
280
+ } : void 0,
281
+ onSummarySuggestion: launchSuggestion,
282
+ onClick: (event) => {
283
+ returnFocusRef.current = event.currentTarget;
284
+ setOpen(true);
285
+ }
286
+ }
287
+ )
276
288
  }
277
- ) });
289
+ );
278
290
  }
279
291
  const handleKeyDown = (event) => {
280
292
  if (event.key === "Escape") {
@@ -336,13 +348,19 @@ function ChatLauncher({
336
348
  onKeyDown: handleKeyDown,
337
349
  children: [
338
350
  /* @__PURE__ */ jsx(
339
- ChatWidget,
351
+ Suspense,
340
352
  {
341
- ...widget,
342
- fullscreenEnabled: !takeover,
343
- placementEnabled: !takeover,
344
- compact: takeover || !isFull,
345
- phone: takeover
353
+ fallback: /* @__PURE__ */ jsx("div", { className: "ds-chat-launcher__loading", children: /* @__PURE__ */ jsx(Spinner, { size: "lg", tone: "neutral", label: loadingLabel }) }),
354
+ children: /* @__PURE__ */ jsx(
355
+ DeferredChatWidget.Component,
356
+ {
357
+ ...widget,
358
+ fullscreenEnabled: !takeover,
359
+ placementEnabled: !takeover,
360
+ compact: takeover || !isFull,
361
+ phone: takeover
362
+ }
363
+ )
346
364
  }
347
365
  ),
348
366
  children,
@@ -78,8 +78,8 @@
78
78
  display: none;
79
79
  }
80
80
 
81
- .ds-chat-widget__placement-menu .ds-circular-button[aria-expanded="true"],
82
- .ds-chat-widget__placement-menu .ds-circular-button[aria-expanded="true"]:hover {
81
+ .ds-chat-widget__placement-menu .ds-icon-button[aria-expanded="true"],
82
+ .ds-chat-widget__placement-menu .ds-icon-button[aria-expanded="true"]:hover {
83
83
  background-color: var(--color-action-passive-bg-hover);
84
84
  }
85
85
 
@@ -1025,8 +1025,8 @@
1025
1025
  /* The agent toggle's on-state: the passive wash, held down while the panel
1026
1026
  is up. Paired with the library class so it beats the variant's resting
1027
1027
  background whatever order the stylesheets load in. */
1028
- .ds-circular-button.ds-chat-widget__agent-toggle--on,
1029
- .ds-circular-button.ds-chat-widget__agent-toggle--on:hover {
1028
+ .ds-icon-button.ds-chat-widget__agent-toggle--on,
1029
+ .ds-icon-button.ds-chat-widget__agent-toggle--on:hover {
1030
1030
  background-color: var(--color-action-passive-bg-hover);
1031
1031
  }
1032
1032
 
@@ -1076,6 +1076,15 @@
1076
1076
 
1077
1077
  /* The widen grip drives --ds-chat-width frame by frame; the width glide
1078
1078
  above would rubber-band behind the pointer, so resizing suspends it. */
1079
+ /* The panel while the widget's code is still arriving (it loads on first
1080
+ open; src/behaviors/deferComponent.ts): the frame above is already
1081
+ drawn, and a spinner holds its centre. */
1082
+ .ds-chat-launcher__loading {
1083
+ flex: 1;
1084
+ display: grid;
1085
+ place-items: center;
1086
+ }
1087
+
1079
1088
  html[data-chat-resizing] .ds-chat-launcher__panel {
1080
1089
  transition: none;
1081
1090
  }