rift-ds 1.42.0 → 1.43.1

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 (105) hide show
  1. package/README.md +3 -3
  2. package/behaviors/framePacer.d.ts +5 -0
  3. package/behaviors/framePacer.js +44 -0
  4. package/behaviors/useFocusScope.js +4 -2
  5. package/behaviors/useLayer.d.ts +16 -0
  6. package/behaviors/useLayer.js +12 -2
  7. package/bin/rift-ds.mjs +25 -5
  8. package/bin/templates/blocks/app/dashboard/page.module.css +2 -2
  9. package/bin/templates/blocks/app/notifications/Inbox.tsx +13 -45
  10. package/bin/templates/blocks/app/notifications/page.module.css +5 -0
  11. package/bin/templates/blocks/app/planner/page.tsx +2 -2
  12. package/bin/templates/blocks/app/settings/Settings.tsx +4 -4
  13. package/bin/templates/blocks/components/blocks/AppShell.tsx +13 -18
  14. package/bin/templates/blocks/components/blocks/notifications.ts +77 -0
  15. package/bin/templates/blocks/registry.json +5 -0
  16. package/chat/ChatWidget.js +2 -1
  17. package/chat/ResponseActions.js +3 -1
  18. package/chat/server.d.ts +1 -1
  19. package/chat/server.js +6 -1
  20. package/chat/upstash.js +13 -1
  21. package/components/AiButton/AiButton.js +1 -1
  22. package/components/AppLayout/AppLayout.css +7 -0
  23. package/components/AppLayout/AppLayout.d.ts +4 -0
  24. package/components/AppLayout/AppLayout.js +5 -1
  25. package/components/AppSidebar/AppSidebar.css +4 -0
  26. package/components/AppSidebar/AppSidebar.js +7 -2
  27. package/components/AppToolbar/AppToolbar.d.ts +5 -2
  28. package/components/AppToolbar/AppToolbar.js +3 -1
  29. package/components/Attachment/Attachment.css +1 -0
  30. package/components/Attachment/AttachmentDropZone.js +1 -1
  31. package/components/Chart/AreaChart.js +7 -1
  32. package/components/Chart/Chart.css +12 -0
  33. package/components/Chart/LineChart.js +7 -1
  34. package/components/Chart/RadarChart.js +2 -1
  35. package/components/Chart/ScatterChart.js +7 -1
  36. package/components/Chart/StackedBarChart.js +7 -1
  37. package/components/ChatMessage/ChatMessage.css +6 -0
  38. package/components/ColorPicker/ColorPicker.css +1 -0
  39. package/components/Combobox/Combobox.css +8 -0
  40. package/components/CommandPalette/CommandPalette.css +1 -0
  41. package/components/Composer/Composer.css +1 -0
  42. package/components/ContextMenu/ContextMenu.css +1 -0
  43. package/components/CurrencyInput/CurrencyInput.d.ts +1 -1
  44. package/components/CurrencyInput/CurrencyInput.js +2 -1
  45. package/components/DataTable/DataTable.css +6 -0
  46. package/components/DataTable/DataTable.d.ts +2 -2
  47. package/components/DataTable/DataTable.js +11 -8
  48. package/components/DataTable/columnTypes.js +1 -0
  49. package/components/DateInput/DateInput.css +7 -0
  50. package/components/DatePicker/calendar.d.ts +5 -1
  51. package/components/DatePicker/calendar.js +3 -3
  52. package/components/DateRangePicker/DateRangePicker.js +77 -73
  53. package/components/Dialog/Dialog.css +1 -0
  54. package/components/Drawer/Drawer.css +1 -0
  55. package/components/Dropdown/Dropdown.css +7 -0
  56. package/components/Dropdown/Dropdown.js +9 -0
  57. package/components/EntitySwitcher/EntitySwitcher.js +1 -0
  58. package/components/ErrorSummary/ErrorSummary.js +5 -0
  59. package/components/EventCalendar/EventCalendar.css +12 -0
  60. package/components/EventCalendar/EventCalendar.js +29 -23
  61. package/components/Globe/Globe.js +32 -3
  62. package/components/Input/Input.css +12 -0
  63. package/components/Inspector/Inspector.css +6 -1
  64. package/components/Lightbox/Lightbox.css +1 -0
  65. package/components/Menubar/Menubar.css +1 -0
  66. package/components/NotificationCenter/NotificationCenter.css +136 -27
  67. package/components/NotificationCenter/NotificationCenter.d.ts +67 -8
  68. package/components/NotificationCenter/NotificationCenter.js +97 -12
  69. package/components/NumberInput/NumberInput.css +8 -0
  70. package/components/Popover/Popover.css +3 -0
  71. package/components/Popover/Popover.d.ts +1 -1
  72. package/components/Popover/Popover.js +14 -2
  73. package/components/QuestionCard/QuestionCard.css +8 -4
  74. package/components/RadioButton/RadioButton.js +1 -0
  75. package/components/RichDropdown/RichDropdown.css +7 -0
  76. package/components/RichDropdown/RichDropdown.js +1 -0
  77. package/components/SegmentedControl/SegmentedControl.css +5 -0
  78. package/components/ShaderField/useShaderField.js +4 -2
  79. package/components/ShaderScene/ShaderScene.js +5 -2
  80. package/components/SiteLayout/SiteLayout.css +1 -0
  81. package/components/Slider/Slider.css +12 -0
  82. package/components/Slider/Slider.js +1 -1
  83. package/components/Stat/Stat.css +8 -0
  84. package/components/Table/Table.css +5 -0
  85. package/components/TableToolbar/TableToolbar.css +1 -0
  86. package/components/TableToolbar/TableToolbar.js +18 -1
  87. package/components/TagInput/TagInput.css +8 -0
  88. package/components/Textarea/Textarea.css +7 -0
  89. package/components/ThemeToggle/colorMode.d.ts +3 -3
  90. package/components/ThreadHistory/ThreadHistory.css +1 -0
  91. package/components/TimePicker/TimePicker.css +7 -0
  92. package/components/TimePicker/TimePicker.js +1 -0
  93. package/components/Toolbar/Toolbar.d.ts +6 -1
  94. package/components/Wizard/Wizard.d.ts +8 -3
  95. package/components/Wizard/Wizard.js +4 -1
  96. package/components/registry.d.ts +8 -0
  97. package/components/registry.json +30 -5
  98. package/components/registry.json.d.ts +30 -5
  99. package/components/registry.json.js +1 -1
  100. package/package.json +1 -1
  101. package/tokens/motion.d.ts +1 -1
  102. package/tokens/presets/zest.css +9 -11
  103. package/tokens/values.d.ts +10 -3
  104. package/tokens/values.js +11 -5
  105. package/tokens/values.json.js +1 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  <!-- npm-badge:end -->
