rift-ds 1.32.0 → 1.34.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 (124) hide show
  1. package/README.md +4 -4
  2. package/behaviors/chat-card.css +11 -6
  3. package/behaviors/clipboard.d.ts +7 -0
  4. package/behaviors/clipboard.js +35 -0
  5. package/behaviors/headingSlug.d.ts +8 -0
  6. package/behaviors/headingSlug.js +4 -0
  7. package/behaviors/shell.css +64 -0
  8. package/behaviors/syncedChoice.d.ts +2 -0
  9. package/behaviors/syncedChoice.js +48 -0
  10. package/behaviors/useLayer.d.ts +15 -2
  11. package/behaviors/useLayer.js +3 -2
  12. package/bin/templates/blocks/app/guide/PageFeedback.tsx +55 -0
  13. package/bin/templates/blocks/app/guide/page.module.css +94 -0
  14. package/bin/templates/blocks/app/guide/page.tsx +168 -0
  15. package/bin/templates/blocks/components/blocks/AppShell.module.css +3 -1
  16. package/bin/templates/blocks/components/blocks/AppShell.tsx +8 -0
  17. package/bin/templates/blocks/components/blocks/DocsShell.module.css +18 -0
  18. package/bin/templates/blocks/components/blocks/DocsShell.tsx +179 -0
  19. package/bin/templates/blocks/registry.json +13 -0
  20. package/chat/AssistantTurn.d.ts +2 -0
  21. package/chat/AssistantTurn.js +18 -7
  22. package/chat/ChatProvider.js +14 -0
  23. package/chat/ChatWidget.css +10 -0
  24. package/chat/ChatWidget.d.ts +7 -3
  25. package/chat/ChatWidget.js +6 -3
  26. package/chat/agentState.d.ts +2 -1
  27. package/chat/agentState.js +4 -1
  28. package/chat/awaiting.d.ts +19 -0
  29. package/chat/awaiting.js +21 -0
  30. package/chat/context.d.ts +4 -0
  31. package/chat/index.d.ts +1 -0
  32. package/chat/index.js +3 -1
  33. package/chat/server.d.ts +8 -3
  34. package/chat/server.js +1 -1
  35. package/code/highlight.d.ts +4 -0
  36. package/code/highlight.js +34 -0
  37. package/code/index.d.ts +16 -0
  38. package/code/index.js +23 -0
  39. package/components/ActionCard/ActionCard.css +3 -3
  40. package/components/AgentStatus/AgentStatus.css +114 -22
  41. package/components/AgentStatus/AgentStatus.d.ts +10 -7
  42. package/components/AgentStatus/AgentStatus.js +10 -0
  43. package/components/AiButton/AiButton.d.ts +3 -3
  44. package/components/AnchorNav/AnchorNav.d.ts +29 -3
  45. package/components/AnchorNav/AnchorNav.js +69 -5
  46. package/components/AppLayout/AppLayout.css +8 -4
  47. package/components/AppLayout/AppLayout.d.ts +13 -3
  48. package/components/AppLayout/AppLayout.js +2 -0
  49. package/components/ArtifactPanel/ArtifactPanel.css +46 -0
  50. package/components/ArtifactPanel/ArtifactPanel.d.ts +14 -4
  51. package/components/ArtifactPanel/ArtifactPanel.js +8 -5
  52. package/components/BackToTop/BackToTop.css +28 -0
  53. package/components/BackToTop/BackToTop.d.ts +28 -0
  54. package/components/BackToTop/BackToTop.js +47 -0
  55. package/components/BentoTile/BentoTile.css +3 -0
  56. package/components/CodeBlock/CodeBlock.css +63 -24
  57. package/components/CodeBlock/CodeBlock.d.ts +62 -6
  58. package/components/CodeBlock/CodeBlock.js +90 -48
  59. package/components/Composer/Composer.css +14 -9
  60. package/components/Composer/Composer.d.ts +10 -8
  61. package/components/Composer/Composer.js +2 -1
  62. package/components/CopyButton/CopyButton.d.ts +42 -0
  63. package/components/CopyButton/CopyButton.js +72 -0
  64. package/components/DescriptionList/DescriptionListCopy.d.ts +2 -2
  65. package/components/DescriptionList/DescriptionListCopy.js +7 -35
  66. package/components/Figure/Figure.css +26 -0
  67. package/components/Figure/Figure.d.ts +10 -1
  68. package/components/Figure/Figure.js +15 -3
  69. package/components/Heading/Heading.css +43 -0
  70. package/components/Heading/Heading.d.ts +14 -3
  71. package/components/Heading/Heading.js +22 -4
  72. package/components/HoverCard/HoverCard.js +1 -0
  73. package/components/Link/Link.css +38 -0
  74. package/components/Link/Link.d.ts +3 -3
  75. package/components/Link/Link.js +1 -1
  76. package/components/Menubar/Menubar.css +82 -0
  77. package/components/Menubar/Menubar.d.ts +40 -0
  78. package/components/Menubar/Menubar.js +97 -0
  79. package/components/MessageCard/MessageCard.css +1 -1
  80. package/components/NavList/NavList.css +197 -0
  81. package/components/NavList/NavList.d.ts +54 -6
  82. package/components/NavList/NavList.js +136 -8
  83. package/components/Pagination/Pagination.css +80 -0
  84. package/components/Pagination/Pagination.d.ts +29 -3
  85. package/components/Pagination/Pagination.js +49 -5
  86. package/components/Rating/Rating.css +26 -0
  87. package/components/Rating/Rating.d.ts +18 -5
  88. package/components/Rating/Rating.js +16 -7
  89. package/components/SectionTitle/SectionTitle.css +36 -0
  90. package/components/SectionTitle/SectionTitle.d.ts +10 -1
  91. package/components/SectionTitle/SectionTitle.js +7 -2
  92. package/components/ShaderScene/ShaderScene.d.ts +2 -1
  93. package/components/ShaderScene/ShaderScene.js +20 -2
  94. package/components/SiteFooter/SiteFooter.css +157 -0
  95. package/components/SiteFooter/SiteFooter.d.ts +53 -0
  96. package/components/SiteFooter/SiteFooter.js +61 -0
  97. package/components/SiteHeader/SiteHeader.css +106 -4
  98. package/components/SiteHeader/SiteHeader.d.ts +25 -2
  99. package/components/SiteHeader/SiteHeader.js +46 -8
  100. package/components/SiteLayout/SiteLayout.css +361 -0
  101. package/components/SiteLayout/SiteLayout.d.ts +103 -0
  102. package/components/SiteLayout/SiteLayout.js +68 -0
  103. package/components/SourceTrail/SourceTrail.css +1 -1
  104. package/components/Table/Table.css +14 -0
  105. package/components/Table/Table.d.ts +2 -0
  106. package/components/Table/Table.js +1 -1
  107. package/components/ToolCall/ToolCall.css +2 -2
  108. package/components/Tooltip/Tooltip.js +1 -0
  109. package/components/UsageCard/UsageCard.css +4 -3
  110. package/components/keyboard-patterns.json.d.ts +57 -0
  111. package/components/keyboard-patterns.json.js +1 -1
  112. package/components/registry.json +89 -19
  113. package/components/registry.json.d.ts +89 -19
  114. package/components/registry.json.js +1 -1
  115. package/index.d.ts +5 -0
  116. package/index.js +14 -1
  117. package/package.json +14 -2
  118. package/tokens/breakpoints.js +3 -3
  119. package/tokens/registry.json +5 -0
  120. package/tokens/registry.json.d.ts +5 -0
  121. package/tokens/registry.json.js +1 -1
  122. package/tokens/tokens-dark.css +12 -0
  123. package/tokens/tokens-light.css +12 -0
  124. package/tokens/values.json.js +1 -1
