rift-ds 1.36.0 → 1.37.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 (61) hide show
  1. package/README.md +1 -1
  2. package/behaviors/matchParts.d.ts +9 -0
  3. package/behaviors/matchParts.js +10 -0
  4. package/behaviors/useLayer.d.ts +2 -2
  5. package/bin/templates/blocks/app/landing/page.module.css +50 -0
  6. package/bin/templates/blocks/app/landing/page.tsx +157 -0
  7. package/bin/templates/blocks/app/pricing/page.module.css +15 -0
  8. package/bin/templates/blocks/app/pricing/page.tsx +173 -0
  9. package/bin/templates/blocks/components/blocks/MarketingShell.module.css +66 -0
  10. package/bin/templates/blocks/components/blocks/MarketingShell.tsx +141 -0
  11. package/bin/templates/blocks/components/blocks/emberScene.ts +1 -1
  12. package/bin/templates/blocks/registry.json +24 -0
  13. package/chat/AssistantTurn.js +5 -20
  14. package/components/Chart/ActiveReporter.d.ts +32 -0
  15. package/components/Chart/ActiveReporter.js +31 -0
  16. package/components/Chart/AreaChart.d.ts +7 -1
  17. package/components/Chart/AreaChart.js +8 -3
  18. package/components/Chart/BarChart.d.ts +12 -0
  19. package/components/Chart/BarChart.js +8 -3
  20. package/components/Chart/ComboChart.d.ts +7 -1
  21. package/components/Chart/ComboChart.js +8 -3
  22. package/components/Chart/LineChart.d.ts +7 -1
  23. package/components/Chart/LineChart.js +8 -3
  24. package/components/Chart/StackedBarChart.d.ts +7 -1
  25. package/components/Chart/StackedBarChart.js +8 -3
  26. package/components/Combobox/Combobox.css +26 -0
  27. package/components/Combobox/Combobox.d.ts +10 -0
  28. package/components/Combobox/Combobox.js +10 -0
  29. package/components/CommandPalette/CommandPalette.css +26 -0
  30. package/components/CommandPalette/CommandPalette.d.ts +2 -1
  31. package/components/CommandPalette/CommandPalette.js +21 -4
  32. package/components/Drawer/Drawer.css +49 -7
  33. package/components/Drawer/Drawer.d.ts +17 -1
  34. package/components/Drawer/Drawer.js +27 -5
  35. package/components/Dropdown/Dropdown.css +40 -0
  36. package/components/Dropdown/Dropdown.d.ts +7 -0
  37. package/components/Dropdown/Dropdown.js +23 -38
  38. package/components/Instructions/Instructions.css +21 -0
  39. package/components/Instructions/Instructions.d.ts +5 -2
  40. package/components/Instructions/Instructions.js +1 -1
  41. package/components/Mention/Mention.js +6 -6
  42. package/components/NavList/NavList.d.ts +2 -0
  43. package/components/NavList/NavList.js +1 -0
  44. package/components/ShaderScene/ShaderScene.d.ts +3 -2
  45. package/components/ShaderScene/assemble.js +13 -5
  46. package/components/ShaderScene/renderer.d.ts +2 -2
  47. package/components/ShaderScene/types.d.ts +2 -1
  48. package/components/registry.json +3 -3
  49. package/components/registry.json.d.ts +3 -3
  50. package/components/registry.json.js +1 -1
  51. package/markdown/index.d.ts +8 -0
  52. package/markdown/index.js +10 -0
  53. package/markdown/mappers.d.ts +31 -0
  54. package/markdown/mappers.js +43 -0
  55. package/package.json +7 -2
  56. package/tokens/presets/contrast.css +8 -0
  57. package/tokens/presets/forest.css +8 -0
  58. package/tokens/presets/plum.css +18 -5
  59. package/tokens/presets/warm.css +10 -5
  60. package/tokens/presets/zest.css +22 -5
  61. package/tokens/values.json.js +1 -1
@@ -85,6 +85,30 @@
85
85
  "app/guide/page.module.css",
86
86
  "app/guide/PageFeedback.tsx"
87
87
  ]
