rift-ds 1.41.0 → 1.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/behaviors/LoadingImage.d.ts +2 -0
  2. package/behaviors/LoadingImage.js +34 -0
  3. package/behaviors/ScrollRegion.js +15 -2
  4. package/behaviors/VisuallyHidden.d.ts +30 -0
  5. package/behaviors/VisuallyHidden.js +17 -0
  6. package/behaviors/loading-image.css +30 -0
  7. package/behaviors/quietFocus.d.ts +4 -0
  8. package/behaviors/quietFocus.js +14 -0
  9. package/behaviors/useFocusScope.d.ts +3 -1
  10. package/behaviors/useFocusScope.js +4 -6
  11. package/bin/rift-ds.mjs +1 -0
  12. package/bin/templates/app/components/rift/ColorModeScript.tsx +3 -1
  13. package/bin/templates/app/components/rift/RiftRoot.tsx +40 -1
  14. package/bin/templates/blocks/app/dashboard/page.tsx +7 -5
  15. package/bin/templates/blocks/app/landing/page.tsx +1 -1
  16. package/bin/templates/blocks/app/pricing/page.module.css +15 -1
  17. package/bin/templates/blocks/app/pricing/page.tsx +8 -1
  18. package/bin/templates/blocks/app/sign-in/page.tsx +10 -2
  19. package/bin/templates/blocks/app/sign-up/page.module.css +83 -0
  20. package/bin/templates/blocks/app/sign-up/page.tsx +126 -0
  21. package/bin/templates/blocks/app/starter/page.tsx +1 -1
  22. package/bin/templates/blocks/components/blocks/AppShell.module.css +0 -10
  23. package/bin/templates/blocks/components/blocks/AppShell.tsx +39 -115
  24. package/bin/templates/blocks/components/blocks/DocsShell.tsx +5 -1
  25. package/bin/templates/blocks/registry.json +44 -6
  26. package/components/AgentPlan/AgentPlan.css +1 -1
  27. package/components/AlertDialog/AlertDialog.css +14 -0
  28. package/components/AlertDialog/AlertDialog.d.ts +35 -3
  29. package/components/AlertDialog/AlertDialog.js +16 -5
  30. package/components/AppSidebar/AppSidebar.css +13 -2
  31. package/components/AppSidebar/AppSidebar.js +7 -2
  32. package/components/Attachment/AttachmentGroup.js +2 -1
  33. package/components/Attachment/AttachmentTile.js +2 -1
  34. package/components/Badge/Badge.css +6 -0
  35. package/components/Breadcrumb/Breadcrumb.css +4 -1
  36. package/components/Button/Button.css +20 -1
  37. package/components/Button/Button.js +6 -1
  38. package/components/Card/Card.css +11 -0
  39. package/components/Card/Card.d.ts +9 -3
  40. package/components/Card/Card.js +21 -2
  41. package/components/Chart/AreaChart.d.ts +7 -0
  42. package/components/Chart/AreaChart.js +51 -45
  43. package/components/Chart/BarChart.d.ts +7 -0
  44. package/components/Chart/BarChart.js +52 -46
  45. package/components/Chart/Chart.css +122 -1
  46. package/components/Chart/ChartSkeleton.d.ts +32 -0
  47. package/components/Chart/ChartSkeleton.js +149 -0
  48. package/components/Chart/ComboChart.d.ts +7 -0
  49. package/components/Chart/ComboChart.js +80 -74
  50. package/components/Chart/LineChart.d.ts +17 -3
  51. package/components/Chart/LineChart.js +61 -39
  52. package/components/Chart/PieChart.d.ts +7 -0
  53. package/components/Chart/PieChart.js +41 -34
  54. package/components/Chart/RadarChart.d.ts +7 -0
  55. package/components/Chart/RadarChart.js +38 -32
  56. package/components/Chart/RadialChart.d.ts +7 -0
  57. package/components/Chart/RadialChart.js +5 -1
  58. package/components/Chart/ScatterChart.d.ts +7 -0
  59. package/components/Chart/ScatterChart.js +46 -40
  60. package/components/Chart/StackedBarChart.d.ts +10 -1
  61. package/components/Chart/StackedBarChart.js +51 -43
  62. package/components/Chart/Treemap.d.ts +7 -0
  63. package/components/Chart/Treemap.js +17 -11
  64. package/components/Checkbox/Checkbox.css +25 -1
  65. package/components/Checkbox/Checkbox.d.ts +8 -4
  66. package/components/Checkbox/Checkbox.js +17 -8
  67. package/components/Chip/Chip.css +5 -3
  68. package/components/ContactCard/ContactCard.css +4 -3
  69. package/components/ContributionGraph/ContributionGraph.css +20 -0
  70. package/components/ContributionGraph/ContributionGraph.d.ts +4 -0
  71. package/components/ContributionGraph/ContributionGraph.js +11 -6
  72. package/components/DataTable/DataTable.css +28 -4
  73. package/components/DataTable/DataTable.d.ts +16 -2
  74. package/components/DataTable/DataTable.js +5 -0
  75. package/components/DateInput/DateInput.css +3 -1
  76. package/components/DatePicker/DatePicker.css +16 -0
  77. package/components/DatePicker/DatePicker.d.ts +13 -0
  78. package/components/DatePicker/DatePicker.js +21 -27
  79. package/components/DatePicker/MonthGrid.d.ts +2 -2
  80. package/components/DatePicker/MonthGrid.js +1 -1
  81. package/components/DatePicker/today.d.ts +15 -0
  82. package/components/DatePicker/today.js +17 -0
  83. package/components/DateRangePicker/DateRangePicker.d.ts +14 -1
  84. package/components/DateRangePicker/DateRangePicker.js +18 -7
  85. package/components/DescriptionList/DescriptionList.css +11 -0
  86. package/components/DescriptionList/DescriptionList.d.ts +5 -1
  87. package/components/DescriptionList/DescriptionList.js +21 -6
  88. package/components/Dialog/Dialog.css +9 -0
  89. package/components/Dialog/Dialog.d.ts +9 -0
  90. package/components/Dialog/Dialog.js +32 -19
  91. package/components/DocumentChip/DocumentChip.css +1 -1
  92. package/components/Drawer/Drawer.d.ts +9 -0
  93. package/components/Drawer/Drawer.js +8 -0
  94. package/components/Dropdown/Dropdown.css +3 -1
  95. package/components/EmptyState/EmptyState.css +8 -1
  96. package/components/Field/Field.css +2 -2
  97. package/components/FileInput/FileInput.css +1 -1
  98. package/components/FilterBar/FilterBar.d.ts +6 -1
  99. package/components/FunnelChart/FunnelChart.d.ts +7 -0
  100. package/components/FunnelChart/FunnelChart.js +44 -30
  101. package/components/GanttChart/GanttChart.css +10 -0
  102. package/components/GanttChart/GanttChart.d.ts +4 -0
  103. package/components/GanttChart/GanttChart.js +66 -33
  104. package/components/Gauge/Gauge.css +23 -0
  105. package/components/Gauge/Gauge.d.ts +4 -0
  106. package/components/Gauge/Gauge.js +14 -8
  107. package/components/ImageCompare/ImageCompare.js +2 -1
  108. package/components/Input/Input.css +3 -1
  109. package/components/List/List.css +1 -1
  110. package/components/NotificationCenter/NotificationCenter.css +16 -0
  111. package/components/NotificationCenter/NotificationCenter.d.ts +4 -0
  112. package/components/NotificationCenter/NotificationCenter.js +23 -1
  113. package/components/NumberInput/NumberInput.css +2 -0
  114. package/components/PageHeader/PageHeader.css +12 -4
  115. package/components/Panel/Panel.d.ts +1 -1
  116. package/components/Prose/Prose.css +1 -1
  117. package/components/RadioButton/RadioButton.css +1 -1
  118. package/components/RadioButton/RadioButton.d.ts +4 -2
  119. package/components/RadioButton/RadioButton.js +5 -2
  120. package/components/ResourceTimeline/ResourceTimeline.css +12 -0
  121. package/components/ResourceTimeline/ResourceTimeline.d.ts +5 -1
  122. package/components/ResourceTimeline/ResourceTimeline.js +94 -52
  123. package/components/RichDropdown/RichDropdown.css +3 -1
  124. package/components/SelectionCard/SelectionCard.css +29 -0
  125. package/components/SelectionCard/SelectionCard.d.ts +7 -0
  126. package/components/SelectionCard/SelectionCard.js +25 -2
  127. package/components/Sparkline/Sparkline.css +20 -0
  128. package/components/Sparkline/Sparkline.d.ts +4 -0
  129. package/components/Sparkline/Sparkline.js +14 -8
  130. package/components/Stat/Stat.css +31 -0
  131. package/components/Stat/Stat.d.ts +23 -2
  132. package/components/Stat/Stat.js +21 -6
  133. package/components/Table/Table.css +101 -16
  134. package/components/Table/Table.d.ts +4 -0
  135. package/components/Table/Table.js +43 -28
  136. package/components/Textarea/Textarea.css +4 -2
  137. package/components/ThemeToggle/colorMode.d.ts +10 -2
  138. package/components/ThemeToggle/colorMode.js +4 -2
  139. package/components/ThreadHistory/ThreadHistory.css +11 -0
  140. package/components/ThreadHistory/ThreadHistory.d.ts +5 -1
  141. package/components/ThreadHistory/ThreadHistory.js +6 -1
  142. package/components/ThreadPanel/ThreadPanel.d.ts +4 -0
  143. package/components/ThreadPanel/ThreadPanel.js +5 -1
  144. package/components/TimePicker/TimePicker.css +3 -1
  145. package/components/TimePicker/TimePicker.d.ts +4 -2
  146. package/components/TimePicker/TimePicker.js +11 -3
  147. package/components/Timeline/Timeline.css +15 -0
  148. package/components/Timeline/Timeline.d.ts +8 -0
  149. package/components/Timeline/Timeline.js +21 -0
  150. package/components/Toast/Toast.css +16 -0
  151. package/components/Toast/Toast.d.ts +7 -2
  152. package/components/ToggleGroup/ToggleGroup.css +28 -2
  153. package/components/ToggleSwitch/ToggleSwitch.css +1 -1
  154. package/components/Tooltip/Tooltip.d.ts +9 -0
  155. package/components/Tooltip/Tooltip.js +34 -8
  156. package/components/TreeView/TreeView.css +12 -0
  157. package/components/TreeView/TreeView.d.ts +4 -0
  158. package/components/TreeView/TreeView.js +20 -0
  159. package/components/UsageCard/UsageCard.css +11 -0
  160. package/components/UsageCard/UsageCard.d.ts +4 -0
  161. package/components/UsageCard/UsageCard.js +25 -16
  162. package/components/Widget/Widget.css +7 -0
  163. package/components/Widget/Widget.d.ts +4 -0
  164. package/components/Widget/Widget.js +14 -2
  165. package/components/registry.json +4 -1
  166. package/components/registry.json.d.ts +4 -1
  167. package/components/registry.json.js +1 -1
  168. package/package.json +7 -2
  169. package/tokens/presets/contrast.css +4 -4
  170. package/tokens/presets/coral.css +3 -4
  171. package/tokens/presets/forest.css +16 -4
  172. package/tokens/presets/gold.css +4 -3
  173. package/tokens/presets/marquee.css +2 -3
  174. package/tokens/presets/mono.css +28 -28
  175. package/tokens/presets/pink.css +5 -4
  176. package/tokens/presets/terminal.css +4 -3
  177. package/tokens/presets/violet.css +3 -4
  178. package/tokens/presets/warm.css +16 -4
  179. package/tokens/presets/zest.css +2 -2
  180. package/tokens/registry.json +1 -0
  181. package/tokens/registry.json.d.ts +1 -0
  182. package/tokens/registry.json.js +1 -1
  183. package/tokens/tokens-dark.css +4 -0
  184. package/tokens/tokens-light.css +4 -0
  185. package/tokens/values.d.ts +14 -1
  186. package/tokens/values.js +14 -1
  187. package/tokens/values.json.js +1 -1
