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
@@ -8,7 +8,7 @@ import { ChatHeader } from "../components/ChatHeader/ChatHeader.js";
8
8
  import { DocumentChip } from "../components/DocumentChip/DocumentChip.js";
9
9
  import { ChatMessage } from "../components/ChatMessage/ChatMessage.js";
10
10
  import { ChatThread } from "../components/ChatThread/ChatThread.js";
11
- import { CircularButton } from "../components/CircularButton/CircularButton.js";
11
+ import { IconButton } from "../components/IconButton/IconButton.js";
12
12
  import { PixelAvatar } from "../components/PixelAvatar/PixelAvatar.js";
13
13
  import { Composer } from "../components/Composer/Composer.js";
14
14
  import { DropdownMenu } from "../components/DropdownMenu/DropdownMenu.js";
@@ -456,11 +456,11 @@ function ChatWidget({
456
456
  const actionCount = Number(showNewChat) + Number(Boolean(renderAside)) + Number(artifacts) + Number(placementEnabled) + Number(fullscreenEnabled) + Number(closeEnabled);
457
457
  const headerActions = /* @__PURE__ */ jsxs(Fragment, { children: [
458
458
  showNewChat && /* @__PURE__ */ jsx(
459
- CircularButton,
459
+ IconButton,
460
460
  {
461
461
  icon: "edit_square",
462
462
  variant: "tertiary",
463
- ariaLabel: newChatLabel,
463
+ label: newChatLabel,
464
464
  tooltipPosition: "bottom",
465
465
  onClick: () => {
466
466
  reset();
@@ -470,12 +470,12 @@ function ChatWidget({
470
470
  }
471
471
  ),
472
472
  renderAside && /* @__PURE__ */ jsx(
473
- CircularButton,
473
+ IconButton,
474
474
  {
475
475
  icon: /* @__PURE__ */ jsx(PixelAvatar, { name: title, size: "sm" }),
476
476
  variant: "tertiary",
477
477
  className: asideShown ? "ds-chat-widget__agent-toggle--on" : void 0,
478
- ariaLabel: asideShown ? hideAgentLabel : showAgentLabel,
478
+ label: asideShown ? hideAgentLabel : showAgentLabel,
479
479
  tooltipPosition: "bottom",
480
480
  "aria-expanded": asideShown,
481
481
  "aria-controls": asideShown ? asideId : void 0,
@@ -483,12 +483,12 @@ function ChatWidget({
483
483
  }
484
484
  ),
485
485
  artifacts && /* @__PURE__ */ jsx(
486
- CircularButton,
486
+ IconButton,
487
487
  {
488
488
  icon: artifactShown ? "right_panel_close" : "right_panel_open",
489
489
  variant: "tertiary",
490
490
  className: artifactShown ? "ds-chat-widget__agent-toggle--on" : void 0,
491
- ariaLabel: artifactShown ? hideArtifactLabel : showArtifactLabel,
491
+ label: artifactShown ? hideArtifactLabel : showArtifactLabel,
492
492
  tooltipPosition: "bottom",
493
493
  "aria-expanded": artifactShown,
494
494
  "aria-controls": artifactShown ? artifactId : void 0,
@@ -504,11 +504,11 @@ function ChatWidget({
504
504
  {
505
505
  align: "end",
506
506
  trigger: /* @__PURE__ */ jsx(
507
- CircularButton,
507
+ IconButton,
508
508
  {
509
509
  icon: chatPlacement(placement).icon,
510
510
  variant: "tertiary",
511
- ariaLabel: placementLabel,
511
+ label: placementLabel,
512
512
  tooltipPosition: "bottom",
513
513
  disabled: isFull
514
514
  }
@@ -528,21 +528,21 @@ function ChatWidget({
528
528
  }
529
529
  ) }),
530
530
  fullscreenEnabled && /* @__PURE__ */ jsx(
531
- CircularButton,
531
+ IconButton,
532
532
  {
533
533
  icon: isFull ? "close_fullscreen" : "open_in_full",
534
534
  variant: "tertiary",
535
- ariaLabel: isFull ? exitFullscreenLabel : enterFullscreenLabel,
535
+ label: isFull ? exitFullscreenLabel : enterFullscreenLabel,
536
536
  tooltipPosition: "bottom",
537
537
  onClick: () => setView(isFull ? "panel" : "full")
538
538
  }
539
539
  ),
540
540
  closeEnabled && /* @__PURE__ */ jsx(
541
- CircularButton,
541
+ IconButton,
542
542
  {
543
543
  icon: "close",
544
544
  variant: "tertiary",
545
- ariaLabel: closeLabel,
545
+ label: closeLabel,
546
546
  tooltipPosition: "bottom",
547
547
  onClick: () => setOpen(false)
548
548
  }
@@ -603,11 +603,11 @@ function ChatWidget({
603
603
  {
604
604
  title: /* @__PURE__ */ jsxs("span", { className: "ds-chat-widget__brand", children: [
605
605
  renderThreads && !threadsInline && /* @__PURE__ */ jsx(
606
- CircularButton,
606
+ IconButton,
607
607
  {
608
608
  icon: "menu",
609
609
  variant: "tertiary",
610
- ariaLabel: openThreadsLabel,
610
+ label: openThreadsLabel,
611
611
  tooltipPosition: "bottom",
612
612
  onClick: () => setThreadsOpen(true)
613
613
  }
@@ -0,0 +1,10 @@
1
+ import { ChatWidgetProps } from './ChatWidget';
2
+ export declare const DeferredChatWidget: import('../behaviors/deferComponent').DeferredComponent<ChatWidgetProps>;
3
+ /**
4
+ * Start loading the chat widget's code now. The launcher's own button calls
5
+ * it on hover and focus; a host that opens the chat from a control of its
6
+ * own (`fab={false}`) calls it from that control's `onPointerEnter` and
7
+ * `onFocus`, so its press finds the code already there. Safe to call any
8
+ * number of times.
9
+ */
10
+ export declare const preloadChatWidget: () => void;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { deferComponent } from "../behaviors/deferComponent.js";
3
+ const DeferredChatWidget = deferComponent(
4
+ () => import("./ChatWidget.js").then((module) => module.ChatWidget)
5
+ );
6
+ const preloadChatWidget = DeferredChatWidget.preload;
7
+ export {
8
+ DeferredChatWidget,
9
+ preloadChatWidget
10
+ };
package/chat/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export { sanitiseSelection, selectionLines, DEFAULT_SELECTION_LIMITS, type ChatS
20
20
  export { useGeneratedStarters, type GeneratedStarters, type GeneratedStartersOptions } from './generatedStarters';
21
21
  export { defineAction, planAction, skippedText, createConfirmationMark, sanitiseConfirmation, confirmationLine, planSequence, confirmSequence, defineContext, type ChatAction, type ActionPlan, type ActionConfirmation, type ConfirmationMark, type SanitiseConfirmationOptions, type ConfirmationLineOptions, type SequenceStep, type SequencePlan, type ConfirmedStep, type ContextField, type ContextShape, type ContextValues, type ContextSchema, } from './actions';
22
22
  export { ChatLauncher, CHAT_PANEL_ID, type ChatLauncherProps } from './ChatLauncher';
23
+ export { preloadChatWidget } from './deferredChatWidget';
23
24
  export { useChatAgentState } from './agentState';
24
25
  export { ChatThreads, type ChatThreadsProps } from './ChatThreads';
25
26
  export { ChatTabs, type ChatTabsProps } from './ChatTabs';
package/chat/index.js CHANGED
@@ -5,6 +5,7 @@ import { DEFAULT_SELECTION_LIMITS, sanitiseSelection, selectionLines } from "./s
5
5
  import { useGeneratedStarters } from "./generatedStarters.js";
6
6
  import { confirmSequence, confirmationLine, createConfirmationMark, defineAction, planAction, planSequence, sanitiseConfirmation, skippedText } from "./actions.js";
7
7
  import { CHAT_PANEL_ID, ChatLauncher } from "./ChatLauncher.js";
8
+ import { preloadChatWidget } from "./deferredChatWidget.js";
8
9
  import { useChatAgentState } from "./agentState.js";
9
10
  import { ChatThreads } from "./ChatThreads.js";
10
11
  import { ChatTabs } from "./ChatTabs.js";
@@ -107,6 +108,7 @@ export {
107
108
  pickStarters,
108
109
  planAction,
109
110
  planSequence,
111
+ preloadChatWidget,
110
112
  readGreeting,
111
113
  readSelection,
112
114
  sanitiseConfirmation,
@@ -43,7 +43,7 @@ declare const _default: {
43
43
  "ChatHeader",
44
44
  "ChatMessage",
45
45
  "ChatThread",
46
- "CircularButton",
46
+ "IconButton",
47
47
  "CodeBlock",
48
48
  "Composer",
49
49
  "DocumentChip",
@@ -56,6 +56,7 @@ declare const _default: {
56
56
  "Prose",
57
57
  "QuestionCard",
58
58
  "Reasoning",
59
+ "Spinner",
59
60
  "ThreadPanel",
60
61
  "ThreadTabs"
61
62
  ],
@@ -1,5 +1,5 @@
1
1
  const $comment = "The widget registry: the fourth kind of thing the package ships, between the components and the templates. One member by design. `parts` names the library components the widget composes (held to src/components/registry.json by scripts/validate-chat-widget.mjs), `subpaths` the package exports it occupies (held to scripts/package-manifest.mjs), `category` the component category whose section and sidebar group its page joins (held to src/components/registry.json), `peers` the optional peer dependencies each subpath needs (held to package.json). The widget's page under /components, the /docs/chat page, the chat corpus and the MCP tools read this file; never type its facts elsewhere.";
2
- const widgets = [{ "name": "ChatWidget", "slug": "ai-chat", "label": "AI chat", "category": "ai", "description": "The whole AI chat: the panel, or the page itself in an app shell mode, the streaming replies, the history, the cards and questions a reply can carry and the server handlers, set up with props.", "command": "init chat", "subpaths": { "./chat": "The widget, the provider, the launcher and the engine under them, with the hooks that let it follow the reader and write starters for what they picked.", "./chat/server": "The streaming chat handler, with an opt-in tool for asking the visitor questions, the cards a reply opens with, the page actions a tool returns, its follow-ups, starters and feedback siblings, and the checks for what a reader highlighted, for any web-standard route.", "./chat/actions": "The action definitions a page and its route share, their dry run alone or in a sequence, the mark that says a change was confirmed on its card, and the declared shape of a page's context, with no dependencies.", "./chat/upstash": "Rate limits, a daily budget and the exchange log over Upstash Redis, as the handlers' guardrails.", "./chat/demo": "A scripted conversation with rich cards and fixtures, for a preview that needs no key.", "./chat/chat.css": "The widget's stylesheet." }, "peers": { "./chat": ["react-markdown", "remark-gfm"], "./chat/server": ["@anthropic-ai/sdk"], "./chat/upstash": ["@upstash/ratelimit", "@upstash/redis"], "./chat/demo": ["recharts"] }, "parts": ["AgentRail", "AgentStatus", "AiButton", "ArtifactCard", "ArtifactPanel", "AttachmentDropZone", "AttachmentGroup", "ChatHeader", "ChatMessage", "ChatThread", "CircularButton", "CodeBlock", "Composer", "DocumentChip", "DropdownMenu", "EmptyState", "Mention", "ModelPicker", "PixelAvatar", "PromptSuggestions", "Prose", "QuestionCard", "Reasoning", "ThreadPanel", "ThreadTabs"], "documented": ["ChatWidget", "ChatProvider", "ChatLauncher", "ChatThreads", "ChatTabs", "ChatAgentPane", "ChatArtifactPane", "ChatArtifactCard"] }];
2
+ const widgets = [{ "name": "ChatWidget", "slug": "ai-chat", "label": "AI chat", "category": "ai", "description": "The whole AI chat: the panel, or the page itself in an app shell mode, the streaming replies, the history, the cards and questions a reply can carry and the server handlers, set up with props.", "command": "init chat", "subpaths": { "./chat": "The widget, the provider, the launcher and the engine under them, with the hooks that let it follow the reader and write starters for what they picked.", "./chat/server": "The streaming chat handler, with an opt-in tool for asking the visitor questions, the cards a reply opens with, the page actions a tool returns, its follow-ups, starters and feedback siblings, and the checks for what a reader highlighted, for any web-standard route.", "./chat/actions": "The action definitions a page and its route share, their dry run alone or in a sequence, the mark that says a change was confirmed on its card, and the declared shape of a page's context, with no dependencies.", "./chat/upstash": "Rate limits, a daily budget and the exchange log over Upstash Redis, as the handlers' guardrails.", "./chat/demo": "A scripted conversation with rich cards and fixtures, for a preview that needs no key.", "./chat/chat.css": "The widget's stylesheet." }, "peers": { "./chat": ["react-markdown", "remark-gfm"], "./chat/server": ["@anthropic-ai/sdk"], "./chat/upstash": ["@upstash/ratelimit", "@upstash/redis"], "./chat/demo": ["recharts"] }, "parts": ["AgentRail", "AgentStatus", "AiButton", "ArtifactCard", "ArtifactPanel", "AttachmentDropZone", "AttachmentGroup", "ChatHeader", "ChatMessage", "ChatThread", "IconButton", "CodeBlock", "Composer", "DocumentChip", "DropdownMenu", "EmptyState", "Mention", "ModelPicker", "PixelAvatar", "PromptSuggestions", "Prose", "QuestionCard", "Reasoning", "Spinner", "ThreadPanel", "ThreadTabs"], "documented": ["ChatWidget", "ChatProvider", "ChatLauncher", "ChatThreads", "ChatTabs", "ChatAgentPane", "ChatArtifactPane", "ChatArtifactCard"] }];
3
3
  const registry = {
4
4
  $comment,
5
5
  widgets
@@ -0,0 +1,4 @@
1
+ import { CodeLine } from '../components/CodeBlock/CodeBlock';
2
+ export type { CodeLine, CodeToken, CodeTokenRole } from '../components/CodeBlock/CodeBlock';
3
+ /** Highlight `code` as `lang` (any language shiki bundles: "tsx", "css", "bash", "json" and the rest). */
4
+ export declare function highlight(code: string, lang: string): Promise<CodeLine[]>;
@@ -0,0 +1,34 @@
1
+ import { createCssVariablesTheme, createHighlighter } from "shiki";
2
+ const PREFIX = "--rift-code-";
3
+ const theme = createCssVariablesTheme({ name: "rift", variablePrefix: PREFIX, variableDefaults: {}, fontStyle: false });
4
+ const ROLES = {
5
+ "token-keyword": "keyword",
6
+ "token-string": "string",
7
+ "token-string-expression": "string",
8
+ "token-link": "string",
9
+ "token-function": "function",
10
+ "token-constant": "constant",
11
+ "token-comment": "comment"
12
+ };
13
+ let highlighter;
14
+ const plain = (code) => code.split("\n").map((text) => [{ content: text }]);
15
+ async function highlight(code, lang) {
16
+ highlighter ??= createHighlighter({ themes: [theme], langs: [] });
17
+ const h = await highlighter;
18
+ try {
19
+ if (!h.getLoadedLanguages().includes(lang)) await h.loadLanguage(lang);
20
+ } catch {
21
+ return plain(code);
22
+ }
23
+ const { tokens } = h.codeToTokens(code, { lang, theme: "rift" });
24
+ return tokens.map(
25
+ (line) => line.map((token) => {
26
+ const match = token.color?.match(/var\(--rift-code-([a-z-]+)\)/);
27
+ const role = match ? ROLES[match[1]] : void 0;
28
+ return role ? { content: token.content, role } : { content: token.content };
29
+ })
30
+ );
31
+ }
32
+ export {
33
+ highlight
34
+ };
@@ -0,0 +1,16 @@
1
+ import { CodeBlockTab } from '../components/CodeBlock/CodeBlock';
2
+ export type { CodeBlockTab, CodeLine, CodeToken, CodeTokenRole } from '../components/CodeBlock/CodeBlock';
3
+ /** A package manager `packageManagerTabs` can write a command for. */
4
+ export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
5
+ /** What to write: packages to install, or a package binary to run once. */
6
+ export type PackageCommand = {
7
+ /** Packages to add, e.g. `'rift-ds'` or `['rift-ds', 'shiki']`. */
8
+ install: string | string[];
9
+ /** Add them as development dependencies. */
10
+ dev?: boolean;
11
+ } | {
12
+ /** A package binary and its arguments to run without installing, e.g. `'rift-ds init'`. */
13
+ run: string;
14
+ };
15
+ /** The same command for each package manager, as CodeBlock tabs (npm, pnpm, yarn and bun unless `managers` narrows them). */
16
+ export declare function packageManagerTabs(command: PackageCommand, managers?: PackageManager[]): CodeBlockTab[];
package/code/index.js ADDED
@@ -0,0 +1,23 @@
1
+ const INSTALL = {
2
+ npm: "npm install",
3
+ pnpm: "pnpm add",
4
+ yarn: "yarn add",
5
+ bun: "bun add"
6
+ };
7
+ const DEV_FLAG = { npm: "--save-dev", pnpm: "-D", yarn: "-D", bun: "-d" };
8
+ const RUN = { npm: "npx", pnpm: "pnpm dlx", yarn: "yarn dlx", bun: "bunx" };
9
+ function packageManagerTabs(command, managers = ["npm", "pnpm", "yarn", "bun"]) {
10
+ return managers.map((manager) => {
11
+ let code;
12
+ if ("run" in command) {
13
+ code = `${RUN[manager]} ${command.run}`;
14
+ } else {
15
+ const packages = Array.isArray(command.install) ? command.install.join(" ") : command.install;
16
+ code = [INSTALL[manager], command.dev ? DEV_FLAG[manager] : "", packages].filter(Boolean).join(" ");
17
+ }
18
+ return { value: manager, label: manager, code };
19
+ });
20
+ }
21
+ export {
22
+ packageManagerTabs
23
+ };
@@ -124,3 +124,11 @@
124
124
  color: var(--color-text-secondary);
125
125
  margin: 0;
126
126
  }
127
+
128
+ /* Icon side padding, Button's rule (design.md): a glyph's box carries its
129
+ own side bearing, so a side that holds one takes the step below the text
130
+ side. The trigger always ends on its chevron (20 → 16); the leading
131
+ side keeps the panel's inset, the line its content reads from. */
132
+ .ds-accordion__trigger {
133
+ padding-inline-end: var(--padding-400);
134
+ }
@@ -247,3 +247,11 @@
247
247
  .ds-agent-plan .material-symbols-rounded {
248
248
  color: inherit;
249
249
  }
250
+
251
+ /* Icon side padding, Button's rule (design.md): a glyph's box carries its
252
+ own side bearing, so a side that holds one takes the step below the text
253
+ side. The header's chevron end steps in from the card inset; the
254
+ leading side keeps the inset, the line the body below it reads from. */
255
+ .ds-agent-plan__header:has(.ds-agent-plan__chevron) {
256
+ padding-inline-end: calc(var(--ds-chat-card-inset) - var(--padding-100));
257
+ }
@@ -18,7 +18,7 @@
18
18
  header rather than sitting in it: the header is a centred identity
19
19
  block, and a control in that column would push the portrait off axis. */
20
20
  position: relative;
21
- /* CircularButton's default footprint, named because two rules need it:
21
+ /* IconButton's default footprint, named because two rules need it:
22
22
  the control itself, and the row the rail reserves for it when there is
23
23
  no header underneath it to float over. */
24
24
  --ds-agent-rail-control: 40px;
@@ -48,7 +48,7 @@
48
48
 
49
49
  .ds-agent-rail__collapse {
50
50
  position: absolute;
51
- /* CircularButton's default footprint and glyph, so the control sits in
51
+ /* IconButton's default footprint and glyph, so the control sits in
52
52
  the same row of controls the host puts along the card's top edge —
53
53
  `--ds-agent-rail-collapse-top` is the seat, which a host overrides to
54
54
  line the chevron up with its own header row. */
@@ -63,7 +63,7 @@
63
63
  padding: 0;
64
64
  border: none;
65
65
  border-radius: var(--radius-pill);
66
- /* A tertiary CircularButton's exact resting treatment, because that is
66
+ /* A tertiary IconButton's exact resting treatment, because that is
67
67
  what it sits in a row with: the host's own controls line up opposite it
68
68
  on the same baseline, and a dimmer icon tier beside them would read as a
69
69
  lesser control rather than the same kind of one. */
@@ -743,3 +743,22 @@
743
743
  transition: none;
744
744
  }
745
745
  }
746
+
747
+ /* Icon side padding, Button's rule: beside the label the icon's box carries
748
+ its own side bearing, so its edge takes the step below the text side
749
+ (20 → 16 at default, 12 → 8 at compact). The busy and status glyphs ride
750
+ the same slot. An icon-only button keeps its even box. */
751
+ .ds-ai-button:not(.ds-ai-button--icon-only):has(.ds-ai-button__icon) {
752
+ padding-inline-start: var(--padding-400);
753
+ }
754
+
755
+ .ds-ai-button--compact:not(.ds-ai-button--icon-only):has(.ds-ai-button__icon) {
756
+ padding-inline-start: var(--padding-200);
757
+ }
758
+
759
+ /* The icon-only form's tooltip names the button; while a panel it opened is
760
+ showing (its own request, a Popover, a sheet) the panel says it all, and
761
+ the bubble would sit on the side the panel takes. */
762
+ .ds-tooltip:has(> .ds-ai-button[aria-expanded='true']) .ds-tooltip__panel {
763
+ display: none;
764
+ }
@@ -21,8 +21,17 @@ type AiButtonOwnProps = {
21
21
  label?: string;
22
22
  /** Leading icon — Material Symbol name (string) or custom element (ReactNode) */
23
23
  icon?: string | React.ReactNode;
24
- /** Draws the button as a circle holding only its icon, for a tight bar. The label stays as its accessible name. */
24
+ /** Draws the button holding only its icon, on an even box, for a tight bar. The label stays as its accessible name. */
25
25
  iconOnly?: boolean;
26
+ /**
27
+ * The hover and focus tooltip of the icon-only form, which names itself as
28
+ * IconButton does: by default it carries `label`. Pass a string to show
29
+ * different wording, or `false` to opt out. A button with a `summary`
30
+ * shows none, since its panel opens on the same hover.
31
+ */
32
+ tooltip?: string | false;
33
+ /** Which side the tooltip opens on. `start` and `end` follow the reading direction. */
34
+ tooltipPosition?: 'top' | 'bottom' | 'left' | 'right' | 'start' | 'end';
26
35
  /** Button size */
27
36
  size?: 'default' | 'compact';
28
37
  /** Whether the button is disabled */
@@ -8,6 +8,7 @@ import { AgentStatusMark } from "../AgentStatus/AgentStatus.js";
8
8
  import { PromptSuggestions } from "../PromptSuggestions/PromptSuggestions.js";
9
9
  import { Skeleton } from "../Skeleton/Skeleton.js";
10
10
  import { StreamingText } from "../StreamingText/StreamingText.js";
11
+ import { Tooltip } from "../Tooltip/Tooltip.js";
11
12
  import { MOTION_FEEDBACK_RESET_MS, MOTION_SUMMARY_THINK_MS, MOTION_SUMMARY_REVEAL_MS, MOTION_HOVER_EXIT_GRACE_MS, MOTION_HOVER_SHOW_DELAY_MS } from "../../tokens/motion.js";
12
13
  import "../../behaviors/visually-hidden.css";
13
14
  import "./AiButton.css";
@@ -27,6 +28,8 @@ const AiButton = React.forwardRef(
27
28
  label = "Ask AI",
28
29
  icon = "auto_awesome",
29
30
  iconOnly = false,
31
+ tooltip,
32
+ tooltipPosition = "top",
30
33
  size = "default",
31
34
  disabled,
32
35
  state: status,
@@ -187,7 +190,7 @@ const AiButton = React.forwardRef(
187
190
  ) }),
188
191
  /* @__PURE__ */ jsx("span", { className: iconOnly ? "ds-visually-hidden" : `${baseClass}__text`, children: label })
189
192
  ] });
190
- const control = href && !disabled ? /* @__PURE__ */ jsx(
193
+ const bareControl = href && !disabled ? /* @__PURE__ */ jsx(
191
194
  Link,
192
195
  {
193
196
  ...rest,
@@ -215,6 +218,8 @@ const AiButton = React.forwardRef(
215
218
  children: content
216
219
  }
217
220
  );
221
+ const tooltipContent = !iconOnly || summary || tooltip === false ? null : tooltip ?? label;
222
+ const control = tooltipContent ? /* @__PURE__ */ jsx(Tooltip, { content: tooltipContent, position: tooltipPosition, children: bareControl }) : bareControl;
218
223
  const announcer = status !== void 0 ? /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", role: "status", children: { ...DEFAULT_STATUS_LABELS, ...statusLabels }[status] }) : null;
219
224
  const requestPanel = request ? /* @__PURE__ */ jsx(
220
225
  "aside",
@@ -5,9 +5,35 @@ export interface AnchorNavItem {
5
5
  /** Link text */
6
6
  label: string;
7
7
  }
8
+ /** Where `fromHeadings` (and `useHeadingItems`) look for the page's sections. */
9
+ export interface AnchorNavHeadingSource {
10
+ /** A selector for the element whose headings are listed. Defaults to `main`. */
11
+ root?: string;
12
+ /** Which headings count as sections. Defaults to `h2`. */
13
+ selector?: string;
14
+ /** List nothing until at least this many sections are found, since a rail of one link is no help. Defaults to 2. */
15
+ minItems?: number;
16
+ }
17
+ /**
18
+ * The sections of the page, read from its headings: every match of
19
+ * `selector` under `root`, in document order, skipping any inside an
20
+ * `aside` or a `[data-anchor-ignore]` region (a sidebar's headings, or a
21
+ * demo's). A heading's id is its own, else its enclosing section's, else
22
+ * one made from its text and written onto it. Re-reads when the content
23
+ * under `root` changes, so streamed or late content joins the list.
24
+ * Returns an empty list until `minItems` sections are found.
25
+ */
26
+ export declare function useHeadingItems(source: AnchorNavHeadingSource | undefined): AnchorNavItem[];
8
27
  type AnchorNavOwnProps = {
9
- /** The on-page sections to list, in document order */
10
- items: AnchorNavItem[];
28
+ /** The on-page sections to list, in document order. Leave it out and pass `fromHeadings` to read them from the page. */
29
+ items?: AnchorNavItem[];
30
+ /**
31
+ * Read the sections from the page's headings instead of listing them:
32
+ * `{}` lists every `h2` in `main`, and `root`, `selector` and `minItems`
33
+ * narrow it. Ignored when `items` is passed. Renders nothing until enough
34
+ * sections are found.
35
+ */
36
+ fromHeadings?: AnchorNavHeadingSource;
11
37
  /** Visual form: `list` renders the inline "On this page" rail; `floating` collapses to a stack of short lines that expands into a panel on hover, keyboard focus, or tap, so it can ride a page edge without taking column width */
12
38
  variant?: 'list' | 'floating';
13
39
  /**
@@ -21,7 +47,7 @@ type AnchorNavOwnProps = {
21
47
  activeId?: string;
22
48
  /** Fires when the tracked (or clicked) active item changes */
23
49
  onActiveChange?: (id: string) => void;
24
- /** Distance in px from the viewport top at which a section counts as current, e.g. a sticky header's height */
50
+ /** Distance in px from the viewport top at which a section counts as current, e.g. a sticky header's height. A heading with a larger `scroll-margin-top` counts from there, so a jump to it always marks it. */
25
51
  offset?: number;
26
52
  };
27
53
  export interface AnchorNavProps extends AnchorNavOwnProps, Omit<React.ComponentPropsWithoutRef<'nav'>, keyof AnchorNavOwnProps> {
@@ -1,13 +1,62 @@
1
1
  "use client";
2
2
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
3
- import React, { useRef, useImperativeHandle, useState, useCallback, useEffect } from "react";
3
+ import React, { useRef, useImperativeHandle, useState, useEffect, useCallback } from "react";
4
4
  import { useLayer } from "../../behaviors/useLayer.js";
5
+ import { headingSlug } from "../../behaviors/headingSlug.js";
5
6
  import "./AnchorNav.css";
6
7
  import "../../behaviors/direction.css";
7
8
  import { mirrorClass } from "../../behaviors/direction.js";
9
+ const headingText = (heading) => {
10
+ const copy = heading.cloneNode(true);
11
+ copy.querySelectorAll('.ds-heading__anchor, .ds-section-title__anchor, [aria-hidden="true"]').forEach((el) => el.remove());
12
+ return (copy.textContent ?? "").trim();
13
+ };
14
+ const slug = (text) => headingSlug(text);
15
+ function useHeadingItems(source) {
16
+ const [items, setItems] = useState([]);
17
+ const root = source?.root ?? "main";
18
+ const selector = source?.selector ?? "h2";
19
+ const minItems = source?.minItems ?? 2;
20
+ const enabled = source !== void 0;
21
+ useEffect(() => {
22
+ if (!enabled) return;
23
+ const container = document.querySelector(root);
24
+ const scan = () => {
25
+ const used = /* @__PURE__ */ new Set();
26
+ const found = [];
27
+ for (const heading of container?.querySelectorAll(selector) ?? []) {
28
+ if (heading.closest("aside, [data-anchor-ignore]")) continue;
29
+ const label = headingText(heading);
30
+ if (!label) continue;
31
+ let id = heading.id || heading.closest("section[id]")?.id || "";
32
+ if (!id) {
33
+ const base = slug(label) || "section";
34
+ id = base;
35
+ let n = 2;
36
+ while (used.has(id) || document.getElementById(id)) id = `${base}-${n++}`;
37
+ heading.id = id;
38
+ }
39
+ if (used.has(id)) continue;
40
+ used.add(id);
41
+ found.push({ id, label });
42
+ }
43
+ const next = found.length >= minItems ? found : [];
44
+ setItems(
45
+ (prev) => prev.length === next.length && prev.every((p, i) => p.id === next[i].id && p.label === next[i].label) ? prev : next
46
+ );
47
+ };
48
+ scan();
49
+ if (!container) return;
50
+ const observer = new MutationObserver(scan);
51
+ observer.observe(container, { childList: true, subtree: true, characterData: true });
52
+ return () => observer.disconnect();
53
+ }, [enabled, root, selector, minItems]);
54
+ return items;
55
+ }
8
56
  const AnchorNav = React.forwardRef(
9
57
  ({
10
- items,
58
+ items: itemsProp,
59
+ fromHeadings,
11
60
  variant = "list",
12
61
  title = "On this page",
13
62
  icon = "toc",
@@ -20,13 +69,17 @@ const AnchorNav = React.forwardRef(
20
69
  }, ref) => {
21
70
  const navRef = useRef(null);
22
71
  useImperativeHandle(ref, () => navRef.current);
72
+ const discovered = useHeadingItems(itemsProp ? void 0 : fromHeadings);
73
+ const items = itemsProp ?? discovered;
23
74
  const floating = variant === "floating";
24
75
  const [open, setOpen] = useState(false);
25
76
  const isControlled = activeId !== void 0;
26
77
  const [trackedId, setTrackedId] = useState(void 0);
27
78
  const currentId = isControlled ? activeId : trackedId;
28
79
  const onActiveChangeRef = useRef(onActiveChange);
29
- onActiveChangeRef.current = onActiveChange;
80
+ useEffect(() => {
81
+ onActiveChangeRef.current = onActiveChange;
82
+ });
30
83
  const setActive = useCallback(
31
84
  (id) => {
32
85
  setTrackedId((prev) => {
@@ -36,6 +89,7 @@ const AnchorNav = React.forwardRef(
36
89
  },
37
90
  []
38
91
  );
92
+ const pressedRef = useRef(void 0);
39
93
  useEffect(() => {
40
94
  if (isControlled || items.length === 0) return;
41
95
  let frame = 0;
@@ -45,7 +99,14 @@ const AnchorNav = React.forwardRef(
45
99
  for (const item of items) {
46
100
  const el = document.getElementById(item.id);
47
101
  if (!el) continue;
48
- if (el.getBoundingClientRect().top <= offset + 1) current = item.id;
102
+ const margin = parseFloat(getComputedStyle(el).scrollMarginTop) || 0;
103
+ if (el.getBoundingClientRect().top <= Math.max(offset, margin) + 1) current = item.id;
104
+ }
105
+ const root = document.documentElement;
106
+ if (window.innerHeight + window.scrollY >= root.scrollHeight - 2) {
107
+ const pressed = pressedRef.current ? document.getElementById(pressedRef.current) : null;
108
+ const top = pressed?.getBoundingClientRect().top;
109
+ current = pressed && top !== void 0 && top >= 0 && top < window.innerHeight ? pressedRef.current : items[items.length - 1].id;
49
110
  }
50
111
  setActive(current);
51
112
  };
@@ -93,6 +154,7 @@ const AnchorNav = React.forwardRef(
93
154
  className: item.id === currentId ? "ds-anchor-nav__link ds-anchor-nav__link--active" : "ds-anchor-nav__link",
94
155
  "aria-current": item.id === currentId ? "location" : void 0,
95
156
  onClick: (event) => {
157
+ pressedRef.current = item.id;
96
158
  if (!isControlled) setActive(item.id);
97
159
  else onActiveChangeRef.current?.(item.id);
98
160
  if (floating) {
@@ -103,6 +165,7 @@ const AnchorNav = React.forwardRef(
103
165
  children: item.label
104
166
  }
105
167
  ) }, item.id)) });
168
+ if (!itemsProp && items.length === 0) return null;
106
169
  return /* @__PURE__ */ jsx(
107
170
  "nav",
108
171
  {
@@ -133,5 +196,6 @@ const AnchorNav = React.forwardRef(
133
196
  );
134
197
  AnchorNav.displayName = "AnchorNav";
135
198
  export {
136
- AnchorNav
199
+ AnchorNav,
200
+ useHeadingItems
137
201
  };
@@ -4,6 +4,8 @@
4
4
  ============================================ */
5
5
 
6
6
  .ds-app-layout {
7
+ /* The contained width, AppLayout's own: an app's working column. */
8
+ --ds-shell-contained-width: 1120px;
7
9
  display: flex;
8
10
  min-height: 100vh;
9
11
  /* The shell recipe's plane (src/behaviors/shell.css), set per layout by
@@ -49,7 +51,9 @@
49
51
  ============================================ */
50
52
  .ds-app-layout__content {
51
53
  width: 100%;
52
- max-width: 1120px;
54
+ /* The shell recipe's width axis: the contained width, or none when full. */
55
+ max-width: var(--ds-shell-content-max, var(--ds-shell-contained-width));
56
+ margin-inline: auto;
53
57
  display: flex;
54
58
  flex-direction: column;
55
59
  gap: var(--gap-1000);
@@ -69,7 +73,7 @@
69
73
 
70
74
  /* ============================================
71
75
  INSET LAYOUT — the rail flush on the shell
72
- colour, the content full width in a surface
76
+ colour, the content in a surface
73
77
  inset from the other three edges. The page
74
78
  holds the viewport and the surface scrolls.
75
79
  The rail's own item inset is the gap on its
@@ -115,12 +119,12 @@
115
119
  scrollbar-color: var(--color-bg-container-border) transparent;
116
120
  }
117
121
 
118
- /* Full width in the surface, and a size container: content inside can
122
+ /* A size container, centred in the surface or its full width by the
123
+ width axis like every mode: content inside can
119
124
  restack by the room the surface gives it (an open chat panel or an
120
125
  expanded rail narrows it without the viewport changing) with
121
126
  @container ds-app-layout-content queries. */
122
127
  .ds-app-layout--inset .ds-app-layout__content {
123
- max-width: none;
124
128
  container: ds-app-layout-content / inline-size;
125
129
  }
126
130