88
+ },
89
+ {
90
+ "name": "landing",
91
+ "label": "Landing page",
92
+ "description": "A product's front page in bands: a hero, customer names, features, numbers, quotes, questions and a closing call to act, under a site header and footer.",
93
+ "route": "/landing",
94
+ "files": [
95
+ "components/blocks/MarketingShell.tsx",
96
+ "components/blocks/MarketingShell.module.css",
97
+ "app/landing/page.tsx",
98
+ "app/landing/page.module.css"
99
+ ]
100
+ },
101
+ {
102
+ "name": "pricing",
103
+ "label": "Pricing",
104
+ "description": "Plans side by side with a monthly or yearly choice, each price written for a locale, over a table comparing every feature.",
105
+ "route": "/pricing",
106
+ "files": [
107
+ "components/blocks/MarketingShell.tsx",
108
+ "components/blocks/MarketingShell.module.css",
109
+ "app/pricing/page.tsx",
110
+ "app/pricing/page.module.css"
111
+ ]
88
112
  }
89
113
  ]
90
114
  }
@@ -4,7 +4,7 @@ import { createContext, useContext } from "react";
4
4
  import ReactMarkdown from "react-markdown";
5
5
  import remarkGfm from "remark-gfm";
6
6
  import { AgentStatus } from "../components/AgentStatus/AgentStatus.js";
7
- import { CodeBlock } from "../components/CodeBlock/CodeBlock.js";
7
+ import { MarkdownScrollTable, MarkdownCode } from "../markdown/mappers.js";
8
8
  import { ChatMessage } from "../components/ChatMessage/ChatMessage.js";
9
9
  import { Prose } from "../components/Prose/Prose.js";
10
10
  import { Reasoning } from "../components/Reasoning/Reasoning.js";
@@ -30,29 +30,14 @@ function MarkdownLink({ href, children }) {
30
30
  }
31
31
  }) });
32
32
  }