10
10
  [![license: MIT](https://img.shields.io/badge/license-MIT-4c1)](LICENSE)
11
11
 
12
- An open source React design system built for AI products and coding agents: components on a three-tier token architecture, complete theme presets that restyle everything with one attribute, and machine surfaces (an MCP endpoint, per-component contracts as markdown and JSON schema, the tokens as DTCG files, installable agent skills) so your coding agent knows the library as well as you do.
12
+ The open-source, AI-native design system for React, built for AI products and coding agents: components on a three-tier token architecture, complete theme presets that restyle everything with one attribute, and machine surfaces (an MCP endpoint, per-component contracts as markdown and JSON schema, the tokens as DTCG files, installable agent skills) so your coding agent knows the library as well as you do.
13
13
 
14
14
  ## Why Rift DS
15
15
 
@@ -103,8 +103,8 @@ import 'rift-ds/tokens/presets/presets.css';
103
103
  ```
104
104
 
105
105
  - **Dark mode**: `data-theme="dark"` on the root element; light is the default.
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.
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
+ - **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, corner and faces. To apply a stored theme before first paint, pass `colorModeScript({ brandStorageKey })` the key you keep it under.
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. `rift-ds/tokens/base.css`, imported after the tokens, does exactly that along with the reset the components are tuned against, so an app that imports it has nothing to paint.
108
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.
109
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
110
  - **Overriding component styles**: component styles sit in a third layer, `rift.components`, after the two token layers, so your own CSS outside a layer always beats them, whatever its selector and in whatever order your bundler loads the sheets. `className` is the supported hook: `.my-table { … }` on `<Table className="my-table" />` holds in development and production alike. That reaches your resets too: a bare `* { margin: 0 }` would strip the components' spacing, so put a reset inside `@layer rift.tokens { … }`, or import `tokens/base.css`, which is already there.
@@ -0,0 +1,5 @@
1
+ export type FramePacer = {
2
+ /** Whether a frame is due at `now`, given the last was drawn at `last`, for a loop that wants one every `interval` ms. */
3
+ due: (now: number, last: number, interval: number) => boolean;
4
+ };
5
+ export declare function createFramePacer(): FramePacer;
@@ -0,0 +1,44 @@
1
+ import { MOTION_SHADER_FRAME_SLACK_MS } from "../tokens/motion.js";
2
+ const SAMPLES = 24;
3
+ const MIN_SAMPLES = 6;
4
+ const SLOWEST_TICK_MS = 1e3 / 30 + 2;
5
+ const FASTEST_TICK_MS = 1e3 / 360 - 0.5;
6
+ const COMMON_RATES_HZ = [30, 48, 50, 60, 72, 75, 90, 100, 120, 144, 165, 180, 200, 240, 300, 360];
7
+ const SNAP = 0.04;
8
+ function tickFrom(gaps) {
9
+ const sorted = [...gaps].sort((a, b) => a - b);
10
+ const base = sorted[Math.floor(sorted.length / 4)];
11
+ const singles = sorted.filter((gap) => gap >= base * 0.5 && gap <= base * 1.5);
12
+ const measured = singles[Math.floor(singles.length / 2)];
13
+ for (const hz of COMMON_RATES_HZ) {
14
+ const exact = 1e3 / hz;
15
+ if (Math.abs(measured - exact) / exact <= SNAP) return exact;
16
+ }
17
+ return measured;
18
+ }
19
+ function createFramePacer() {
20
+ const gaps = [];
21
+ let next = 0;
22
+ let previous = 0;
23
+ let tick = 0;
24
+ const learn = (now) => {
25
+ const gap = now - previous;
26
+ previous = now;
27
+ if (gap < FASTEST_TICK_MS || gap > SLOWEST_TICK_MS) return;
28
+ gaps[next] = gap;
29
+ next = (next + 1) % SAMPLES;
30
+ if (gaps.length >= MIN_SAMPLES) tick = tickFrom(gaps);
31
+ };
32
+ return {
33
+ due(now, last, interval) {
34
+ learn(now);
35
+ const elapsed = now - last;
36
+ if (tick === 0) return elapsed >= interval - MOTION_SHADER_FRAME_SLACK_MS;
37
+ const ticks = Math.max(1, Math.round(interval / tick));
38
+ return elapsed >= (ticks - 0.5) * tick;
39
+ }
40
+ };
41
+ }
42
+ export {
43
+ createFramePacer
44
+ };
@@ -28,9 +28,11 @@ const activeModalPanel = () => inertScopes[inertScopes.length - 1]?.panel ?? nul
28
28
  const isVisible = (el) => el.getClientRects().length > 0;
29
29
  const restoreTarget = (previous) => {
30
30
  if (!document.contains(previous)) return null;
31
- if (isVisible(previous)) return previous;
31
+ if (isVisible(previous) && !previous.matches(":disabled")) return previous;
32
32
  for (let el = previous.parentElement; el && el !== document.body; el = el.parentElement) {
33
- if (isVisible(el)) return getFocusable(el)[0] ?? null;
33
+ if (!isVisible(el)) continue;
34
+ const standIn = getFocusable(el)[0];
35
+ if (standIn) return standIn;
34
36
  }
35
37
  return null;
36
38
  };
@@ -28,6 +28,13 @@
28
28
  * press on the backdrop closed the open menu at pointerdown and then the
29
29
  * Dialog on click, two layers for one press.
30
30
  *
31
+ * - **Focus goes back to the opener.** A popup that closes while focus is
32
+ * inside it would drop focus to the page, and the next Tab would start
33
+ * from the top. A layer that names its opener (`returnFocus`) has focus
34
+ * handed back to it, quietly, when the stack dismisses the layer while
35
+ * focus is inside its elements. A modal does not need it: the focus scope
36
+ * restores focus when it closes.
37
+ *
31
38
  * Exactly two document listeners exist while any layer is open, and none
32
39
  * while the stack is empty. Registration order is stack order: overlays open
33
40
  * in the order they are stacked, so stack order and paint order agree
@@ -62,6 +69,15 @@ type LayerOptions = {
62
69
  * from closing it. Escape still reaches it first while it is on top.
63
70
  */
64
71
  passive?: boolean;
72
+ /**
73
+ * The control that opened this layer, for a non-modal popup that takes
74
+ * focus inside itself. When the stack dismisses the layer (Escape, or an
75
+ * outside press) while focus is inside `getElements()` and not already on
76
+ * the opener, focus is handed to it before `onDismiss` runs, quietly, so a
77
+ * Tooltip on the opener stays down. An outside press that lands on
78
+ * something focusable still moves focus there afterwards, as any press does.
79
+ */
80
+ returnFocus?: () => HTMLElement | null | undefined;
65
81
  };
66
82
  export type LayerHandle = {
67
83
  /**
@@ -1,9 +1,19 @@
1
1
  "use client";
2
2
  import { useRef, useEffect, useCallback } from "react";
3
+ import { focusQuietly } from "./quietFocus.js";
3
4
  const layers = [];
4
5
  let listenersInstalled = false;
5
6
  let pressOwner = null;
6
7
  const contains = (layer, target) => (layer.optionsRef.current.getElements?.() ?? []).some((el) => el?.contains(target));
8
+ const dismiss = (layer) => {
9
+ const options = layer.optionsRef.current;
10
+ const opener = options.returnFocus?.();
11
+ const focused = document.activeElement;
12
+ if (opener && focused && focused !== document.body && !opener.contains(focused) && contains(layer, focused)) {
13
+ focusQuietly(opener);
14
+ }
15
+ options.onDismiss?.();
16
+ };
7
17
  const openLayerContains = (node) => layers.some((layer) => contains(layer, node));
8
18
  const hasOpenLayer = () => layers.length > 0;
9
19
  const handleLayerEscape = (event) => {
@@ -13,7 +23,7 @@ const handleLayerEscape = (event) => {
13
23
  const options = top.optionsRef.current;
14
24
  event.preventDefault();
15
25
  if (options.dismissOnEscape === false) return;
16
- options.onDismiss?.();
26
+ dismiss(top);
17
27
  };
18
28
  const handlePointerDown = (event) => {
19
29
  pressOwner = [...layers].reverse().find((layer) => !layer.optionsRef.current.passive) ?? null;
@@ -23,7 +33,7 @@ const handlePointerDown = (event) => {
23
33
  const options = layer.optionsRef.current;
24
34
  if (options.passive) continue;
25
35
  if (!options.dismissOnOutsidePress || contains(layer, target)) break;
26
- options.onDismiss?.();
36
+ dismiss(layer);
27
37
  }
28
38
  };
29
39
  const syncListeners = () => {
package/bin/rift-ds.mjs CHANGED
@@ -65,6 +65,7 @@ const PACKAGE_NAME = 'rift-ds';
65
65
  const CHAT_SLUG = 'ai-chat';
66
66
  const MANIFEST_URL = `${SITE_ORIGIN}/skill/manifest.json`;
67
67
  const DEFAULT_DIR = join('.claude', 'skills');
68
+ const FETCH_TIMEOUT_MS = 20000;
68
69
  const TEMPLATES_ROOT = join(dirname(fileURLToPath(import.meta.url)), 'templates');
69
70
  const TEMPLATES_DIR = join(TEMPLATES_ROOT, 'chat');
70
71
  /*
@@ -157,9 +158,11 @@ function fail(message) {
157
158
  async function get(url) {
158
159
  let response;
159
160
  try {
160
- response = await fetch(url);
161
+ /* A stalled connection would otherwise hang the command with no word. */
162
+ response = await fetch(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
161
163
  } catch (error) {
162
- fail(`could not reach ${url} (${error?.message ?? error}). Check your network and retry.`);
164
+ const why = error?.name === 'TimeoutError' ? `no answer in ${FETCH_TIMEOUT_MS / 1000}s` : (error?.message ?? error);
165
+ fail(`could not reach ${url} (${why}). Check your network and retry.`);
163
166
  }
164
167
  if (!response.ok) {
165
168
  fail(`${url} answered ${response.status}. The site may be mid-deploy; retry in a minute.`);
@@ -312,6 +315,7 @@ function initApp({ app, dryRun }) {
312
315
  console.log(`\nPick a shipped theme before the first screen: the base theme is a neutral starting point, not a look.`);
313
316
  console.log(`Import ${PACKAGE_NAME}/tokens/presets/<id>.css after tokens.css and set data-brand="<id>" on <html>.`);
314
317
  console.log(`Compare them at ${SITE_ORIGIN}/playground.`);
318
+ console.log(`A shipped theme brings its own faces: once you pick one, drop the font.css and riftFont lines above, or the app ships a font it never shows.`);
315
319
  console.log(`A project with a theme.css from the playground already has its look: skip this, and follow that file's own steps for the font.`);
316
320
  console.log(`\nThen add a first page: npx ${PACKAGE_NAME} init block dashboard (no name lists them).`);
317
321
  console.log(`Setup and theming: ${SITE_ORIGIN}/docs/get-started`);
@@ -400,7 +404,8 @@ function initBlock({ name, app, dryRun }) {
400
404
  const { blocks } = JSON.parse(readFileSync(registryFile, 'utf8'));
401
405
  if (!name) {
402
406
  console.log('Blocks:\n');
403
- for (const block of blocks) console.log(` ${block.name.padEnd(12)} ${block.description}`);
407
+ const width = Math.max(...blocks.map((block) => block.name.length));
408
+ for (const block of blocks) console.log(` ${block.name.padEnd(width)} ${block.description}`);
404
409
  console.log(`\nAdd one with: npx ${PACKAGE_NAME} init block <name>`);
405
410
  console.log(`See them: ${SITE_ORIGIN}/docs/blocks`);
406
411
  return;
@@ -414,7 +419,9 @@ function initBlock({ name, app, dryRun }) {
414
419
  console.log(
415
420
  dryRun
416
421
  ? `\n✓ Dry run: ${written.length} files would be written, ${skipped.length} left alone.`
417
- : `\n✓ ${block.label} block added: ${written.length} files written, ${skipped.length} left alone.`
422
+ : written.length === 0
423
+ ? `\n· ${block.label} block already in place: 0 files written, ${skipped.length} left alone.`
424
+ : `\n✓ ${block.label} block added: ${written.length} files written, ${skipped.length} left alone.`
418
425
  );
419
426
  console.log(`\nNext:`);
420
427
  console.log(` 1. If you have not, run npx ${PACKAGE_NAME} init app and make your root layout the one it prints,`);
@@ -442,12 +449,25 @@ function option(flag, what) {
442
449
  return value;
443
450
  }
444
451
 
452
+ /*
453
+ * A flag this command does not know is refused, never ignored: a mistyped
454
+ * --dry-run would otherwise write the files it was asked only to list.
455
+ */
456
+ const VALUE_FLAGS = ['--app', '--skill', '--dir', '--out'];
457
+ const BOOLEAN_FLAGS = ['--dry-run', '--actions'];
458
+ const unknownFlag = args.find(
459
+ (arg) => arg.startsWith('-') && !VALUE_FLAGS.includes(arg) && !BOOLEAN_FLAGS.includes(arg)
460
+ );
461
+ if (unknownFlag) fail(`unknown option "${unknownFlag}"\n\n${USAGE}`);
462
+ /** What follows the init target, less every flag and the value a flag takes. */
463
+ const positionals = args.slice(2).filter((arg, at, rest) => !arg.startsWith('-') && !VALUE_FLAGS.includes(rest[at - 1]));
464
+
445
465
  if (args[1] === 'chat' || args[1] === 'app' || args[1] === 'block') {
446
466
  const appFlag = option('--app', 'a directory');
447
467
  const scaffoldArgs = { app: appFlag ? resolve(appFlag) : undefined, dryRun: args.includes('--dry-run') };
448
468
  if (args[1] === 'chat') initChat({ ...scaffoldArgs, actions: args.includes('--actions') });
449
469
  else if (args[1] === 'app') initApp(scaffoldArgs);
450
- else initBlock({ ...scaffoldArgs, name: args[2] && !args[2].startsWith('--') ? args[2] : undefined });
470
+ else initBlock({ ...scaffoldArgs, name: positionals[0] });
451
471
  } else {
452
472
  if (args[1] && !args[1].startsWith('--')) fail(`unknown init target "${args[1]}"\n\n${USAGE}`);
453
473
  const only = option('--skill', 'a skill name');
@@ -1,6 +1,6 @@
1
1
  /* The dashboard's grid. Four stats across on a desktop, two from the
2
- laptop width down to a phone, where each stat drops its delta under its
3
- label once its tile is narrow (deltaPlacement="auto"); the two panels sit
2
+ laptop width down to a phone, each stat keeping its delta beside its
3
+ value (deltaPlacement="inline") so the row reads as one shape; the two panels sit
4
4
  side by side until the tablet width, then stack. */
5
5
 
6
6
  .stats {
@@ -2,10 +2,11 @@
2
2
 
3
3
  /**
4
4
  * The notifications block's inbox: the page header's actions, the filters
5
- * and the list share one record of what is read and what is left, so they
6
- * hold here together. Swap INBOX for your notifications, `read` for your
7
- * server's read state, and the `onSelect` of each row for where it should
8
- * take the reader.
5
+ * and the list share one record of what is read and what is left with the
6
+ * bell in the shell's toolbar (`useNotifications` in components/blocks/notifications.ts), so a
7
+ * count reads the same in both. Swap that record for your notifications and
8
+ * your server's read state, and the `onSelect` of each row for where it
9
+ * should take the reader.
9
10
  */
10
11
 
11
12
  import { useState } from 'react';
@@ -14,35 +15,10 @@ import { Dropdown } from 'rift-ds/components/Dropdown/Dropdown';
14
15
  import { EmptyState } from 'rift-ds/components/EmptyState/EmptyState';
15
16
  import { NotificationItem } from 'rift-ds/components/NotificationCenter/NotificationCenter';
16
17
  import { Tabs } from 'rift-ds/components/Tabs/Tabs';
17
- import { AppShell } from '../../components/blocks/AppShell';
18
+ import { AppShell, PRODUCT_NAME } from '../../components/blocks/AppShell';
19
+ import { useNotifications } from '../../components/blocks/notifications';
18
20
  import styles from './page.module.css';
19
21
 
20
- type Category = 'payments' | 'cards' | 'team' | 'approvals';
21
-
22
- interface Notification {
23
- id: string;
24
- /** Which day group the row sits under. */
25
- group: 'Today' | 'This week' | 'Earlier';
26
- category: Category;
27
- icon: string;
28
- title: string;
29
- text: string;
30
- /** When it happened, already written for the reader. */
31
- time: string;
32
- }
33
-
34
- const INBOX: Notification[] = [
35
- { id: 'n1', group: 'Today', category: 'payments', icon: 'payments', title: 'Payment received', text: 'Northwind Supply paid invoice 1042 for $4,180.00.', time: '2m' },
36
- { id: 'n2', group: 'Today', category: 'approvals', icon: 'approval', title: 'Approval needed', text: 'Jordan Reyes asked to spend $1,632.42 from the Software budget.', time: '1h' },
37
- { id: 'n3', group: 'Today', category: 'cards', icon: 'credit_card_off', title: 'Card frozen', text: 'The card ending in 7781 is frozen until you unfreeze it.', time: '3h' },
38
- { id: 'n4', group: 'This week', category: 'team', icon: 'person_add', title: 'Invite accepted', text: 'Sam Patel joined Acme as an admin.', time: 'Tue' },
39
- { id: 'n5', group: 'This week', category: 'payments', icon: 'schedule', title: 'Payment scheduled', text: '$5,000.00 to Bright Studio goes out on Friday.', time: 'Mon' },
40
- { id: 'n6', group: 'This week', category: 'approvals', icon: 'receipt_long', title: 'Receipt missing', text: 'Add a receipt for $375.87 at Harbor Bistro.', time: 'Mon' },
41
- { id: 'n7', group: 'Earlier', category: 'cards', icon: 'credit_card', title: 'New card requested', text: 'Lee Chen asked for a card with a $5,000 limit.', time: 'Nov 18' },
42
- { id: 'n8', group: 'Earlier', category: 'team', icon: 'shield_person', title: 'Two admins required', text: 'Sensitive changes now need a second admin to approve.', time: 'Nov 14' },
43
- { id: 'n9', group: 'Earlier', category: 'payments', icon: 'description', title: 'Statement ready', text: 'Your October statement is ready to download.', time: 'Nov 1' },
44
- ];
45
-
46
22
  const GROUPS = ['Today', 'This week', 'Earlier'] as const;
47
23
 
48
24
  const CATEGORY_OPTIONS = [
@@ -54,17 +30,10 @@ const CATEGORY_OPTIONS = [
54
30
  ];
55
31
 
56
32
  export function Inbox() {
57
- const [items, setItems] = useState(INBOX);
58
- const [unread, setUnread] = useState<string[]>(['n1', 'n2', 'n3', 'n4']);
33
+ const { items, unread, read, readAll, dismiss, clear } = useNotifications();
59
34
  const [show, setShow] = useState('all');
60
35
  const [category, setCategory] = useState('all');
61
36
 
62
- const read = (id: string) => setUnread((ids) => ids.filter((other) => other !== id));
63
- const dismiss = (id: string) => {
64
- setItems((list) => list.filter((item) => item.id !== id));
65
- read(id);
66
- };
67
-
68
37
  const shown = items.filter(
69
38
  (item) =>
70
39
  (show === 'all' || unread.includes(item.id)) && (category === 'all' || item.category === category),
@@ -73,26 +42,25 @@ export function Inbox() {
73
42
  return (
74
43
  <AppShell
75
44
  activeKey="inbox"
76
- breadcrumb={[{ label: 'Acme', href: '#' }, { label: 'Notifications' }]}
45
+ breadcrumb={[{ label: PRODUCT_NAME, href: '#' }, { label: 'Notifications' }]}
77
46
  title="Notifications"
78
47
  actions={
79
48
  <>
80
49
  <Button
81
50
  label="Mark all as read"
82
51
  variant="secondary"
52
+ size="compact"
83
53
  iconLeft="done_all"
84
54
  disabled={unread.length === 0}
85
- onClick={() => setUnread([])}
55
+ onClick={readAll}
86
56
  />
87
57
  <Button
88
58
  label="Clear all"
89
59
  variant="tertiary"
60
+ size="compact"
90
61
  tone="destructive"
91
62
  disabled={items.length === 0}
92
- onClick={() => {
93
- setItems([]);
94
- setUnread([]);
95
- }}
63
+ onClick={clear}
96
64
  />
97
65
  </>
98
66
  }
@@ -56,6 +56,11 @@
56
56
  border-top: var(--border-025) solid var(--color-divider);
57
57
  }
58
58
 
59
+ /* A ruled row is square: a rule drawn on a curved corner bows at both ends. */
60
+ .list > :global(.ds-notification-item) {
61
+ border-radius: 0;
62
+ }
63
+
59
64
  @media (max-width: 480px) {
60
65
  .category {
61
66
  width: 100%;
@@ -8,7 +8,7 @@
8
8
 
9
9
  import { Button } from 'rift-ds/components/Button/Button';
10
10
  import { Widget } from 'rift-ds/components/Widget/Widget';
11
- import { AppShell } from '../../components/blocks/AppShell';
11
+ import { AppShell, PRODUCT_NAME } from '../../components/blocks/AppShell';
12
12
  import { PlannerGrid } from './PlannerGrid';
13
13
  import { Requests } from './Requests';
14
14
  import styles from './page.module.css';
@@ -17,7 +17,7 @@ export default function PlannerPage() {
17
17
  return (
18
18
  <AppShell
19
19
  activeKey="projects"
20
- breadcrumb={[{ label: 'Acme', href: '#' }, { label: 'Planner' }]}
20
+ breadcrumb={[{ label: PRODUCT_NAME, href: '#' }, { label: 'Planner' }]}
21
21
  title="Planner"
22
22
  actions={<Button label="Add a row" variant="secondary" iconLeft="add" />}
23
23
  >
@@ -36,7 +36,7 @@ import { RadioGroup } from 'rift-ds/components/RadioButton/RadioButton';
36
36
  import { SegmentedControl } from 'rift-ds/components/SegmentedControl/SegmentedControl';
37
37
  import { Slider } from 'rift-ds/components/Slider/Slider';
38
38
  import { ToggleSwitch } from 'rift-ds/components/ToggleSwitch/ToggleSwitch';
39
- import { AppShell, SETTINGS_SECTIONS } from '../../components/blocks/AppShell';
39
+ import { AppShell, PRODUCT_NAME, SETTINGS_SECTIONS } from '../../components/blocks/AppShell';
40
40
  import styles from './page.module.css';
41
41
 
42
42
  type SectionId = (typeof SETTINGS_SECTIONS)[number]['id'];
@@ -69,7 +69,7 @@ const HOURS = ['18:00', '20:00', '22:00', '06:00', '08:00'].map((hour) => ({ val
69
69
  type FieldKey = 'workspaceName' | 'workspaceUrl' | 'name' | 'email' | 'phone' | 'password';
70
70
 
71
71
  const INITIAL: Record<FieldKey, string> = {
72
- workspaceName: 'Acme',
72
+ workspaceName: PRODUCT_NAME,
73
73
  workspaceUrl: 'acme',
74
74
  name: 'Alex Morgan',
75
75
  email: 'alex@example.com',
@@ -297,7 +297,7 @@ export function Settings() {
297
297
  <AppShell
298
298
  activeKey="settings"
299
299
  activeSubKey={active}
300
- breadcrumb={[{ label: 'Acme', href: '#' }, { label: 'Settings', href: '#general' }, { label: section.label }]}
300
+ breadcrumb={[{ label: PRODUCT_NAME, href: '#' }, { label: 'Settings', href: '#general' }, { label: section.label }]}
301
301
  title={section.label}
302
302
  description={section.description}
303
303
  >
@@ -362,7 +362,7 @@ export function Settings() {
362
362
  <Row
363
363
  label="Delete this workspace"
364
364
  description="Removes the workspace and everything in it for every member. This cannot be undone."
365
- control={<Button size="compact" variant="primary" tone="destructive" label="Delete workspace" />}
365
+ control={<Button size="compact" variant="secondary" tone="destructive" label="Delete workspace" />}
366
366
  />
367
367
  </Group>
368
368
  </>
@@ -14,11 +14,11 @@
14
14
  * scrolls, moves the page over while the sidebar's panel is open, sets the
15
15
  * content in a raised surface in the inset mode, and on a phone turns the
16
16
  * sidebar into a drawer behind its menu button. The toolbar folds itself by
17
- * its own width: the AI entry to its icon, then the search, then the icon
18
- * controls after the first into a More menu.
17
+ * its own width: the AI entry to its icon, then the search. Help stays in the
18
+ * bar, since a More menu would hold it alone.
19
19
  */
20
20
 
21
- import { useState, type ReactNode } from 'react';
21
+ import type { ReactNode } from 'react';
22
22
  import { AppLayout } from 'rift-ds/components/AppLayout/AppLayout';
23
23
  import type { AppSidebarLayout, AppSidebarProfile, AppSidebarSection } from 'rift-ds/components/AppSidebar/AppSidebar';
24
24
  import { AppToolbar } from 'rift-ds/components/AppToolbar/AppToolbar';
@@ -27,6 +27,7 @@ import { NotificationCenter, NotificationItem } from 'rift-ds/components/Notific
27
27
  import { PageHeader } from 'rift-ds/components/PageHeader/PageHeader';
28
28
  import { useColorMode } from 'rift-ds/components/ThemeToggle/useColorMode';
29
29
  import { useLinkComponent } from 'rift-ds/behaviors/LinkProvider';
30
+ import { useNotifications } from './notifications';
30
31
  import styles from './AppShell.module.css';
31
32
 
32
33
  /**
@@ -59,8 +60,8 @@ type ContentWidth = 'narrow' | 'contained' | 'full';
59
60
  */
60
61
  const CONTENT_WIDTH: ContentWidth = 'contained';
61
62
 
62
- /** The product's name, shown beside the logo in the sidebar. */
63
- const PRODUCT_NAME = 'Acme';
63
+ /** The product's name: beside the logo in the sidebar, and wherever a page names it (import it there). */
64
+ export const PRODUCT_NAME = 'Acme';
64
65
 
65
66
  /** The sidebar's navigation. Give an item an `href` (`'/dashboard'`) to make it a link. */
66
67
  const NAV_SECTIONS: AppSidebarSection[] = [
@@ -138,15 +139,8 @@ function navFor(activeKey: string): AppSidebarSection[] {
138
139
  */
139
140
  const ROUTES = { notifications: 'notifications', settings: 'settings' };
140
141
 
141
- /**
142
- * The bell's latest notifications. Read your own; See all opens the
143
- * notifications block's page at /notifications.
144
- */
145
- const LATEST = [
146
- { id: 'payment', icon: 'payments', title: 'Payment received', text: 'Northwind Supply paid invoice 1042.', time: '2m' },
147
- { id: 'approval', icon: 'approval', title: 'Approval needed', text: 'Jordan Reyes asked to spend $1,632.42.', time: '1h' },
148
- { id: 'statement', icon: 'description', title: 'Statement ready', text: 'Your October statement is ready.', time: 'Mon' },
149
- ];
142
+ /** How many of the newest notifications the bell's panel lists. */
143
+ const BELL_ROWS = 3;
150
144
 
151
145
  const PROFILE: AppSidebarProfile = {
152
146
  name: 'Alex Morgan',
@@ -172,7 +166,8 @@ export interface AppShellProps {
172
166
 
173
167
  export function AppShell({ activeKey, activeSubKey, breadcrumb, title, description, actions, children }: AppShellProps) {
174
168
  const [mode, setMode] = useColorMode();
175
- const [unread, setUnread] = useState<string[]>(['payment', 'approval']);
169
+ const notifications = useNotifications();
170
+ const { unread } = notifications;
176
171
  // PageHeader renders on the server too, so it takes its link as a prop
177
172
  // rather than reading the provider: hand it the app's router link here,
178
173
  // or every breadcrumb click reloads the page.
@@ -231,17 +226,17 @@ export function AppShell({ activeKey, activeSubKey, breadcrumb, title, descripti
231
226
  panel: (
232
227
  <NotificationCenter
233
228
  unreadCount={unread.length}
234
- onMarkAllRead={() => setUnread([])}
229
+ onMarkAllRead={notifications.readAll}
235
230
  seeAllHref={ROUTES.notifications}
236
231
  >
237
- {LATEST.map((item) => (
232
+ {notifications.items.slice(0, BELL_ROWS).map((item) => (
238
233
  <NotificationItem
239
234
  key={item.id}
240
235
  media={item.icon}
241
236
  title={item.title}
242
237
  time={item.time}
243
238
  unread={unread.includes(item.id)}
244
- onSelect={() => setUnread((ids) => ids.filter((id) => id !== item.id))}
239
+ onSelect={() => notifications.read(item.id)}
245
240
  >
246
241
  {item.text}
247
242
  </NotificationItem>
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * The one record of the app's notifications and which are unread. The bell
5
+ * in the shell's toolbar (AppShell.tsx) and the notifications block's page
6
+ * (app/notifications/Inbox.tsx) both read it, so a count is the same
7
+ * wherever it shows and "Mark all as read" on the page clears the bell. It
8
+ * lives in memory for the visit. This file is yours: swap it for your own
9
+ * notifications and your server's read state, behind the same
10
+ * `useNotifications`.
11
+ */
12
+
13
+ import { useSyncExternalStore } from 'react';
14
+
15
+ /** One notification, as the bell and the notifications page both show it. */
16
+ export interface AppNotification {
17
+ id: string;
18
+ /** Which day group the row sits under on the notifications page. */
19
+ group: 'Today' | 'This week' | 'Earlier';
20
+ category: 'payments' | 'cards' | 'team' | 'approvals';
21
+ icon: string;
22
+ title: string;
23
+ text: string;
24
+ /** When it happened, already written for the reader. */
25
+ time: string;
26
+ }
27
+
28
+ const NOTIFICATIONS: AppNotification[] = [
29
+ { id: 'n1', group: 'Today', category: 'payments', icon: 'payments', title: 'Payment received', text: 'Northwind Supply paid invoice 1042 for $4,180.00.', time: '2m' },
30
+ { id: 'n2', group: 'Today', category: 'approvals', icon: 'approval', title: 'Approval needed', text: 'Jordan Reyes asked to spend $1,632.42 from the Software budget.', time: '1h' },
31
+ { id: 'n3', group: 'Today', category: 'cards', icon: 'credit_card_off', title: 'Card frozen', text: 'The card ending in 7781 is frozen until you unfreeze it.', time: '3h' },
32
+ { id: 'n4', group: 'This week', category: 'team', icon: 'person_add', title: 'Invite accepted', text: 'Sam Patel joined the workspace as an admin.', time: 'Tue' },
33
+ { id: 'n5', group: 'This week', category: 'payments', icon: 'schedule', title: 'Payment scheduled', text: '$5,000.00 to Bright Studio goes out on Friday.', time: 'Mon' },
34
+ { id: 'n6', group: 'This week', category: 'approvals', icon: 'receipt_long', title: 'Receipt missing', text: 'Add a receipt for $375.87 at Harbor Bistro.', time: 'Mon' },
35
+ { id: 'n7', group: 'Earlier', category: 'cards', icon: 'credit_card', title: 'New card requested', text: 'Lee Chen asked for a card with a $5,000 limit.', time: 'Nov 18' },
36
+ { id: 'n8', group: 'Earlier', category: 'team', icon: 'shield_person', title: 'Two admins required', text: 'Sensitive changes now need a second admin to approve.', time: 'Nov 14' },
37
+ { id: 'n9', group: 'Earlier', category: 'payments', icon: 'description', title: 'Statement ready', text: 'Your October statement is ready to download.', time: 'Nov 1' },
38
+ ];
39
+
40
+ // The record itself, held in memory for the visit.
41
+ let inbox: { items: AppNotification[]; unread: string[] } = {
42
+ items: NOTIFICATIONS,
43
+ unread: ['n1', 'n2', 'n3', 'n4'],
44
+ };
45
+ const inboxListeners = new Set<() => void>();
46
+ const subscribeInbox = (listener: () => void) => {
47
+ inboxListeners.add(listener);
48
+ return () => {
49
+ inboxListeners.delete(listener);
50
+ };
51
+ };
52
+ const readInbox = () => inbox;
53
+ function writeInbox(next: typeof inbox) {
54
+ inbox = next;
55
+ inboxListeners.forEach((listener) => listener());
56
+ }
57
+
58
+ /** The notifications, which are unread, and the four things a reader does to them. */
59
+ export function useNotifications() {
60
+ const { items, unread } = useSyncExternalStore(subscribeInbox, readInbox, readInbox);
61
+ return {
62
+ items,
63
+ unread,
64
+ /** Marks one as read. */
65
+ read: (id: string) => writeInbox({ items: inbox.items, unread: inbox.unread.filter((other) => other !== id) }),
66
+ /** Marks every one as read. */
67
+ readAll: () => writeInbox({ items: inbox.items, unread: [] }),
68
+ /** Clears one from the list. */
69
+ dismiss: (id: string) =>
70
+ writeInbox({
71
+ items: inbox.items.filter((item) => item.id !== id),
72
+ unread: inbox.unread.filter((other) => other !== id),
73
+ }),
74
+ /** Clears the whole list. */
75
+ clear: () => writeInbox({ items: [], unread: [] }),
76
+ };
77
+ }
@@ -9,6 +9,7 @@
9
9
  "files": [
10
10
  "components/blocks/AppShell.tsx",
11
11
  "components/blocks/AppShell.module.css",
12
+ "components/blocks/notifications.ts",
12
13
  "app/starter/page.tsx",
13
14
  "app/starter/page.module.css",
14
15
  "app/settings/page.tsx",
@@ -27,6 +28,7 @@
27
28
  "files": [
28
29
  "components/blocks/AppShell.tsx",
29
30
  "components/blocks/AppShell.module.css",
31
+ "components/blocks/notifications.ts",
30
32
  "app/dashboard/page.tsx",
31
33
  "app/dashboard/page.module.css",
32
34
  "app/settings/page.tsx",
@@ -45,6 +47,7 @@
45
47
  "files": [
46
48
  "components/blocks/AppShell.tsx",
47
49
  "components/blocks/AppShell.module.css",
50
+ "components/blocks/notifications.ts",
48
51
  "app/settings/page.tsx",
49
52
  "app/settings/page.module.css",
50
53
  "app/settings/Settings.tsx",
@@ -61,6 +64,7 @@
61
64
  "files": [
62
65
  "components/blocks/AppShell.tsx",
63
66
  "components/blocks/AppShell.module.css",
67
+ "components/blocks/notifications.ts",
64
68
  "app/notifications/page.tsx",
65
69
  "app/notifications/page.module.css",
66
70
  "app/notifications/Inbox.tsx",
@@ -77,6 +81,7 @@
77
81
  "files": [
78
82
  "components/blocks/AppShell.tsx",
79
83
  "components/blocks/AppShell.module.css",
84
+ "components/blocks/notifications.ts",
80
85
  "app/planner/page.tsx",
81
86
  "app/planner/page.module.css",
82
87
  "app/planner/PlannerGrid.tsx",
@@ -396,6 +396,7 @@ function ChatWidget({
396
396
  }, [artifacts, turns, openArtifact]);
397
397
  const trailingUp = artifactInline || Boolean(renderAside) && asideOpen && asideWide;
398
398
  const threadsInline = threadsWide && !(trailingUp && !asideRoomy);
399
+ const railNamesChat = builtInThreads && threadsInline && (threadsProps?.logoText ?? title) === title;
399
400
  useEffect(() => {
400
401
  if (!artifacts) return;
401
402
  const host = railsHostRef.current;
@@ -628,7 +629,7 @@ function ChatWidget({
628
629
  }
629
630
  ),
630
631
  typeof logo === "string" ? /* @__PURE__ */ jsx("img", { src: logo, alt: "", width: 20, height: 20 }) : logo,
631
- /* @__PURE__ */ jsx("span", { className: "ds-chat-widget__brand-name", children: title })
632
+ !railNamesChat && /* @__PURE__ */ jsx("span", { className: "ds-chat-widget__brand-name", children: title })
632
633
  ] }),
633
634
  actions: (
634
635
  /* With the agent rail seated inline the cluster moves to the