rift-ds 1.27.0 → 1.29.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 (65) hide show
  1. package/README.md +1 -1
  2. package/behaviors/typeahead.d.ts +27 -0
  3. package/behaviors/typeahead.js +30 -0
  4. package/bin/rift-ds.mjs +5 -4
  5. package/bin/templates/blocks/app/shader/page.module.css +75 -0
  6. package/bin/templates/blocks/app/shader/page.tsx +81 -0
  7. package/bin/templates/blocks/components/blocks/emberScene.ts +53 -0
  8. package/bin/templates/blocks/registry.json +11 -0
  9. package/chat/ChatWidget.d.ts +1 -1
  10. package/chat/threads.js +7 -4
  11. package/components/Button/Button.css +38 -0
  12. package/components/Button/Button.d.ts +12 -1
  13. package/components/Button/Button.js +2 -0
  14. package/components/Carousel/Carousel.js +4 -0
  15. package/components/ColorPicker/ColorPicker.js +5 -0
  16. package/components/CommandPalette/CommandPalette.js +1 -0
  17. package/components/ContextMenu/ContextMenu.js +8 -0
  18. package/components/DataTable/DataTable.css +1 -1
  19. package/components/Dropdown/Dropdown.js +13 -0
  20. package/components/DropdownMenu/DropdownMenu.js +12 -0
  21. package/components/EntitySwitcher/EntitySwitcher.js +23 -1
  22. package/components/FilterBar/FilterBar.js +8 -0
  23. package/components/ModelPicker/ModelPicker.js +8 -0
  24. package/components/RadioButton/RadioButton.js +19 -2
  25. package/components/RichDropdown/RichDropdown.js +8 -0
  26. package/components/SegmentedControl/SegmentedControl.js +6 -0
  27. package/components/ShaderScene/ShaderScene.d.ts +36 -13
  28. package/components/ShaderScene/ShaderScene.js +41 -3
  29. package/components/ShaderScene/assemble.d.ts +10 -3
  30. package/components/ShaderScene/assemble.js +29 -0
  31. package/components/ShaderScene/renderer.d.ts +12 -4
  32. package/components/ShaderScene/renderer.js +32 -20
  33. package/components/ShaderScene/scenes.d.ts +78 -0
  34. package/components/ShaderScene/scenes.js +933 -1
  35. package/components/ShaderScene/types.d.ts +52 -23
  36. package/components/ThemePicker/ThemePicker.js +14 -2
  37. package/components/TimePicker/TimePicker.js +8 -0
  38. package/components/Toolbar/Toolbar.d.ts +3 -1
  39. package/components/TreeView/TreeView.js +10 -0
  40. package/components/WorldMap/WorldMap.d.ts +1 -1
  41. package/components/WorldMap/WorldMap.js +1 -1
  42. package/components/keyboard-patterns.json.d.ts +625 -0
  43. package/components/keyboard-patterns.json.js +8 -0
  44. package/components/registry.d.ts +52 -0
  45. package/components/registry.js +13 -1
  46. package/components/registry.json +358 -179
  47. package/components/registry.json.d.ts +358 -179
  48. package/components/registry.json.js +1 -1
  49. package/package.json +1 -1
  50. package/tokens/presets/contrast.css +2 -2
  51. package/tokens/presets/coral.css +2 -2
  52. package/tokens/presets/forest.css +2 -2
  53. package/tokens/presets/gold.css +2 -2
  54. package/tokens/presets/mono.css +92 -98
  55. package/tokens/presets/pink.css +2 -2
  56. package/tokens/presets/plum.css +2 -2
  57. package/tokens/presets/terminal.css +2 -2
  58. package/tokens/presets/warm.css +2 -2
  59. package/tokens/presets/zest.css +2 -2
  60. package/tokens/registry.json +19 -18
  61. package/tokens/registry.json.d.ts +19 -18
  62. package/tokens/registry.json.js +1 -1
  63. package/tokens/tokens-dark.css +4 -1
  64. package/tokens/tokens-light.css +3 -0
  65. package/tokens/values.json.js +1 -1