@@ -79,4 +79,24 @@
79
79
  color: var(--color-text-secondary);
80
80
  }
81
81
 
82
+ /* Loading: a quiet placeholder line in a container step, whatever the tone,
83
+ pulsing in place of the draw-on. */
84
+
85
+ .ds-sparkline.ds-sparkline--loading {
86
+ color: var(--color-bg-container-tertiary);
87
+ }
88
+
89
+ .ds-sparkline--loading .ds-sparkline__line,
90
+ .ds-sparkline--loading .ds-sparkline__fill {
91
+ /* ds-allow(motion): the pulse needs a symmetric in-out curve and no
92
+ --motion-ease-* token provides one; the duration is tokenized. */
93
+ animation: ds-sparkline-pulse var(--motion-duration-loop-shimmer) ease-in-out infinite alternate;
94
+ }
95
+
96
+ @keyframes ds-sparkline-pulse {
97
+ to {
98
+ opacity: 0.5;
99
+ }
100
+ }
101
+
82
102
  } /* @layer rift.components */
@@ -33,6 +33,10 @@ type SparklineOwnProps = {
33
33
  * omitted the SVG is decorative and hidden from assistive technology.
34
34
  */
35
35
  label?: string;
36
+ /** Draws a quiet placeholder line, pulsing, in place of the trend while its data is being fetched. `data` is ignored meanwhile. */
37
+ loading?: boolean;
38
+ /** Accessible name announced while `loading`. */
39
+ loadingLabel?: string;
36
40
  /** Additional CSS classes */
37
41
  className?: string;
38
42
  };