33
- const hastText = (node) => node.type === "text" ? node.value ?? "" : (node.children ?? []).map(hastText).join("");
34
- function MarkdownPre({ node, children, ...props }) {
35
- const { codeLabel, ...labels } = useContext(CodeBlockLabelsContext) ?? {};
36
- const code = node?.children?.find(
37
- (child) => child.type === "element" && child.tagName === "code"
38
- );
39
- if (!code) return /* @__PURE__ */ jsx("pre", { ...props, children });
40
- const classes = code.properties?.className;
41
- const language = (Array.isArray(classes) ? classes : []).map(String).find((name) => name.startsWith("language-"))?.slice("language-".length);
42
- return /* @__PURE__ */ jsx(
43
- CodeBlock,
44
- {
45
- ...labels,
46
- codeLabel: codeLabel?.(language),
47
- code: hastText(code).replace(/\n$/, ""),
48
- language
49
- }
50
- );
33
+ function MarkdownPre(props) {
34
+ const labels = useContext(CodeBlockLabelsContext);
35
+ return /* @__PURE__ */ jsx(MarkdownCode, { ...props, labels });
51
36
  }
52
37
  const markdownComponents = {
53
38
  a: MarkdownLink,
54
39
  pre: MarkdownPre,
55
- table: ({ children, ...props }) => /* @__PURE__ */ jsx("table", { tabIndex: 0, ...props, children })
40
+ table: MarkdownScrollTable
56
41
  };
57
42
  function AssistantTurn({
58
43
  turn,
@@ -0,0 +1,32 @@
1
+ import { ChartActiveHandler } from './BarChart';
2
+ interface ActiveReporterProps {
3
+ /** Whether recharts has a point active: the pointer over the plot, or the keyboard cursor on a point. */
4
+ active?: boolean;
5
+ /** The tooltip's entries; each carries the row of `data` it was drawn from. */
6
+ payload?: {
7
+ payload?: Record<string, unknown>;
8
+ }[];
9
+ /** The active point's x-axis value, the fallback for finding its row. */
10
+ label?: string | number;
11
+ /** The chart's data, as the consumer passed it. */
12
+ data: Record<string, unknown>[];
13
+ /** The chart's x-axis key. */
14
+ xKey: string;
15
+ /** The consumer's callback. */
16
+ onActiveChange: ChartActiveHandler;
17
+ }
18
+ /**
19
+ * Reports the active point of a cartesian chart to the consumer: the row of
20
+ * `data` under the pointer or the keyboard cursor, and null once neither is
21
+ * on the plot.
22
+ *
23
+ * It renders nothing and sits inside each chart's tooltip content, because
24
+ * that is the one place recharts hands over the active point for a pointer
25
+ * and for its keyboard layer alike, in every 3.x release. The row is found
26
+ * by identity first (recharts passes the consumer's own object through) and
27
+ * by the x-axis value as the fallback. The callback fires only when the
28
+ * active row changes, never per pointer move, and once more with null when
29
+ * the chart unmounts while a point is active.
30
+ */
31
+ export declare function ActiveReporter({ active, payload, label, data, xKey, onActiveChange }: ActiveReporterProps): null;
32
+ export {};
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { useRef, useEffect } from "react";
3
+ function ActiveReporter({ active, payload, label, data, xKey, onActiveChange }) {
4
+ const handlerRef = useRef(onActiveChange);
5
+ useEffect(() => {
6
+ handlerRef.current = onActiveChange;
7
+ });
8
+ let index = -1;
9
+ if (active && payload?.length) {
10
+ const row = payload[0]?.payload;
11
+ index = row ? data.indexOf(row) : -1;
12
+ if (index === -1 && label !== void 0) index = data.findIndex((entry) => entry[xKey] === label);
13
+ }
14
+ const lastIndex = useRef(-1);
15
+ useEffect(() => {
16
+ if (index === lastIndex.current) return;
17
+ lastIndex.current = index;
18
+ if (index >= 0) handlerRef.current(data[index], index);
19
+ else handlerRef.current(null, null);
20
+ }, [index, data]);
21
+ useEffect(
22
+ () => () => {
23
+ if (lastIndex.current !== -1) handlerRef.current(null, null);
24
+ },
25
+ []
26
+ );
27
+ return null;
28
+ }
29
+ export {
30
+ ActiveReporter
31
+ };
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChartSummaryItem } from './BarChart';
2
+ import { ChartActiveHandler, ChartSummaryItem } from './BarChart';
3
3
  export interface AreaSeriesConfig {
4
4
  /** Key in data for this series */
5
5
  dataKey: string;
@@ -39,6 +39,12 @@ type AreaChartOwnProps = {
39
39
  showLegend?: boolean;
40
40
  /** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
41
41
  bare?: boolean;
42
+ /**
43
+ * Called when the active point changes: with the row of `data` under the
44
+ * pointer or the keyboard cursor and its index, and with `null, null` once
45
+ * neither is on the plot. For a headline figure that follows the cursor.
46
+ */
47
+ onActiveChange?: ChartActiveHandler;
42
48
  /** Additional CSS classes on the wrapper */
43
49
  className?: string;
44
50
  };
@@ -1,7 +1,8 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
3
  import React, { useCallback, useId } from "react";
4
4
  import { ResponsiveContainer, AreaChart as AreaChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Area, Legend } from "recharts";
5
+ import { ActiveReporter } from "./ActiveReporter.js";
5
6
  import { readTokenPx, getChartSeriesColors } from "./palette.js";
6
7
  import { useChartAnimation } from "./useChartAnimation.js";
7
8
  import "./Chart.css";
@@ -33,6 +34,7 @@ const AreaChart = React.forwardRef(({
33
34
  showLegend = true,
34
35
  bare = false,
35
36
  className = "",
37
+ onActiveChange,
36
38
  yAxisFormatter,
37
39
  locale: localeProp,
38
40
  ...rest
@@ -53,8 +55,11 @@ const AreaChart = React.forwardRef(({
53
55
  const seriesColors = getChartSeriesColors();
54
56
  const renderTooltip = useCallback(
55
57
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
56
- (props) => /* @__PURE__ */ jsx(AreaTooltip, { ...props, locale }),
57
- [locale]
58
+ (props) => /* @__PURE__ */ jsxs(Fragment, { children: [
59
+ onActiveChange && /* @__PURE__ */ jsx(ActiveReporter, { ...props, data, xKey, onActiveChange }),
60
+ /* @__PURE__ */ jsx(AreaTooltip, { ...props, locale })
61
+ ] }),
62
+ [locale, data, xKey, onActiveChange]
58
63
  );
59
64
  return /* @__PURE__ */ jsxs(
60
65
  "div",
@@ -1,4 +1,10 @@
1
1
  import { default as React } from 'react';
2
+ /**
3
+ * The `onActiveChange` callback of the charts drawn from one `data` array
4
+ * over a shared x-axis (Area, Line, Bar, StackedBar, Combo): the active row
5
+ * of `data` and its index, or `null, null` when no point is active.
6
+ */
7
+ export type ChartActiveHandler = (datum: Record<string, unknown> | null, index: number | null) => void;
2
8
  export interface ChartSummaryItem {
3
9
  /** Label shown above the value */
4
10
  label: string;
@@ -34,6 +40,12 @@ type BarChartOwnProps = {
34
40
  yAxisFormatter?: (value: number) => string;
35
41
  /** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
36
42
  bare?: boolean;
43
+ /**
44
+ * Called when the active point changes: with the row of `data` under the
45
+ * pointer or the keyboard cursor and its index, and with `null, null` once
46
+ * neither is on the plot. For a headline figure that follows the cursor.
47
+ */
48
+ onActiveChange?: ChartActiveHandler;
37
49
  /** Additional CSS classes on the wrapper */
38
50
  className?: string;
39
51
  };
@@ -1,9 +1,10 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
3
  import React, { useCallback, useId } from "react";
4
4
  import { ResponsiveContainer, BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Bar } from "recharts";
5
5
  import { useChartAnimation } from "./useChartAnimation.js";
6
6
  import "./Chart.css";
7
+ import { ActiveReporter } from "./ActiveReporter.js";
7
8
  import { readTokenPx } from "./palette.js";
8
9
  import { useLocale } from "../../behaviors/LocaleProvider.js";
9
10
  import { formatAxisNumber, formatNumber } from "../../behaviors/locale.js";
@@ -40,6 +41,7 @@ const BarChart = React.forwardRef(({
40
41
  height = 350,
41
42
  bare = false,
42
43
  className = "",
44
+ onActiveChange,
43
45
  yAxisFormatter,
44
46
  locale: localeProp,
45
47
  ...rest
@@ -61,8 +63,11 @@ const BarChart = React.forwardRef(({
61
63
  const cursorColor = getCSSVar("--color-bg-container-secondary", "#F1F1F1");
62
64
  const renderTooltip = useCallback(
63
65
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
64
- (props) => /* @__PURE__ */ jsx(ChartTooltip, { ...props, locale, barColor: resolvedBarColor, dataLabel }),
65
- [resolvedBarColor, dataLabel, locale]
66
+ (props) => /* @__PURE__ */ jsxs(Fragment, { children: [
67
+ onActiveChange && /* @__PURE__ */ jsx(ActiveReporter, { ...props, data, xKey, onActiveChange }),
68
+ /* @__PURE__ */ jsx(ChartTooltip, { ...props, locale, barColor: resolvedBarColor, dataLabel })
69
+ ] }),
70
+ [resolvedBarColor, dataLabel, locale, data, xKey, onActiveChange]
66
71
  );
67
72
  return /* @__PURE__ */ jsxs(
68
73
  "div",
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChartSummaryItem } from './BarChart';
2
+ import { ChartActiveHandler, ChartSummaryItem } from './BarChart';
3
3
  /** Props owned by ComboChart itself; everything else falls through to the root div. */
4
4
  type ComboChartOwnProps = {
5
5
  /** The BCP 47 locale the values, tooltips and value axis are written in, such as `de-DE`. Defaults to the nearest LocaleProvider's, else `en-US`. */
@@ -39,6 +39,12 @@ type ComboChartOwnProps = {
39
39
  secondaryAxisFormatter?: (value: number) => string;
40
40
  /** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
41
41
  bare?: boolean;
42
+ /**
43
+ * Called when the active point changes: with the row of `data` under the
44
+ * pointer or the keyboard cursor and its index, and with `null, null` once
45
+ * neither is on the plot. For a headline figure that follows the cursor.
46
+ */
47
+ onActiveChange?: ChartActiveHandler;
42
48
  /** Additional CSS classes on the wrapper */
43
49
  className?: string;
44
50
  };
@@ -1,7 +1,8 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
3
  import React, { useCallback, useId } from "react";
4
4
  import { ResponsiveContainer, ComposedChart, CartesianGrid, XAxis, YAxis, Tooltip, Bar, Line } from "recharts";
5
+ import { ActiveReporter } from "./ActiveReporter.js";
5
6
  import { readTokenPx, getChartSeriesColors } from "./palette.js";
6
7
  import { useChartAnimation } from "./useChartAnimation.js";
7
8
  import "./Chart.css";
@@ -43,6 +44,7 @@ const ComboChart = React.forwardRef(({
43
44
  height = 350,
44
45
  bare = false,
45
46
  className = "",
47
+ onActiveChange,
46
48
  yAxisFormatter,
47
49
  secondaryAxisFormatter,
48
50
  locale: localeProp,
@@ -69,8 +71,11 @@ const ComboChart = React.forwardRef(({
69
71
  const resolvedLineLabel = lineLabel || lineKey;
70
72
  const renderTooltip = useCallback(
71
73
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
72
- (props) => /* @__PURE__ */ jsx(ComboTooltip, { ...props, locale }),
73
- [locale]
74
+ (props) => /* @__PURE__ */ jsxs(Fragment, { children: [
75
+ onActiveChange && /* @__PURE__ */ jsx(ActiveReporter, { ...props, data, xKey, onActiveChange }),
76
+ /* @__PURE__ */ jsx(ComboTooltip, { ...props, locale })
77
+ ] }),
78
+ [locale, data, xKey, onActiveChange]
74
79
  );
75
80
  return /* @__PURE__ */ jsxs(
76
81
  "div",
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChartSummaryItem } from './BarChart';
2
+ import { ChartActiveHandler, ChartSummaryItem } from './BarChart';
3
3
  export interface LineSeriesConfig {
4
4
  /** Key in data for this series */
5
5
  dataKey: string;
@@ -35,6 +35,12 @@ type LineChartOwnProps = {
35
35
  yAxisFormatter?: (value: number) => string;
36
36
  /** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
37
37
  bare?: boolean;
38
+ /**
39
+ * Called when the active point changes: with the row of `data` under the
40
+ * pointer or the keyboard cursor and its index, and with `null, null` once
41
+ * neither is on the plot. For a headline figure that follows the cursor.
42
+ */
43
+ onActiveChange?: ChartActiveHandler;
38
44
  /** Additional CSS classes on the wrapper */
39
45
  className?: string;
40
46
  };
@@ -1,7 +1,8 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
3
  import React, { useCallback, useId } from "react";
4
4
  import { ResponsiveContainer, LineChart as LineChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Line } from "recharts";
5
+ import { ActiveReporter } from "./ActiveReporter.js";
5
6
  import { readTokenPx, getChartSeriesColors } from "./palette.js";
6
7
  import { useChartAnimation } from "./useChartAnimation.js";
7
8
  import "./Chart.css";
@@ -31,6 +32,7 @@ const LineChart = React.forwardRef(({
31
32
  height = 350,
32
33
  bare = false,
33
34
  className = "",
35
+ onActiveChange,
34
36
  yAxisFormatter,
35
37
  locale: localeProp,
36
38
  ...rest
@@ -51,8 +53,11 @@ const LineChart = React.forwardRef(({
51
53
  const seriesColors = getChartSeriesColors();
52
54
  const renderTooltip = useCallback(
53
55
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
54
- (props) => /* @__PURE__ */ jsx(LineChartTooltip, { ...props, locale }),
55
- [locale]
56
+ (props) => /* @__PURE__ */ jsxs(Fragment, { children: [
57
+ onActiveChange && /* @__PURE__ */ jsx(ActiveReporter, { ...props, data, xKey, onActiveChange }),
58
+ /* @__PURE__ */ jsx(LineChartTooltip, { ...props, locale })
59
+ ] }),
60
+ [locale, data, xKey, onActiveChange]
56
61
  );
57
62
  return /* @__PURE__ */ jsxs(
58
63
  "div",
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChartSummaryItem } from './BarChart';
2
+ import { ChartActiveHandler, ChartSummaryItem } from './BarChart';
3
3
  export interface BarSeriesConfig {
4
4
  /** Key in data for this series */
5
5
  dataKey: string;
@@ -33,6 +33,12 @@ type StackedBarChartOwnProps = {
33
33
  yAxisFormatter?: (value: number) => string;
34
34
  /** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
35
35
  bare?: boolean;
36
+ /**
37
+ * Called when the active point changes: with the row of `data` under the
38
+ * pointer or the keyboard cursor and its index, and with `null, null` once
39
+ * neither is on the plot. For a headline figure that follows the cursor.
40
+ */
41
+ onActiveChange?: ChartActiveHandler;
36
42
  /** Additional CSS classes on the wrapper */
37
43
  className?: string;
38
44
  };
@@ -1,7 +1,8 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
3
  import React, { useCallback, useId } from "react";
4
4
  import { ResponsiveContainer, BarChart, CartesianGrid, XAxis, YAxis, Tooltip, Bar } from "recharts";
5
+ import { ActiveReporter } from "./ActiveReporter.js";
5
6
  import { readTokenPx, getChartSeriesColors } from "./palette.js";
6
7
  import { useChartAnimation } from "./useChartAnimation.js";
7
8
  import "./Chart.css";
@@ -32,6 +33,7 @@ const StackedBarChart = React.forwardRef(({
32
33
  yAxisFormatter,
33
34
  bare = false,
34
35
  className = "",
36
+ onActiveChange,
35
37
  locale: localeProp,
36
38
  ...rest
37
39
  }, ref) => {
@@ -52,8 +54,11 @@ const StackedBarChart = React.forwardRef(({
52
54
  const defaultColors = getChartSeriesColors();
53
55
  const renderTooltip = useCallback(
54
56
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
55
- (props) => /* @__PURE__ */ jsx(StackedTooltip, { ...props, locale }),
56
- [locale]
57
+ (props) => /* @__PURE__ */ jsxs(Fragment, { children: [
58
+ onActiveChange && /* @__PURE__ */ jsx(ActiveReporter, { ...props, data, xKey, onActiveChange }),
59
+ /* @__PURE__ */ jsx(StackedTooltip, { ...props, locale })
60
+ ] }),
61
+ [locale, data, xKey, onActiveChange]
57
62
  );
58
63
  return /* @__PURE__ */ jsxs(
59
64
  "div",
@@ -257,6 +257,32 @@
257
257
  flex-direction: column;
258
258
  gap: var(--gap-050);
259
259
  min-width: 0;
260
+ flex: 1;
261
+ }
262
+
263
+ /* The rich row, shared with Dropdown's: a leading mark, and a secondary
264
+ value at the row's end before the chosen mark. The icon side takes the
265
+ padding step below the text side (Button's rule, design.md). */
266
+ .ds-combobox__option-icon {
267
+ --icon-size: var(--icon-size-500);
268
+ color: var(--color-icon-primary);
269
+ flex-shrink: 0;
270
+ }
271
+
272
+ .ds-combobox__option:has(.ds-combobox__option-icon) {
273
+ padding-inline-start: var(--padding-200);
274
+ }
275
+
276
+ .ds-combobox__option-trailing {
277
+ flex-shrink: 0;
278
+ margin-inline-start: var(--gap-200);
279
+ font-family: var(--font-paragraph-sm-family);
280
+ font-size: var(--font-paragraph-sm-size);
281
+ font-weight: var(--font-paragraph-sm-weight);
282
+ line-height: var(--font-paragraph-sm-line-height);
283
+ letter-spacing: var(--font-paragraph-sm-letter-spacing);
284
+ font-variant-numeric: tabular-nums;
285
+ color: var(--color-text-secondary);
260
286
  }
261
287
 
262
288
  .ds-combobox__option-label {
@@ -6,6 +6,16 @@ export interface ComboboxOption {
6
6
  value: string;
7
7
  /** Optional secondary line shown under the label */
8
8
  description?: string;
9
+ /**
10
+ * Mark drawn before the label in the option row: a Material Symbol name
11
+ * (string) or a custom element (ReactNode) such as an Avatar or a logo.
12
+ */
13
+ icon?: string | React.ReactNode;
14
+ /**
15
+ * Content at the end of the option row, before the chosen mark: a balance,
16
+ * a count, a Badge. Shown in the row only, never in the field.
17
+ */
18
+ trailing?: React.ReactNode;
9
19
  /** Whether this option is disabled */
10
20
  disabled?: boolean;
11
21
  }
@@ -7,6 +7,7 @@ import { useAnchoredPosition } from "../../behaviors/useAnchoredPosition.js";
7
7
  import { Field } from "../Field/Field.js";
8
8
  import "./Combobox.css";
9
9
  import "../../fonts/material-symbols.css";
10
+ import { mirrorClass } from "../../behaviors/direction.js";
10
11
  const Combobox = React.forwardRef(({
11
12
  label,
12
13
  placeholder = "Search…",
@@ -243,10 +244,19 @@ const Combobox = React.forwardRef(({
243
244
  onMouseDown: (e) => e.preventDefault(),
244
245
  onClick: () => handleSelect(option),
245
246
  children: [
247
+ option.icon && (typeof option.icon === "string" ? /* @__PURE__ */ jsx(
248
+ "span",
249
+ {
250
+ className: `${baseClass}__option-icon material-symbols-rounded ${mirrorClass(option.icon)}`,
251
+ "aria-hidden": "true",
252
+ children: option.icon
253
+ }
254
+ ) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__option-icon`, "aria-hidden": "true", children: option.icon })),
246
255
  /* @__PURE__ */ jsxs("span", { className: `${baseClass}__option-text`, children: [
247
256
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__option-label`, children: option.label }),
248
257
  option.description && /* @__PURE__ */ jsx("span", { className: `${baseClass}__option-description`, children: option.description })
249
258
  ] }),
259
+ option.trailing != null && option.trailing !== false && /* @__PURE__ */ jsx("span", { className: `${baseClass}__option-trailing`, children: option.trailing }),
250
260
  isSelected && /* @__PURE__ */ jsx(ChosenMark, {})
251
261
  ]
252
262
  },
@@ -250,6 +250,32 @@
250
250
  white-space: nowrap;
251
251
  }
252
252
 
253
+ /* While a query narrows the list, the typed part of each row's text holds
254
+ full strength and the labels step back, the way a mention menu marks a
255
+ match, so a row whose name holds the query reads strongest. Colour
256
+ carries it as well as weight, because a theme may set both paragraph
257
+ weights the same. A destructive row keeps its own colour. */
258
+ .ds-command-palette--filtered .ds-command-palette__command-label {
259
+ color: var(--color-text-secondary);
260
+ }
261
+
262
+ .ds-command-palette__match {
263
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
264
+ color: var(--color-text-primary);
265
+ }
266
+
267
+ .ds-command-palette__command-label .ds-command-palette__match {
268
+ font-weight: inherit;
269
+ }
270
+
271
+ .ds-command-palette--filtered .ds-command-palette__command--destructive .ds-command-palette__command-label {
272
+ color: var(--color-action-destructive-text-secondary);
273
+ }
274
+
275
+ .ds-command-palette__command--destructive .ds-command-palette__command-label .ds-command-palette__match {
276
+ color: inherit;
277
+ }
278
+
253
279
  /* ============================================
254
280
  SHORTCUT KEYS
255
281
  ============================================ */
@@ -90,7 +90,8 @@ export interface CommandPaletteProps extends CommandPaletteOwnProps, Omit<React.
90
90
  }
91
91
  /**
92
92
  * CommandPalette component — a modal Cmd+K launcher that searches a grouped
93
- * command list. Filtering matches labels, descriptions, and keywords; the
93
+ * command list. Filtering matches labels, descriptions, and keywords, and the
94
+ * part of a row's text that holds what was typed is drawn stronger; the
94
95
  * arrow keys move a highlight that stays in view, and Enter runs the command.
95
96
  */
96
97
  export declare const CommandPalette: React.ForwardRefExoticComponent<CommandPaletteProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
3
3
  import React, { useState, useRef, useCallback, useId, useMemo, useEffect } from "react";
4
4
  import { IconButton } from "../IconButton/IconButton.js";
5
5
  import ReactDOM from "react-dom";
@@ -10,9 +10,19 @@ import { useMounted } from "../../behaviors/useMounted.js";
10
10
  import { useLayer } from "../../behaviors/useLayer.js";
11
11
  import { useFocusScope } from "../../behaviors/useFocusScope.js";
12
12
  import { useScrollLock } from "../../behaviors/useScrollLock.js";
13
+ import { matchParts } from "../../behaviors/matchParts.js";
13
14
  import { useShortcut } from "../../behaviors/shortcuts.js";
14
15
  import { mirrorClass } from "../../behaviors/direction.js";
15
16
  const DEFAULT_HOTKEY_KEYS = ["meta+k", "ctrl+k"];
17
+ const renderMatch = (text, query) => {
18
+ const parts = matchParts(text, query);
19
+ if (!parts) return text;
20
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
21
+ parts[0],
22
+ /* @__PURE__ */ jsx("span", { className: "ds-command-palette__match", children: parts[1] }),
23
+ parts[2]
24
+ ] });
25
+ };
16
26
  const CommandPalette = React.forwardRef(({
17
27
  open,
18
28
  onOpenChange,
@@ -138,7 +148,14 @@ const CommandPalette = React.forwardRef(({
138
148
  const listboxId = `${generatedId}-listbox`;
139
149
  const activeCommand = flatCommands[activeIndex];
140
150
  const activeDescendantId = activeCommand && !loading ? `${generatedId}-command-${activeCommand.id}` : void 0;
141
- const classes = [baseClass, open ? `${baseClass}--open` : "", className].filter(Boolean).join(" ");
151
+ const classes = [
152
+ baseClass,
153
+ open ? `${baseClass}--open` : "",
154
+ // Under manualFiltering the host chose the rows by its own test, so a
155
+ // row may not hold the query at all: the labels keep full strength.
156
+ !manualFiltering && query.trim() !== "" ? `${baseClass}--filtered` : "",
157
+ className
158
+ ].filter(Boolean).join(" ");
142
159
  let commandIndex = 0;
143
160
  const palette = /* @__PURE__ */ jsxs("div", { className: classes, children: [
144
161
  /* @__PURE__ */ jsx(
@@ -243,8 +260,8 @@ const CommandPalette = React.forwardRef(({
243
260
  }
244
261
  ),
245
262
  /* @__PURE__ */ jsxs("span", { className: `${baseClass}__command-text`, children: [
246
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__command-label`, children: command.label }),
247
- command.description && /* @__PURE__ */ jsx("span", { className: `${baseClass}__command-description`, children: command.description })
263
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__command-label`, children: renderMatch(command.label, query) }),
264
+ command.description && /* @__PURE__ */ jsx("span", { className: `${baseClass}__command-description`, children: renderMatch(command.description, query) })
248
265
  ] }),
249
266
  command.keys ? /* @__PURE__ */ jsx("span", { className: `${baseClass}__shortcut`, children: /* @__PURE__ */ jsx(Kbd, { keys: command.keys, keyLabels, size: "compact" }) }) : command.shortcut && command.shortcut.length > 0 && /* @__PURE__ */ jsx("span", { className: `${baseClass}__shortcut`, children: command.shortcut.map((key, i) => /* @__PURE__ */ jsx(Kbd, { size: "compact", children: key }, i)) }),
250
267
  command.trailing && /* @__PURE__ */ jsx("span", { className: `${baseClass}__trailing`, children: command.trailing })