package/README.md CHANGED
@@ -76,7 +76,7 @@ The quickest start is one file: save [AGENTS.md](https://rift-ds.com/AGENTS.md)
76
76
  curl -o AGENTS.md https://rift-ds.com/AGENTS.md
77
77
  ```
78
78
 
79
- For the full setup, one command teaches a coding agent the system: it installs the generated agent skills into your project and prints the MCP connect line. The skills cover the library's rules, moving existing screens onto the tokens and components, and auditing styles against them.
79
+ For the full setup, one command teaches a coding agent the system: it installs the generated agent skills into your project and prints the MCP connect line. The skills cover the library's rules, moving existing screens onto the tokens and components, auditing styles against them, and writing a shader scene of your own.
80
80
 
81
81
  ```bash
82
82
  npx rift-ds init
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Type-to-find for a list of named items: a menu's items, a listbox's
3
+ * options. Typing a character moves to the next item whose name starts with
4
+ * it; typing several quickly narrows to the first name that starts with all
5
+ * of them, and pressing one character again steps through the names that
6
+ * share it (the WAI-ARIA menu and listbox patterns' typeahead).
7
+ *
8
+ * `useTypeahead` returns one function. A component's keydown handler calls
9
+ * it first, for every key, with the event, the items' names in order and
10
+ * the index it is on. On an index it moves there and is done; on `null` it
11
+ * carries on to its own keys. The handler
12
+ * owns the move and `preventDefault`; this owns only the matching, so it
13
+ * serves a list that moves focus and one that points with
14
+ * `aria-activedescendant` alike.
15
+ *
16
+ * It answers `null`, leaving the key alone, for anything that is not one
17
+ * printable character, for a chord (Ctrl, Meta, Alt), and for a Space that
18
+ * starts a search, since Space on its own activates the item. A `null`
19
+ * name is an item that cannot be landed on (disabled, or unnamed).
20
+ *
21
+ * The run of characters ends at any other key (an arrow, Enter, Escape),
22
+ * which is why the handler passes every key through, or when the next key comes later than the
23
+ * shortcut-sequence window, the same pause that ends a "g then i" shortcut,
24
+ * read from the events' own timestamps so no timer is kept.
25
+ */
26
+ export type Typeahead = (event: Pick<KeyboardEvent, 'key' | 'ctrlKey' | 'metaKey' | 'altKey' | 'timeStamp'>, names: readonly (string | null | undefined)[], current: number) => number | null;
27
+ export declare function useTypeahead(): Typeahead;
@@ -0,0 +1,30 @@
1
+ import { useRef } from "react";
2
+ import { MOTION_SHORTCUT_SEQUENCE_MS } from "../tokens/motion.js";
3
+ const MODIFIERS = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta", "CapsLock"]);
4
+ function useTypeahead() {
5
+ const run = useRef({ text: "", at: 0 });
6
+ return (event, names, current) => {
7
+ const { key } = event;
8
+ if (key.length !== 1) {
9
+ if (!MODIFIERS.has(key)) run.current = { text: "", at: 0 };
10
+ return null;
11
+ }
12
+ if (event.ctrlKey || event.metaKey || event.altKey) return null;
13
+ const fresh = event.timeStamp - run.current.at > MOTION_SHORTCUT_SEQUENCE_MS;
14
+ if (key === " " && (fresh || run.current.text === "")) return null;
15
+ const typed = key.toLowerCase();
16
+ const text = fresh ? typed : run.current.text + typed;
17
+ run.current = { text, at: event.timeStamp };
18
+ const repeated = [...text].every((character) => character === typed);
19
+ const needle = repeated ? typed : text;
20
+ const offset = repeated ? 1 : 0;
21
+ for (let step = 0; step < names.length; step += 1) {
22
+ const index = (Math.max(current, 0) + offset + step) % names.length;
23
+ if (names[index]?.trim().toLowerCase().startsWith(needle)) return index;
24
+ }
25
+ return null;
26
+ };
27
+ }
28
+ export {
29
+ useTypeahead
30
+ };
package/bin/rift-ds.mjs CHANGED
@@ -121,10 +121,11 @@ init chat
121
121
 
122
122
  init block [<name>]
123
123
  Copies a block into a Next.js app router project: a whole starting page
124
- (an app shell, a dashboard, a sign-in) built from the library, its page
125
- under app/ and any shared parts under components/blocks/. The files are
126
- yours from then on. With no name, lists the blocks. Run init app first.
127
- Existing files are never overwritten.
124
+ (an app shell, a dashboard, a sign-in, a shader scene) built from the
125
+ library, its page under app/ and any shared parts under
126
+ components/blocks/. The files are yours from then on. With no name,
127
+ lists the blocks. Run init app first. Existing files are never
128
+ overwritten.
128
129
 
129
130
  --app <dir> The app router folder (default: app/ or src/app/, whichever exists)
130
131
  --dry-run Print what would be written and write nothing
@@ -0,0 +1,75 @@
1
+ /* The scene on a stage beside its controls: two columns on a desktop, the
2
+ stage above the panel on a phone. The stage is the scene's positioned
3
+ ancestor, and it clips the scene to its own rounded box. */
4
+
5
+ .page {
6
+ min-height: 100dvh;
7
+ display: grid;
8
+ grid-template-columns: minmax(0, 1fr) 320px;
9
+ gap: var(--gap-500);
10
+ padding: var(--padding-500);
11
+ background-color: var(--color-bg-page-primary);
12
+ }
13
+
14
+ .stage {
15
+ position: relative;
16
+ min-height: 320px;
17
+ overflow: hidden;
18
+ border-radius: var(--radius-600);
19
+ background-color: var(--color-bg-container-secondary);
20
+ }
21
+
22
+ .panel {
23
+ align-self: start;
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: var(--gap-500);
27
+ padding: var(--padding-500);
28
+ border-radius: var(--radius-600);
29
+ background-color: var(--color-bg-container-primary);
30
+ }
31
+
32
+ .intro {
33
+ display: flex;
34
+ flex-direction: column;
35
+ gap: var(--gap-200);
36
+ }
37
+
38
+ .title {
39
+ margin: 0;
40
+ font-family: var(--font-heading-2-family);
41
+ font-size: var(--font-heading-2-size);
42
+ font-weight: var(--font-heading-2-weight);
43
+ line-height: var(--font-heading-2-line-height);
44
+ letter-spacing: var(--font-heading-2-letter-spacing);
45
+ color: var(--color-text-primary);
46
+ }
47
+
48
+ .subhead,
49
+ .note {
50
+ margin: 0;
51
+ font-size: var(--font-paragraph-sm-size);
52
+ line-height: var(--font-paragraph-sm-line-height);
53
+ color: var(--color-text-secondary);
54
+ }
55
+
56
+ .log {
57
+ margin: 0;
58
+ padding: var(--padding-300);
59
+ overflow-x: auto;
60
+ border-radius: var(--radius-300);
61
+ background-color: var(--color-bg-container-secondary);
62
+ font-family: var(--font-family-code);
63
+ font-size: var(--font-paragraph-sm-size);
64
+ line-height: var(--font-paragraph-sm-line-height);
65
+ color: var(--color-text-primary);
66
+ white-space: pre-wrap;
67
+ }
68
+
69
+ @media (max-width: 959px) {
70
+ .page {
71
+ grid-template-columns: minmax(0, 1fr);
72
+ grid-template-rows: minmax(320px, 50dvh) auto;
73
+ padding: var(--padding-400);
74
+ }
75
+ }
@@ -0,0 +1,81 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * The shader scene block: a scene of your own on a stage, with a slider for
5
+ * each setting it declares. The scene is `emberScene` in
6
+ * components/blocks/emberScene.ts; edit its GLSL and this page follows.
7
+ */
8
+
9
+ import { useState } from 'react';
10
+ import {
11
+ SHADER_PASSES,
12
+ ShaderScene,
13
+ shaderSceneDefaults,
14
+ type ShaderSceneStatus,
15
+ type ShaderSceneValues,
16
+ } from 'rift-ds/components/ShaderScene/ShaderScene';
17
+ import { Slider } from 'rift-ds/components/Slider/Slider';
18
+ import { emberScene } from '../../components/blocks/emberScene';
19
+ import styles from './page.module.css';
20
+
21
+ const SPEED = 1.6;
22
+
23
+ /* What the scene reads each frame: its own settings and every finishing
24
+ pass, at their defaults, with the two fades off so the light fills the
25
+ stage. */
26
+ const initialValues = (): ShaderSceneValues => ({
27
+ speed: SPEED,
28
+ scene: shaderSceneDefaults(emberScene.params),
29
+ passes: Object.fromEntries(
30
+ SHADER_PASSES.map((pass) => [
31
+ pass.id,
32
+ { on: pass.id.startsWith('fade') ? false : pass.on, params: shaderSceneDefaults(pass.params) },
33
+ ])
34
+ ),
35
+ });
36
+
37
+ export default function ShaderScenePage() {
38
+ /* The sliders write this ref and the scene reads it every frame, so a
39
+ drag moves the picture without rendering the page. */
40
+ const [values] = useState(() => ({ current: initialValues() }));
41
+
42
+ const [status, setStatus] = useState<ShaderSceneStatus>('pending');
43
+ const [error, setError] = useState<string>();
44
+
45
+ return (
46
+ <div className={styles.page}>
47
+ <div className={styles.stage}>
48
+ <ShaderScene scene={emberScene} liveRef={values} onStatusChange={setStatus} onError={setError} />
49
+ </div>
50
+
51
+ <main className={styles.panel}>
52
+ <div className={styles.intro}>
53
+ <h1 className={styles.title}>Ember</h1>
54
+ <p className={styles.subhead}>A scene of your own, in the theme’s colours.</p>
55
+ </div>
56
+
57
+ {emberScene.params.map((param) => (
58
+ <Slider
59
+ key={param.key}
60
+ label={param.label}
61
+ min={param.min}
62
+ max={param.max}
63
+ step={param.step}
64
+ defaultValue={param.default}
65
+ showValue
66
+ onValueChange={(value) => {
67
+ values.current.scene[param.key] = value;
68
+ }}
69
+ />
70
+ ))}
71
+
72
+ {status === 'unavailable' && (
73
+ <p className={styles.note} role="status">
74
+ {error ? 'The scene did not compile:' : 'This browser cannot run the scene.'}
75
+ </p>
76
+ )}
77
+ {error && <pre className={styles.log}>{error}</pre>}
78
+ </main>
79
+ </div>
80
+ );
81
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * A shader scene of your own, for ShaderScene's `scene` prop: a bed of
3
+ * light that rises in slow tongues. Rename it, then change it. The three
4
+ * parts are everything a scene is:
5
+ *
6
+ * - `colours`: the custom properties it reads, handed to the GLSL as
7
+ * `u_col[0]`, `u_col[1]` and so on. Naming the theme's ambient roles
8
+ * means it follows the theme and the colour mode.
9
+ * - `params`: its settings. Each arrives as `uniform float u_<key>`,
10
+ * declared for you, and is set through the component's `params` prop.
11
+ * - `glsl`: `vec3 scene(vec2 uv, float t)`, returning the pixel's linear
12
+ * colour over the ground (`u_ground`). `uv` runs 0 to 1 from the bottom
13
+ * left, `t` is seconds, and `fbm`, `vnoise`, `rnd` and `lobe` are there
14
+ * to call.
15
+ *
16
+ * `mode: 'dark'` says it only adds light: on a light page the component
17
+ * lays that light on as a pale tint. Leave it out for a scene that paints
18
+ * both modes itself.
19
+ */
20
+
21
+ import type { ShaderSceneSource } from 'rift-ds/components/ShaderScene/ShaderScene';
22
+
23
+ export const emberScene: ShaderSceneSource = {
24
+ mode: 'dark',
25
+ colours: ['--color-ambient-4', '--color-ambient-5'],
26
+ params: [
27
+ { key: 'glow', label: 'Glow', min: 0, max: 2, step: 0.01, default: 1 },
28
+ { key: 'height', label: 'Height', min: 0.1, max: 1.5, step: 0.01, default: 0.8 },
29
+ { key: 'scale', label: 'Scale', min: 0.5, max: 6, step: 0.05, default: 2.4 },
30
+ ],
31
+ glsl: /* glsl */ `
32
+ vec3 scene(vec2 uv, float t) {
33
+ // Square the space up, so the noise is not stretched on a wide stage.
34
+ float aspect = u_size.x / u_size.y;
35
+ vec2 p = vec2((uv.x - 0.5) * aspect, uv.y);
36
+
37
+ // How high the light reaches in this column: slow noise, drifting.
38
+ float reach = u_height * (0.35 + 1.1 * fbm(vec2(p.x * u_scale + t * 0.05, t * 0.08)));
39
+
40
+ // Brightest at the floor and gone at its reach, with a soft top edge.
41
+ float body = smoothstep(reach, 0.0, uv.y);
42
+ body *= body;
43
+
44
+ // Finer noise rising through it lifts the second colour out as embers.
45
+ float fine = fbm(vec2(p.x, uv.y) * u_scale * 5.0 - vec2(0.0, t * 0.35));
46
+ float embers = smoothstep(0.5, 0.85, fine) * body;
47
+
48
+ // Add the light to the ground: the fades and light mode depend on it.
49
+ vec3 light = (u_col[0] * body * 1.2 + u_col[1] * embers * 0.5) * u_glow;
50
+ return u_ground + light;
51
+ }
52
+ `,
53
+ };
@@ -34,6 +34,17 @@
34
34
  "app/sign-in/page.tsx",
35
35
  "app/sign-in/page.module.css"
36
36
  ]
37
+ },
38
+ {
39
+ "name": "shader-scene",
40
+ "label": "Shader scene",
41
+ "description": "A shader scene of your own on a stage, written in GLSL from the theme's colour roles, with a slider for each setting it declares.",
42
+ "route": "/shader",
43
+ "files": [
44
+ "components/blocks/emberScene.ts",
45
+ "app/shader/page.tsx",
46
+ "app/shader/page.module.css"
47
+ ]
37
48
  }
38
49
  ]
