rift-ds 1.36.0 → 1.37.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.
- package/README.md +1 -1
- package/behaviors/matchParts.d.ts +9 -0
- package/behaviors/matchParts.js +10 -0
- package/behaviors/useLayer.d.ts +2 -2
- package/behaviors/whenProgramLinked.d.ts +26 -0
- package/behaviors/whenProgramLinked.js +22 -0
- package/bin/templates/blocks/app/landing/page.module.css +50 -0
- package/bin/templates/blocks/app/landing/page.tsx +157 -0
- package/bin/templates/blocks/app/pricing/page.module.css +15 -0
- package/bin/templates/blocks/app/pricing/page.tsx +173 -0
- package/bin/templates/blocks/components/blocks/MarketingShell.module.css +66 -0
- package/bin/templates/blocks/components/blocks/MarketingShell.tsx +141 -0
- package/bin/templates/blocks/components/blocks/emberScene.ts +1 -1
- package/bin/templates/blocks/registry.json +24 -0
- package/chat/AssistantTurn.js +5 -20
- package/components/Chart/ActiveReporter.d.ts +32 -0
- package/components/Chart/ActiveReporter.js +31 -0
- package/components/Chart/AreaChart.d.ts +7 -1
- package/components/Chart/AreaChart.js +8 -3
- package/components/Chart/BarChart.d.ts +12 -0
- package/components/Chart/BarChart.js +8 -3
- package/components/Chart/ComboChart.d.ts +7 -1
- package/components/Chart/ComboChart.js +8 -3
- package/components/Chart/LineChart.d.ts +7 -1
- package/components/Chart/LineChart.js +8 -3
- package/components/Chart/StackedBarChart.d.ts +7 -1
- package/components/Chart/StackedBarChart.js +8 -3
- package/components/Combobox/Combobox.css +26 -0
- package/components/Combobox/Combobox.d.ts +10 -0
- package/components/Combobox/Combobox.js +10 -0
- package/components/CommandPalette/CommandPalette.css +26 -0
- package/components/CommandPalette/CommandPalette.d.ts +2 -1
- package/components/CommandPalette/CommandPalette.js +21 -4
- package/components/Drawer/Drawer.css +49 -7
- package/components/Drawer/Drawer.d.ts +17 -1
- package/components/Drawer/Drawer.js +27 -5
- package/components/Dropdown/Dropdown.css +40 -0
- package/components/Dropdown/Dropdown.d.ts +7 -0
- package/components/Dropdown/Dropdown.js +23 -38
- package/components/Instructions/Instructions.css +21 -0
- package/components/Instructions/Instructions.d.ts +5 -2
- package/components/Instructions/Instructions.js +1 -1
- package/components/Mention/Mention.js +6 -6
- package/components/NavList/NavList.d.ts +2 -0
- package/components/NavList/NavList.js +1 -0
- package/components/ShaderField/useShaderField.js +63 -27
- package/components/ShaderScene/ShaderScene.d.ts +3 -2
- package/components/ShaderScene/ShaderScene.js +135 -95
- package/components/ShaderScene/assemble.js +13 -5
- package/components/ShaderScene/renderer.d.ts +17 -5
- package/components/ShaderScene/renderer.js +45 -14
- package/components/ShaderScene/types.d.ts +2 -1
- package/components/SiteHeader/SiteHeader.css +15 -0
- package/components/registry.json +3 -3
- package/components/registry.json.d.ts +3 -3
- package/components/registry.json.js +1 -1
- package/markdown/index.d.ts +8 -0
- package/markdown/index.js +10 -0
- package/markdown/mappers.d.ts +31 -0
- package/markdown/mappers.js +43 -0
- package/package.json +7 -2
- package/tokens/presets/contrast.css +8 -0
- package/tokens/presets/forest.css +8 -0
- package/tokens/presets/plum.css +18 -5
- package/tokens/presets/warm.css +10 -5
- package/tokens/presets/zest.css +22 -5
- package/tokens/values.json.js +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shell the marketing blocks sit in: rift-ds's SiteHeader over the page
|
|
3
|
+
* and a SiteFooter under it, sharing one page width. `Band` is the
|
|
4
|
+
* full-width strip every section of a marketing page is: a surface running
|
|
5
|
+
* edge to edge with its content held to one centred width. This file is
|
|
6
|
+
* yours: rename the product, replace the sections and the footer's columns
|
|
7
|
+
* with your own.
|
|
8
|
+
*
|
|
9
|
+
* A page is a stack of bands. Alternate `surface` between `page` and
|
|
10
|
+
* `raised` to separate one section from the next with no rule between
|
|
11
|
+
* them, and pass `width="narrow"` for a band of reading copy (a FAQ, a
|
|
12
|
+
* closing line).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { ReactNode } from 'react';
|
|
16
|
+
import { Button } from 'rift-ds/components/Button/Button';
|
|
17
|
+
import { SiteFooter, type SiteFooterColumn } from 'rift-ds/components/SiteFooter/SiteFooter';
|
|
18
|
+
import { SiteHeader, type SiteHeaderSection } from 'rift-ds/components/SiteHeader/SiteHeader';
|
|
19
|
+
import { ThemeToggle } from 'rift-ds/components/ThemeToggle/ThemeToggle';
|
|
20
|
+
import styles from './MarketingShell.module.css';
|
|
21
|
+
|
|
22
|
+
/** The product's name, shown in the header and the footer. */
|
|
23
|
+
const PRODUCT_NAME = 'Acme';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* How wide the page's column runs: `narrow` (1200px), `default` (1440px)
|
|
27
|
+
* or `wide` (1680px). The header, every band and the footer read it, so
|
|
28
|
+
* they share one pair of edges.
|
|
29
|
+
*/
|
|
30
|
+
const PAGE_WIDTH: 'narrow' | 'default' | 'wide' = 'narrow';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The header's sections. Point each `href` at the route it opens in your
|
|
34
|
+
* app (the placeholders are fragments, so the block works before those
|
|
35
|
+
* routes exist), and give one a `mega` menu when it has pages of its own.
|
|
36
|
+
*/
|
|
37
|
+
const SECTIONS: SiteHeaderSection[] = [
|
|
38
|
+
{ id: 'product', label: 'Product', href: '#product' },
|
|
39
|
+
{ id: 'pricing', label: 'Pricing', href: '#pricing' },
|
|
40
|
+
{ id: 'docs', label: 'Docs', href: '#docs' },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
/** The footer's sitemap. */
|
|
44
|
+
const FOOTER_COLUMNS: SiteFooterColumn[] = [
|
|
45
|
+
{
|
|
46
|
+
label: 'Product',
|
|
47
|
+
links: [
|
|
48
|
+
{ label: 'Overview', href: '#' },
|
|
49
|
+
{ label: 'Pricing', href: '#' },
|
|
50
|
+
{ label: 'Changelog', href: '#' },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: 'Resources',
|
|
55
|
+
links: [
|
|
56
|
+
{ label: 'Docs', href: '#' },
|
|
57
|
+
{ label: 'Guides', href: '#' },
|
|
58
|
+
{ label: 'Status', href: '#' },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: 'Company',
|
|
63
|
+
links: [
|
|
64
|
+
{ label: 'About', href: '#' },
|
|
65
|
+
{ label: 'Careers', href: '#' },
|
|
66
|
+
{ label: 'Contact', href: '#' },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export interface MarketingShellProps {
|
|
72
|
+
/** The path of the page being shown, which marks its section in the header. */
|
|
73
|
+
currentHref?: string;
|
|
74
|
+
/** The page: a stack of bands. */
|
|
75
|
+
children: ReactNode;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function MarketingShell({ currentHref, children }: MarketingShellProps) {
|
|
79
|
+
return (
|
|
80
|
+
<div className={styles.shell} data-ds-width="contained" data-ds-contained={PAGE_WIDTH}>
|
|
81
|
+
<SiteHeader
|
|
82
|
+
brand={<span className={styles.brand}>{PRODUCT_NAME}</span>}
|
|
83
|
+
sections={SECTIONS}
|
|
84
|
+
currentHref={currentHref}
|
|
85
|
+
width="contained"
|
|
86
|
+
actions={<ThemeToggle size="compact" cycle />}
|
|
87
|
+
wideActions={
|
|
88
|
+
<>
|
|
89
|
+
<Button variant="tertiary" label="Sign in" href="#" />
|
|
90
|
+
<Button variant="primary" label="Get started" href="#" />
|
|
91
|
+
</>
|
|
92
|
+
}
|
|
93
|
+
drawerFooter={
|
|
94
|
+
<>
|
|
95
|
+
<Button variant="secondary" tone="neutral" label="Sign in" href="#" />
|
|
96
|
+
<Button variant="primary" label="Get started" href="#" />
|
|
97
|
+
</>
|
|
98
|
+
}
|
|
99
|
+
/>
|
|
100
|
+
<main className={styles.main}>{children}</main>
|
|
101
|
+
{/* The footer sits in the same column as the bands. */}
|
|
102
|
+
<div className={`${styles.inner} ${styles.footer}`}>
|
|
103
|
+
<SiteFooter
|
|
104
|
+
brand={<span className={styles.brand}>{PRODUCT_NAME}</span>}
|
|
105
|
+
description="The one place your team plans, ships and learns."
|
|
106
|
+
columns={FOOTER_COLUMNS}
|
|
107
|
+
legal={`© ${PRODUCT_NAME}, Inc.`}
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface BandProps {
|
|
115
|
+
/** The strip's fill: the page's own, or the raised surface that sets a section apart. */
|
|
116
|
+
surface?: 'page' | 'raised';
|
|
117
|
+
/** How wide the content runs: the page's width, or a reading measure. */
|
|
118
|
+
width?: 'default' | 'narrow';
|
|
119
|
+
/** How much room the strip gives above and below its content. */
|
|
120
|
+
spacing?: 'default' | 'large';
|
|
121
|
+
/** An id on the section, for a link to it. */
|
|
122
|
+
id?: string;
|
|
123
|
+
/** Names the section for assistive technology when it has no heading of its own. */
|
|
124
|
+
'aria-label'?: string;
|
|
125
|
+
children: ReactNode;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function Band({ surface = 'page', width = 'default', spacing = 'default', id, children, ...rest }: BandProps) {
|
|
129
|
+
const classes = [
|
|
130
|
+
styles.band,
|
|
131
|
+
surface === 'raised' ? styles.bandRaised : '',
|
|
132
|
+
spacing === 'large' ? styles.bandLarge : '',
|
|
133
|
+
]
|
|
134
|
+
.filter(Boolean)
|
|
135
|
+
.join(' ');
|
|
136
|
+
return (
|
|
137
|
+
<section id={id} className={classes} aria-label={rest['aria-label']}>
|
|
138
|
+
<div className={width === 'narrow' ? `${styles.inner} ${styles.innerNarrow}` : styles.inner}>{children}</div>
|
|
139
|
+
</section>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* to call.
|
|
15
15
|
*
|
|
16
16
|
* `mode: 'dark'` says it only adds light: on a light page the component
|
|
17
|
-
* lays that light on as
|
|
17
|
+
* lays that light on as colour and ink. Leave it out for a scene that paints
|
|
18
18
|
* both modes itself.
|
|
19
19
|
*/
|
|
20
20
|
|
|
@@ -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
|
}
|
package/chat/AssistantTurn.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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:
|
|
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 {
|
|
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__ */
|
|
57
|
-
|
|
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 {
|
|
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__ */
|
|
65
|
-
|
|
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 {
|
|
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__ */
|
|
73
|
-
|
|
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 {
|
|
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__ */
|
|
55
|
-
|
|
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 {
|
|
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__ */
|
|
56
|
-
|
|
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
|
},
|