@@ -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
+ };
@@ -7,9 +7,9 @@
7
7
 
8
8
  A content card of the chat furniture: the
9
9
  container fill behind its border, at the
10
- ArtifactCard's radius, with a bubble's
11
- padding so its text starts where the
12
- reply's own text does.
10
+ ArtifactCard's radius, with the recipe's
11
+ edge and inset as its padding so its text
12
+ starts where the reply's own text does.
13
13
  ============================================ */
14
14
 
15
15
  .ds-action-card {
@@ -192,18 +192,7 @@
192
192
  --ds-agent-label-color: var(--color-status-error-text);
193
193
  }
194
194
 
195
- /* Terminal states fill the matrix solid, so the shape itself reads as
196
- finished, and twinkle: one or two dots at a time dip and return, so the
197
- finished mark stays alive without drawing the eye. The doubled class and
198
- :nth-child(n) lift the rule over every pattern's dark-dot opt-outs, so
199
- the whole matrix twinkles whatever the pattern. */
200
- .ds-agent-status.ds-agent-status--done .ds-agent-status__dot:nth-child(n),
201
- .ds-agent-status.ds-agent-status--error .ds-agent-status__dot:nth-child(n) {
202
- opacity: 1;
203
- transform: none;
204
- animation: ds-agent-dot-twinkle var(--ds-agent-twinkle-cycle) var(--motion-ease-standard) infinite;
205
- animation-delay: calc(var(--ds-agent-twinkle-step, 0) * var(--ds-agent-twinkle-slot));
206
- }
195
+ /* What the matrix draws once a run ends or waits is in GLYPHS, below. */
207
196
 
