rift-ds 1.30.0 → 1.32.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 (162) hide show
  1. package/README.md +6 -4
  2. package/behaviors/chat-card.css +4 -1
  3. package/behaviors/deferComponent.d.ts +43 -0
  4. package/behaviors/deferComponent.js +35 -0
  5. package/behaviors/locale.d.ts +7 -0
  6. package/behaviors/locale.js +5 -0
  7. package/behaviors/shell.css +33 -0
  8. package/bin/rift-ds.mjs +35 -9
  9. package/bin/templates/blocks/app/planner/PlannerGrid.tsx +58 -0
  10. package/bin/templates/blocks/app/planner/Requests.tsx +42 -0
  11. package/bin/templates/blocks/app/planner/page.module.css +17 -0
  12. package/bin/templates/blocks/app/planner/page.tsx +32 -0
  13. package/bin/templates/blocks/components/blocks/AppShell.module.css +10 -1
  14. package/bin/templates/blocks/registry.json +14 -0
  15. package/bin/templates/chat/app/api/chat/route.actions.ts +108 -0
  16. package/bin/templates/chat/components/chat/ChatMount.actions.tsx +55 -0
  17. package/bin/templates/chat/components/chat/ChatMount.tsx +14 -1
  18. package/bin/templates/chat/components/chat/proposals/ProposalCard.tsx +81 -0
  19. package/bin/templates/chat/components/chat/proposals/actions.ts +60 -0
  20. package/bin/templates/chat/components/chat/proposals/confirmation.ts +9 -0
  21. package/bin/templates/chat/components/chat/proposals/renderers.tsx +9 -0
  22. package/chat/ChatLauncher.d.ts +13 -2
  23. package/chat/ChatLauncher.js +52 -29
  24. package/chat/ChatProvider.d.ts +19 -2
  25. package/chat/ChatProvider.js +26 -3
  26. package/chat/ChatWidget.css +23 -4
  27. package/chat/ChatWidget.d.ts +2 -1
  28. package/chat/ChatWidget.js +23 -21
  29. package/chat/actions.d.ts +52 -6
  30. package/chat/actions.js +53 -5
  31. package/chat/contextSchema.d.ts +76 -0
  32. package/chat/contextSchema.js +58 -0
  33. package/chat/deferredChatWidget.d.ts +10 -0
  34. package/chat/deferredChatWidget.js +10 -0
  35. package/chat/index.d.ts +3 -2
  36. package/chat/index.js +7 -1
  37. package/chat/registry.json.d.ts +4 -3
  38. package/chat/registry.json.js +1 -1
  39. package/chat/server.d.ts +18 -2
  40. package/chat/server.js +10 -1
  41. package/chat/suggestions.d.ts +7 -0
  42. package/chat/suggestions.js +13 -1
  43. package/chat/types.d.ts +23 -0
  44. package/chat/useChat.d.ts +2 -2
  45. package/chat/useChat.js +15 -1
  46. package/components/Accordion/Accordion.css +8 -0
  47. package/components/AgentPlan/AgentPlan.css +8 -0
  48. package/components/AgentRail/AgentRail.css +3 -3
  49. package/components/AiButton/AiButton.css +19 -0
  50. package/components/AiButton/AiButton.d.ts +10 -1
  51. package/components/AiButton/AiButton.js +6 -1
  52. package/components/AppSidebar/AppSidebar.css +12 -0
  53. package/components/ArtifactPanel/ArtifactPanel.js +5 -5
  54. package/components/Attachment/AttachmentViewer.js +7 -7
  55. package/components/BentoTile/BentoTile.css +1 -1
  56. package/components/BentoTile/BentoTile.js +5 -5
  57. package/components/Button/Button.css +28 -1
  58. package/components/Button/Button.d.ts +7 -2
  59. package/components/Button/Button.js +7 -3
  60. package/components/ButtonGroup/ButtonGroup.css +10 -1
  61. package/components/Chart/RadarChart.js +24 -10
  62. package/components/ChatHeader/ChatHeader.d.ts +1 -1
  63. package/components/ChatThread/ChatThread.css +1 -1
  64. package/components/Chip/Chip.css +26 -0
  65. package/components/CircularButton/CircularButton.d.ts +16 -96
  66. package/components/CircularButton/CircularButton.js +11 -94
  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/DataTable/DataTable.css +19 -4
  77. package/components/DataTable/DataTable.d.ts +14 -2
  78. package/components/DataTable/DataTable.js +28 -17
  79. package/components/DataTable/periodColumns.d.ts +37 -0
  80. package/components/DataTable/periodColumns.js +48 -0
  81. package/components/DateInput/DateInput.css +20 -0
  82. package/components/DatePicker/DatePicker.css +22 -6
  83. package/components/DatePicker/DatePicker.d.ts +2 -1
  84. package/components/DatePicker/DatePicker.js +2 -2
  85. package/components/DateRangePicker/DateRangePicker.js +2 -2
  86. package/components/DecisionRow/DecisionRow.css +46 -0
  87. package/components/DecisionRow/DecisionRow.d.ts +62 -0
  88. package/components/DecisionRow/DecisionRow.js +93 -0
  89. package/components/DescriptionList/DescriptionListCopy.d.ts +1 -1
  90. package/components/DescriptionList/DescriptionListCopy.js +3 -3
  91. package/components/Dialog/Dialog.css +1 -1
  92. package/components/Dialog/Dialog.js +3 -3
  93. package/components/DocumentChip/DocumentChip.css +12 -0
  94. package/components/DocumentViewer/DocumentViewer.js +10 -10
  95. package/components/Drawer/Drawer.css +1 -1
  96. package/components/Drawer/Drawer.js +3 -3
  97. package/components/Dropdown/Dropdown.css +30 -0
  98. package/components/DropdownMenu/DropdownMenu.css +24 -0
  99. package/components/EventCalendar/EventCalendar.css +54 -0
  100. package/components/EventCalendar/EventCalendar.d.ts +27 -5
  101. package/components/EventCalendar/EventCalendar.js +50 -15
  102. package/components/FileInput/FileInput.css +9 -0
  103. package/components/FilterBar/FilterBar.css +12 -0
  104. package/components/FunnelChart/FunnelChart.js +33 -22
  105. package/components/Globe/Globe.css +7 -0
  106. package/components/Globe/Globe.js +1 -1
  107. package/components/{CircularButton/CircularButton.css → IconButton/IconButton.css} +91 -81
  108. package/components/IconButton/IconButton.d.ts +108 -0
  109. package/components/IconButton/IconButton.js +101 -0
  110. package/components/Input/Input.css +53 -0
  111. package/components/Input/Input.js +3 -3
  112. package/components/MaskedInput/MaskedInput.js +3 -3
  113. package/components/ModelPicker/ModelPicker.css +12 -1
  114. package/components/NavList/NavList.css +1 -1
  115. package/components/Pagination/Pagination.css +1 -1
  116. package/components/QuestionCard/QuestionCard.js +3 -3
  117. package/components/RadioButton/RadioButton.css +14 -12
  118. package/components/RichDropdown/RichDropdown.css +7 -0
  119. package/components/SegmentedControl/SegmentedControl.css +16 -5
  120. package/components/SegmentedControl/SegmentedControl.js +7 -4
  121. package/components/SiteHeader/SiteHeader.css +12 -5
  122. package/components/SiteHeader/SiteHeader.js +3 -3
  123. package/components/SourceTrail/SourceTrail.css +8 -0
  124. package/components/SplitButton/SplitButton.css +14 -14
  125. package/components/SplitButton/SplitButton.js +3 -3
  126. package/components/Table/Table.css +7 -0
  127. package/components/Table/Table.js +1 -1
  128. package/components/TableToolbar/TableToolbar.css +2 -2
  129. package/components/TableToolbar/TableToolbar.js +36 -37
  130. package/components/Tabs/Tabs.css +21 -3
  131. package/components/ThreadPanel/ThreadPanel.css +8 -0
  132. package/components/ThreadTabs/ThreadTabs.css +7 -0
  133. package/components/TimePicker/TimePicker.css +12 -0
  134. package/components/Timeline/Timeline.css +8 -0
  135. package/components/ToolCall/ToolCall.css +8 -0
  136. package/components/Tooltip/Tooltip.js +3 -2
  137. package/components/Widget/Widget.css +2 -0
  138. package/components/WorldMap/WorldMap.css +15 -0
  139. package/components/WorldMap/WorldMap.js +61 -6
  140. package/components/registry.d.ts +3 -1
  141. package/components/registry.json +39 -13
  142. package/components/registry.json.d.ts +39 -13
  143. package/components/registry.json.js +1 -1
  144. package/index.d.ts +2 -0
  145. package/index.js +8 -0
  146. package/package.json +6 -2
  147. package/tokens/presets/blueprint.css +9 -0
  148. package/tokens/presets/bubblegum.css +9 -0
  149. package/tokens/presets/contrast.css +3 -3
  150. package/tokens/presets/coral.css +3 -3
  151. package/tokens/presets/ember.css +9 -0
  152. package/tokens/presets/getaway.css +9 -0
  153. package/tokens/presets/gold.css +3 -3
  154. package/tokens/presets/mono.css +3 -3
  155. package/tokens/presets/pink.css +3 -3
  156. package/tokens/presets/plum.css +3 -3
  157. package/tokens/presets/signal.css +9 -0
  158. package/tokens/presets/smoke.css +9 -0
  159. package/tokens/presets/velvet.css +9 -0
  160. package/tokens/presets/violet.css +3 -3
  161. package/tokens/presets/volt.css +9 -0
  162. package/tokens/presets/warm.css +3 -3