39
50
  }
@@ -171,7 +171,7 @@ export interface ChatWidgetProps {
171
171
  contextPlacement?: 'above' | 'inside';
172
172
  /** The composer's context note, written from `contextLabel`, for a host still on the label prop; `context` takes its `note` as a line. @deprecated Use `context` with its `note`. */
173
173
  contextNote?: (title: string) => string;
174
- /** The second line of the drop overlay with attachments on, written from the limits: the largest file as text ("50 MB"), the most files per message, and the largest file in bytes for a host that formats sizes itself. Defaults to `Up to <maxSize> each · <maxFiles> files max`. */
174
+ /** The second line of the drop overlay with attachments on, written from the limits: the largest file as text ("50 MB"), the most files per message, and the largest file in bytes for a host that formats sizes itself. Defaults to `Up to <maxSize> each · <maxFiles> files max`, which reads the first two and leaves `maxBytes` to a custom hint. */
175
175
  attachHint?: (maxSize: string, maxFiles: number, maxBytes: number) => string;
176
176
  /** The welcome greeting for each part of the visitor's day; a key left out keeps its English. Defaults to "Good morning", "Good afternoon" and "Good evening". */
177
177
  greetings?: Partial<GreetingCopy>;
package/chat/threads.js CHANGED
@@ -35,10 +35,13 @@ function useThreads(chat, options = {}) {
35
35
  const [groups, setGroups] = useState(initialGroups);
36
36
  const [activeThreadId, setActiveThreadId] = useState("");
37
37
  const [renamingId, setRenamingId] = useState(null);
38
- const [projects, setProjects] = useState(options.projects ?? []);
39
- const [activeProjectId, setActiveProjectId] = useState(
40
- options.projects?.[0]?.id
38
+ const [addedProjects, setAddedProjects] = useState([]);
39
+ const projects = useMemo(
40
+ () => [...options.projects ?? [], ...addedProjects],
41
+ [options.projects, addedProjects]
41
42
  );
43
+ const [pickedProjectId, setActiveProjectId] = useState(void 0);
44
+ const activeProjectId = projects.some((project) => project.id === pickedProjectId) ? pickedProjectId : projects[0]?.id;
42
45
  const [openTabs, setOpenTabs] = useState([]);
43
46
  const threadSeq = useRef(0);
44
47
  const nameCursor = useRef(0);
@@ -199,7 +202,7 @@ function useThreads(chat, options = {}) {
199
202
  projectSeq.current += 1;
200
203
  const id = `project-${projectSeq.current}`;
201
204
  const index = projectSeq.current;
202
- setProjects((list) => [...list, { id, label: labels.newProject(index), meta: labels.newProjectMeta }]);
205
+ setAddedProjects((list) => [...list, { id, label: labels.newProject(index), meta: labels.newProjectMeta }]);
203
206
  setActiveProjectId(id);
204
207
  }, [labels]);
205
208
  const actionsFor = useCallback(
@@ -573,6 +573,44 @@
573
573
  height: 100%;
574
574
  }
575
575
 
576
+ /* ============================================
577
+ GLASS
578
+ glass: the button frosts what is behind it, for a busy ground. The blur
579
+ is the floating surfaces' own. An outlined or ghost cell takes the glass
580
+ fill at rest; a filled cell keeps its colour and lets a little of the
581
+ ground through it. These sit after the cells' rest rules and match
582
+ their weight, so they win at rest (and on a disabled button, which
583
+ keeps its glass under the usual dimming), while every pointer hover and
584
+ press rule above carries one more class and still fills the button
585
+ solid. The documentation-only hover and active classes are left out
586
+ through :where(), which adds no weight, so a forced state shows the
587
+ cell's own fill too.
588
+ ============================================ */
589
+
590
+ .ds-button--glass {
591
+ -webkit-backdrop-filter: blur(24px);
592
+ backdrop-filter: blur(24px);
593
+ }
594
+
595
+ .ds-button--glass.ds-button--secondary:where(:not(.ds-button--hover, .ds-button--active)),
596
+ .ds-button--glass.ds-button--secondary-neutral:where(:not(.ds-button--hover, .ds-button--active)),
597
+ .ds-button--glass.ds-button--tertiary:where(:not(.ds-button--hover, .ds-button--active)),
598
+ .ds-button--glass.ds-button--destructive:where(:not(.ds-button--hover, .ds-button--active)) {
599
+ background-color: var(--color-bg-glass);
600
+ }
601
+
602
+ .ds-button--glass.ds-button--primary:where(:not(.ds-button--hover, .ds-button--active)) {
603
+ background-color: color-mix(in srgb, var(--color-action-primary-bg) 72%, transparent);
604
+ }
605
+
606
+ .ds-button--glass.ds-button--neutral:where(:not(.ds-button--hover, .ds-button--active)) {
607
+ background-color: color-mix(in srgb, var(--color-action-neutral-bg) 72%, transparent);
608
+ }
609
+
610
+ .ds-button--glass.ds-button--primary-destructive:where(:not(.ds-button--hover, .ds-button--active)) {
611
+ background-color: color-mix(in srgb, var(--color-action-destructive-bg) 72%, transparent);
612
+ }
613
+
576
614
  /* ============================================
577
615
  FOCUS
578
616
  ============================================ */
@@ -21,6 +21,7 @@ type ButtonOwnProps = {
21
21
  * legacy values from before the split: `neutral` renders as
22
22
  * `variant="primary" tone="neutral"` and `destructive` as
23
23
  * `variant="secondary" tone="destructive"`.
24
+ * @default 'primary'
24
25
  */
25
26
  variant?: 'primary' | 'secondary' | 'tertiary' | 'neutral' | 'destructive';
26
27
  /**
@@ -28,7 +29,9 @@ type ButtonOwnProps = {
28
29
  * `neutral` the greys, `destructive` the danger colour. Tertiary is
29
30
  * already grey, so `neutral` leaves it unchanged; a tertiary
30
31
  * `destructive` takes the outlined look, since a danger action needs a
31
- * visible edge.
32
+ * visible edge. Left unset, a legacy `variant` (`neutral` or
33
+ * `destructive`) supplies the tone instead.
34
+ * @default 'default'
32
35
  */
33
36
  tone?: 'default' | 'neutral' | 'destructive';
34
37
  /** Button size */
@@ -41,6 +44,14 @@ type ButtonOwnProps = {
41
44
  * `disabled`) and sets `aria-busy` on the rendered element.
42
45
  */
43
46
  loading?: boolean;
47
+ /**
48
+ * Frosts the button for a busy ground (a shader, a photo, a chart): the
49
+ * page behind it is blurred, an outlined or ghost button takes the glass
50
+ * fill at rest and a filled one lets a little of the ground through its
51
+ * colour. Hover and press are the variant's own. Works on every `variant`
52
+ * and `tone`.
53
+ */
54
+ glass?: boolean;
44
55
  /** Optional href — renders as <a> instead of <button> */
45
56
  href?: string;
46
57
  /** Optional target attribute for links */
@@ -35,6 +35,7 @@ const Button = React.forwardRef(
35
35
  size = "default",
36
36
  disabled,
37
37
  loading,
38
+ glass,
38
39
  href,
39
40
  target,
40
41
  rel,
@@ -66,6 +67,7 @@ const Button = React.forwardRef(
66
67
  `${baseClass}--${resolvedState}`,
67
68
  `${baseClass}--${size}`,
68
69
  isLoading && `${baseClass}--loading`,
70
+ glass && `${baseClass}--glass`,
69
71
  className
70
72
  ].filter(Boolean).join(" ");
71
73
  const iconClass = "material-symbols-rounded";
@@ -98,6 +98,10 @@ const Carousel = React.forwardRef(
98
98
  target = loop ? (index + 1) % slideCount : Math.min(index + 1, slideCount - 1);
99
99
  } else if (key === "ArrowLeft") {
100
100
  target = loop ? (index - 1 + slideCount) % slideCount : Math.max(index - 1, 0);
101
+ } else if (key === "Home") {
102
+ target = 0;
103
+ } else if (key === "End") {
104
+ target = slideCount - 1;
101
105
  }
102
106
  if (target === void 0) return;
103
107
  e.preventDefault();
@@ -137,6 +137,11 @@ const ColorPicker = React.forwardRef(
137
137
  dismissOnOutsidePress: true,
138
138
  getElements: () => [rootRef.current]
139
139
  });
140
+ useEffect(() => {
141
+ if (!isOpen) return;
142
+ const frame = requestAnimationFrame(() => satRef.current?.focus());
143
+ return () => cancelAnimationFrame(frame);
144
+ }, [isOpen]);
140
145
  const handleRootKeyDown = (e) => {
141
146
  if (e.key === "Escape" && isOpen) {
142
147
  e.preventDefault();
@@ -200,6 +200,7 @@ const CommandPalette = React.forwardRef(({
200
200
  className: `${baseClass}__list`,
201
201
  role: !loading && filteredGroups.length > 0 ? "listbox" : void 0,
202
202
  id: listboxId,
203
+ "aria-label": !loading && filteredGroups.length > 0 ? placeholder : void 0,
203
204
  ref: listRef,
204
205
  children: [
205
206
  loading && /* @__PURE__ */ jsx("p", { className: `${baseClass}__status`, role: "status", children: loadingMessage }),
@@ -3,6 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import React, { useState, useRef, useId, useCallback, useEffect, useLayoutEffect } from "react";
4
4
  import { ChosenMark } from "../Dropdown/Dropdown.js";
5
5
  import { useLayer } from "../../behaviors/useLayer.js";
6
+ import { useTypeahead } from "../../behaviors/typeahead.js";
6
7
  import { MOTION_HOVER_HIDE_DELAY_MS } from "../../tokens/motion.js";
7
8
  import "./ContextMenu.css";
8
9
  import "../../fonts/material-symbols.css";
@@ -243,7 +244,14 @@ const ContextMenu = React.forwardRef(
243
244
  }
244
245
  panel.focus({ preventScroll: true });
245
246
  }, [isOpen, position]);
247
+ const typeahead = useTypeahead();
246
248
  const handleKeyDown = (e) => {
249
+ const hit = typeahead(e, flatItems.map((item) => item.disabled ? null : item.label), focusedIndex);
250
+ if (hit !== null) {
251
+ e.preventDefault();
252
+ setFocusedIndex(hit);
253
+ return;
254
+ }
247
255
  switch (e.key) {
248
256
  case "Enter":
249
257
  case " ": {
@@ -630,7 +630,7 @@
630
630
  /* A save that failed rolled the value back; the cell says so until it is
631
631
  edited again (the message is its tooltip and was announced). */
632
632
  .ds-table__cell.ds-data-table__cell--failed {
633
- box-shadow: inset 0 0 0 var(--border-025) var(--color-status-error-border);
633
+ box-shadow: inset 0 0 0 var(--border-025) var(--color-table-cell-failed);
634
634
  }
635
635
 
636
636
  /* Cell mode: an editable cell shows a pencil at its end edge, centred on
@@ -3,6 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import React, { useState, useId, useRef, useEffect } from "react";
4
4
  import { useAnchoredPosition } from "../../behaviors/useAnchoredPosition.js";
5
5
  import { useLayer } from "../../behaviors/useLayer.js";
6
+ import { useTypeahead } from "../../behaviors/typeahead.js";
6
7
  import { Field } from "../Field/Field.js";
7
8
  import "./Dropdown.css";
8
9
  import "./ChosenMark.css";
@@ -104,8 +105,20 @@ const Dropdown = React.forwardRef(
104
105
  dismissOnOutsidePress: true,
105
106
  getElements: () => [dropdownRef.current]
106
107
  });
108
+ const typeahead = useTypeahead();
107
109
  const handleKeyDown = (e) => {
108
110
  if (disabled) return;
111
+ const hit = typeahead(
112
+ e,
113
+ flatOptions.map((option) => option.disabled ? null : option.label),
114
+ isOpen ? focusedIndex : selectedIndex
115
+ );
116
+ if (hit !== null) {
117
+ e.preventDefault();
118
+ if (isOpen) setFocusedIndex(hit);
119
+ else if (flatOptions[hit].value !== value) handleSelect(flatOptions[hit].value);
120
+ return;
121
+ }
109
122
  switch (e.key) {
110
123
  case "Enter":
111
124
  case " ":
@@ -4,6 +4,7 @@ import React, { useState, useCallback, useRef, useId, useEffect } from "react";
4
4
  import { ChosenMark } from "../Dropdown/Dropdown.js";
5
5
  import { CheckboxIndicator } from "../Checkbox/Checkbox.js";
6
6
  import { useLayer } from "../../behaviors/useLayer.js";
7
+ import { useTypeahead } from "../../behaviors/typeahead.js";
7
8
  import { useAnchoredPosition } from "../../behaviors/useAnchoredPosition.js";
8
9
  import { MOTION_HOVER_HIDE_DELAY_MS } from "../../tokens/motion.js";
9
10
  import "./DropdownMenu.css";
@@ -258,7 +259,14 @@ const DropdownMenu = React.forwardRef(({
258
259
  dismissOnOutsidePress: true,
259
260
  getElements: () => [rootRef.current]
260
261
  });
262
+ const typeahead = useTypeahead();
261
263
  const handleKeyDown = (e) => {
264
+ const hit = typeahead(e, flatItems.map((item) => item.disabled ? null : item.label), focusedIndex);
265
+ if (hit !== null && isOpen) {
266
+ e.preventDefault();
267
+ setFocusedIndex(hit);
268
+ return;
269
+ }
262
270
  switch (e.key) {
263
271
  case "Enter":
264
272
  case " ":
@@ -415,8 +423,10 @@ const DropdownMenu = React.forwardRef(({
415
423
  ].filter(Boolean).join(" ");
416
424
  const itemCounter = { count: 0 };
417
425
  const triggerProps = React.isValidElement(trigger) ? trigger.props : void 0;
426
+ const triggerId = triggerProps?.id ?? `${generatedId}-trigger`;
418
427
  return /* @__PURE__ */ jsx(MenuKeyLabelsContext.Provider, { value: keyLabels, children: /* @__PURE__ */ jsxs("div", { ...rest, className: classes, ref: setRootRef, children: [
419
428
  /* @__PURE__ */ jsx("div", { ref: triggerRef, className: `${baseClass}__trigger`, children: React.isValidElement(trigger) ? React.cloneElement(trigger, {
429
+ id: triggerId,
420
430
  "aria-haspopup": "menu",
421
431
  "aria-expanded": isOpen,
422
432
  "aria-controls": isOpen ? menuId : void 0,
@@ -433,6 +443,7 @@ const DropdownMenu = React.forwardRef(({
433
443
  "button",
434
444
  {
435
445
  type: "button",
446
+ id: triggerId,
436
447
  "aria-haspopup": "menu",
437
448
  "aria-expanded": isOpen,
438
449
  "aria-controls": isOpen ? menuId : void 0,
@@ -448,6 +459,7 @@ const DropdownMenu = React.forwardRef(({
448
459
  id: menuId,
449
460
  className: panelClasses,
450
461
  role: "menu",
462
+ "aria-labelledby": triggerId,
451
463
  ref: (el) => {
452
464
  panelRef.current = el;
453
465
  },
@@ -5,6 +5,7 @@ import { Popover } from "../Popover/Popover.js";
5
5
  import { Input } from "../Input/Input.js";
6
6
  import { ChosenMark } from "../Dropdown/Dropdown.js";
7
7
  import { logicalArrowKey, mirrorClass } from "../../behaviors/direction.js";
8
+ import { useTypeahead } from "../../behaviors/typeahead.js";
8
9
  import "./EntitySwitcher.css";
9
10
  import "../../behaviors/direction.css";
10
11
  import "../../fonts/material-symbols.css";
@@ -93,6 +94,8 @@ function EntitySwitcher({
93
94
  const isCollapsed = collapsedProp ?? !!rootRef.current?.closest('[data-expanded="false"]');
94
95
  setBeside(isCollapsed);
95
96
  setWidth(isCollapsed ? void 0 : rootRef.current?.getBoundingClientRect().width);
97
+ } else if (listRef.current?.closest(".ds-entity-switcher__panel")?.contains(document.activeElement)) {
98
+ rootRef.current?.querySelector(".ds-entity-switcher__trigger")?.focus();
96
99
  }
97
100
  if (openProp === void 0) setOwnOpen(next);
98
101
  onOpenChange?.(next);
@@ -112,12 +115,23 @@ function EntitySwitcher({
112
115
  const term = query.trim().toLowerCase();
113
116
  const level = trail[trail.length - 1];
114
117
  const rows = term ? all.filter((l) => l.item.name.toLowerCase().includes(term)) : (level?.children ?? items).map((item) => ({ item, path: trail }));
118
+ const typeahead = useTypeahead();
115
119
  const onListKeyDown = (event) => {
116
120
  const rowEls = Array.from(
117
121
  listRef.current?.querySelectorAll('[data-row]:not([aria-disabled="true"])') ?? []
118
122
  );
119
123
  const at = rowEls.indexOf(document.activeElement);
120
124
  const key = logicalArrowKey(event.key, event.currentTarget);
125
+ const hit = typeahead(
126
+ event,
127
+ rowEls.map((row2) => row2.querySelector(".ds-entity-switcher__name")?.textContent),
128
+ at
129
+ );
130
+ if (hit !== null) {
131
+ event.preventDefault();
132
+ rowEls[hit]?.focus();
133
+ return;
134
+ }
121
135
  if (key === "ArrowDown" || key === "ArrowUp") {
122
136
  event.preventDefault();
123
137
  const step = key === "ArrowDown" ? 1 : -1;
@@ -249,7 +263,15 @@ function EntitySwitcher({
249
263
  )
250
264
  ] });
251
265
  React.useEffect(() => {
252
- if (open && !searchable) focusFirstRow();
266
+ if (!open) return;
267
+ if (!searchable) {
268
+ focusFirstRow();
269
+ return;
270
+ }
271
+ const frame = requestAnimationFrame(
272
+ () => listRef.current?.closest(".ds-entity-switcher__panel")?.querySelector(".ds-entity-switcher__search input")?.focus()
273
+ );
274
+ return () => cancelAnimationFrame(frame);
253
275
  }, [open, searchable]);
254
276
  if (!selected) return null;
255
277
  const triggerSub = selected.item.description ?? (selected.path.map((p) => p.name).join(" / ") || void 0);