208
197
  /* ============================================
209
198
  SIZES
@@ -574,7 +563,7 @@
574
563
  animation-delay: calc(var(--ds-agent-twinkle-step, 0) * var(--ds-agent-twinkle-slot));
575
564
  }
576
565
 
577
- /* The twinkle's scatter, shared by the pattern and the finished states */
566
+ /* The twinkle pattern's scatter */
578
567
  .ds-agent-status__dot:nth-child(1) { --ds-agent-twinkle-step: 7; }
579
568
  .ds-agent-status__dot:nth-child(2) { --ds-agent-twinkle-step: 2; }
580
569
  .ds-agent-status__dot:nth-child(3) { --ds-agent-twinkle-step: 10; }
@@ -653,15 +642,6 @@
653
642
  --ds-agent-color: var(--color-status-error-icon);
654
643
  }
655
644
 
656
- /* Finished: solid and twinkling, as AgentStatus's matrix does. */
657
- .ds-agent-status-mark.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(n),
658
- .ds-agent-status-mark.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(n) {
659
- opacity: 1;
660
- transform: none;
661
- animation: ds-agent-dot-twinkle var(--ds-agent-twinkle-cycle) var(--motion-ease-standard) infinite;
662
- animation-delay: calc(var(--ds-agent-twinkle-step, 0) * var(--ds-agent-twinkle-slot));
663
- }
664
-
665
645
  .ds-agent-status-mark--animated .ds-agent-status-mark__dot {
666
646
  animation: ds-agent-dot var(--ds-agent-cycle) var(--motion-ease-standard) infinite;
667
647
  animation-delay: calc(var(--ds-agent-step, 0) * var(--ds-agent-slot));
@@ -1107,6 +1087,116 @@
1107
1087
  }
1108
1088
  }
1109
1089
 
