rift-ds 1.29.0 → 1.30.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.
- package/README.md +4 -3
- package/bin/rift-ds.mjs +1 -1
- package/bin/templates/app/components/rift/ColorModeScript.tsx +7 -3
- package/bin/templates/blocks/app/settings/ProfileForm.tsx +98 -0
- package/bin/templates/blocks/app/settings/page.module.css +11 -0
- package/bin/templates/blocks/app/settings/page.tsx +84 -0
- package/bin/templates/blocks/components/blocks/AppShell.module.css +8 -41
- package/bin/templates/blocks/components/blocks/AppShell.tsx +9 -11
- package/bin/templates/blocks/registry.json +13 -0
- package/bin/templates/chat/app/api/chat/feedback/route.ts +0 -3
- package/bin/templates/chat/app/api/chat/followups/route.ts +0 -3
- package/bin/templates/chat/app/api/chat/route.ts +0 -2
- package/chat/ChatLauncher.d.ts +9 -1
- package/chat/ChatLauncher.js +3 -1
- package/components/Alert/Alert.css +12 -0
- package/components/Alert/Alert.d.ts +2 -0
- package/components/Alert/Alert.js +3 -1
- package/components/Attachment/Attachment.css +92 -0
- package/components/Attachment/FileRow.d.ts +47 -0
- package/components/Attachment/FileRow.js +38 -0
- package/components/Avatar/Avatar.css +14 -0
- package/components/Avatar/Avatar.d.ts +3 -1
- package/components/Avatar/Avatar.js +3 -2
- package/components/Chart/AreaChart.d.ts +2 -0
- package/components/Chart/AreaChart.js +2 -1
- package/components/Chart/BarChart.d.ts +2 -0
- package/components/Chart/BarChart.js +2 -1
- package/components/Chart/ComboChart.d.ts +4 -0
- package/components/Chart/ComboChart.js +4 -2
- package/components/Chart/LineChart.d.ts +2 -0
- package/components/Chart/LineChart.js +2 -1
- package/components/Chart/PieChart.d.ts +4 -4
- package/components/Chart/PieChart.js +1 -1
- package/components/Chart/ScatterChart.d.ts +2 -0
- package/components/Chart/ScatterChart.js +2 -1
- package/components/Checklist/Checklist.css +123 -0
- package/components/Checklist/Checklist.d.ts +66 -0
- package/components/Checklist/Checklist.js +115 -0
- package/components/CircularButton/CircularButton.css +39 -0
- package/components/CircularButton/CircularButton.d.ts +13 -0
- package/components/CircularButton/CircularButton.js +18 -4
- package/components/ColourSwatch/ColourSwatch.css +3 -1
- package/components/ColourSwatch/ColourSwatch.d.ts +5 -3
- package/components/ColourSwatch/ColourSwatch.js +5 -0
- package/components/Combobox/Combobox.d.ts +4 -2
- package/components/Combobox/Combobox.js +7 -3
- package/components/DataTable/DataTable.css +35 -0
- package/components/DataTable/DataTable.d.ts +34 -2
- package/components/DataTable/DataTable.js +58 -5
- package/components/DataTable/columnTypes.d.ts +1 -1
- package/components/DataTable/columnTypes.js +1 -1
- package/components/DateInput/DateInput.d.ts +4 -2
- package/components/DateInput/DateInput.js +7 -3
- package/components/DescriptionList/DescriptionList.css +28 -0
- package/components/DescriptionList/DescriptionList.d.ts +3 -1
- package/components/DescriptionList/DescriptionList.js +4 -3
- package/components/DescriptionList/DescriptionListCopy.js +2 -0
- package/components/Dropdown/Dropdown.d.ts +4 -2
- package/components/Dropdown/Dropdown.js +7 -3
- package/components/EmptyState/EmptyState.css +12 -0
- package/components/EmptyState/EmptyState.d.ts +7 -0
- package/components/EmptyState/EmptyState.js +2 -0
- package/components/EventCalendar/EventCalendar.css +59 -0
- package/components/EventCalendar/EventCalendar.d.ts +24 -2
- package/components/EventCalendar/EventCalendar.js +104 -19
- package/components/FormSection/FormSection.css +70 -0
- package/components/FormSection/FormSection.d.ts +35 -0
- package/components/FormSection/FormSection.js +35 -0
- package/components/Grid/Grid.css +52 -0
- package/components/Grid/Grid.d.ts +30 -0
- package/components/Grid/Grid.js +36 -0
- package/components/Icon/Icon.css +55 -0
- package/components/Icon/Icon.d.ts +27 -0
- package/components/Icon/Icon.js +42 -0
- package/components/NumberInput/NumberInput.d.ts +4 -2
- package/components/NumberInput/NumberInput.js +7 -3
- package/components/OrgChart/OrgChart.css +143 -0
- package/components/OrgChart/OrgChart.d.ts +44 -0
- package/components/OrgChart/OrgChart.js +26 -0
- package/components/PageHeader/PageHeader.css +74 -0
- package/components/PageHeader/PageHeader.d.ts +39 -0
- package/components/PageHeader/PageHeader.js +33 -0
- package/components/Panel/Panel.css +7 -0
- package/components/Panel/Panel.d.ts +5 -2
- package/components/Panel/Panel.js +2 -1
- package/components/ResourceTimeline/ResourceTimeline.css +194 -0
- package/components/ResourceTimeline/ResourceTimeline.d.ts +57 -0
- package/components/ResourceTimeline/ResourceTimeline.js +129 -0
- package/components/ShaderField/useShaderField.js +13 -1
- package/components/ShaderScene/ShaderScene.d.ts +3 -2
- package/components/ShaderScene/ShaderScene.js +47 -4
- package/components/Stack/Stack.css +68 -0
- package/components/Stack/Stack.d.ts +37 -0
- package/components/Stack/Stack.js +39 -0
- package/components/Stat/Stat.css +65 -0
- package/components/Stat/Stat.d.ts +7 -1
- package/components/Stat/Stat.js +16 -1
- package/components/Table/Table.css +11 -0
- package/components/Table/Table.d.ts +2 -0
- package/components/Table/Table.js +5 -1
- package/components/Tabs/Tabs.css +23 -0
- package/components/Tabs/Tabs.d.ts +9 -8
- package/components/Tabs/Tabs.js +38 -5
- package/components/Textarea/Textarea.d.ts +4 -2
- package/components/Textarea/Textarea.js +7 -3
- package/components/ThemeToggle/colorMode.d.ts +17 -1
- package/components/ThemeToggle/colorMode.js +11 -2
- package/components/Widget/Widget.css +21 -0
- package/components/Widget/Widget.d.ts +4 -0
- package/components/Widget/Widget.js +13 -5
- package/components/Wizard/Wizard.css +67 -0
- package/components/Wizard/Wizard.d.ts +54 -0
- package/components/Wizard/Wizard.js +71 -0
- package/components/registry.d.ts +25 -0
- package/components/registry.js +8 -0
- package/components/registry.json +233 -32
- package/components/registry.json.d.ts +233 -32
- package/components/registry.json.js +1 -1
- package/index.d.ts +10 -0
- package/index.js +20 -0
- package/package.json +1 -1
- package/tokens/motion.d.ts +2 -0
- package/tokens/motion.js +2 -0
- package/tokens/values.d.ts +31 -0
- package/tokens/values.js +16 -0
- package/tokens/values.json.js +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LinkComponent } from '../../behaviors/LinkProvider';
|
|
3
|
+
import { FileKind } from './fileTypes';
|
|
4
|
+
/** Props owned by FileRow itself; everything else falls through to the root `<div>`. */
|
|
5
|
+
type FileRowOwnProps = {
|
|
6
|
+
/** The file's name with its extension (`Q3 report.pdf`), which also picks its type mark. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** The file's MIME type, when its name has no telling extension. */
|
|
9
|
+
mimeType?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The file's kind, when neither its name nor its MIME type says it.
|
|
12
|
+
* @default picked from the name and the MIME type
|
|
13
|
+
*/
|
|
14
|
+
kind?: FileKind;
|
|
15
|
+
/** The type mark's lettering, in place of the one derived from the name. */
|
|
16
|
+
typeLabel?: string;
|
|
17
|
+
/** A quiet second line: the size, who added it, when. */
|
|
18
|
+
meta?: React.ReactNode;
|
|
19
|
+
/** Makes the name a link to the file or its preview page. */
|
|
20
|
+
href?: string;
|
|
21
|
+
/** Makes the name a button that opens the file in place, such as in a DocumentViewer dialog. `href` wins when both are set. */
|
|
22
|
+
onOpen?: () => void;
|
|
23
|
+
/** Controls at the row's end: a download, a share, a menu. */
|
|
24
|
+
actions?: React.ReactNode;
|
|
25
|
+
/** Row density: `compact` for a list in a side panel. */
|
|
26
|
+
size?: 'default' | 'compact';
|
|
27
|
+
/**
|
|
28
|
+
* The component the name's link renders with, such as Next.js's `Link`, so
|
|
29
|
+
* it navigates through the app's router; a plain `<a>` when unset. This
|
|
30
|
+
* component can render on the server, so it never reads a LinkProvider:
|
|
31
|
+
* pass the prop even under one.
|
|
32
|
+
*/
|
|
33
|
+
linkComponent?: LinkComponent;
|
|
34
|
+
/** Additional CSS classes */
|
|
35
|
+
className?: string;
|
|
36
|
+
};
|
|
37
|
+
export interface FileRowProps extends FileRowOwnProps, Omit<React.ComponentPropsWithRef<'div'>, keyof FileRowOwnProps | 'children'> {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One file in a list: its type mark, its name and a line of detail, with
|
|
41
|
+
* controls at the end. The name opens the file, as a link or a button, so a
|
|
42
|
+
* document library, a record's attachments or a shared folder reads as rows
|
|
43
|
+
* a keyboard can walk. The mark is the attachment family's own, so a file
|
|
44
|
+
* looks the same as a row, a tile and in the viewer. Server-renderable.
|
|
45
|
+
*/
|
|
46
|
+
export declare function FileRow({ name, mimeType, kind, typeLabel, meta, href, onOpen, actions, size, linkComponent, className, ref, ...rest }: FileRowProps): React.JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { getFileKind } from "./fileTypes.js";
|
|
4
|
+
import { renderTypeMark } from "./typeMark.js";
|
|
5
|
+
import "./Attachment.css";
|
|
6
|
+
function FileRow({
|
|
7
|
+
name,
|
|
8
|
+
mimeType,
|
|
9
|
+
kind,
|
|
10
|
+
typeLabel,
|
|
11
|
+
meta,
|
|
12
|
+
href,
|
|
13
|
+
onOpen,
|
|
14
|
+
actions,
|
|
15
|
+
size = "default",
|
|
16
|
+
linkComponent,
|
|
17
|
+
className = "",
|
|
18
|
+
ref,
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
const Link = linkComponent ?? "a";
|
|
22
|
+
const resolvedKind = kind ?? getFileKind({ name, type: mimeType });
|
|
23
|
+
const hasMeta = meta != null && meta !== false && meta !== "";
|
|
24
|
+
const hasActions = actions != null && actions !== false;
|
|
25
|
+
const classes = ["ds-file-row", size === "compact" ? "ds-file-row--compact" : "", className].filter(Boolean).join(" ");
|
|
26
|
+
const nameClass = "ds-file-row__name";
|
|
27
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
|
|
28
|
+
renderTypeMark(name, resolvedKind, { typeLabel }),
|
|
29
|
+
/* @__PURE__ */ jsxs("span", { className: "ds-file-row__main", children: [
|
|
30
|
+
href !== void 0 ? /* @__PURE__ */ jsx(Link, { href, className: `${nameClass} ds-file-row__name--action`, children: name }) : onOpen ? /* @__PURE__ */ jsx("button", { type: "button", className: `${nameClass} ds-file-row__name--action`, onClick: onOpen, children: name }) : /* @__PURE__ */ jsx("span", { className: nameClass, children: name }),
|
|
31
|
+
hasMeta && /* @__PURE__ */ jsx("span", { className: "ds-file-row__meta", children: meta })
|
|
32
|
+
] }),
|
|
33
|
+
hasActions && /* @__PURE__ */ jsx("span", { className: "ds-file-row__actions", children: actions })
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
FileRow
|
|
38
|
+
};
|
|
@@ -32,6 +32,20 @@
|
|
|
32
32
|
height: 56px;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/* ============================================
|
|
36
|
+
SQUARE (an organisation)
|
|
37
|
+
A logo is fitted whole, never cropped to the box.
|
|
38
|
+
============================================ */
|
|
39
|
+
|
|
40
|
+
.ds-avatar--square,
|
|
41
|
+
.ds-avatar--square .ds-avatar__image {
|
|
42
|
+
border-radius: var(--radius-300);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ds-avatar--square .ds-avatar__image {
|
|
46
|
+
object-fit: contain;
|
|
47
|
+
}
|
|
48
|
+
|
|
35
49
|
/* ============================================
|
|
36
50
|
IMAGE
|
|
37
51
|
============================================ */
|
|
@@ -4,12 +4,14 @@ import { AvatarFill } from './avatarFill';
|
|
|
4
4
|
type AvatarOwnProps = {
|
|
5
5
|
/** Image source URL */
|
|
6
6
|
src?: string;
|
|
7
|
-
/** Alt text for the image, also the avatar's accessible name. A passed `aria-label` takes precedence. */
|
|
7
|
+
/** Alt text for the image, also the avatar's accessible name. A passed `aria-label` takes precedence. An organisation's avatar (`shape="square"`) should pass it, or it is announced as a user's. */
|
|
8
8
|
alt?: string;
|
|
9
9
|
/** User's name — used for initials fallback */
|
|
10
10
|
name?: string;
|
|
11
11
|
/** Avatar size */
|
|
12
12
|
size?: 'sm' | 'md' | 'lg';
|
|
13
|
+
/** `circle` for a person; `square` for an organisation (a company, a bank, a vendor, an integration): rounded corners on the radius scale, a logo fitted whole rather than cropped, and a building glyph when there is no image or name. */
|
|
14
|
+
shape?: 'circle' | 'square';
|
|
13
15
|
/**
|
|
14
16
|
* Which of the six fills the initials sit on. Picked from the name when
|
|
15
17
|
* unset, so a person keeps one colour everywhere; `neutral` keeps the
|
|
@@ -10,6 +10,7 @@ const Avatar = React.forwardRef(
|
|
|
10
10
|
alt,
|
|
11
11
|
name,
|
|
12
12
|
size = "md",
|
|
13
|
+
shape = "circle",
|
|
13
14
|
fill,
|
|
14
15
|
status,
|
|
15
16
|
statusLabel,
|
|
@@ -21,7 +22,7 @@ const Avatar = React.forwardRef(
|
|
|
21
22
|
const sizeClass = `${baseClass}--${size}`;
|
|
22
23
|
const fillIndex = name?.trim() && fill !== "neutral" ? fill ?? avatarFill(name.trim()) : null;
|
|
23
24
|
const fillClass = fillIndex ? `${baseClass}--fill-${fillIndex}` : "";
|
|
24
|
-
const classes = [baseClass, sizeClass, fillClass, className].filter(Boolean).join(" ");
|
|
25
|
+
const classes = [baseClass, sizeClass, shape === "square" ? `${baseClass}--square` : "", fillClass, className].filter(Boolean).join(" ");
|
|
25
26
|
const getInitials = (fullName) => {
|
|
26
27
|
const parts = fullName.trim().split(/\s+/);
|
|
27
28
|
if (parts.length === 1) return parts[0][0].toUpperCase();
|
|
@@ -47,7 +48,7 @@ const Avatar = React.forwardRef(
|
|
|
47
48
|
{
|
|
48
49
|
className: `${baseClass}__icon material-symbols-rounded`,
|
|
49
50
|
"aria-hidden": "true",
|
|
50
|
-
children: "person"
|
|
51
|
+
children: shape === "square" ? "domain" : "person"
|
|
51
52
|
}
|
|
52
53
|
),
|
|
53
54
|
status && /* @__PURE__ */ jsx(
|
|
@@ -33,6 +33,8 @@ type AreaChartOwnProps = {
|
|
|
33
33
|
summaryItems?: ChartSummaryItem[];
|
|
34
34
|
/** Chart area height in pixels */
|
|
35
35
|
height?: number;
|
|
36
|
+
/** Y-axis tick formatter, such as a currency or a percent. Defaults to a short number in the chart's locale. */
|
|
37
|
+
yAxisFormatter?: (value: number) => string;
|
|
36
38
|
/** Show the legend under a multi-series chart */
|
|
37
39
|
showLegend?: boolean;
|
|
38
40
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
@@ -33,6 +33,7 @@ const AreaChart = React.forwardRef(({
|
|
|
33
33
|
showLegend = true,
|
|
34
34
|
bare = false,
|
|
35
35
|
className = "",
|
|
36
|
+
yAxisFormatter,
|
|
36
37
|
locale: localeProp,
|
|
37
38
|
...rest
|
|
38
39
|
}, ref) => {
|
|
@@ -96,7 +97,7 @@ const AreaChart = React.forwardRef(({
|
|
|
96
97
|
/* @__PURE__ */ jsx(
|
|
97
98
|
YAxis,
|
|
98
99
|
{
|
|
99
|
-
tickFormatter: formatTick,
|
|
100
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
100
101
|
tick: { fill: textSecondary, fontSize: textSize },
|
|
101
102
|
tickLine: false,
|
|
102
103
|
axisLine: false
|
|
@@ -30,6 +30,8 @@ type BarChartOwnProps = {
|
|
|
30
30
|
barColor?: string;
|
|
31
31
|
/** Chart area height in pixels */
|
|
32
32
|
height?: number;
|
|
33
|
+
/** Y-axis tick formatter, such as a currency or a percent. Defaults to a short number in the chart's locale. */
|
|
34
|
+
yAxisFormatter?: (value: number) => string;
|
|
33
35
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
34
36
|
bare?: boolean;
|
|
35
37
|
/** Additional CSS classes on the wrapper */
|
|
@@ -40,6 +40,7 @@ const BarChart = React.forwardRef(({
|
|
|
40
40
|
height = 350,
|
|
41
41
|
bare = false,
|
|
42
42
|
className = "",
|
|
43
|
+
yAxisFormatter,
|
|
43
44
|
locale: localeProp,
|
|
44
45
|
...rest
|
|
45
46
|
}, ref) => {
|
|
@@ -104,7 +105,7 @@ const BarChart = React.forwardRef(({
|
|
|
104
105
|
/* @__PURE__ */ jsx(
|
|
105
106
|
YAxis,
|
|
106
107
|
{
|
|
107
|
-
tickFormatter: formatTick,
|
|
108
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
108
109
|
tick: { fill: textSecondary, fontSize: textSize },
|
|
109
110
|
tickLine: false,
|
|
110
111
|
axisLine: false
|
|
@@ -33,6 +33,10 @@ type ComboChartOwnProps = {
|
|
|
33
33
|
summaryItems?: ChartSummaryItem[];
|
|
34
34
|
/** Chart area height in pixels */
|
|
35
35
|
height?: number;
|
|
36
|
+
/** Tick formatter for the bar series' axis, such as a currency. Defaults to a short number in the chart's locale. */
|
|
37
|
+
yAxisFormatter?: (value: number) => string;
|
|
38
|
+
/** Tick formatter for the line series' axis when `secondaryAxis` draws it, such as a percent. Defaults to a short number in the chart's locale. */
|
|
39
|
+
secondaryAxisFormatter?: (value: number) => string;
|
|
36
40
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
37
41
|
bare?: boolean;
|
|
38
42
|
/** Additional CSS classes on the wrapper */
|
|
@@ -43,6 +43,8 @@ const ComboChart = React.forwardRef(({
|
|
|
43
43
|
height = 350,
|
|
44
44
|
bare = false,
|
|
45
45
|
className = "",
|
|
46
|
+
yAxisFormatter,
|
|
47
|
+
secondaryAxisFormatter,
|
|
46
48
|
locale: localeProp,
|
|
47
49
|
...rest
|
|
48
50
|
}, ref) => {
|
|
@@ -109,7 +111,7 @@ const ComboChart = React.forwardRef(({
|
|
|
109
111
|
/* @__PURE__ */ jsx(
|
|
110
112
|
YAxis,
|
|
111
113
|
{
|
|
112
|
-
tickFormatter: formatTick,
|
|
114
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
113
115
|
yAxisId: "bar",
|
|
114
116
|
tick: { fill: textSecondary, fontSize: textSize },
|
|
115
117
|
tickLine: false,
|
|
@@ -119,7 +121,7 @@ const ComboChart = React.forwardRef(({
|
|
|
119
121
|
secondaryAxis && /* @__PURE__ */ jsx(
|
|
120
122
|
YAxis,
|
|
121
123
|
{
|
|
122
|
-
tickFormatter: formatTick,
|
|
124
|
+
tickFormatter: secondaryAxisFormatter ?? formatTick,
|
|
123
125
|
yAxisId: "line",
|
|
124
126
|
orientation: "right",
|
|
125
127
|
tick: { fill: textSecondary, fontSize: textSize },
|
|
@@ -31,6 +31,8 @@ type LineChartOwnProps = {
|
|
|
31
31
|
summaryItems?: ChartSummaryItem[];
|
|
32
32
|
/** Chart area height in pixels */
|
|
33
33
|
height?: number;
|
|
34
|
+
/** Y-axis tick formatter, such as a currency or a percent. Defaults to a short number in the chart's locale. */
|
|
35
|
+
yAxisFormatter?: (value: number) => string;
|
|
34
36
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
35
37
|
bare?: boolean;
|
|
36
38
|
/** Additional CSS classes on the wrapper */
|
|
@@ -31,6 +31,7 @@ const LineChart = React.forwardRef(({
|
|
|
31
31
|
height = 350,
|
|
32
32
|
bare = false,
|
|
33
33
|
className = "",
|
|
34
|
+
yAxisFormatter,
|
|
34
35
|
locale: localeProp,
|
|
35
36
|
...rest
|
|
36
37
|
}, ref) => {
|
|
@@ -87,7 +88,7 @@ const LineChart = React.forwardRef(({
|
|
|
87
88
|
/* @__PURE__ */ jsx(
|
|
88
89
|
YAxis,
|
|
89
90
|
{
|
|
90
|
-
tickFormatter: formatTick,
|
|
91
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
91
92
|
tick: { fill: textSecondary, fontSize: textSize },
|
|
92
93
|
tickLine: false,
|
|
93
94
|
axisLine: false
|
|
@@ -25,10 +25,10 @@ type PieChartOwnProps = {
|
|
|
25
25
|
summaryItems?: ChartSummaryItem[];
|
|
26
26
|
/** Chart area height in pixels */
|
|
27
27
|
height?: number;
|
|
28
|
-
/** Inner radius for donut
|
|
29
|
-
innerRadius?: number;
|
|
30
|
-
/** Outer radius */
|
|
31
|
-
outerRadius?: number;
|
|
28
|
+
/** Inner radius for a donut (0 for a solid pie): pixels, or a percentage of the room the plot has, such as `'60%'`, so the hole scales with the chart. */
|
|
29
|
+
innerRadius?: number | string;
|
|
30
|
+
/** Outer radius: pixels, or a percentage of the room the plot has once the header and legend take theirs. Defaults to `'90%'`, so the pie fits any `height` without running into its legend. */
|
|
31
|
+
outerRadius?: number | string;
|
|
32
32
|
/** Show legend */
|
|
33
33
|
showLegend?: boolean;
|
|
34
34
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
@@ -33,6 +33,8 @@ type ScatterChartOwnProps = {
|
|
|
33
33
|
summaryItems?: ChartSummaryItem[];
|
|
34
34
|
/** Chart area height in pixels */
|
|
35
35
|
height?: number;
|
|
36
|
+
/** Y-axis tick formatter, such as a currency or a percent. Defaults to a short number in the chart's locale. */
|
|
37
|
+
yAxisFormatter?: (value: number) => string;
|
|
36
38
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
37
39
|
bare?: boolean;
|
|
38
40
|
/** Additional CSS classes on the wrapper */
|
|
@@ -38,6 +38,7 @@ const ScatterChart = React.forwardRef(({
|
|
|
38
38
|
height = 350,
|
|
39
39
|
bare = false,
|
|
40
40
|
className = "",
|
|
41
|
+
yAxisFormatter,
|
|
41
42
|
locale: localeProp,
|
|
42
43
|
...rest
|
|
43
44
|
}, ref) => {
|
|
@@ -99,7 +100,7 @@ const ScatterChart = React.forwardRef(({
|
|
|
99
100
|
/* @__PURE__ */ jsx(
|
|
100
101
|
YAxis,
|
|
101
102
|
{
|
|
102
|
-
tickFormatter: formatTick,
|
|
103
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
103
104
|
type: "number",
|
|
104
105
|
dataKey: yKey,
|
|
105
106
|
name: yLabel,
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
CHECKLIST
|
|
3
|
+
A heading with the count done and a bar, then
|
|
4
|
+
one row per task: the Checkbox with its label
|
|
5
|
+
and description, and at the row's end the
|
|
6
|
+
owner's avatar and an action. Rows divide like
|
|
7
|
+
a WidgetRow list, on --color-divider.
|
|
8
|
+
============================================ */
|
|
9
|
+
|
|
10
|
+
/* Base */
|
|
11
|
+
.ds-checklist {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: var(--gap-400);
|
|
15
|
+
min-width: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Header */
|
|
19
|
+
.ds-checklist__header {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
gap: var(--gap-200);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ds-checklist__title {
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ds-checklist__progress {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: var(--gap-300);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ds-checklist__count {
|
|
36
|
+
flex-shrink: 0;
|
|
37
|
+
font-family: var(--font-paragraph-sm-family);
|
|
38
|
+
font-size: var(--font-paragraph-sm-size);
|
|
39
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
40
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
41
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
42
|
+
color: var(--color-text-secondary);
|
|
43
|
+
font-variant-numeric: tabular-nums;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ds-checklist__bar {
|
|
47
|
+
flex: 1 1 auto;
|
|
48
|
+
min-width: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* List */
|
|
52
|
+
.ds-checklist__list {
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
margin: 0;
|
|
56
|
+
padding: 0;
|
|
57
|
+
list-style: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ds-checklist__item {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: space-between;
|
|
64
|
+
gap: var(--gap-300);
|
|
65
|
+
padding-block: var(--padding-300);
|
|
66
|
+
border-block-end: var(--border-025) solid var(--color-divider);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ds-checklist__item:last-child {
|
|
70
|
+
border-block-end: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ds-checklist--compact .ds-checklist__item {
|
|
74
|
+
padding-block: var(--padding-200);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ds-checklist__task {
|
|
78
|
+
min-width: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Owner and action at the row's end */
|
|
82
|
+
.ds-checklist__meta {
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
gap: var(--gap-200);
|
|
86
|
+
flex-shrink: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Read-only rows: the shared box beside the label, in Checkbox's own type. */
|
|
90
|
+
.ds-checklist__static {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: flex-start;
|
|
93
|
+
gap: var(--gap-200);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.ds-checklist__text {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
gap: var(--gap-050);
|
|
100
|
+
min-width: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.ds-checklist__label {
|
|
104
|
+
font-family: var(--font-paragraph-family);
|
|
105
|
+
font-size: var(--font-paragraph-size);
|
|
106
|
+
font-weight: var(--font-paragraph-weight);
|
|
107
|
+
line-height: var(--font-paragraph-line-height);
|
|
108
|
+
letter-spacing: var(--font-paragraph-letter-spacing);
|
|
109
|
+
color: var(--color-text-primary);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.ds-checklist--compact .ds-checklist__label,
|
|
113
|
+
.ds-checklist__description {
|
|
114
|
+
font-family: var(--font-paragraph-sm-family);
|
|
115
|
+
font-size: var(--font-paragraph-sm-size);
|
|
116
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
117
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
118
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.ds-checklist__description {
|
|
122
|
+
color: var(--color-text-tertiary);
|
|
123
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** One task on a checklist. */
|
|
3
|
+
export interface ChecklistItem {
|
|
4
|
+
/** A stable id, which `values` holds while the task is done. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** What the task is ("Invite your team"). */
|
|
7
|
+
label: string;
|
|
8
|
+
/** A line under the label on what doing it involves. */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Who the task is with: a name, and an image for their avatar. */
|
|
11
|
+
owner?: {
|
|
12
|
+
name: string;
|
|
13
|
+
src?: string;
|
|
14
|
+
};
|
|
15
|
+
/** A control at the end of the row that does the task or opens it, such as a compact Button or a Link. */
|
|
16
|
+
action?: React.ReactNode;
|
|
17
|
+
/** Holds the task as it is: it cannot be ticked or unticked. */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Props owned by Checklist itself; everything else falls through to the root `<section>`. */
|
|
21
|
+
type ChecklistOwnProps = {
|
|
22
|
+
/** The tasks, in the order they are best done. */
|
|
23
|
+
items: ChecklistItem[];
|
|
24
|
+
/**
|
|
25
|
+
* The checklist's heading, which names its section.
|
|
26
|
+
* Note: this shadows the native `title` tooltip attribute, which Checklist does not expose.
|
|
27
|
+
*/
|
|
28
|
+
title?: string;
|
|
29
|
+
/** The ids of the done tasks, for a controlled list. Leave undefined to let the list keep its own, seeded from `defaultValues`. */
|
|
30
|
+
values?: string[];
|
|
31
|
+
/** The ids done on first render when the list is uncontrolled. */
|
|
32
|
+
defaultValues?: string[];
|
|
33
|
+
/** Fires with every done id after a task is ticked or unticked. */
|
|
34
|
+
onValuesChange?: (values: string[]) => void;
|
|
35
|
+
/** Shows the done marks without letting them change, for a list that reports what the host already knows (a setup's steps, a review's checks). */
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
/** Shows how many tasks are done, as a count and a bar, under the heading. Defaults to true. */
|
|
38
|
+
showProgress?: boolean;
|
|
39
|
+
/** The progress count, given the done and total tasks already written in the resolved locale. Defaults to "3 of 5 done". */
|
|
40
|
+
progressLabel?: (done: string, total: string) => string;
|
|
41
|
+
/** The owner avatar's accessible name, given the owner's name. Defaults to "Owner: <name>". */
|
|
42
|
+
ownerLabel?: (name: string) => string;
|
|
43
|
+
/** A read-only row's state, read after its label. Defaults to "Done". */
|
|
44
|
+
doneLabel?: string;
|
|
45
|
+
/** A read-only row's state when it is not done. Defaults to "Not done". */
|
|
46
|
+
notDoneLabel?: string;
|
|
47
|
+
/** The BCP 47 locale the counts are written in, such as `ar-EG`. Defaults to the nearest LocaleProvider's, else `en-US`. */
|
|
48
|
+
locale?: string;
|
|
49
|
+
/** Row density: `compact` for a checklist in a side panel. */
|
|
50
|
+
size?: 'default' | 'compact';
|
|
51
|
+
/** The title's place in the outline. Defaults to 3, a part of a section. */
|
|
52
|
+
headingLevel?: 2 | 3 | 4;
|
|
53
|
+
/** Additional CSS classes */
|
|
54
|
+
className?: string;
|
|
55
|
+
};
|
|
56
|
+
export interface ChecklistProps extends ChecklistOwnProps, Omit<React.ComponentPropsWithRef<'section'>, keyof ChecklistOwnProps | 'children'> {
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Tasks with a done state each: a setup to finish, an onboarding to work
|
|
60
|
+
* through, the checks before a release. Each row is a Checkbox with the
|
|
61
|
+
* task's label and description, its owner's avatar and an optional action,
|
|
62
|
+
* under a heading with the count done and a bar. Read-only, it reports done
|
|
63
|
+
* marks the host owns.
|
|
64
|
+
*/
|
|
65
|
+
export declare function Checklist({ items, title, values, defaultValues, onValuesChange, readOnly, showProgress, progressLabel, ownerLabel, doneLabel, notDoneLabel, locale: localeProp, size, headingLevel, className, ref, ...rest }: ChecklistProps): React.JSX.Element;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { Avatar } from "../Avatar/Avatar.js";
|
|
5
|
+
import { CheckboxIndicator, Checkbox } from "../Checkbox/Checkbox.js";
|
|
6
|
+
import { Heading } from "../Heading/Heading.js";
|
|
7
|
+
import { ProgressBar } from "../ProgressBar/ProgressBar.js";
|
|
8
|
+
import { formatNumber } from "../../behaviors/locale.js";
|
|
9
|
+
import { useLocale } from "../../behaviors/LocaleProvider.js";
|
|
10
|
+
import "../../behaviors/visually-hidden.css";
|
|
11
|
+
import "./Checklist.css";
|
|
12
|
+
const defaultProgressLabel = (done, total) => `${done} of ${total} done`;
|
|
13
|
+
const defaultOwnerLabel = (name) => `Owner: ${name}`;
|
|
14
|
+
function Checklist({
|
|
15
|
+
items,
|
|
16
|
+
title,
|
|
17
|
+
values,
|
|
18
|
+
defaultValues,
|
|
19
|
+
onValuesChange,
|
|
20
|
+
readOnly = false,
|
|
21
|
+
showProgress = true,
|
|
22
|
+
progressLabel = defaultProgressLabel,
|
|
23
|
+
ownerLabel = defaultOwnerLabel,
|
|
24
|
+
doneLabel = "Done",
|
|
25
|
+
notDoneLabel = "Not done",
|
|
26
|
+
locale: localeProp,
|
|
27
|
+
size = "default",
|
|
28
|
+
headingLevel = 3,
|
|
29
|
+
className = "",
|
|
30
|
+
ref,
|
|
31
|
+
...rest
|
|
32
|
+
}) {
|
|
33
|
+
const locale = useLocale(localeProp);
|
|
34
|
+
const headingId = useId();
|
|
35
|
+
const [internal, setInternal] = useState(() => defaultValues ?? []);
|
|
36
|
+
const done = values ?? internal;
|
|
37
|
+
const doneSet = new Set(done);
|
|
38
|
+
const doneCount = items.filter((item) => doneSet.has(item.id)).length;
|
|
39
|
+
const total = items.length;
|
|
40
|
+
const toggle = (id, checked) => {
|
|
41
|
+
const next = checked ? [...done.filter((v) => v !== id), id] : done.filter((v) => v !== id);
|
|
42
|
+
if (values === void 0) setInternal(next);
|
|
43
|
+
onValuesChange?.(next);
|
|
44
|
+
};
|
|
45
|
+
const countText = progressLabel(formatNumber(doneCount, locale), formatNumber(total, locale));
|
|
46
|
+
const classes = ["ds-checklist", size === "compact" ? "ds-checklist--compact" : "", className].filter(Boolean).join(" ");
|
|
47
|
+
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": title ? headingId : void 0, ...rest, ref, className: classes, children: [
|
|
48
|
+
(title || showProgress) && /* @__PURE__ */ jsxs("div", { className: "ds-checklist__header", children: [
|
|
49
|
+
title && /* @__PURE__ */ jsx(Heading, { id: headingId, level: headingLevel, tier: "title-body", className: "ds-checklist__title", children: title }),
|
|
50
|
+
showProgress && total > 0 && /* @__PURE__ */ jsxs("div", { className: "ds-checklist__progress", children: [
|
|
51
|
+
/* @__PURE__ */ jsx("span", { className: "ds-checklist__count", children: countText }),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
ProgressBar,
|
|
54
|
+
{
|
|
55
|
+
value: doneCount / total * 100,
|
|
56
|
+
size: "compact",
|
|
57
|
+
"aria-label": countText,
|
|
58
|
+
locale,
|
|
59
|
+
className: "ds-checklist__bar"
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
] })
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ jsx("ul", { className: "ds-checklist__list", children: items.map((item) => {
|
|
65
|
+
const isDone = doneSet.has(item.id);
|
|
66
|
+
return /* @__PURE__ */ jsxs(
|
|
67
|
+
"li",
|
|
68
|
+
{
|
|
69
|
+
className: ["ds-checklist__item", isDone ? "ds-checklist__item--done" : ""].filter(Boolean).join(" "),
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsx("div", { className: "ds-checklist__task", children: readOnly ? /* @__PURE__ */ jsxs("div", { className: "ds-checklist__static", children: [
|
|
72
|
+
/* @__PURE__ */ jsx(CheckboxIndicator, { checked: isDone, size }),
|
|
73
|
+
/* @__PURE__ */ jsxs("span", { className: "ds-checklist__text", children: [
|
|
74
|
+
/* @__PURE__ */ jsxs("span", { className: "ds-checklist__label", children: [
|
|
75
|
+
item.label,
|
|
76
|
+
/* @__PURE__ */ jsxs("span", { className: "ds-visually-hidden", children: [
|
|
77
|
+
", ",
|
|
78
|
+
isDone ? doneLabel : notDoneLabel
|
|
79
|
+
] })
|
|
80
|
+
] }),
|
|
81
|
+
item.description && /* @__PURE__ */ jsx("span", { className: "ds-checklist__description", children: item.description })
|
|
82
|
+
] })
|
|
83
|
+
] }) : /* @__PURE__ */ jsx(
|
|
84
|
+
Checkbox,
|
|
85
|
+
{
|
|
86
|
+
label: item.label,
|
|
87
|
+
helperText: item.description,
|
|
88
|
+
checked: isDone,
|
|
89
|
+
disabled: item.disabled,
|
|
90
|
+
size,
|
|
91
|
+
onCheckedChange: (checked) => toggle(item.id, checked)
|
|
92
|
+
}
|
|
93
|
+
) }),
|
|
94
|
+
(item.owner || item.action) && /* @__PURE__ */ jsxs("div", { className: "ds-checklist__meta", children: [
|
|
95
|
+
item.owner && /* @__PURE__ */ jsx(
|
|
96
|
+
Avatar,
|
|
97
|
+
{
|
|
98
|
+
name: item.owner.name,
|
|
99
|
+
src: item.owner.src,
|
|
100
|
+
size: "sm",
|
|
101
|
+
"aria-label": ownerLabel(item.owner.name)
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
item.action
|
|
105
|
+
] })
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
item.id
|
|
109
|
+
);
|
|
110
|
+
}) })
|
|
111
|
+
] });
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
Checklist
|
|
115
|
+
};
|