package/README.md CHANGED
@@ -13,7 +13,7 @@ An open source React design system built for AI products and coding agents: comp
13
13
 
14
14
  ## Why Rift DS
15
15
 
16
- - **<!-- component-count -->188<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
16
+ - **<!-- component-count -->189<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
17
17
  - **A matching <!-- figma-kit-link -->[Figma kit](https://www.figma.com/community/file/1701820123445795117)<!-- /figma-kit-link -->.** Every component has a page in it, with a sticker sheet of its states, built on variables named after the same tokens. Duplicate it from the Figma Community to design with the same system.
18
18
  - **AI patterns, the whole chat and templates, ready to use.** Composer, streaming chat thread, tool calls, reasoning and thread panel are in the box, the complete AI chat ships assembled as one widget that one command scaffolds, and the docs site has complete template screens built from them.
19
19
  - **Fully themeable.** The shipped themes are complete looks to start from, each in light and dark. One `data-brand` attribute applies a theme, and a few CSS overrides make your own.
@@ -54,6 +54,8 @@ The whole AI chat ships as one widget: the panel with its docked, overlay and ta
54
54
  npx rift-ds init chat
55
55
  ```
56
56
 
57
+ Add `--actions` for a chat that proposes changes to the page's records and applies one only when the reader confirms it on the card.
58
+
57
59
  The panel alone, with no route behind it, is three imports:
58
60
 
59
61
  ```tsx
@@ -101,7 +103,7 @@ import 'rift-ds/tokens/presets/presets.css';
101
103
  ```
102
104
 
103
105
  - **Dark mode**: `data-theme="dark"` on the root element; light is the default.
104
- - **Theme names**: a preset's id is its `data-brand` value and stylesheet name, which can differ from the name a theme menu shows (Signal ships as `plum`). `SHIPPED_THEMES` from `rift-ds/tokens/values` lists every theme with its name and attribute, and `shippedThemeOptions()` hands ThemePicker the same list with each theme's swatch. To apply a stored theme before first paint, pass `colorModeScript({ brandStorageKey })` the key you keep it under.
106
+ - **Theme names**: a preset's id is its `data-brand` value and stylesheet name, and a theme shown under another name answers to that name in lowercase too (Signal, id `plum`, also applies as `data-brand="signal"` and `tokens/presets/signal.css`). `SHIPPED_THEMES` from `rift-ds/tokens/values` lists every theme with its name and attribute, and `shippedThemeOptions()` hands ThemePicker the same list with each theme's swatch. To apply a stored theme before first paint, pass `colorModeScript({ brandStorageKey })` the key you keep it under.
105
107
  - **Page colours**: the token stylesheet defines custom properties and styles no element, so paint the page once: set `background: var(--color-bg-page-primary)`, `color: var(--color-text-primary)` and `font-family: var(--font-family-primary)` on `body`. Without it a dark theme lands as dark components on a white page.
106
108
  - **Your own brand**: every semantic token chains to a primitive, so overriding one primitive re-themes everything built on it. The [playground](https://rift-ds.com/playground) restyles the system live and copies out a complete, paste-ready override.
107
109
  - **One part of a shipped theme**: the token and theme stylesheets sit in cascade layers (`rift.tokens`, then `rift.preset`), so any rule of your own outranks them whatever its selector. A plain `:root { --font-family-primary: … }` keeps a preset's colours with your face, in light and dark alike. To set a default that a preset still replaces, declare it inside `@layer rift.tokens { … }`.
@@ -110,13 +112,13 @@ import 'rift-ds/tokens/presets/presets.css';
110
112
 
111
113
  ## Components
112
114
 
113
- <!-- component-count -->188<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
115
+ <!-- component-count -->189<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
114
116
 
115
117
  <details>
116
118
  <summary>The full list</summary>
117
119
 
118
120
  <!-- component-list:start -->
119
- Accordion · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Checklist · Chip · Circular button · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Currency input · Data table · Date input · Date picker · Date range picker · Deadline · Description list · Dialog · Divider · Document chip · Document viewer · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Error summary · Event calendar · Field · Figure · File input · File row · Filter bar · Form section · Funnel chart · Gantt chart · Gauge · Globe · Grid · Heading · Hover card · Icon · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link · Link list · List · Map callout · Map legend · Masked input · Mega menu · Mention · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Resource timeline · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Shader scene · Sidebar panel · Signature pad · Site header · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stack · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · Wizard · World map
121
+ Accordion · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Checklist · Chip · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Currency input · Data table · Date input · Date picker · Date range picker · Deadline · Decision row · Description list · Dialog · Divider · Document chip · Document viewer · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Error summary · Event calendar · Field · Figure · File input · File row · Filter bar · Form section · Funnel chart · Gantt chart · Gauge · Globe · Grid · Heading · Hover card · Icon · Icon button · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link · Link list · List · Map callout · Map legend · Masked input · Mega menu · Mention · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Resource timeline · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Shader scene · Sidebar panel · Signature pad · Site header · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stack · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · Wizard · World map
120
122
  <!-- component-list:end -->
121
123
 
122
124
  </details>
@@ -106,7 +106,10 @@
106
106
  align-items: center;
107
107
  gap: var(--gap-200);
108
108
  height: var(--control-height-compact);
109
- padding: 0 var(--padding-300);
109
+ /* Compact Button's padding, with its icon side rule: the leading icon's
110
+ edge takes the step below the text side (12 → 8). */
111
+ padding-block: 0;
112
+ padding-inline: var(--padding-200) var(--padding-300);
110
113
  border-radius: var(--radius-pill);
111
114
  background-color: var(--ds-chat-card-readout-bg);
112
115
  color: var(--ds-chat-card-readout-text);
@@ -0,0 +1,43 @@
1
+ import { ComponentType, LazyExoticComponent } from 'react';
2
+ export interface DeferredComponent<Props> {
3
+ /** The component, loaded when it first renders. Render it inside a Suspense. */
4
+ Component: LazyExoticComponent<ComponentType<Props>>;
5
+ /**
6
+ * Start the load now. Safe to call any number of times, and to pass as an
7
+ * event handler: it takes no arguments, returns nothing and never throws.
8
+ */
9
+ preload: () => void;
10
+ }
11
+ /**
12
+ * A component that loads when it first renders, and a `preload` that starts
13
+ * the load early.
14
+ *
15
+ * `load` resolves to the component itself, so a named export is picked out
16
+ * of its module where the import is written:
17
+ *
18
+ * ```tsx
19
+ * const DeferredPanel = deferComponent<PanelProps>(() =>
20
+ * import('./Panel').then((module) => module.Panel),
21
+ * );
22
+ * ```
23
+ *
24
+ * A failed `preload` is not an error: the next `preload`, or the first
25
+ * render, asks again. A load that fails once the component has rendered is
26
+ * one: like any lazy component, it is thrown to the nearest error boundary,
27
+ * and stays failed there.
28
+ */
29
+ export declare function deferComponent<Props>(load: () => Promise<ComponentType<Props>>): DeferredComponent<Props>;
30
+ /**
31
+ * Call `preload` as soon as the page is interactive: in the browser's first
32
+ * idle moment after this component mounts, and no later than a short
33
+ * deadline if the page never goes idle. It runs once per mount, and calls
34
+ * the latest function it was given, so an inline function is fine.
35
+ *
36
+ * Waiting for the page to finish loading and then go idle was tried first
37
+ * and measured: on a slow phone the page stays busy for seconds, the
38
+ * preload started late and then queued behind everything else the page
39
+ * fetches after load, and a first press arrived before the code did. The
40
+ * code is off the page's critical path either way; what matters is that
41
+ * its fetch starts early.
42
+ */
43
+ export declare function usePreloadWhenIdle(preload: () => void): void;
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { lazy, useRef, useEffect } from "react";
3
+ function deferComponent(load) {
4
+ let pending;
5
+ const start = () => pending ??= load().then((component) => ({ default: component }));
6
+ return {
7
+ Component: lazy(start),
8
+ preload: () => {
9
+ start().catch(() => {
10
+ pending = void 0;
11
+ });
12
+ }
13
+ };
14
+ }
15
+ const PRELOAD_DEADLINE_MS = 300;
16
+ function usePreloadWhenIdle(preload) {
17
+ const latest = useRef(preload);
18
+ useEffect(() => {
19
+ latest.current = preload;
20
+ });
21
+ useEffect(() => {
22
+ if (navigator.connection?.saveData) return;
23
+ const run = () => latest.current();
24
+ if (typeof window.requestIdleCallback === "function") {
25
+ const idle = window.requestIdleCallback(run, { timeout: PRELOAD_DEADLINE_MS });
26
+ return () => window.cancelIdleCallback(idle);
27
+ }
28
+ const timer = window.setTimeout(run, 1);
29
+ return () => window.clearTimeout(timer);
30
+ }, []);
31
+ }
32
+ export {
33
+ deferComponent,
34
+ usePreloadWhenIdle
35
+ };
@@ -28,6 +28,13 @@ export declare function rotateWeek<T>(sundayFirst: readonly T[], start: Weekday)
28
28
  export declare const weekdayOffset: (day: number, start: Weekday) => number;
29
29
  /** The seven weekday names in `locale`, Sunday first, at the given width. */
30
30
  export declare function weekdayNamesIn(locale: string, width: 'long' | 'short' | 'narrow'): string[];
31
+ /**
32
+ * The weekday names a seven-column calendar heads its columns with: the
33
+ * locale's short names where they are abbreviations (`Mo.`, `lun.`, `пн`),
34
+ * and its narrow ones where its short names are whole words (Arabic's
35
+ * `الأربعاء`), which would widen a column past the day under it on a phone.
36
+ */
37
+ export declare function weekdayHeadersIn(locale: string): string[];
31
38
  /** Whether `locale` is written in English, the language every built-in label defaults to. */
32
39
  export declare function isEnglish(locale: string): boolean;
33
40
  /** Whether `locale` writes times on a 12-hour clock (en-US) rather than a 24-hour one (en-GB, de-DE). */
@@ -31,6 +31,10 @@ function weekdayNamesIn(locale, width) {
31
31
  const format = new Intl.DateTimeFormat(locale, { weekday: width, timeZone: "UTC" });
32
32
  return Array.from({ length: 7 }, (_, day) => format.format(Date.UTC(2023, 0, 1 + day)));
33
33
  }
34
+ function weekdayHeadersIn(locale) {
35
+ const short = weekdayNamesIn(locale, "short");
36
+ return short.some((name) => Array.from(name).length > 4) ? weekdayNamesIn(locale, "narrow") : short;
37
+ }
34
38
  function isEnglish(locale) {
35
39
  try {
36
40
  return new Intl.Locale(locale).language === "en";
@@ -82,6 +86,7 @@ export {
82
86
  rotateWeek,
83
87
  uses12HourClock,
84
88
  weekStartOf,
89
+ weekdayHeadersIn,
85
90
  weekdayNamesIn,
86
91
  weekdayOffset
87
92
  };
@@ -117,3 +117,36 @@
117
117
  background-color: var(--ds-shell-backdrop-fill);
118
118
  backdrop-filter: var(--ds-shell-backdrop-filter);
119
119
  }
120
+
121
+ /* Room for a docked chat. ChatLauncher marks <html> with data-chat="docked"
122
+ (or "docked-left") while its panel is docked, and keeps the panel's width
123
+ in --ds-chat-width and its gap off the window edge in --ds-chat-inset
124
+ (src/chat/ChatWidget.css). The outermost app shell gives up that width
125
+ plus that gap on the docked side, so in every mode the content ends one
126
+ gap short of the panel, as the panel ends one gap short of the window,
127
+ and no host writes its own rule. The plane still runs under the panel,
128
+ so the gap shows the plane. A chat seated as the page (its rails carry
129
+ the marker too) never pads for itself. A host that already makes room
130
+ on its own (a site that pads its body) sets --ds-shell-chat-room to 0px
131
+ on <html> to opt out. The dock is a screen edge the reader picks, not a
132
+ reading direction. */
133
+ :root {
134
+ --ds-shell-chat-room: calc(var(--ds-chat-width, 420px) + var(--ds-chat-inset, 20px));
135
+ }
136
+
137
+ html[data-chat='docked'] :where([data-ds-shell]:not(.ds-chat-widget__rails)):not(:where([data-ds-shell] *)) {
138
+ padding-right: var(--ds-shell-chat-room); /* ds-allow(physical): the panel docks to the screen edge the reader picked */
139
+ }
140
+
141
+ html[data-chat='docked-left'] :where([data-ds-shell]:not(.ds-chat-widget__rails)):not(:where([data-ds-shell] *)) {
142
+ padding-left: var(--ds-shell-chat-room); /* ds-allow(physical): the panel docks to the screen edge the reader picked */
143
+ }
144
+
145
+ :where([data-ds-shell]) {
146
+ transition: padding var(--motion-duration-slow) var(--motion-ease-emphasized);
147
+ }
148
+
149
+ /* The widen grip drives the width frame by frame, so the room follows it at once. */
150
+ html[data-chat-resizing] :where([data-ds-shell]) {
151
+ transition: none;
152
+ }
package/bin/rift-ds.mjs CHANGED
@@ -67,6 +67,17 @@ const MANIFEST_URL = `${SITE_ORIGIN}/skill/manifest.json`;
67
67
  const DEFAULT_DIR = join('.claude', 'skills');
68
68
  const TEMPLATES_ROOT = join(dirname(fileURLToPath(import.meta.url)), 'templates');
69
69
  const TEMPLATES_DIR = join(TEMPLATES_ROOT, 'chat');
70
+ /*
71
+ * The chat templates' propose-and-confirm files, written only by
72
+ * `init chat --actions`: a `<name>.actions.<ext>` file takes the place of
73
+ * `<name>.<ext>`, and the proposals/ folder is added. They live beside the
74
+ * plain chat's so their imports resolve and the library build type-checks
75
+ * them; scripts/validate-chat-widget.mjs holds them to the docs page's
76
+ * ACTIONS_SCAFFOLD_FILES.
77
+ */
78
+ const ACTIONS_VARIANT = /\.actions(?=\.[a-z]+$)/;
79
+ const ACTIONS_FOLDER = 'components/chat/proposals/';
80
+ const isActionsOnly = (file) => ACTIONS_VARIANT.test(file) || file.startsWith(ACTIONS_FOLDER);
70
81
  const APP_TEMPLATES_DIR = join(TEMPLATES_ROOT, 'app');
71
82
  const BLOCKS_DIR = join(TEMPLATES_ROOT, 'blocks');
72
83
 
@@ -84,7 +95,7 @@ const CHAT_PEERS = [
84
95
 
85
96
  const USAGE = `Usage: npx ${PACKAGE_NAME} init [--skill <name>] [--dir <dir>]
86
97
  npx ${PACKAGE_NAME} init app [--app <dir>] [--dry-run]
87
- npx ${PACKAGE_NAME} init chat [--app <dir>] [--dry-run]
98
+ npx ${PACKAGE_NAME} init chat [--actions] [--app <dir>] [--dry-run]
88
99
  npx ${PACKAGE_NAME} init block [<name>] [--app <dir>] [--dry-run]
89
100
 
90
101
  init
@@ -116,6 +127,10 @@ init chat
116
127
  them, the mount and its model list under components/chat/, and an
117
128
  .env.chat.example. Existing files are never overwritten.
118
129
 
130
+ --actions Write the propose-and-confirm example instead of a plain
131
+ chat: changes defined once for the page and the route, a
132
+ tool that proposes them on a card, the card that confirms,
133
+ and the record the reply opens with
119
134
  --app <dir> The app router folder (default: app/ or src/app/, whichever exists)
120
135
  --dry-run Print what would be written and write nothing
121
136
 
@@ -233,11 +248,11 @@ function findAppDir(app) {
233
248
  * Writes every template under `base` (or only `files`, paths relative to
234
249
  * it) that does not exist yet; returns what was written and skipped.
235
250
  */
236
- function scaffold(base, appDir, dryRun, files = templateFiles(base)) {
251
+ function scaffold(base, appDir, dryRun, files = templateFiles(base), targetOf = (file) => file) {
237
252
  const written = [];
238
253
  const skipped = [];
239
254
  for (const file of files) {
240
- const dest = destinationFor(file, appDir);
255
+ const dest = destinationFor(targetOf(file), appDir);
241
256
  if (existsSync(dest)) {
242
257
  skipped.push(dest);
243
258
  continue;
@@ -327,12 +342,17 @@ function ignoresEnvExample() {
327
342
  return ignored;
328
343
  }
329
344
 
330
- function initChat({ app, dryRun }) {
345
+ function initChat({ app, dryRun, actions }) {
331
346
  if (!existsSync(TEMPLATES_DIR)) {
332
347
  fail('this copy carries no chat templates: run the published bin (npx ' + PACKAGE_NAME + ' init chat).');
333
348
  }
334
349
  const appDir = findAppDir(app);
335
- const { written, skipped } = scaffold(TEMPLATES_DIR, appDir, dryRun);
350
+ const all = templateFiles(TEMPLATES_DIR);
351
+ const plainName = (file) => file.replace(ACTIONS_VARIANT, '');
352
+ /* With --actions, a variant replaces its plain file and the proposals are added; without it, neither is written. */
353
+ const replaced = new Set(actions ? all.filter((file) => ACTIONS_VARIANT.test(file)).map(plainName) : []);
354
+ const files = all.filter((file) => (actions ? !replaced.has(file) : !isActionsOnly(file)));
355
+ const { written, skipped } = scaffold(TEMPLATES_DIR, appDir, dryRun, files, plainName);
336
356
 
337
357
  console.log(
338
358
  dryRun
@@ -340,14 +360,20 @@ function initChat({ app, dryRun }) {
340
360
  : `\n✓ Chat scaffolded: ${written.length} files written, ${skipped.length} left alone.`
341
361
  );
342
362
  console.log(`\nNext:`);
343
- console.log(` 1. Install the peers the chat imports:\n npm install ${CHAT_PEERS.join(' ')}`);
363
+ /* The actions mount plays no demo, so it needs no recharts. */
364
+ const peers = actions ? CHAT_PEERS.filter((peer) => peer !== 'recharts') : CHAT_PEERS;
365
+ console.log(` 1. Install the peers the chat imports:\n npm install ${peers.join(' ')}`);
344
366
  console.log(
345
367
  ` 2. Render <ChatMount /> at the end of your root layout's body, after the page content:\n` +
346
368
  ` import { ChatMount } from '${relative(appDir, join(dirname(appDir), 'components', 'chat', 'ChatMount')).split('\\').join('/')}';`
347
369
  );
348
370
  console.log(
349
- ` 3. Copy .env.chat.example into .env.local. With NEXT_PUBLIC_CHAT_DEMO=true the widget plays a scripted\n` +
350
- ` conversation and needs no key; set ANTHROPIC_API_KEY and CHAT_ENABLED=true to go live.`
371
+ actions
372
+ ? ` 3. Copy .env.chat.example into .env.local and set ANTHROPIC_API_KEY and CHAT_ENABLED=true: the\n` +
373
+ ` propose-and-confirm mount talks to the route, with no scripted demo. Then replace the sample\n` +
374
+ ` records and applyPlan in components/chat/proposals/ with your own.`
375
+ : ` 3. Copy .env.chat.example into .env.local. With NEXT_PUBLIC_CHAT_DEMO=true the widget plays a scripted\n` +
376
+ ` conversation and needs no key; set ANTHROPIC_API_KEY and CHAT_ENABLED=true to go live.`
351
377
  );
352
378
  if (ignoresEnvExample()) {
353
379
  console.log(
@@ -415,7 +441,7 @@ function option(flag, what) {
415
441
  if (args[1] === 'chat' || args[1] === 'app' || args[1] === 'block') {
416
442
  const appFlag = option('--app', 'a directory');
417
443
  const scaffoldArgs = { app: appFlag ? resolve(appFlag) : undefined, dryRun: args.includes('--dry-run') };
418
- if (args[1] === 'chat') initChat(scaffoldArgs);
444
+ if (args[1] === 'chat') initChat({ ...scaffoldArgs, actions: args.includes('--actions') });
419
445
  else if (args[1] === 'app') initApp(scaffoldArgs);
420
446
  else initBlock({ ...scaffoldArgs, name: args[2] && !args[2].startsWith('--') ? args[2] : undefined });
421
447
  } else {
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * The plan: rows of work grouped by team, one editable column per week from
5
+ * periodColumns, a row total from totalOf, each team's subtotal on its group
6
+ * row and the sum of every week in the totals row. Edits are kept in this
7
+ * component's state; save them to your own store in onCellEdit.
8
+ */
9
+
10
+ import { useState } from 'react';
11
+ import { DataTable, periodColumns, totalOf, type DataTableColumn, type DataTableRow } from 'rift-ds/components/DataTable/DataTable';
12
+
13
+ /** The first week shown, as YYYY-MM-DD. Yours is probably this week's Monday. */
14
+ const START = '2026-03-02';
15
+ const WEEKS = periodColumns({
16
+ start: START,
17
+ count: 6,
18
+ unit: 'week',
19
+ keyPrefix: 'w:',
20
+ column: { type: 'number', align: 'end', editable: true, aggregate: 'sum', minWidth: 88 },
21
+ });
22
+ const WEEK_KEYS = WEEKS.map((column) => column.key);
23
+
24
+ const COLUMNS: DataTableColumn[] = [
25
+ { key: 'work', header: 'Work', rowHeader: true, pin: 'start', minWidth: 180 },
26
+ { key: 'team', header: 'Team', groupable: true },
27
+ ...WEEKS,
28
+ { key: 'total', header: 'Total', type: 'number', align: 'end', compute: totalOf(WEEK_KEYS), aggregate: 'sum', pin: 'end' },
29
+ ];
30
+
31
+ const PLAN: [string, string, number[]][] = [
32
+ ['Checkout redesign', 'Design', [4, 5, 5, 3, 2, 0]],
33
+ ['Help centre refresh', 'Design', [1, 1, 2, 3, 3, 2]],
34
+ ['Payments migration', 'Engineering', [8, 8, 10, 10, 6, 4]],
35
+ ['Search indexing', 'Engineering', [3, 3, 2, 2, 4, 5]],
36
+ ['Spring launch', 'Marketing', [2, 2, 3, 5, 6, 6]],
37
+ ];
38
+
39
+ const ROWS: DataTableRow[] = PLAN.map(([work, team, days], index) => ({
40
+ id: `p${index + 1}`,
41
+ values: { work, team, ...Object.fromEntries(WEEK_KEYS.map((key, i) => [key, days[i]])) },
42
+ }));
43
+
44
+ export function PlannerGrid() {
45
+ const [rows, setRows] = useState(ROWS);
46
+ return (
47
+ <DataTable
48
+ caption="Days planned by week"
49
+ columns={COLUMNS}
50
+ rows={rows}
51
+ defaultGrouping={['team']}
52
+ totalsRow
53
+ onCellEdit={({ row, key, value }) =>
54
+ setRows((current) => current.map((r) => (r.id === row.id ? { ...r, values: { ...r.values, [key]: value } } : r)))
55
+ }
56
+ />
57
+ );
58
+ }
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * Requests waiting on a decision, each a DecisionRow that settles to the
5
+ * answer and offers Undo. The statuses live here; send each decision to your
6
+ * own store in onStatusChange.
7
+ */
8
+
9
+ import { useState } from 'react';
10
+ import { Avatar } from 'rift-ds/components/Avatar/Avatar';
11
+ import { DecisionRow, type DecisionRowStatus } from 'rift-ds/components/DecisionRow/DecisionRow';
12
+ import { Widget } from 'rift-ds/components/Widget/Widget';
13
+
14
+ const REQUESTS = [
15
+ { id: 'r1', name: 'Priya Natarajan', what: 'Two more days on search', when: '10m ago' },
16
+ { id: 'r2', name: 'Tom Okafor', what: 'Move the launch a week', when: 'Yesterday' },
17
+ { id: 'r3', name: 'Lena Fischer', what: 'A designer for help centre', when: 'Mon' },
18
+ ];
19
+
20
+ export function Requests({ className }: { className?: string }) {
21
+ const [statuses, setStatuses] = useState<Record<string, DecisionRowStatus>>({});
22
+ return (
23
+ <Widget className={className} title="Waiting on you" count={REQUESTS.filter((r) => (statuses[r.id] ?? 'pending') === 'pending').length}>
24
+ {REQUESTS.map((request) => (
25
+ <DecisionRow
26
+ key={request.id}
27
+ title={request.name}
28
+ description={request.what}
29
+ meta={request.when}
30
+ leading={<Avatar name={request.name} size="sm" />}
31
+ status={statuses[request.id] ?? 'pending'}
32
+ onStatusChange={(status) => setStatuses((current) => ({ ...current, [request.id]: status }))}
33
+ onUndo={() => {}}
34
+ acceptLabel="Approve"
35
+ declineLabel="Deny"
36
+ acceptedLabel="Approved"
37
+ declinedLabel="Denied"
38
+ />
39
+ ))}
40
+ </Widget>
41
+ );
42
+ }
@@ -0,0 +1,17 @@
1
+ /* The plan takes the column's whole width, so as many weeks show as the
2
+ screen has room for before the table scrolls; the queue sits under it at
3
+ a reading width, where a name, a fact and two buttons fit on one line. */
4
+
5
+ .layout {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: var(--gap-400);
9
+ }
10
+
11
+ .plan {
12
+ min-width: 0;
13
+ }
14
+
15
+ .queue {
16
+ max-width: 560px; /* the queue's reading width */
17
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The planner block: the app shell with a plan laid out across weeks, one
3
+ * editable column per week, a total for each row, a subtotal for each team
4
+ * and a sum for each week, beside a queue of requests waiting on a yes or a
5
+ * no. The figures are placeholders; read and write your own (PlannerGrid.tsx
6
+ * and Requests.tsx beside this page hold them).
7
+ */
8
+
9
+ import { Button } from 'rift-ds/components/Button/Button';
10
+ import { Widget } from 'rift-ds/components/Widget/Widget';
11
+ import { AppShell } from '../../components/blocks/AppShell';
12
+ import { PlannerGrid } from './PlannerGrid';
13
+ import { Requests } from './Requests';
14
+ import styles from './page.module.css';
15
+
16
+ export default function PlannerPage() {
17
+ return (
18
+ <AppShell
19
+ activeKey="projects"
20
+ breadcrumb={[{ label: 'Acme', href: '#' }, { label: 'Planner' }]}
21
+ title="Planner"
22
+ actions={<Button label="Add a row" variant="secondary" iconLeft="add" />}
23
+ >
24
+ <div className={styles.layout}>
25
+ <Widget title="Days planned by week" padding="none" className={styles.plan}>
26
+ <PlannerGrid />
27
+ </Widget>
28
+ <Requests className={styles.queue} />
29
+ </div>
30
+ </AppShell>
31
+ );
32
+ }
@@ -150,6 +150,13 @@
150
150
  display: none;
151
151
  }
152
152
 
153
+ /* An icon-only control wears a tooltip, which wraps it: the wrapper leaves
154
+ the row with the control, or it would hold a gap open. */
155
+ .topBarActions :global(.ds-tooltip):has(> .searchIcon),
156
+ .topBarActions :global(.ds-tooltip):has(> .aiIcon) {
157
+ display: none;
158
+ }
159
+
153
160
  .topBarActions {
154
161
  display: flex;
155
162
  align-items: center;
@@ -221,7 +228,9 @@
221
228
  }
222
229
 
223
230
  .searchIcon,
224
- .aiIcon {
231
+ .aiIcon,
232
+ .topBarActions :global(.ds-tooltip):has(> .searchIcon),
233
+ .topBarActions :global(.ds-tooltip):has(> .aiIcon) {
225
234
  display: inline-flex;
226
235
  }
227
236
 
@@ -38,6 +38,20 @@
38
38
  "app/settings/ProfileForm.tsx"
39
39
  ]
40
40
  },
41
+ {
42
+ "name": "planner",
43
+ "label": "Planner",
44
+ "description": "The app shell with a plan across weeks, each cell editable with totals down and across, over a queue of requests to decide.",
45
+ "route": "/planner",
46
+ "files": [
47
+ "components/blocks/AppShell.tsx",
48
+ "components/blocks/AppShell.module.css",
49
+ "app/planner/page.tsx",
50
+ "app/planner/page.module.css",
51
+ "app/planner/PlannerGrid.tsx",
52
+ "app/planner/Requests.tsx"
53
+ ]
54
+ },
41
55
  {
42
56
  "name": "sign-in",
43
57
  "label": "Sign in",
@@ -0,0 +1,108 @@
1
+ import {
2
+ confirmationLine,
3
+ createChatHandler,
4
+ planAction,
5
+ sanitiseConfirmation,
6
+ sanitisePath,
7
+ type ActionConfirmation,
8
+ type ChatTool,
9
+ } from 'rift-ds/chat/server';
10
+ import { CHAT_MODELS, DEFAULT_CHAT_MODEL } from '../../../components/chat/models';
11
+ import { ACTIONS, SAMPLE_ITEMS, itemNoun, type ActionId } from '../../../components/chat/proposals/actions';
12
+ import { guardrails } from './guardrails';
13
+
14
+ export const maxDuration = 60;
15
+
16
+ /**
17
+ * The propose-and-confirm chat. The model can only propose: its tool plans
18
+ * an action over the records the request means and sends the plan as a
19
+ * `proposal` card, which the reader confirms on the page (ProposalCard.tsx).
20
+ * Nothing here writes. A confirmed message arrives with the page's mark in
21
+ * its context; the route rebuilds it as untrusted input, tells the model
22
+ * whether this message was confirmed on its card, and opens the reply with
23
+ * the record of what was done as a `lead` card.
24
+ */
25
+ const SYSTEM = `You are the assistant on this page. You can propose changes to the items with the propose_change tool, but you never make a change yourself: the reader confirms it on the card. Say a change is made only when you are told this message was confirmed on its card.`;
26
+
27
+ /** The context the page sends: its path, and the confirmation the page marked, if any. */
28
+ type RequestContext = { path: string | null; confirmation: ActionConfirmation | null };
29
+
30
+ const isItem = (id: string) => id in SAMPLE_ITEMS;
31
+
32
+ /* The browser's context is untrusted: keep a slug path and a confirmation
33
+ rebuilt against the real actions and records, and nothing else. */
34
+ function sanitiseContext(raw: unknown): string | null {
35
+ if (typeof raw !== 'string' || raw.length > 4000) return null;
36
+ try {
37
+ const value = JSON.parse(raw) as Record<string, unknown>;
38
+ const context: RequestContext = {
39
+ path: sanitisePath(value.path),
40
+ confirmation: sanitiseConfirmation(value.confirmation, { actions: ACTIONS, isId: isItem, maxCount: 500 }),
41
+ };
42
+ return JSON.stringify(context);
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ const readContext = (context: string | null): RequestContext =>
49
+ context ? (JSON.parse(context) as RequestContext) : { path: null, confirmation: null };
50
+
51
+ const proposeChange: ChatTool = {
52
+ definition: {
53
+ name: 'propose_change',
54
+ description: `Propose a change for the reader to confirm. Actions: ${Object.keys(ACTIONS).join(', ')}. Items: ${Object.entries(SAMPLE_ITEMS)
55
+ .map(([id, item]) => `${id} "${item.title}" (${item.state})`)
56
+ .join('; ')}.`,
57
+ input_schema: {
58
+ type: 'object',
59
+ properties: {
60
+ action: { type: 'string', enum: Object.keys(ACTIONS) },
61
+ ids: { type: 'array', items: { type: 'string' } },
62
+ },
63
+ required: ['action', 'ids'],
64
+ },
65
+ },
66
+ tracePoint: () => 'Planned a change',
67
+ execute: (input) => {
68
+ const action = ACTIONS[input.action as ActionId];
69
+ const ids = Array.isArray(input.ids) ? input.ids.filter((id): id is string => typeof id === 'string' && isItem(id)) : [];
70
+ if (!action) return JSON.stringify({ error: 'Unknown action.' });
71
+ const plan = planAction(action, ids.map((id) => ({ id, values: SAMPLE_ITEMS[id] })));
72
+ if (plan.ids.length === 0) return JSON.stringify({ error: 'None of those items can take that change.', skipped: plan.skipped });
73
+ return {
74
+ text: `Proposed on a card for the reader to confirm: ${plan.ids.length} ${itemNoun(plan.ids.length)}. Nothing has changed yet.`,
75
+ card: { kind: 'proposal', data: { ...plan, id: crypto.randomUUID() } },
76
+ };
77
+ },
78
+ };
79
+
80
+ const handler = createChatHandler({
81
+ apiKey: process.env.ANTHROPIC_API_KEY,
82
+ enabled: process.env.CHAT_ENABLED === 'true' && Boolean(process.env.ANTHROPIC_API_KEY),
83
+ system: [{ type: 'text', text: SYSTEM, cache_control: { type: 'ephemeral' } }],
84
+ models: CHAT_MODELS,
85
+ defaultModel: DEFAULT_CHAT_MODEL,
86
+ tools: [proposeChange],
87
+ sanitiseContext,
88
+ /* What the model reads about this request, after the cached block. */
89
+ contextBlock: (context) => {
90
+ const { path, confirmation } = readContext(context);
91
+ return [
92
+ path ? `The reader is on the page ${path}.` : null,
93
+ confirmationLine(confirmation, { actions: ACTIONS, noun: itemNoun }),
94
+ ]
95
+ .filter(Boolean)
96
+ .join('\n\n');
97
+ },
98
+ /* A confirmed message's reply opens with the record of what was done. */
99
+ lead: ({ context }) => {
100
+ const { confirmation } = readContext(context);
101
+ return confirmation ? [{ kind: 'record', data: { action: confirmation.action, count: confirmation.count } }] : [];
102
+ },
103
+ guardrails,
104
+ });
105
+
106
+ export async function POST(request: Request): Promise<Response> {
107
+ return handler(request);
108
+ }