1090
+ /* ============================================
1091
+ GLYPHS
1092
+ The three states that ask something of the
1093
+ reader each resolve the matrix into a mark of
1094
+ their own, so the shape says which one it is
1095
+ before the colour or the label does:
1096
+
1097
+ done error waiting
1098
+ . . . o o . . o o . . .
1099
+ o . o . . o o . . o . .
1100
+ . o . . o . . o o . o o
1101
+
1102
+ a tick, a cross, and a prompt whose cursor
1103
+ breathes. The mark's square grid draws the same
1104
+ three with a row to spare. Each is drawn in
1105
+ stroke order, one dot a slot, then holds. The
1106
+ doubled class and :nth-child(n) lift these
1107
+ rules over every pattern's own, so a finished
1108
+ matrix draws its glyph whatever pattern ran.
1109
+ Waiting draws the prompt on its default pattern
1110
+ only: a pattern asked for by name still runs.
1111
+ ============================================ */
1112
+
1113
+ .ds-agent-status--waiting.ds-agent-status--breathe,
1114
+ .ds-agent-status-mark--waiting.ds-agent-status-mark--breathe {
1115
+ /* The glyph is the signal now, so the unlit dots fall back to the
1116
+ working floor and the prompt stands clear of them. */
1117
+ --ds-agent-dot-dim: 0.2;
1118
+ }
1119
+
1120
+ .ds-agent-status.ds-agent-status--done .ds-agent-status__dot:nth-child(n),
1121
+ .ds-agent-status.ds-agent-status--error .ds-agent-status__dot:nth-child(n),
1122
+ .ds-agent-status.ds-agent-status--waiting.ds-agent-status--breathe .ds-agent-status__dot:nth-child(n),
1123
+ .ds-agent-status-mark.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(n),
1124
+ .ds-agent-status-mark.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(n),
1125
+ .ds-agent-status-mark.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe .ds-agent-status-mark__dot:nth-child(n) {
1126
+ opacity: var(--ds-agent-dot-dim);
1127
+ transform: scale(var(--ds-agent-dot-rest));
1128
+ animation: none;
1129
+ }
1130
+
1131
+ .ds-agent-status.ds-agent-status--done .ds-agent-status__dot:is(:nth-child(4), :nth-child(5), :nth-child(7), :nth-child(10)),
1132
+ .ds-agent-status.ds-agent-status--error .ds-agent-status__dot:is(:nth-child(1), :nth-child(4), :nth-child(6), :nth-child(7), :nth-child(9), :nth-child(12)),
1133
+ .ds-agent-status.ds-agent-status--waiting.ds-agent-status--breathe .ds-agent-status__dot:is(:nth-child(1), :nth-child(6), :nth-child(9)),
1134
+ .ds-agent-status-mark.ds-agent-status-mark--done .ds-agent-status-mark__dot:is(:nth-child(8), :nth-child(9), :nth-child(11), :nth-child(14)),
1135
+ .ds-agent-status-mark.ds-agent-status-mark--error .ds-agent-status-mark__dot:is(:nth-child(1), :nth-child(4), :nth-child(6), :nth-child(7), :nth-child(10), :nth-child(11), :nth-child(13), :nth-child(16)),
1136
+ .ds-agent-status-mark.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe .ds-agent-status-mark__dot:is(:nth-child(1), :nth-child(6), :nth-child(9)) {
1137
+ opacity: 1;
1138
+ transform: none;
1139
+ animation: var(--ds-agent-glyph-draw, none) var(--motion-duration-slow) var(--motion-ease-entrance) backwards;
1140
+ animation-delay: calc(var(--ds-agent-glyph-step, 0) * var(--ds-agent-slot));
1141
+ }
1142
+
1143
+ /* The stroke-by-stroke draw runs only when the indicator reaches its state
1144
+ while on screen. One that mounts already there shows the glyph standing. */
1145
+ .ds-agent-status--arrived,
1146
+ .ds-agent-status-mark--arrived {
1147
+ --ds-agent-glyph-draw: ds-agent-dot-draw;
1148
+ }
1149
+
1150
+ /* The prompt's cursor: the two dots after the chevron, breathing. */
1151
+ .ds-agent-status.ds-agent-status--waiting.ds-agent-status--breathe .ds-agent-status__dot:is(:nth-child(11), :nth-child(12)),
1152
+ .ds-agent-status-mark.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe .ds-agent-status-mark__dot:is(:nth-child(15), :nth-child(16)) {
1153
+ animation: ds-agent-dot-breathe var(--ds-agent-cycle) var(--motion-ease-standard) infinite;
1154
+ }
1155
+
1156
+ /* Stroke order. The tick runs down its short arm and up its long one; the
1157
+ cross draws one stroke, then the other; the chevron runs top to bottom. */
1158
+ .ds-agent-status--done .ds-agent-status__dot:nth-child(5) { --ds-agent-glyph-step: 0; }
1159
+ .ds-agent-status--done .ds-agent-status__dot:nth-child(10) { --ds-agent-glyph-step: 1; }
1160
+ .ds-agent-status--done .ds-agent-status__dot:nth-child(7) { --ds-agent-glyph-step: 2; }
1161
+ .ds-agent-status--done .ds-agent-status__dot:nth-child(4) { --ds-agent-glyph-step: 3; }
1162
+ .ds-agent-status--error .ds-agent-status__dot:nth-child(1) { --ds-agent-glyph-step: 0; }
1163
+ .ds-agent-status--error .ds-agent-status__dot:nth-child(6) { --ds-agent-glyph-step: 1; }
1164
+ .ds-agent-status--error .ds-agent-status__dot:nth-child(12) { --ds-agent-glyph-step: 2; }
1165
+ .ds-agent-status--error .ds-agent-status__dot:nth-child(4) { --ds-agent-glyph-step: 3; }
1166
+ .ds-agent-status--error .ds-agent-status__dot:nth-child(7) { --ds-agent-glyph-step: 4; }
1167
+ .ds-agent-status--error .ds-agent-status__dot:nth-child(9) { --ds-agent-glyph-step: 5; }
1168
+ .ds-agent-status--waiting .ds-agent-status__dot:nth-child(1) { --ds-agent-glyph-step: 0; }
1169
+ .ds-agent-status--waiting .ds-agent-status__dot:nth-child(6) { --ds-agent-glyph-step: 1; }
1170
+ .ds-agent-status--waiting .ds-agent-status__dot:nth-child(9) { --ds-agent-glyph-step: 2; }
1171
+
1172
+ .ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(9) { --ds-agent-glyph-step: 0; }
1173
+ .ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(14) { --ds-agent-glyph-step: 1; }
1174
+ .ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(11) { --ds-agent-glyph-step: 2; }
1175
+ .ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(8) { --ds-agent-glyph-step: 3; }
1176
+ .ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(1) { --ds-agent-glyph-step: 0; }
1177
+ .ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(6) { --ds-agent-glyph-step: 1; }
1178
+ .ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(11) { --ds-agent-glyph-step: 2; }
1179
+ .ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(16) { --ds-agent-glyph-step: 3; }
1180
+ .ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(4) { --ds-agent-glyph-step: 4; }
1181
+ .ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(7) { --ds-agent-glyph-step: 5; }
1182
+ .ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(10) { --ds-agent-glyph-step: 6; }
1183
+ .ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(13) { --ds-agent-glyph-step: 7; }
1184
+ .ds-agent-status-mark--waiting .ds-agent-status-mark__dot:nth-child(1) { --ds-agent-glyph-step: 0; }
1185
+ .ds-agent-status-mark--waiting .ds-agent-status-mark__dot:nth-child(6) { --ds-agent-glyph-step: 1; }
1186
+ .ds-agent-status-mark--waiting .ds-agent-status-mark__dot:nth-child(9) { --ds-agent-glyph-step: 2; }
1187
+
1188
+ @keyframes ds-agent-dot-draw {
1189
+ from {
1190
+ opacity: var(--ds-agent-dot-dim);
1191
+ transform: scale(var(--ds-agent-dot-rest));
1192
+ }
1193
+
1194
+ 60% {
1195
+ opacity: 1;
1196
+ transform: scale(1.2);
1197
+ }
1198
+ }
1199
+
1110
1200
  /* ============================================
1111
1201
  REDUCED MOTION
1112
1202
  The global guard collapses every animation to
@@ -1121,6 +1211,8 @@
1121
1211
  .ds-agent-status.ds-agent-status--error .ds-agent-status__dot:nth-child(n),
1122
1212
  .ds-agent-status-mark.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(n),
1123
1213
  .ds-agent-status-mark.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(n),
1214
+ .ds-agent-status.ds-agent-status--waiting.ds-agent-status--breathe .ds-agent-status__dot:nth-child(n),
1215
+ .ds-agent-status-mark.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe .ds-agent-status-mark__dot:nth-child(n),
1124
1216
  .ds-agent-status--animated.ds-agent-status--twinkle .ds-agent-status__dot:nth-child(n),
1125
1217
  .ds-agent-status-mark--animated.ds-agent-status-mark--twinkle .ds-agent-status-mark__dot:nth-child(n) {
1126
1218
  animation: none;
@@ -2,11 +2,11 @@ import { default as React } from 'react';
2
2
  import { AgentStatusPattern, AgentStatusState } from './AgentStatusPatterns';
3
3
  /** Props owned by AgentStatus itself — everything else falls through to the root element. */