@@ -1,6 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import "./Sparkline.css";
4
+ const LOADING_SERIES = [4, 5, 4.5, 6, 5.5, 7];
4
5
  const round = (n) => Math.round(n * 100) / 100;
5
6
  const buildMonotonePath = (pts) => {
6
7
  const n = pts.length;
@@ -41,27 +42,31 @@ const Sparkline = React.forwardRef(
41
42
  width = 120,
42
43
  height = 32,
43
44
  label,
45
+ loading = false,
46
+ loadingLabel = "Loading",
44
47
  className = "",
45
48
  ...rest
46
49
  }, ref) => {
47
50
  const baseClass = "ds-sparkline";
51
+ const series = loading ? LOADING_SERIES : data;
48
52
  const toneClass = tone === "error" ? "negative" : tone;
49
53
  const classes = [
50
54
  baseClass,
51
55
  `${baseClass}--${variant}`,
52
56
  `${baseClass}--${toneClass}`,
57
+ loading ? `${baseClass}--loading` : "",
53
58
  className
54
59
  ].filter(Boolean).join(" ");
55
60
  const dotRadius = strokeWidth * 1.5;
56
61
  const pad = dotRadius + strokeWidth / 2;
57
62
  const innerWidth = Math.max(width - pad * 2, 0);
58
63
  const innerHeight = Math.max(height - pad * 2, 0);
59
- const min = Math.min(...data);
60
- const max = Math.max(...data);
64
+ const min = Math.min(...series);
65
+ const max = Math.max(...series);
61
66
  const range = max - min;
62
- const points = data.map((value, i) => ({
67
+ const points = series.map((value, i) => ({
63
68
  x: round(
64
- data.length < 2 ? pad + innerWidth : pad + i / (data.length - 1) * innerWidth
69
+ series.length < 2 ? pad + innerWidth : pad + i / (series.length - 1) * innerWidth
65
70
  ),
66
71
  // A flat series (range 0) draws a horizontal midline instead of dividing by zero.
67
72
  y: round(
@@ -83,9 +88,10 @@ const Sparkline = React.forwardRef(
83
88
  width,
84
89
  height,
85
90
  xmlns: "http://www.w3.org/2000/svg",
86
- role: label ? "img" : void 0,
87
- "aria-label": label,
88
- "aria-hidden": label ? void 0 : true,
91
+ role: loading ? "status" : label ? "img" : void 0,
92
+ "aria-label": loading ? loadingLabel : label,
93
+ "aria-busy": loading || void 0,
94
+ "aria-hidden": loading || label ? void 0 : true,
89
95
  children: [
90
96
  areaPath && /* @__PURE__ */ jsx("path", { className: `${baseClass}__fill`, d: areaPath }),
91
97
  linePath && /* @__PURE__ */ jsx(
@@ -97,7 +103,7 @@ const Sparkline = React.forwardRef(
97
103
  pathLength: 100
98
104
  }
99
105
  ),
100
- showDot && lastPoint && /* @__PURE__ */ jsx(
106
+ showDot && !loading && lastPoint && /* @__PURE__ */ jsx(
101
107
  "circle",
102
108
  {
103
109
  className: `${baseClass}__dot`,
@@ -146,6 +146,18 @@
146
146
  color: var(--color-text-tertiary);
147
147
  }
148
148
 
149
+ /* A stated sentiment owns the colour and leaves the arrow to the trend, so
150
+ a fall that is good news is a down arrow in the positive colour. These
151
+ follow the trend rules at the same weight, so they win. `--neutral` above
152
+ serves both: a neutral sentiment is the neutral trend's colour. */
153
+ .ds-stat__delta--positive {
154
+ color: var(--color-trend-up);
155
+ }
156
+
157
+ .ds-stat__delta--negative {
158
+ color: var(--color-trend-down);
159
+ }
160
+
149
161
  /* ============================================
150
162
  INLINE DELTA — delta to the right of the
151
163
  value, bottom-aligned to its baseline
@@ -264,4 +276,23 @@
264
276
  color: inherit;
265
277
  }
266
278
 
279
+ /* ============================================
280
+ LOADING — a placeholder where the value and
281
+ the delta go, each one text line tall, so
282
+ the tile keeps its height when they land
283
+ ============================================ */
284
+
285
+ .ds-stat__value > .ds-skeleton {
286
+ width: 5ch;
287
+ max-width: 100%;
288
+ height: calc(1lh - var(--padding-300));
289
+ margin-block: var(--padding-150);
290
+ }
291
+
292
+ .ds-stat__delta > .ds-skeleton {
293
+ width: 8ch;
294
+ height: calc(1lh - var(--padding-200));
295
+ margin-block: var(--padding-100);
296
+ }
297
+
267
298
  } /* @layer rift.components */
@@ -7,14 +7,26 @@ type StatOwnProps = {
7
7
  label: string;
8
8
  /** Optional change annotation, e.g. "+42% vs last quarter" */
9
9
  delta?: string;
10
- /** Direction of the delta — colours it and adds an arrow */
10
+ /** Direction of the delta: it draws the arrow, and colours the delta too unless `sentiment` says otherwise. */
11
11
  trend?: 'up' | 'down' | 'neutral';
12
+ /**
13
+ * Whether the change is good news, apart from which way it went: `positive`,
14
+ * `negative` or `neutral`. It sets the delta's colour and leaves the arrow to
15
+ * `trend`, so a figure where lower is better (a response time, a churn rate)
16
+ * shows a down arrow in the positive colour. Without it the colour follows
17
+ * `trend`: up is positive, down is negative.
18
+ * @default the colour `trend` gives
19
+ */
20
+ sentiment?: 'positive' | 'negative' | 'neutral';
12
21
  /**
13
22
  * Where the delta sits: stacked below the label, inline to the right of the
14
23
  * value (bottom-aligned), or `auto`: inline while the stat has room and
15
24
  * stacked once it is narrow, such as a KPI tile in a two-up phone grid.
16
25
  * `auto` fills its parent's width and reads its own, so it restacks
17
- * wherever it sits, whatever the viewport.
26
+ * wherever it sits, whatever the viewport. Each tile decides for itself, so
27
+ * in a row whose figures differ much in length one delta can wrap while its
28
+ * neighbours sit inline; give every Stat in such a row `stacked` (or
29
+ * `inline`) and they all take one shape.
18
30
  */
19
31
  deltaPlacement?: 'stacked' | 'inline' | 'auto';
20
32
  /** Stat size */
@@ -32,6 +44,10 @@ type StatOwnProps = {
32
44
  children?: React.ReactNode;
33
45
  /** 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. */
34
46
  locale?: string;
47
+ /** Holds a placeholder where the value goes, and one for the delta when a `delta` is passed, while the figure is being fetched. The label, icon and caption stay. */
48
+ loading?: boolean;
49
+ /** Accessible name announced while `loading`. */
50
+ loadingLabel?: string;
35
51
  /** Additional CSS classes */
36
52
  className?: string;
37
53
  };
@@ -41,6 +57,11 @@ export interface StatProps extends StatOwnProps, Omit<React.ComponentPropsWithou
41
57
  * Stat component — a single headline metric with a label and an
42
58
  * optional trend delta. Compose several in a row for a metrics band.
43
59
  * Forwards a ref to the root div and spreads native attributes onto it.
60
+ *
61
+ * A Stat has no surface of its own. On a product screen each one sits in
62
+ * a Panel, one KPI tile per Stat in a grid (with `deltaPlacement="auto"`,
63
+ * so a narrow tile restacks); bare on the page it is a report's metrics
64
+ * band, set among prose.
44
65
  */
45
66
  export declare const Stat: React.ForwardRefExoticComponent<StatProps & React.RefAttributes<HTMLDivElement>>;
46
67
  export {};
@@ -4,6 +4,7 @@ import "./Stat.css";
4
4
  import "../../fonts/material-symbols.css";
5
5
  import { formatNumber, DEFAULT_LOCALE } from "../../behaviors/locale.js";
6
6
  import { Icon } from "../Icon/Icon.js";
7
+ import { Skeleton } from "../Skeleton/Skeleton.js";
7
8
  const TREND_ICONS = {
8
9
  up: "arrow_upward",
9
10
  down: "arrow_downward",
@@ -15,6 +16,7 @@ const Stat = React.forwardRef(
15
16
  label,
16
17
  delta,
17
18
  trend = "neutral",
19
+ sentiment,
18
20
  deltaPlacement = "stacked",
19
21
  size = "default",
20
22
  icon,
@@ -22,6 +24,8 @@ const Stat = React.forwardRef(
22
24
  captionPlacement = "head",
23
25
  children,
24
26
  locale = DEFAULT_LOCALE,
27
+ loading = false,
28
+ loadingLabel = "Loading",
25
29
  className = "",
26
30
  ...rest
27
31
  }, ref) => {
@@ -40,17 +44,28 @@ const Stat = React.forwardRef(
40
44
  className
41
45
  ].filter(Boolean).join(" ");
42
46
  const parts = /* @__PURE__ */ jsxs(Fragment, { children: [
43
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__value`, children: typeof value === "number" ? formatNumber(value, locale) : value }),
47
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__value`, children: loading ? /* @__PURE__ */ jsx(Skeleton, { variant: "rectangular", loadingLabel }) : typeof value === "number" ? formatNumber(value, locale) : value }),
44
48
  captionInLabel ? /* @__PURE__ */ jsxs("span", { className: `${baseClass}__label ${baseClass}__label--captioned`, children: [
45
49
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__label-text`, children: label }),
46
50
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__caption`, children: caption })
47
51
  ] }) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: label }),
48
- delta && /* @__PURE__ */ jsxs("span", { className: `${baseClass}__delta ${baseClass}__delta--${trend}`, children: [
49
- /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", "aria-hidden": "true", children: TREND_ICONS[trend] }),
50
- delta
51
- ] })
52
+ delta && loading && /* @__PURE__ */ jsx("span", { className: `${baseClass}__delta`, children: /* @__PURE__ */ jsx(Skeleton, { variant: "rectangular", "aria-hidden": "true" }) }),
53
+ delta && !loading && /* @__PURE__ */ jsxs(
54
+ "span",
55
+ {
56
+ className: [
57
+ `${baseClass}__delta`,
58
+ `${baseClass}__delta--${trend}`,
59
+ sentiment ? `${baseClass}__delta--${sentiment}` : ""
60
+ ].filter(Boolean).join(" "),
61
+ children: [
62
+ /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", "aria-hidden": "true", children: TREND_ICONS[trend] }),
63
+ delta
64
+ ]
65
+ }
66
+ )
52
67
  ] });
53
- return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
68
+ return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, "aria-busy": loading || void 0, children: [
54
69
  hasHead && /* @__PURE__ */ jsxs("span", { className: `${baseClass}__head`, children: [
55
70
  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 })),
56
71
  captionInHead && /* @__PURE__ */ jsx("span", { className: `${baseClass}__caption`, children: caption })
@@ -20,6 +20,19 @@
20
20
  inherits: false;
21
21
  }
22
22
 
23
+ /* The scroll cue's two fades, as lengths so each eases in and out. */
24
+ @property --ds-table-cue-left {
25
+ syntax: '<length>';
26
+ initial-value: 0px;
27
+ inherits: false;
28
+ }
29
+
30
+ @property --ds-table-cue-right {
31
+ syntax: '<length>';
32
+ initial-value: 0px;
33
+ inherits: false;
34
+ }
35
+
23
36
  @layer rift.components {
24
37
 
25
38
  .ds-table {
@@ -74,10 +87,23 @@
74
87
  ============================================ */
75
88
 
76
89
  .ds-table__row {
77
- border-bottom: var(--border-025) solid var(--color-table-divider);
78
90
  transition: background-color var(--motion-duration-base) var(--motion-ease-standard);
79
91
  }
80
92
 
93
+ /* The line between rows sits on the cells: with border-collapse: separate
94
+ a row's own border never paints. Every table draws it here (a frameless
95
+ table wider than a phone clears it and paints its own, cut to the
96
+ content). The last body row has none: the table simply ends, or its
97
+ frame closes it. */
98
+ .ds-table__header-cell,
99
+ .ds-table__cell {
100
+ border-bottom: var(--border-025) solid var(--color-table-divider);
101
+ }
102
+
103
+ .ds-table__body:last-of-type .ds-table__row:last-child > .ds-table__cell {
104
+ border-bottom: none;
105
+ }
106
+
81
107
  /* A row that heads a group, and a row the ones above add up to: both in
82
108
  the emphasis weight, the total under a heavier rule. */
83
109
  .ds-table__row--heading .ds-table__cell,
@@ -85,15 +111,13 @@
85
111
  font-weight: var(--font-paragraph-emphasis-weight);
86
112
  }
87
113
 
88
- /* The total's rule sits on its cells: with border-collapse: separate a
89
- row's own border never paints (the bordered variant's dividers below are
90
- on cells for the same reason). In the bordered table the row above drops
91
- its hairline, so the heavier rule is the only line between them. */
114
+ /* The total's rule sits on its cells too, and the row above drops its
115
+ hairline, so the heavier rule is the only line between them. */
92
116
  .ds-table__row--total .ds-table__cell {
93
117
  border-top: var(--border-050) solid var(--color-table-divider);
94
118
  }
95
119
 
96
- .ds-table--bordered .ds-table__row:has(+ .ds-table__row--total) .ds-table__cell {
120
+ .ds-table__row:has(+ .ds-table__row--total) .ds-table__cell {
97
121
  border-bottom: none;
98
122
  }
99
123
 
@@ -149,13 +173,17 @@
149
173
 
150
174
  /* ============================================
151
175
  STRIPED ROWS
176
+ Every other record. A row that heads a group (DataTable's group rows,
177
+ marked data-group-row) is a heading, not a record, so it is left out of
178
+ the count and the records under it start unstriped. The :where() keeps
179
+ the selector's weight what a plain :nth-child's is.
152
180
  ============================================ */
153
181
 
154
- .ds-table--striped .ds-table__body .ds-table__row:nth-child(even) {
182
+ .ds-table--striped .ds-table__body .ds-table__row:nth-child(even of :where(:not([data-group-row]))) {
155
183
  background-color: var(--color-table-row-stripe-bg);
156
184
  }
157
185
 
158
- .ds-table--striped .ds-table__body .ds-table__row:nth-child(even):hover {
186
+ .ds-table--striped .ds-table__body .ds-table__row:nth-child(even of :where(:not([data-group-row]))):hover {
159
187
  background-color: var(--color-table-row-hover-bg);
160
188
  }
161
189
 
@@ -180,7 +208,9 @@
180
208
  .ds-table__wrapper {
181
209
  overflow-x: auto;
182
210
  border: var(--border-025) solid var(--color-table-border);
183
- border-radius: var(--radius-300); /* 12px */
211
+ /* The content-card corner, Panel's and Widget's. The wrapper scrolls, so
212
+ it clips the header band, a pinned column and the last row to it. */
213
+ border-radius: var(--radius-600); /* 24px */
184
214
  background: var(--color-table-body-bg);
185
215
  }
186
216
 
@@ -194,6 +224,56 @@
194
224
  max-width: 100%;
195
225
  }
196
226
 
227
+ /* The scroll cue: while a table is wider than its container, the edge it
228
+ continues past fades out, so columns off screen are never a surprise.
229
+ ScrollRegion marks the sides that hold more (data-scroll-start and
230
+ data-scroll-end, written on scroll); each fades over --ds-table-cue
231
+ (an override hook; --ds-table-cue-start and --ds-table-cue-end set one
232
+ side) and comes back sharp once that side is scrolled to
233
+ its end. The fade is a mask on the scroll container, so it sits over
234
+ whatever the table is drawn on. A focused region drops it: a mask would
235
+ clip the focus ring drawn outside the box. */
236
+ .ds-table__scroll,
237
+ .ds-table__wrapper {
238
+ transition:
239
+ --ds-table-cue-left var(--motion-duration-fast) var(--motion-ease-standard),
240
+ --ds-table-cue-right var(--motion-duration-fast) var(--motion-ease-standard);
241
+ }
242
+
243
+ :is(.ds-table__scroll, .ds-table__wrapper):is([data-scroll-start], [data-scroll-end]):not(:focus-visible) {
244
+ /* ds-allow(color): mask alpha keywords (black/transparent), not palette colours */
245
+ -webkit-mask-image: linear-gradient(
246
+ to right, /* ds-allow(physical): the two fades are assigned by reading direction below */
247
+ transparent,
248
+ black var(--ds-table-cue-left),
249
+ black calc(100% - var(--ds-table-cue-right)),
250
+ transparent
251
+ );
252
+ mask-image: linear-gradient(
253
+ to right, /* ds-allow(physical): the two fades are assigned by reading direction below */
254
+ transparent,
255
+ black var(--ds-table-cue-left),
256
+ black calc(100% - var(--ds-table-cue-right)),
257
+ transparent
258
+ );
259
+ }
260
+
261
+ :is(.ds-table__scroll, .ds-table__wrapper)[data-scroll-start]:dir(ltr) {
262
+ --ds-table-cue-left: var(--ds-table-cue-start, var(--ds-table-cue, var(--gap-1000)));
263
+ }
264
+
265
+ :is(.ds-table__scroll, .ds-table__wrapper)[data-scroll-end]:dir(ltr) {
266
+ --ds-table-cue-right: var(--ds-table-cue-end, var(--ds-table-cue, var(--gap-1000)));
267
+ }
268
+
269
+ :is(.ds-table__scroll, .ds-table__wrapper)[data-scroll-start]:dir(rtl) {
270
+ --ds-table-cue-right: var(--ds-table-cue-start, var(--ds-table-cue, var(--gap-1000)));
271
+ }
272
+
273
+ :is(.ds-table__scroll, .ds-table__wrapper)[data-scroll-end]:dir(rtl) {
274
+ --ds-table-cue-left: var(--ds-table-cue-end, var(--ds-table-cue, var(--gap-1000)));
275
+ }
276
+
197
277
  @media (max-width: 768px) {
198
278
  .ds-table__scroll .ds-table,
199
279
  .ds-table__wrapper .ds-table {
@@ -222,11 +302,6 @@
222
302
  background: var(--color-table-header-bg);
223
303
  }
224
304
 
225
- /* Remove row-level border — border-collapse: separate ignores it */
226
- .ds-table--bordered .ds-table__row {
227
- border-bottom: none;
228
- }
229
-
230
305
  /* Header cells: bottom divider */
231
306
  .ds-table--bordered .ds-table__header-cell {
232
307
  border-bottom: var(--border-025) solid var(--color-table-divider);
@@ -373,7 +448,7 @@
373
448
  /* Rows paint nothing; their cells paint the tile. */
374
449
  .ds-table--frameless .ds-table__body .ds-table__row,
375
450
  .ds-table--frameless .ds-table__body .ds-table__row:hover,
376
- .ds-table.ds-table--frameless.ds-table--striped .ds-table__body .ds-table__row:nth-child(even),
451
+ .ds-table.ds-table--frameless.ds-table--striped .ds-table__body .ds-table__row:nth-child(even of :where(:not([data-group-row]))),
377
452
  .ds-table.ds-table--frameless .ds-table__body .ds-table__row.ds-table__row--selected:nth-child(n) {
378
453
  background-color: transparent;
379
454
  }
@@ -466,7 +541,7 @@
466
541
  /* A tint with no edge (stripe, selection) covers its own line. Striped,
467
542
  hovered and selected share a weight, so the later one wins: selected
468
543
  over hovered over striped. */
469
- .ds-table.ds-table--frameless.ds-table--striped .ds-table__body .ds-table__row:nth-child(even) > * {
544
+ .ds-table.ds-table--frameless.ds-table--striped .ds-table__body .ds-table__row:nth-child(even of :where(:not([data-group-row]))) > * {
470
545
  --ds-table-fill: var(--color-table-row-stripe-bg);
471
546
  --ds-table-line: transparent;
472
547
  }
@@ -596,4 +671,14 @@
596
671
  }
597
672
  }
598
673
 
674
+ /* ============================================
675
+ LOADING — placeholder rows under the header,
676
+ each line in a box one text line tall, so a
677
+ loading row is as tall as a row of text
678
+ ============================================ */
679
+
680
+ .ds-table__cell-content--loading {
681
+ min-height: 1lh;
682
+ }
683
+
599
684
  } /* @layer rift.components */
@@ -73,6 +73,10 @@ type TableOwnProps = {
73
73
  caption?: string;
74
74
  /** Whether to visually hide the caption (still available to screen readers) */
75
75
  captionHidden?: boolean;
76
+ /** Holds placeholder rows under the header while the rows are being fetched: as many as `rows` holds, or five when it is empty. */
77
+ loading?: boolean;
78
+ /** Accessible name announced while `loading`. */
79
+ loadingLabel?: string;
76
80
  /** Additional CSS classes */
77
81
  className?: string;
78
82
  };
@@ -4,6 +4,9 @@ import "./Table.css";
4
4
  import { ScrollRegion } from "../../behaviors/ScrollRegion.js";
5
5
  import "../../behaviors/visually-hidden.css";
6
6
  import { warnOnce } from "../../behaviors/devWarning.js";
7
+ import { Skeleton } from "../Skeleton/Skeleton.js";
8
+ const LOADING_ROWS = 5;
9
+ const LOADING_WIDTHS = ["72%", "48%", "84%", "60%"];
7
10
  const Table = React.forwardRef(
8
11
  ({
9
12
  columns,
@@ -17,6 +20,8 @@ const Table = React.forwardRef(
17
20
  outerControl = false,
18
21
  caption,
19
22
  captionHidden = false,
23
+ loading = false,
24
+ loadingLabel = "Loading",
20
25
  className = "",
21
26
  ...rest
22
27
  }, ref) => {
@@ -37,7 +42,7 @@ const Table = React.forwardRef(
37
42
  className
38
43
  ].filter(Boolean).join(" ");
39
44
  const outsideCaption = framed && caption && !captionHidden;
40
- const table = /* @__PURE__ */ jsxs("table", { ...rest, ref, className: classes, children: [
45
+ const table = /* @__PURE__ */ jsxs("table", { ...rest, ref, className: classes, "aria-busy": loading || void 0, children: [
41
46
  caption && /* @__PURE__ */ jsx(
42
47
  "caption",
43
48
  {
@@ -59,33 +64,43 @@ const Table = React.forwardRef(
59
64
  },
60
65
  col.key
61
66
  )) }) }),
62
- /* @__PURE__ */ jsx("tbody", { className: `${baseClass}__body`, children: rows.map((row) => /* @__PURE__ */ jsx(
63
- "tr",
64
- {
65
- className: [
66
- `${baseClass}__row`,
67
- row.selected ? `${baseClass}__row--selected` : "",
68
- row.variant && row.variant !== "default" ? `${baseClass}__row--${row.variant}` : ""
69
- ].filter(Boolean).join(" "),
70
- children: columns.map((col, index) => {
71
- const align = alignOf(col, index);
72
- const content = /* @__PURE__ */ jsx(
73
- "div",
74
- {
75
- className: `${baseClass}__cell-content${col.mono ? ` ${baseClass}__cell-content--mono` : ""}`,
76
- style: {
77
- // flex-start and flex-end follow the reading direction;
78
- // left and right stay on their screen side.
79
- justifyContent: align === "center" ? "center" : align === "end" ? "flex-end" : align === "left" || align === "right" ? align : "flex-start"
80
- },
81
- children: row.cells[col.key]
82
- }
83
- );
84
- return col.rowHeader ? /* @__PURE__ */ jsx("th", { className: `${baseClass}__cell ${baseClass}__cell--row-header`, scope: "row", children: content }, col.key) : /* @__PURE__ */ jsx("td", { className: `${baseClass}__cell`, children: content }, col.key);
85
- })
86
- },
87
- row.id
88
- )) })
67
+ /* @__PURE__ */ jsxs("tbody", { className: `${baseClass}__body`, children: [
68
+ loading && Array.from({ length: rows.length || LOADING_ROWS }, (_, rowIndex) => /* @__PURE__ */ jsx("tr", { className: `${baseClass}__row ${baseClass}__row--loading`, children: columns.map((col, index) => /* @__PURE__ */ jsx("td", { className: `${baseClass}__cell`, children: /* @__PURE__ */ jsx("div", { className: `${baseClass}__cell-content ${baseClass}__cell-content--loading`, children: /* @__PURE__ */ jsx(
69
+ Skeleton,
70
+ {
71
+ variant: "text",
72
+ width: LOADING_WIDTHS[(rowIndex + index) % LOADING_WIDTHS.length],
73
+ ...rowIndex === 0 && index === 0 ? { loadingLabel } : { "aria-hidden": true }
74
+ }
75
+ ) }) }, col.key)) }, rowIndex)),
76
+ !loading && rows.map((row) => /* @__PURE__ */ jsx(
77
+ "tr",
78
+ {
79
+ className: [
80
+ `${baseClass}__row`,
81
+ row.selected ? `${baseClass}__row--selected` : "",
82
+ row.variant && row.variant !== "default" ? `${baseClass}__row--${row.variant}` : ""
83
+ ].filter(Boolean).join(" "),
84
+ children: columns.map((col, index) => {
85
+ const align = alignOf(col, index);
86
+ const content = /* @__PURE__ */ jsx(
87
+ "div",
88
+ {
89
+ className: `${baseClass}__cell-content${col.mono ? ` ${baseClass}__cell-content--mono` : ""}`,
90
+ style: {
91
+ // flex-start and flex-end follow the reading direction;
92
+ // left and right stay on their screen side.
93
+ justifyContent: align === "center" ? "center" : align === "end" ? "flex-end" : align === "left" || align === "right" ? align : "flex-start"
94
+ },
95
+ children: row.cells[col.key]
96
+ }
97
+ );
98
+ return col.rowHeader ? /* @__PURE__ */ jsx("th", { className: `${baseClass}__cell ${baseClass}__cell--row-header`, scope: "row", children: content }, col.key) : /* @__PURE__ */ jsx("td", { className: `${baseClass}__cell`, children: content }, col.key);
99
+ })
100
+ },
101
+ row.id
102
+ ))
103
+ ] })
89
104
  ] });
90
105
  if (framed) {
91
106
  const region = /* @__PURE__ */ jsx(ScrollRegion, { className: `${baseClass}__wrapper`, children: table });
@@ -73,7 +73,9 @@
73
73
  ERROR STATE
74
74
  ============================================ */
75
75
 
76
- .ds-textarea--error .ds-textarea__field {
76
+ /* The hover rule above is more specific, so the error border names it too. */
77
+ .ds-textarea--error .ds-textarea__field,
78
+ .ds-textarea--error .ds-textarea__field:hover:not(:focus):not(:disabled) {
77
79
  border-color: var(--color-status-error-border);
78
80
  }
79
81
 
@@ -82,7 +84,7 @@
82
84
  }
83
85
 
84
86
  .ds-textarea--error .ds-textarea__counter {
85
- color: var(--color-status-error-border);
87
+ color: var(--color-text-error);
86
88
  }
87
89
 
88
90
  /* ============================================
@@ -47,13 +47,21 @@ export type ColorModeScriptOptions = ColorModeOptions & {
47
47
  brandStorageKey?: string;
48
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
49
  baseThemeId?: string;
50
+ /**
51
+ * The mode a first-time visitor opens in, before they have chosen one:
52
+ * `dark` for a dark-first app, `light` to ignore the operating system.
53
+ * It applies only while nothing is stored, so a visitor's own choice
54
+ * (`system` included) always wins. Default `system`.
55
+ */
56
+ defaultMode?: ColorModeSetting;
50
57
  };
51
58
  /**
52
59
  * The script that applies the stored choice before first paint: it sets
53
60
  * `data-theme-setting` and `data-theme` on `<html>` and, while the setting
54
61
  * is `system`, keeps `data-theme` following the operating system. Render it
55
62
  * inline in the document head, before anything paints. Storage being
56
- * unavailable (a private window) leaves the page on `system`.
63
+ * unavailable (a private window) leaves the page on `system`, or on
64
+ * `defaultMode` when one is given.
57
65
  *
58
66
  * It also puts the choice back when React wipes it. A hydration failure that
59
67
  * reaches the root (a browser extension editing the page before hydration
@@ -65,4 +73,4 @@ export type ColorModeScriptOptions = ColorModeOptions & {
65
73
  * applies the stored choice again. A ThemeToggle change only ever replaces
66
74
  * the value, so it never trips the repair.
67
75
  */
68
- export declare function colorModeScript({ storageKey, brandStorageKey, baseThemeId, }?: ColorModeScriptOptions): string;
76
+ export declare function colorModeScript({ storageKey, brandStorageKey, baseThemeId, defaultMode, }?: ColorModeScriptOptions): string;
@@ -4,9 +4,11 @@ const isColorModeSetting = (value) => colorModeSettings.includes(value);
4
4
  function colorModeScript({
5
5
  storageKey = DEFAULT_COLOR_MODE_STORAGE_KEY,
6
6
  brandStorageKey,
7
- baseThemeId = "tide"
7
+ baseThemeId = "tide",
8
+ defaultMode = "system"
8
9
  } = {}) {
9
10
  const key = JSON.stringify(storageKey);
11
+ const setting = defaultMode === "light" || defaultMode === "dark" ? `saved === 'light' || saved === 'dark' || saved === 'system' ? saved : '${defaultMode}'` : `saved === 'light' || saved === 'dark' ? saved : 'system'`;
10
12
  const brand = brandStorageKey ? `
11
13
  var brand = null;
12
14
  try { brand = localStorage.getItem(${JSON.stringify(brandStorageKey)}); } catch (e) {}
@@ -18,7 +20,7 @@ function colorModeScript({
18
20
  function apply() {
19
21
  var saved = null;
20
22
  try { saved = localStorage.getItem(${key}); } catch (e) {}
21
- var setting = saved === 'light' || saved === 'dark' ? saved : 'system';
23
+ var setting = ${setting};
22
24
  root.setAttribute('data-theme-setting', setting);
23
25
  root.setAttribute('data-theme', setting === 'system' ? (media.matches ? 'dark' : 'light') : setting);${brand}
24
26
  }
@@ -516,4 +516,15 @@
516
516
  }
517
517
  }
518
518
 
519
+ /* Loading: a title line in a box the size of a thread row, on the row's own
520
+ inset. */
521
+
522
+ .ds-thread-history__row--loading {
523
+ box-sizing: border-box;
524
+ display: flex;
525
+ align-items: center;
526
+ height: 40px; /* ds-allow(spacing): the thread row's own height */
527
+ padding-inline: var(--padding-200) var(--padding-300);
528
+ }
529
+
519
530
  } /* @layer rift.components */