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,37 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** A step on the gap scale, as the `--gap-*` token it names. */
|
|
3
|
+
export type StackGap = '050' | '100' | '200' | '300' | '400' | '500' | '1000' | '1500' | '2000' | '3000';
|
|
4
|
+
/** Props owned by Stack itself; everything else falls through to the root element. */
|
|
5
|
+
type StackOwnProps = {
|
|
6
|
+
/** `column` lays the children top to bottom; `row` lays them in the reading direction. */
|
|
7
|
+
direction?: 'column' | 'row';
|
|
8
|
+
/** The space between children, as a step on the gap scale (`--gap-400` by default). */
|
|
9
|
+
gap?: StackGap;
|
|
10
|
+
/**
|
|
11
|
+
* How children line up across the stack: `stretch` fills it, which keeps
|
|
12
|
+
* cards in a row the same height. A column stretches and a row centres
|
|
13
|
+
* unless it is set.
|
|
14
|
+
* @default 'stretch' in a column, 'center' in a row
|
|
15
|
+
*/
|
|
16
|
+
align?: 'start' | 'center' | 'end' | 'baseline' | 'stretch';
|
|
17
|
+
/** How children spread along the stack. `between` pushes the first and last to the ends. */
|
|
18
|
+
justify?: 'start' | 'center' | 'end' | 'between';
|
|
19
|
+
/** Lets a row wrap onto more lines when it runs out of room, keeping the gap between lines. */
|
|
20
|
+
wrap?: boolean;
|
|
21
|
+
/** The element the stack renders as, so it can be a list, a section or a form. */
|
|
22
|
+
as?: 'div' | 'section' | 'ul' | 'ol' | 'li' | 'form' | 'fieldset' | 'header' | 'footer' | 'nav' | 'span';
|
|
23
|
+
/** The stack's children. */
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
/** Additional CSS classes */
|
|
26
|
+
className?: string;
|
|
27
|
+
};
|
|
28
|
+
export interface StackProps extends StackOwnProps, Omit<React.ComponentPropsWithRef<'div'>, keyof StackOwnProps> {
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Lays children out in one direction with a gap from the scale: the column
|
|
32
|
+
* every page, panel and form is made of, or a row of controls or cards.
|
|
33
|
+
* Presentational and server-renderable; it adds no semantics, so `as` picks
|
|
34
|
+
* the element when the stack is a list or a section.
|
|
35
|
+
*/
|
|
36
|
+
export declare function Stack({ direction, gap, align, justify, wrap, as, className, style, children, ref, ...rest }: StackProps): React.JSX.Element;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "./Stack.css";
|
|
4
|
+
function Stack({
|
|
5
|
+
direction = "column",
|
|
6
|
+
gap = "400",
|
|
7
|
+
align,
|
|
8
|
+
justify = "start",
|
|
9
|
+
wrap = false,
|
|
10
|
+
as = "div",
|
|
11
|
+
className = "",
|
|
12
|
+
style,
|
|
13
|
+
children,
|
|
14
|
+
ref,
|
|
15
|
+
...rest
|
|
16
|
+
}) {
|
|
17
|
+
const Element = as;
|
|
18
|
+
const classes = [
|
|
19
|
+
"ds-stack",
|
|
20
|
+
`ds-stack--${direction}`,
|
|
21
|
+
`ds-stack--align-${align ?? (direction === "row" ? "center" : "stretch")}`,
|
|
22
|
+
`ds-stack--justify-${justify}`,
|
|
23
|
+
wrap ? "ds-stack--wrap" : "",
|
|
24
|
+
className
|
|
25
|
+
].filter(Boolean).join(" ");
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
Element,
|
|
28
|
+
{
|
|
29
|
+
...rest,
|
|
30
|
+
ref,
|
|
31
|
+
className: classes,
|
|
32
|
+
style: { ...style, "--ds-stack-gap": `var(--gap-${gap})` },
|
|
33
|
+
children
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
Stack
|
|
39
|
+
};
|
package/components/Stat/Stat.css
CHANGED
|
@@ -33,6 +33,50 @@
|
|
|
33
33
|
letter-spacing: var(--font-display-2-letter-spacing);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/* ============================================
|
|
37
|
+
HEAD — an icon tile and a caption above the
|
|
38
|
+
value. A headed stat fills its tile's width,
|
|
39
|
+
so the caption reaches the far end.
|
|
40
|
+
============================================ */
|
|
41
|
+
|
|
42
|
+
.ds-stat--headed {
|
|
43
|
+
display: flex;
|
|
44
|
+
gap: var(--gap-050);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ds-stat__head {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
gap: var(--gap-200);
|
|
52
|
+
align-self: stretch;
|
|
53
|
+
/* The head sits --gap-300 above the value: the stat's own row gap
|
|
54
|
+
(--gap-050) plus this margin. */
|
|
55
|
+
margin-block-end: calc(var(--gap-300) - var(--gap-050));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* A node passed as the icon sits where Icon's tile would. */
|
|
59
|
+
.ds-stat__icon {
|
|
60
|
+
flex-shrink: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ds-stat__caption {
|
|
64
|
+
margin-inline-start: auto;
|
|
65
|
+
font-family: var(--font-caption-family);
|
|
66
|
+
font-size: var(--font-caption-size);
|
|
67
|
+
font-weight: var(--font-caption-weight);
|
|
68
|
+
line-height: var(--font-caption-line-height);
|
|
69
|
+
letter-spacing: var(--font-caption-letter-spacing);
|
|
70
|
+
color: var(--color-text-tertiary);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* What follows the figures (a Sparkline, an AvatarGroup) runs the stat's width. */
|
|
74
|
+
.ds-stat__extra {
|
|
75
|
+
display: block;
|
|
76
|
+
align-self: stretch;
|
|
77
|
+
margin-block-start: var(--gap-200);
|
|
78
|
+
}
|
|
79
|
+
|
|
36
80
|
/* ============================================
|
|
37
81
|
LABEL
|
|
38
82
|
============================================ */
|
|
@@ -95,6 +139,22 @@
|
|
|
95
139
|
row-gap: var(--gap-050);
|
|
96
140
|
}
|
|
97
141
|
|
|
142
|
+
/* A head and the extras run the grid's full width, above and below. */
|
|
143
|
+
.ds-stat--delta-inline.ds-stat--headed {
|
|
144
|
+
grid-template-areas:
|
|
145
|
+
'head head'
|
|
146
|
+
'value delta'
|
|
147
|
+
'label label';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.ds-stat--delta-inline .ds-stat__head {
|
|
151
|
+
grid-area: head;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.ds-stat--delta-inline .ds-stat__extra {
|
|
155
|
+
grid-column: 1 / -1;
|
|
156
|
+
}
|
|
157
|
+
|
|
98
158
|
.ds-stat--delta-inline .ds-stat__value {
|
|
99
159
|
grid-area: value;
|
|
100
160
|
}
|
|
@@ -125,6 +185,11 @@
|
|
|
125
185
|
container: ds-stat / inline-size;
|
|
126
186
|
}
|
|
127
187
|
|
|
188
|
+
/* The auto root is a block, with no row gap: the margin is the whole space. */
|
|
189
|
+
.ds-stat--delta-auto .ds-stat__head {
|
|
190
|
+
margin-block-end: var(--gap-300);
|
|
191
|
+
}
|
|
192
|
+
|
|
128
193
|
.ds-stat__body {
|
|
129
194
|
display: grid;
|
|
130
195
|
grid-template-columns: auto 1fr;
|
|
@@ -19,12 +19,18 @@ type StatOwnProps = {
|
|
|
19
19
|
deltaPlacement?: 'stacked' | 'inline' | 'auto';
|
|
20
20
|
/** Stat size */
|
|
21
21
|
size?: 'default' | 'large';
|
|
22
|
+
/** A decorative mark in a round tile above the value, naming what the metric is about: a Material Symbol name (string) or a node. */
|
|
23
|
+
icon?: string | React.ReactNode;
|
|
24
|
+
/** A short note at the far end of the top row, in the caption face: the period the figure covers ("Last 30 days"), its source. */
|
|
25
|
+
caption?: React.ReactNode;
|
|
26
|
+
/** Shown after the value, label and delta, such as a Sparkline of the metric's recent history or an AvatarGroup of who it counts. */
|
|
27
|
+
children?: React.ReactNode;
|
|
22
28
|
/** The BCP 47 locale a number `value` is written in, such as `ar-EG`. Defaults to `en-US`. This component can render from a Server Component, so it takes the prop alone and reads no LocaleProvider. */
|
|
23
29
|
locale?: string;
|
|
24
30
|
/** Additional CSS classes */
|
|
25
31
|
className?: string;
|
|
26
32
|
};
|
|
27
|
-
export interface StatProps extends StatOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof StatOwnProps
|
|
33
|
+
export interface StatProps extends StatOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof StatOwnProps> {
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* Stat component — a single headline metric with a label and an
|
package/components/Stat/Stat.js
CHANGED
|
@@ -3,6 +3,7 @@ import React from "react";
|
|
|
3
3
|
import "./Stat.css";
|
|
4
4
|
import "../../fonts/material-symbols.css";
|
|
5
5
|
import { formatNumber, DEFAULT_LOCALE } from "../../behaviors/locale.js";
|
|
6
|
+
import { Icon } from "../Icon/Icon.js";
|
|
6
7
|
const TREND_ICONS = {
|
|
7
8
|
up: "arrow_upward",
|
|
8
9
|
down: "arrow_downward",
|
|
@@ -16,16 +17,23 @@ const Stat = React.forwardRef(
|
|
|
16
17
|
trend = "neutral",
|
|
17
18
|
deltaPlacement = "stacked",
|
|
18
19
|
size = "default",
|
|
20
|
+
icon,
|
|
21
|
+
caption,
|
|
22
|
+
children,
|
|
19
23
|
locale = DEFAULT_LOCALE,
|
|
20
24
|
className = "",
|
|
21
25
|
...rest
|
|
22
26
|
}, ref) => {
|
|
23
27
|
const baseClass = "ds-stat";
|
|
28
|
+
const hasIcon = icon != null && icon !== false && icon !== "";
|
|
29
|
+
const hasCaption = caption != null && caption !== false && caption !== "";
|
|
30
|
+
const hasHead = hasIcon || hasCaption;
|
|
24
31
|
const classes = [
|
|
25
32
|
baseClass,
|
|
26
33
|
`${baseClass}--${size}`,
|
|
27
34
|
deltaPlacement === "inline" ? `${baseClass}--delta-inline` : "",
|
|
28
35
|
deltaPlacement === "auto" ? `${baseClass}--delta-auto` : "",
|
|
36
|
+
hasHead ? `${baseClass}--headed` : "",
|
|
29
37
|
className
|
|
30
38
|
].filter(Boolean).join(" ");
|
|
31
39
|
const parts = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -36,7 +44,14 @@ const Stat = React.forwardRef(
|
|
|
36
44
|
delta
|
|
37
45
|
] })
|
|
38
46
|
] });
|
|
39
|
-
return /* @__PURE__ */
|
|
47
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
|
|
48
|
+
hasHead && /* @__PURE__ */ jsxs("span", { className: `${baseClass}__head`, children: [
|
|
49
|
+
hasIcon && (typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { name: icon, size: "500", tile: true, className: `${baseClass}__icon` }) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon`, "aria-hidden": "true", children: icon })),
|
|
50
|
+
hasCaption && /* @__PURE__ */ jsx("span", { className: `${baseClass}__caption`, children: caption })
|
|
51
|
+
] }),
|
|
52
|
+
deltaPlacement === "auto" ? /* @__PURE__ */ jsx("span", { className: `${baseClass}__body`, children: parts }) : parts,
|
|
53
|
+
children != null && children !== false && /* @__PURE__ */ jsx("span", { className: `${baseClass}__extra`, children })
|
|
54
|
+
] });
|
|
40
55
|
}
|
|
41
56
|
);
|
|
42
57
|
Stat.displayName = "Stat";
|
|
@@ -52,6 +52,17 @@
|
|
|
52
52
|
transition: background-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/* A row that heads a group, and a row the ones above add up to: both in
|
|
56
|
+
the emphasis weight, the total under a heavier rule. */
|
|
57
|
+
.ds-table__row--heading .ds-table__cell,
|
|
58
|
+
.ds-table__row--total .ds-table__cell {
|
|
59
|
+
font-weight: var(--font-paragraph-emphasis-weight);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.ds-table__row--total {
|
|
63
|
+
border-top: var(--border-050) solid var(--color-table-divider);
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
/* ============================================
|
|
56
67
|
HEADER CELL
|
|
57
68
|
============================================ */
|
|
@@ -20,6 +20,8 @@ export interface TableRow {
|
|
|
20
20
|
cells: Record<string, React.ReactNode>;
|
|
21
21
|
/** Whether the row is selected, drawn with the table's selected-row tint. */
|
|
22
22
|
selected?: boolean;
|
|
23
|
+
/** `heading` opens a group of rows in the emphasis weight; `total` is a row the ones above add up to, in the emphasis weight under a heavier rule. */
|
|
24
|
+
variant?: 'default' | 'heading' | 'total';
|
|
23
25
|
}
|
|
24
26
|
/** Props owned by Table itself — everything else falls through to the <table>. */
|
|
25
27
|
type TableOwnProps = {
|
|
@@ -51,7 +51,11 @@ const Table = React.forwardRef(
|
|
|
51
51
|
/* @__PURE__ */ jsx("tbody", { className: `${baseClass}__body`, children: rows.map((row) => /* @__PURE__ */ jsx(
|
|
52
52
|
"tr",
|
|
53
53
|
{
|
|
54
|
-
className:
|
|
54
|
+
className: [
|
|
55
|
+
`${baseClass}__row`,
|
|
56
|
+
row.selected ? `${baseClass}__row--selected` : "",
|
|
57
|
+
row.variant && row.variant !== "default" ? `${baseClass}__row--${row.variant}` : ""
|
|
58
|
+
].filter(Boolean).join(" "),
|
|
55
59
|
children: columns.map((col) => {
|
|
56
60
|
const content = /* @__PURE__ */ jsx(
|
|
57
61
|
"div",
|
package/components/Tabs/Tabs.css
CHANGED
|
@@ -74,6 +74,15 @@
|
|
|
74
74
|
transition: color var(--motion-duration-base) var(--motion-ease-standard);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/* ============================================
|
|
78
|
+
COUNT
|
|
79
|
+
============================================ */
|
|
80
|
+
|
|
81
|
+
.ds-tabs__count {
|
|
82
|
+
color: var(--color-text-tertiary);
|
|
83
|
+
font-variant-numeric: tabular-nums;
|
|
84
|
+
}
|
|
85
|
+
|
|
77
86
|
/* ============================================
|
|
78
87
|
ICON
|
|
79
88
|
============================================ */
|
|
@@ -138,3 +147,17 @@
|
|
|
138
147
|
opacity: 0.4;
|
|
139
148
|
cursor: not-allowed;
|
|
140
149
|
}
|
|
150
|
+
|
|
151
|
+
/* ============================================
|
|
152
|
+
PANELS — rendered when the tabs carry content
|
|
153
|
+
============================================ */
|
|
154
|
+
|
|
155
|
+
.ds-tabs__panel {
|
|
156
|
+
padding-block-start: var(--padding-500);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.ds-tabs__panel:focus-visible {
|
|
160
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
161
|
+
outline-offset: 2px;
|
|
162
|
+
border-radius: var(--radius-200);
|
|
163
|
+
}
|
|
@@ -6,10 +6,14 @@ export interface Tab {
|
|
|
6
6
|
label: string;
|
|
7
7
|
/** Optional icon — Material Symbol name (string) or custom element (ReactNode) */
|
|
8
8
|
icon?: string | React.ReactNode;
|
|
9
|
+
/** A count after the label (unread items, results), written in the resolved locale; the tab's name carries it through `countLabel`. */
|
|
10
|
+
count?: number;
|
|
9
11
|
/** Whether this tab is disabled */
|
|
10
12
|
disabled?: boolean;
|
|
11
|
-
/** The id of the `role="tabpanel"` element this tab shows, written as the tab's `aria-controls`.
|
|
13
|
+
/** The id of the `role="tabpanel"` element this tab shows, written as the tab's `aria-controls`. Set it when you render the panels yourself; with `content`, Tabs names its own panel and this id is used for it. */
|
|
12
14
|
panelId?: string;
|
|
15
|
+
/** What the tab shows. When any tab has content, Tabs renders a `role="tabpanel"` for each after the tab list, the selected one shown, each named by its tab. The panels are the tab list's siblings, with no wrapper, and the ref and `className` stay on the tab list. Leave it out to render the panels yourself. */
|
|
16
|
+
content?: React.ReactNode;
|
|
13
17
|
}
|
|
14
18
|
/** Props owned by Tabs itself — everything else falls through to the tablist. */
|
|
15
19
|
type TabsOwnProps = {
|
|
@@ -43,6 +47,10 @@ type TabsOwnProps = {
|
|
|
43
47
|
size?: 'default' | 'compact';
|
|
44
48
|
/** Whether tabs fill the available width */
|
|
45
49
|
fullWidth?: boolean;
|
|
50
|
+
/** What a screen reader hears after a tab's label for its count, given the count already written in the resolved locale. Defaults to ", 3"; say what it counts (", 3 unread") when the label does not. */
|
|
51
|
+
countLabel?: (count: string) => string;
|
|
52
|
+
/** The BCP 47 locale the tab counts are written in, such as `ar-EG`. Defaults to the nearest LocaleProvider's, else `en-US`. */
|
|
53
|
+
locale?: string;
|
|
46
54
|
/** Additional CSS classes */
|
|
47
55
|
className?: string;
|
|
48
56
|
/**
|
|
@@ -54,12 +62,5 @@ type TabsOwnProps = {
|
|
|
54
62
|
};
|
|
55
63
|
export interface TabsProps extends TabsOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof TabsOwnProps | 'children'> {
|
|
56
64
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Tabs switch between related views in one place.
|
|
59
|
-
*
|
|
60
|
-
* Forwards a ref to the `role="tablist"` element, which is the component's
|
|
61
|
-
* only wrapper, and spreads unrecognised props onto it. The list is named
|
|
62
|
-
* "Tabs" unless a native `aria-label` or `aria-labelledby` says otherwise.
|
|
63
|
-
*/
|
|
64
65
|
export declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
65
66
|
export {};
|
package/components/Tabs/Tabs.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import React, { useState } from "react";
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import React, { useId, useState } from "react";
|
|
4
|
+
import "../../behaviors/visually-hidden.css";
|
|
4
5
|
import "./Tabs.css";
|
|
5
6
|
import "../../fonts/material-symbols.css";
|
|
6
7
|
import { mirrorClass, logicalArrowKey } from "../../behaviors/direction.js";
|
|
8
|
+
import { formatNumber } from "../../behaviors/locale.js";
|
|
9
|
+
import { useLocale } from "../../behaviors/LocaleProvider.js";
|
|
10
|
+
const defaultCountLabel = (count) => `, ${count}`;
|
|
7
11
|
const Tabs = React.forwardRef(
|
|
8
12
|
({
|
|
9
13
|
tabs,
|
|
@@ -14,11 +18,18 @@ const Tabs = React.forwardRef(
|
|
|
14
18
|
onTabChange,
|
|
15
19
|
size = "default",
|
|
16
20
|
fullWidth = false,
|
|
21
|
+
locale: localeProp,
|
|
22
|
+
countLabel = defaultCountLabel,
|
|
17
23
|
className = "",
|
|
18
24
|
ariaLabel,
|
|
19
25
|
...rest
|
|
20
26
|
}, ref) => {
|
|
21
27
|
const baseClass = "ds-tabs";
|
|
28
|
+
const baseId = useId();
|
|
29
|
+
const ownsPanels = tabs.some((tab) => tab.content !== void 0);
|
|
30
|
+
const tabId = (index) => `${baseId}-tab-${index}`;
|
|
31
|
+
const panelIdOf = (tab, index) => tab.panelId ?? (ownsPanels ? `${baseId}-panel-${index}` : void 0);
|
|
32
|
+
const locale = useLocale(localeProp);
|
|
22
33
|
const sizeClass = `${baseClass}--${size}`;
|
|
23
34
|
const fullWidthClass = fullWidth ? `${baseClass}--full-width` : "";
|
|
24
35
|
const controlledValue = value ?? activeTab;
|
|
@@ -64,7 +75,7 @@ const Tabs = React.forwardRef(
|
|
|
64
75
|
targetEl?.focus();
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
|
-
|
|
78
|
+
const list = /* @__PURE__ */ jsx(
|
|
68
79
|
"div",
|
|
69
80
|
{
|
|
70
81
|
"aria-label": ariaLabel ?? "Tabs",
|
|
@@ -87,14 +98,19 @@ const Tabs = React.forwardRef(
|
|
|
87
98
|
role: "tab",
|
|
88
99
|
"aria-selected": isActive,
|
|
89
100
|
"aria-disabled": tab.disabled,
|
|
90
|
-
|
|
101
|
+
id: ownsPanels ? tabId(index) : void 0,
|
|
102
|
+
"aria-controls": panelIdOf(tab, index),
|
|
91
103
|
tabIndex: isActive ? 0 : -1,
|
|
92
104
|
"data-tab-value": tab.value,
|
|
93
105
|
onClick: () => !tab.disabled && select(tab.value),
|
|
94
106
|
onKeyDown: (e) => handleKeyDown(e, index),
|
|
95
107
|
children: [
|
|
96
108
|
tab.icon && (typeof tab.icon === "string" ? /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon material-symbols-rounded ${mirrorClass(tab.icon)}`, "aria-hidden": "true", children: tab.icon }) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon`, "aria-hidden": "true", children: tab.icon })),
|
|
97
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ jsxs("span", { className: `${baseClass}__label`, children: [
|
|
110
|
+
tab.label,
|
|
111
|
+
tab.count !== void 0 && /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", children: countLabel(formatNumber(tab.count, locale)) })
|
|
112
|
+
] }),
|
|
113
|
+
tab.count !== void 0 && /* @__PURE__ */ jsx("span", { className: `${baseClass}__count`, "aria-hidden": "true", children: formatNumber(tab.count, locale) })
|
|
98
114
|
]
|
|
99
115
|
},
|
|
100
116
|
tab.value
|
|
@@ -102,6 +118,23 @@ const Tabs = React.forwardRef(
|
|
|
102
118
|
})
|
|
103
119
|
}
|
|
104
120
|
);
|
|
121
|
+
if (!ownsPanels) return list;
|
|
122
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
123
|
+
list,
|
|
124
|
+
tabs.map((tab, index) => /* @__PURE__ */ jsx(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
id: panelIdOf(tab, index),
|
|
128
|
+
role: "tabpanel",
|
|
129
|
+
"aria-labelledby": tabId(index),
|
|
130
|
+
hidden: tab.value !== selectedValue,
|
|
131
|
+
tabIndex: 0,
|
|
132
|
+
className: `${baseClass}__panel`,
|
|
133
|
+
children: tab.content
|
|
134
|
+
},
|
|
135
|
+
tab.value
|
|
136
|
+
))
|
|
137
|
+
] });
|
|
105
138
|
}
|
|
106
139
|
);
|
|
107
140
|
Tabs.displayName = "Tabs";
|
|
@@ -12,10 +12,12 @@ type TextareaOwnProps = {
|
|
|
12
12
|
defaultValue?: string;
|
|
13
13
|
/** Component size */
|
|
14
14
|
size?: 'default' | 'compact';
|
|
15
|
-
/** Error state
|
|
15
|
+
/** Error state: marks the control invalid and, in the older form without `errorText`, recolours the helper text as the error message. */
|
|
16
16
|
error?: boolean;
|
|
17
|
-
/** Helper
|
|
17
|
+
/** Helper text displayed below the control. With the older `error` flag and no `errorText`, it doubles as the error message. */
|
|
18
18
|
helperText?: string;
|
|
19
|
+
/** The error message, shown under the control while the helper text keeps its place. Setting it marks the control invalid, so `error` is not needed alongside it; Field's spec owns the wiring. */
|
|
20
|
+
errorText?: React.ReactNode;
|
|
19
21
|
/** Whether the textarea is resizable */
|
|
20
22
|
resize?: 'none' | 'vertical' | 'horizontal' | 'both';
|
|
21
23
|
/** Max character count — shows counter when set */
|
|
@@ -15,6 +15,7 @@ const Textarea = React.forwardRef(
|
|
|
15
15
|
required = false,
|
|
16
16
|
error = false,
|
|
17
17
|
helperText,
|
|
18
|
+
errorText,
|
|
18
19
|
resize = "vertical",
|
|
19
20
|
maxLength,
|
|
20
21
|
onChange,
|
|
@@ -27,10 +28,12 @@ const Textarea = React.forwardRef(
|
|
|
27
28
|
...rest
|
|
28
29
|
}, ref) => {
|
|
29
30
|
const baseClass = "ds-textarea";
|
|
31
|
+
const hasErrorText = errorText != null && errorText !== false && errorText !== "";
|
|
32
|
+
const invalid = error || hasErrorText;
|
|
30
33
|
const classes = [
|
|
31
34
|
baseClass,
|
|
32
35
|
size === "compact" ? `${baseClass}--compact` : "",
|
|
33
|
-
|
|
36
|
+
invalid ? `${baseClass}--error` : "",
|
|
34
37
|
disabled ? `${baseClass}--disabled` : "",
|
|
35
38
|
className
|
|
36
39
|
].filter(Boolean).join(" ");
|
|
@@ -44,13 +47,14 @@ const Textarea = React.forwardRef(
|
|
|
44
47
|
};
|
|
45
48
|
const inputId = id || name || label?.toLowerCase().replace(/\s+/g, "-");
|
|
46
49
|
const charCount = currentValue.length;
|
|
47
|
-
const describedBy = [rest["aria-describedby"], helperText ? `${inputId}-helper` : void 0].filter(Boolean).join(" ") || void 0;
|
|
50
|
+
const describedBy = [rest["aria-describedby"], hasErrorText ? `${inputId}-error` : void 0, helperText ? `${inputId}-helper` : void 0].filter(Boolean).join(" ") || void 0;
|
|
48
51
|
return /* @__PURE__ */ jsx(
|
|
49
52
|
Field,
|
|
50
53
|
{
|
|
51
54
|
className: classes,
|
|
52
55
|
label,
|
|
53
56
|
helperText,
|
|
57
|
+
errorText,
|
|
54
58
|
error,
|
|
55
59
|
required,
|
|
56
60
|
disabled,
|
|
@@ -76,7 +80,7 @@ const Textarea = React.forwardRef(
|
|
|
76
80
|
required,
|
|
77
81
|
maxLength,
|
|
78
82
|
"aria-label": rest["aria-label"] ?? ariaLabel ?? label,
|
|
79
|
-
"aria-invalid":
|
|
83
|
+
"aria-invalid": invalid,
|
|
80
84
|
"aria-describedby": describedBy,
|
|
81
85
|
onChange: handleChange,
|
|
82
86
|
style: { resize, ...style }
|
|
@@ -32,6 +32,22 @@ export type ColorModeOptions = {
|
|
|
32
32
|
/** The localStorage key the choice is kept under. Default `theme`. */
|
|
33
33
|
storageKey?: string;
|
|
34
34
|
};
|
|
35
|
+
/** The script's options: the colour mode's key, and optionally the key a host keeps its theme choice under. */
|
|
36
|
+
export type ColorModeScriptOptions = ColorModeOptions & {
|
|
37
|
+
/**
|
|
38
|
+
* The localStorage key a host keeps its chosen theme under, as a preset id
|
|
39
|
+
* (`plum`, from `SHIPPED_THEMES` in `rift-ds/tokens/values`). When set, the
|
|
40
|
+
* script also applies it as `data-brand` on `<html>` before first paint, so a
|
|
41
|
+
* returning visitor never sees the default theme flash first; an empty
|
|
42
|
+
* value, the base theme's id or a value that is not an id leaves the
|
|
43
|
+
* attribute as the layout rendered it. The host writes the key when the
|
|
44
|
+
* visitor picks a theme. Unset by default: the script then never touches
|
|
45
|
+
* `data-brand`.
|
|
46
|
+
*/
|
|
47
|
+
brandStorageKey?: string;
|
|
48
|
+
/** The base theme's id, which applies by removing `data-brand` rather than setting it. Defaults to `tide`, the value of `BASE_THEME_ID` in `rift-ds/tokens/values`. */
|
|
49
|
+
baseThemeId?: string;
|
|
50
|
+
};
|
|
35
51
|
/**
|
|
36
52
|
* The script that applies the stored choice before first paint: it sets
|
|
37
53
|
* `data-theme-setting` and `data-theme` on `<html>` and, while the setting
|
|
@@ -49,4 +65,4 @@ export type ColorModeOptions = {
|
|
|
49
65
|
* applies the stored choice again. A ThemeToggle change only ever replaces
|
|
50
66
|
* the value, so it never trips the repair.
|
|
51
67
|
*/
|
|
52
|
-
export declare function colorModeScript({ storageKey }?:
|
|
68
|
+
export declare function colorModeScript({ storageKey, brandStorageKey, baseThemeId, }?: ColorModeScriptOptions): string;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
const colorModeSettings = ["system", "light", "dark"];
|
|
2
2
|
const DEFAULT_COLOR_MODE_STORAGE_KEY = "theme";
|
|
3
3
|
const isColorModeSetting = (value) => colorModeSettings.includes(value);
|
|
4
|
-
function colorModeScript({
|
|
4
|
+
function colorModeScript({
|
|
5
|
+
storageKey = DEFAULT_COLOR_MODE_STORAGE_KEY,
|
|
6
|
+
brandStorageKey,
|
|
7
|
+
baseThemeId = "tide"
|
|
8
|
+
} = {}) {
|
|
5
9
|
const key = JSON.stringify(storageKey);
|
|
10
|
+
const brand = brandStorageKey ? `
|
|
11
|
+
var brand = null;
|
|
12
|
+
try { brand = localStorage.getItem(${JSON.stringify(brandStorageKey)}); } catch (e) {}
|
|
13
|
+
if (brand === ${JSON.stringify(baseThemeId)}) root.removeAttribute('data-brand');
|
|
14
|
+
else if (brand && /^[a-z0-9-]+$/.test(brand)) root.setAttribute('data-brand', brand);` : "";
|
|
6
15
|
return `(function () {
|
|
7
16
|
var root = document.documentElement;
|
|
8
17
|
var media = window.matchMedia('(prefers-color-scheme: dark)');
|
|
@@ -11,7 +20,7 @@ function colorModeScript({ storageKey = DEFAULT_COLOR_MODE_STORAGE_KEY } = {}) {
|
|
|
11
20
|
try { saved = localStorage.getItem(${key}); } catch (e) {}
|
|
12
21
|
var setting = saved === 'light' || saved === 'dark' ? saved : 'system';
|
|
13
22
|
root.setAttribute('data-theme-setting', setting);
|
|
14
|
-
root.setAttribute('data-theme', setting === 'system' ? (media.matches ? 'dark' : 'light') : setting)
|
|
23
|
+
root.setAttribute('data-theme', setting === 'system' ? (media.matches ? 'dark' : 'light') : setting);${brand}
|
|
15
24
|
}
|
|
16
25
|
apply();
|
|
17
26
|
media.addEventListener('change', function (event) {
|
|
@@ -269,6 +269,27 @@
|
|
|
269
269
|
font-variant-numeric: tabular-nums;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
+
/* Controls at the row's end, after the meta: a request's Approve and Decline. */
|
|
273
|
+
.ds-widget-row__actions {
|
|
274
|
+
display: inline-flex;
|
|
275
|
+
flex-shrink: 0;
|
|
276
|
+
align-items: center;
|
|
277
|
+
gap: var(--gap-200);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/* The chevron on a row that goes somewhere: a quiet glyph at the end of the
|
|
281
|
+
line, after the meta, that brightens with the row's hover. */
|
|
282
|
+
.ds-widget-row__chevron {
|
|
283
|
+
flex-shrink: 0;
|
|
284
|
+
--icon-size: var(--icon-size-500);
|
|
285
|
+
color: var(--color-icon-secondary);
|
|
286
|
+
transition: color var(--motion-duration-fast) var(--motion-ease-standard);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.ds-widget-row--interactive:hover .ds-widget-row__chevron {
|
|
290
|
+
color: var(--color-icon-primary);
|
|
291
|
+
}
|
|
292
|
+
|
|
272
293
|
/* A row that goes somewhere: the hover fill bleeds past the text into the
|
|
273
294
|
tile's padding, so the whole line reads as one target. */
|
|
274
295
|
|
|
@@ -66,8 +66,12 @@ type WidgetRowOwnProps = {
|
|
|
66
66
|
leading?: React.ReactNode;
|
|
67
67
|
/** Trailing fact in the caption face: a date, an amount, a state. */
|
|
68
68
|
meta?: React.ReactNode;
|
|
69
|
+
/** Controls at the row's end, after the meta: an Approve and a Decline button on a request, say. A row with actions is not itself a link or a button, since a control cannot hold others, so it takes no `href` or `onClick`. */
|
|
70
|
+
actions?: React.ReactNode;
|
|
69
71
|
/** Renders the row as a link to this URL. */
|
|
70
72
|
href?: string;
|
|
73
|
+
/** A trailing chevron saying the row goes somewhere, mirrored in a right-to-left context. Defaults to on for a row with `href` and off otherwise; a row whose `onClick` opens a page of its own can turn it on. */
|
|
74
|
+
chevron?: boolean;
|
|
71
75
|
/** Additional CSS classes */
|
|
72
76
|
className?: string;
|
|
73
77
|
/**
|
|
@@ -3,6 +3,8 @@ import React, { useId } from "react";
|
|
|
3
3
|
import "./Widget.css";
|
|
4
4
|
import { formatNumber, DEFAULT_LOCALE } from "../../behaviors/locale.js";
|
|
5
5
|
import { WidgetDisclosure } from "./WidgetDisclosure.js";
|
|
6
|
+
import { warnOnce } from "../../behaviors/devWarning.js";
|
|
7
|
+
import "../../fonts/material-symbols.css";
|
|
6
8
|
const Widget = React.forwardRef(
|
|
7
9
|
({
|
|
8
10
|
title,
|
|
@@ -100,10 +102,14 @@ const WidgetGroup = React.forwardRef(
|
|
|
100
102
|
);
|
|
101
103
|
WidgetGroup.displayName = "WidgetGroup";
|
|
102
104
|
const WidgetRow = React.forwardRef(
|
|
103
|
-
({ title, description, leading, meta, href, className = "", onClick, linkComponent, ...rest }, ref) => {
|
|
105
|
+
({ title, description, leading, meta, actions, href, chevron, className = "", onClick, linkComponent, ...rest }, ref) => {
|
|
104
106
|
const baseClass = "ds-widget-row";
|
|
105
107
|
const Link = linkComponent ?? "a";
|
|
106
|
-
const
|
|
108
|
+
const hasActions = actions != null && actions !== false;
|
|
109
|
+
if (hasActions && (href || onClick)) {
|
|
110
|
+
warnOnce("WidgetRow: a row with `actions` takes no `href` or `onClick`, since a control cannot hold others. They are ignored.");
|
|
111
|
+
}
|
|
112
|
+
const interactive = !hasActions && Boolean(href || onClick);
|
|
107
113
|
const classes = [baseClass, interactive ? `${baseClass}--interactive` : "", className].filter(Boolean).join(" ");
|
|
108
114
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
109
115
|
leading && /* @__PURE__ */ jsx("span", { className: `${baseClass}__leading`, children: leading }),
|
|
@@ -111,9 +117,11 @@ const WidgetRow = React.forwardRef(
|
|
|
111
117
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__title`, children: title }),
|
|
112
118
|
description && /* @__PURE__ */ jsx("span", { className: `${baseClass}__description`, children: description })
|
|
113
119
|
] }),
|
|
114
|
-
meta !== void 0 && meta !== null && /* @__PURE__ */ jsx("span", { className: `${baseClass}__meta`, children: meta })
|
|
120
|
+
meta !== void 0 && meta !== null && /* @__PURE__ */ jsx("span", { className: `${baseClass}__meta`, children: meta }),
|
|
121
|
+
hasActions && /* @__PURE__ */ jsx("span", { className: `${baseClass}__actions`, children: actions }),
|
|
122
|
+
interactive && (chevron ?? Boolean(href)) && /* @__PURE__ */ jsx("span", { className: `${baseClass}__chevron material-symbols-rounded ds-mirror-rtl`, "aria-hidden": "true", children: "chevron_right" })
|
|
115
123
|
] });
|
|
116
|
-
if (href) {
|
|
124
|
+
if (interactive && href) {
|
|
117
125
|
return /* @__PURE__ */ jsx(
|
|
118
126
|
Link,
|
|
119
127
|
{
|
|
@@ -126,7 +134,7 @@ const WidgetRow = React.forwardRef(
|
|
|
126
134
|
}
|
|
127
135
|
);
|
|
128
136
|
}
|
|
129
|
-
if (onClick) {
|
|
137
|
+
if (interactive && onClick) {
|
|
130
138
|
return /* @__PURE__ */ jsx(
|
|
131
139
|
"button",
|
|
132
140
|
{
|