4
4
  type AgentStatusOwnProps = {
5
- /** What the agent is doing. Drives the colour, the default label, and whether the matrix animates. */
5
+ /** What the agent is doing. Drives the colour, the default label, and whether the matrix animates. `waiting` takes the warning status colour, `done` the positive one (with a tick) and `error` the error one (with a cross); the other three stay monochrome. */
6
6
  state?: AgentStatusState;
7
7
  /** Status text. Falls back to a default for the state. Ignored when `children` are given. */
8
8
  label?: string;
9
- /** Which dot-matrix choreography to run. Defaults to `breathe` while `waiting`, a still pulse that reads as the person's turn (the same as AgentStatusMark), and `orbit` otherwise. */
9
+ /** Which dot-matrix choreography to run while the agent is active. Defaults to `orbit`. `waiting` with no pattern draws its glyph instead, a prompt whose cursor breathes (the same as AgentStatusMark); `done` and `error` draw a tick and a cross whatever the pattern. */
10
10
  pattern?: AgentStatusPattern;
11
11
  /**
12
12
  * Sweep a highlight across the label while the agent is active. Defaults to
@@ -22,8 +22,9 @@ type AgentStatusOwnProps = {
22
22
  /**
23
23
  * `inline` sits in a line of content; `bar` is a full-width row for the
24
24
  * top of a panel; `pill` is a glass pill for a status that floats over
25
- * the page while a run goes on; once it ends the dots fill solid in the
26
- * status colour, as in every variant. The pill does not position itself.
25
+ * the page while a run goes on; once it ends the dots draw a tick or a
26
+ * cross in the status colour, as in every variant. The pill does not
27
+ * position itself.
27
28
  */
28
29
  variant?: 'inline' | 'bar' | 'pill';
29
30
  /** A trailing control after the status text, such as a link that opens the run. Meant for the `pill` and `bar` variants. */
@@ -41,6 +42,8 @@ export interface AgentStatusProps extends AgentStatusOwnProps, Omit<React.Compon
41
42
  *
42
43
  * Colour carries meaning rather than decoration — the three working states are
43
44
  * monochrome, and only `waiting`, `done` and `error` take a status colour.
45
+ * Those three also resolve the matrix into a glyph of their own (a prompt, a
46
+ * tick, a cross), so the shape says which it is before the colour does.
44
47
  * The whole thing is one polite live region, so a screen reader hears the state
45
48
  * change without the caller wiring anything up.
46
49
  */
@@ -49,7 +52,7 @@ export declare const AgentStatus: React.ForwardRefExoticComponent<AgentStatusPro
49
52
  type AgentStatusMarkOwnProps = {
50
53
  /** What the agent is doing. Drives the colour and whether the dots animate, as on AgentStatus. Defaults to `working`, unlike AgentStatus's `thinking`: the mark stands in for an icon on a control (AiButton's, a pill's), where the commonest moment it is drawn is a run under way, while the labelled AgentStatus most often opens a reply. */
51
54
  state?: AgentStatusState;
52
- /** Which choreography to run: every AgentStatus pattern, redrawn for the square grid. Defaults to `breathe` while `waiting`, a still pulse that reads as the person's turn, and `orbit` otherwise. */
55
+ /** Which choreography to run while the agent is active: every AgentStatus pattern, redrawn for the square grid. Defaults to `orbit`. `waiting` with no pattern draws its glyph instead, a prompt whose cursor breathes; `done` and `error` draw a tick and a cross whatever the pattern. */
53
56
  pattern?: AgentStatusPattern;
54
57
  /** Additional CSS classes */
55
58
  className?: string;
@@ -61,8 +64,8 @@ export interface AgentStatusMarkProps extends AgentStatusMarkOwnProps, Omit<Reac
61
64
  * by `--icon-size`, drawn inside a Material Symbol's live area, so it swaps
62
65
  * with a glyph without moving or outgrowing it. Every AgentStatus pattern
63
66
  * runs on it, redrawn for the square, in AgentStatus's cycle and colours;
64
- * orbit is the default, and breathe while waiting. AiButton's status is
65
- * the first host.
67
+ * orbit is the default, and waiting, done and error draw AgentStatus's
68
+ * three glyphs. AiButton's status is the first host.
66
69
  * Hidden from assistive technology; the host announces the state.
67
70
  */
68
71
  export declare const AgentStatusMark: React.ForwardRefExoticComponent<AgentStatusMarkProps & React.RefAttributes<HTMLSpanElement>>;
@@ -11,6 +11,12 @@ const DEFAULT_LABELS = {
11
11
  done: "Done",
12
12
  error: "Failed"
13
13
  };
14
+ function useArrived(state) {
15
+ const [initial] = useState(state);
16
+ const [arrived, setArrived] = useState(false);
17
+ if (!arrived && state !== initial) setArrived(true);
18
+ return arrived;
19
+ }
14
20
  const ACTIVE_STATES = ["thinking", "working", "waiting"];
15
21
  const AgentStatus = React.forwardRef(
16
22
  ({
@@ -26,6 +32,7 @@ const AgentStatus = React.forwardRef(
26
32
  ...rest
27
33
  }, ref) => {
28
34
  const baseClass = "ds-agent-status";
35
+ const arrived = useArrived(state);
29
36
  const isActive = ACTIVE_STATES.includes(state);
30
37
  const isShimmering = shimmer ?? isActive;
31
38
  const resolvedSize = size === "sm" ? "compact" : size === "md" ? "default" : size;
@@ -47,6 +54,7 @@ const AgentStatus = React.forwardRef(
47
54
  `${baseClass}--${resolvedSize}`,
48
55
  `${baseClass}--${variant}`,
49
56
  isActive ? `${baseClass}--animated` : "",
57
+ arrived ? `${baseClass}--arrived` : "",
50
58
  className
51
59
  ].filter(Boolean).join(" ");
52
60
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, role: "status", children: [
@@ -87,11 +95,13 @@ const MARK_DOT_COUNT = 16;
87
95
  const AgentStatusMark = React.forwardRef(
88
96
  ({ state = "working", pattern, className = "", ...rest }, ref) => {
89
97
  const baseClass = "ds-agent-status-mark";
98
+ const arrived = useArrived(state);
90
99
  const classes = [
91
100
  baseClass,
92
101
  `${baseClass}--${state}`,
93
102
  `${baseClass}--${pattern ?? (state === "waiting" ? "breathe" : "orbit")}`,
94
103
  ACTIVE_STATES.includes(state) ? `${baseClass}--animated` : "",
104
+ arrived ? `${baseClass}--arrived` : "",
95
105
  className
96
106
  ].filter(Boolean).join(" ");
97
107
  return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", ...rest, ref, className: classes, children: Array.from({ length: MARK_DOT_COUNT }, (_, i) => /* @__PURE__ */ jsx("span", { className: `${baseClass}__dot` }, i)) });
@@ -40,9 +40,9 @@ type AiButtonOwnProps = {
40
40
  * What the agent behind the button is doing, in AgentStatus's vocabulary.
41
41
  * The label never changes; the icon carries the state. `thinking` and
42
42
  * `working` show AgentStatusMark and spin the ring faster, `waiting` shows
43
- * the mark breathing in the warning colour with the ring at rest, and `done` and
44
- * `error` turn the button to their status colours with the mark filled
45
- * solid in the status colour, then return to the resting look after a
43
+ * the mark's prompt glyph in the warning colour with the ring at rest, and `done` and
44
+ * `error` turn the button to their status colours with the mark drawing a
45
+ * tick or a cross in the status colour, then return to the resting look after a
46
46
  * beat. The button stays clickable throughout, unlike Button's
47
47
  * `loading`, so a click can open the conversation to watch the work.
48
48
  */
@@ -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
 
@@ -29,11 +29,21 @@ type AppLayoutOwnProps = {
29
29
  * colour behind a hairline, the content centred beside it on the crisp
30
30
  * app surface, nothing raised. `floating` floats the rail as a glass card,
31
31
  * the content still centred. `inset` runs the rail flush on the shell
32
- * colour and sets the content full width in a raised surface (hairline
33
- * and floating shadow) inset from the other edges, which scrolls inside
34
- * itself.
32
+ * colour and sets the content in a raised surface (hairline and floating
33
+ * shadow) inset from the other edges, which scrolls inside itself. How
34
+ * wide the content runs is `width`, apart from the mode.
35
35
  */
36
36
  layout?: AppSidebarLayout;
37
+ /**
38
+ * How wide the content runs, in any `layout`: `contained` centres it at
39
+ * the contained width (1120px here, or `--ds-shell-contained-width` set
40
+ * on the layout); `full` runs it the whole width the mode leaves it. An
41
+ * app's working column, so it takes none of SiteLayout's site-scale
42
+ * `containedWidth` steps. `inset` no longer forces full width, as it did
43
+ * up to 1.32: pass `width="full"` for that edge-to-edge inset.
44
+ * @default 'contained'
45
+ */
46
+ width?: 'contained' | 'full';
37
47
  /**
38
48
  * Colour scheme: 'dark' pins the layout to the dark theme (the historical
39
49
  * behaviour and the default); 'inherit' drops the pin so the layout
@@ -18,6 +18,7 @@ const AppLayout = React.forwardRef(
18
18
  logo,
19
19
  children,
20
20
  layout = "flush",
21
+ width = "contained",
21
22
  theme = "dark",
22
23
  linkComponent,
23
24
  className = "",
@@ -52,6 +53,7 @@ const AppLayout = React.forwardRef(
52
53
  className: classes,
53
54
  ...theme === "dark" ? { "data-theme": "dark" } : {},
54
55
  "data-ds-shell": layout,
56
+ "data-ds-width": width,
55
57
  children: [
56
58
  /* @__PURE__ */ jsx(
57
59
  AppSidebar,
@@ -157,3 +157,49 @@
157
157
  min-height: 0;
158
158
  border: none;
159
159
  }
160
+
161
+ /* ============================================
162
+ INLINE (layout="inline")
163
+ A live example in the flow of a page: its own card on the
164
+ container fill, sized by what it shows. The preview is a stage
165
+ with the content centred and room around it; the code view is
166
+ the CodeBlock flush against the card, its own border dropped so
167
+ the two edges never double.
168
+ ============================================ */
169
+
170
+ .ds-artifact-panel--inline {
171
+ height: auto;
172
+ border: var(--border-025) solid var(--color-bg-container-border);
173
+ border-radius: var(--radius-300);
174
+ background-color: var(--color-bg-container-primary);
175
+ overflow: hidden;
176
+ }
177
+
178
+ .ds-artifact-panel--inline .ds-artifact-panel__header {
179
+ border-block-end: var(--border-025) solid var(--color-bg-container-border);
180
+ }
181
+
182
+ .ds-artifact-panel--inline .ds-artifact-panel__content {
183
+ display: flex;
184
+ flex-wrap: wrap;
185
+ align-items: center;
186
+ justify-content: center;
187
+ gap: var(--gap-400);
188
+ min-height: var(--ds-artifact-panel-stage-height, calc(6 * var(--control-height-default)));
189
+ padding: var(--padding-1000) var(--padding-500);
190
+ box-sizing: border-box;
191
+ }
192
+
193
+ .ds-artifact-panel--inline .ds-artifact-panel__code {
194
+ padding: 0;
195
+ max-height: var(--ds-artifact-panel-code-height, calc(12 * var(--control-height-default)));
196
+ }
197
+
198
+ .ds-artifact-panel--inline .ds-code-block {
199
+ border: none;
200
+ border-radius: 0;
201
+ }
202
+
203
+ .ds-artifact-panel--inline .ds-artifact-panel__frame {
204
+ min-height: var(--ds-artifact-panel-stage-height, calc(6 * var(--control-height-default)));
205
+ }