rift-ds 1.41.0 → 1.43.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 (212) hide show
  1. package/README.md +2 -2
  2. package/behaviors/LoadingImage.d.ts +2 -0
  3. package/behaviors/LoadingImage.js +34 -0
  4. package/behaviors/ScrollRegion.js +15 -2
  5. package/behaviors/VisuallyHidden.d.ts +30 -0
  6. package/behaviors/VisuallyHidden.js +17 -0
  7. package/behaviors/loading-image.css +30 -0
  8. package/behaviors/quietFocus.d.ts +4 -0
  9. package/behaviors/quietFocus.js +14 -0
  10. package/behaviors/useFocusScope.d.ts +3 -1
  11. package/behaviors/useFocusScope.js +4 -6
  12. package/bin/rift-ds.mjs +2 -0
  13. package/bin/templates/app/components/rift/ColorModeScript.tsx +3 -1
  14. package/bin/templates/app/components/rift/RiftRoot.tsx +40 -1
  15. package/bin/templates/blocks/app/dashboard/page.module.css +2 -2
  16. package/bin/templates/blocks/app/dashboard/page.tsx +7 -5
  17. package/bin/templates/blocks/app/landing/page.tsx +1 -1
  18. package/bin/templates/blocks/app/notifications/Inbox.tsx +13 -45
  19. package/bin/templates/blocks/app/notifications/page.module.css +5 -0
  20. package/bin/templates/blocks/app/planner/page.tsx +2 -2
  21. package/bin/templates/blocks/app/pricing/page.module.css +15 -1
  22. package/bin/templates/blocks/app/pricing/page.tsx +8 -1
  23. package/bin/templates/blocks/app/settings/Settings.tsx +4 -4
  24. package/bin/templates/blocks/app/sign-in/page.tsx +10 -2
  25. package/bin/templates/blocks/app/sign-up/page.module.css +83 -0
  26. package/bin/templates/blocks/app/sign-up/page.tsx +126 -0
  27. package/bin/templates/blocks/app/starter/page.tsx +1 -1
  28. package/bin/templates/blocks/components/blocks/AppShell.module.css +0 -10
  29. package/bin/templates/blocks/components/blocks/AppShell.tsx +51 -132
  30. package/bin/templates/blocks/components/blocks/DocsShell.tsx +5 -1
  31. package/bin/templates/blocks/components/blocks/notifications.ts +77 -0
  32. package/bin/templates/blocks/registry.json +49 -6
  33. package/chat/ChatWidget.js +2 -1
  34. package/components/AgentPlan/AgentPlan.css +1 -1
  35. package/components/AlertDialog/AlertDialog.css +14 -0
  36. package/components/AlertDialog/AlertDialog.d.ts +35 -3
  37. package/components/AlertDialog/AlertDialog.js +16 -5
  38. package/components/AppLayout/AppLayout.css +6 -0
  39. package/components/AppLayout/AppLayout.d.ts +4 -0
  40. package/components/AppLayout/AppLayout.js +5 -1
  41. package/components/AppSidebar/AppSidebar.css +17 -2
  42. package/components/AppSidebar/AppSidebar.js +9 -2
  43. package/components/AppToolbar/AppToolbar.d.ts +5 -2
  44. package/components/AppToolbar/AppToolbar.js +3 -1
  45. package/components/Attachment/AttachmentGroup.js +2 -1
  46. package/components/Attachment/AttachmentTile.js +2 -1
  47. package/components/Badge/Badge.css +6 -0
  48. package/components/Breadcrumb/Breadcrumb.css +4 -1
  49. package/components/Button/Button.css +20 -1
  50. package/components/Button/Button.js +6 -1
  51. package/components/Card/Card.css +11 -0
  52. package/components/Card/Card.d.ts +9 -3
  53. package/components/Card/Card.js +21 -2
  54. package/components/Chart/AreaChart.d.ts +7 -0
  55. package/components/Chart/AreaChart.js +57 -45
  56. package/components/Chart/BarChart.d.ts +7 -0
  57. package/components/Chart/BarChart.js +52 -46
  58. package/components/Chart/Chart.css +134 -1
  59. package/components/Chart/ChartSkeleton.d.ts +32 -0
  60. package/components/Chart/ChartSkeleton.js +149 -0
  61. package/components/Chart/ComboChart.d.ts +7 -0
  62. package/components/Chart/ComboChart.js +80 -74
  63. package/components/Chart/LineChart.d.ts +17 -3
  64. package/components/Chart/LineChart.js +67 -39
  65. package/components/Chart/PieChart.d.ts +7 -0
  66. package/components/Chart/PieChart.js +41 -34
  67. package/components/Chart/RadarChart.d.ts +7 -0
  68. package/components/Chart/RadarChart.js +39 -32
  69. package/components/Chart/RadialChart.d.ts +7 -0
  70. package/components/Chart/RadialChart.js +5 -1
  71. package/components/Chart/ScatterChart.d.ts +7 -0
  72. package/components/Chart/ScatterChart.js +52 -40
  73. package/components/Chart/StackedBarChart.d.ts +10 -1
  74. package/components/Chart/StackedBarChart.js +57 -43
  75. package/components/Chart/Treemap.d.ts +7 -0
  76. package/components/Chart/Treemap.js +17 -11
  77. package/components/ChatMessage/ChatMessage.css +6 -0
  78. package/components/Checkbox/Checkbox.css +25 -1
  79. package/components/Checkbox/Checkbox.d.ts +8 -4
  80. package/components/Checkbox/Checkbox.js +17 -8
  81. package/components/Chip/Chip.css +5 -3
  82. package/components/ContactCard/ContactCard.css +4 -3
  83. package/components/ContributionGraph/ContributionGraph.css +20 -0
  84. package/components/ContributionGraph/ContributionGraph.d.ts +4 -0
  85. package/components/ContributionGraph/ContributionGraph.js +11 -6
  86. package/components/DataTable/DataTable.css +34 -4
  87. package/components/DataTable/DataTable.d.ts +16 -2
  88. package/components/DataTable/DataTable.js +8 -2
  89. package/components/DateInput/DateInput.css +3 -1
  90. package/components/DatePicker/DatePicker.css +16 -0
  91. package/components/DatePicker/DatePicker.d.ts +13 -0
  92. package/components/DatePicker/DatePicker.js +21 -27
  93. package/components/DatePicker/MonthGrid.d.ts +2 -2
  94. package/components/DatePicker/MonthGrid.js +1 -1
  95. package/components/DatePicker/today.d.ts +15 -0
  96. package/components/DatePicker/today.js +17 -0
  97. package/components/DateRangePicker/DateRangePicker.d.ts +14 -1
  98. package/components/DateRangePicker/DateRangePicker.js +18 -7
  99. package/components/DescriptionList/DescriptionList.css +11 -0
  100. package/components/DescriptionList/DescriptionList.d.ts +5 -1
  101. package/components/DescriptionList/DescriptionList.js +21 -6
  102. package/components/Dialog/Dialog.css +9 -0
  103. package/components/Dialog/Dialog.d.ts +9 -0
  104. package/components/Dialog/Dialog.js +32 -19
  105. package/components/DocumentChip/DocumentChip.css +1 -1
  106. package/components/Drawer/Drawer.d.ts +9 -0
  107. package/components/Drawer/Drawer.js +8 -0
  108. package/components/Dropdown/Dropdown.css +3 -1
  109. package/components/Dropdown/Dropdown.js +8 -0
  110. package/components/EmptyState/EmptyState.css +8 -1
  111. package/components/EventCalendar/EventCalendar.css +12 -0
  112. package/components/Field/Field.css +2 -2
  113. package/components/FileInput/FileInput.css +1 -1
  114. package/components/FilterBar/FilterBar.d.ts +6 -1
  115. package/components/FunnelChart/FunnelChart.d.ts +7 -0
  116. package/components/FunnelChart/FunnelChart.js +44 -30
  117. package/components/GanttChart/GanttChart.css +10 -0
  118. package/components/GanttChart/GanttChart.d.ts +4 -0
  119. package/components/GanttChart/GanttChart.js +66 -33
  120. package/components/Gauge/Gauge.css +23 -0
  121. package/components/Gauge/Gauge.d.ts +4 -0
  122. package/components/Gauge/Gauge.js +14 -8
  123. package/components/ImageCompare/ImageCompare.js +2 -1
  124. package/components/Input/Input.css +15 -1
  125. package/components/Inspector/Inspector.css +4 -1
  126. package/components/List/List.css +1 -1
  127. package/components/NotificationCenter/NotificationCenter.css +152 -27
  128. package/components/NotificationCenter/NotificationCenter.d.ts +71 -8
  129. package/components/NotificationCenter/NotificationCenter.js +120 -13
  130. package/components/NumberInput/NumberInput.css +2 -0
  131. package/components/PageHeader/PageHeader.css +12 -4
  132. package/components/Panel/Panel.d.ts +1 -1
  133. package/components/Popover/Popover.css +3 -0
  134. package/components/Popover/Popover.d.ts +1 -1
  135. package/components/Popover/Popover.js +9 -1
  136. package/components/Prose/Prose.css +1 -1
  137. package/components/QuestionCard/QuestionCard.css +7 -4
  138. package/components/RadioButton/RadioButton.css +1 -1
  139. package/components/RadioButton/RadioButton.d.ts +4 -2
  140. package/components/RadioButton/RadioButton.js +5 -2
  141. package/components/ResourceTimeline/ResourceTimeline.css +12 -0
  142. package/components/ResourceTimeline/ResourceTimeline.d.ts +5 -1
  143. package/components/ResourceTimeline/ResourceTimeline.js +94 -52
  144. package/components/RichDropdown/RichDropdown.css +3 -1
  145. package/components/SegmentedControl/SegmentedControl.css +5 -0
  146. package/components/SelectionCard/SelectionCard.css +29 -0
  147. package/components/SelectionCard/SelectionCard.d.ts +7 -0
  148. package/components/SelectionCard/SelectionCard.js +25 -2
  149. package/components/Sparkline/Sparkline.css +20 -0
  150. package/components/Sparkline/Sparkline.d.ts +4 -0
  151. package/components/Sparkline/Sparkline.js +14 -8
  152. package/components/Stat/Stat.css +39 -0
  153. package/components/Stat/Stat.d.ts +23 -2
  154. package/components/Stat/Stat.js +21 -6
  155. package/components/Table/Table.css +106 -16
  156. package/components/Table/Table.d.ts +4 -0
  157. package/components/Table/Table.js +43 -28
  158. package/components/Textarea/Textarea.css +4 -2
  159. package/components/ThemeToggle/colorMode.d.ts +13 -5
  160. package/components/ThemeToggle/colorMode.js +4 -2
  161. package/components/ThreadHistory/ThreadHistory.css +11 -0
  162. package/components/ThreadHistory/ThreadHistory.d.ts +5 -1
  163. package/components/ThreadHistory/ThreadHistory.js +6 -1
  164. package/components/ThreadPanel/ThreadPanel.d.ts +4 -0
  165. package/components/ThreadPanel/ThreadPanel.js +5 -1
  166. package/components/TimePicker/TimePicker.css +3 -1
  167. package/components/TimePicker/TimePicker.d.ts +4 -2
  168. package/components/TimePicker/TimePicker.js +11 -3
  169. package/components/Timeline/Timeline.css +15 -0
  170. package/components/Timeline/Timeline.d.ts +8 -0
  171. package/components/Timeline/Timeline.js +21 -0
  172. package/components/Toast/Toast.css +16 -0
  173. package/components/Toast/Toast.d.ts +7 -2
  174. package/components/ToggleGroup/ToggleGroup.css +28 -2
  175. package/components/ToggleSwitch/ToggleSwitch.css +1 -1
  176. package/components/Toolbar/Toolbar.d.ts +6 -1
  177. package/components/Tooltip/Tooltip.d.ts +9 -0
  178. package/components/Tooltip/Tooltip.js +34 -8
  179. package/components/TreeView/TreeView.css +12 -0
  180. package/components/TreeView/TreeView.d.ts +4 -0
  181. package/components/TreeView/TreeView.js +20 -0
  182. package/components/UsageCard/UsageCard.css +11 -0
  183. package/components/UsageCard/UsageCard.d.ts +4 -0
  184. package/components/UsageCard/UsageCard.js +25 -16
  185. package/components/Widget/Widget.css +7 -0
  186. package/components/Widget/Widget.d.ts +4 -0
  187. package/components/Widget/Widget.js +14 -2
  188. package/components/Wizard/Wizard.d.ts +8 -3
  189. package/components/Wizard/Wizard.js +4 -1
  190. package/components/registry.json +15 -6
  191. package/components/registry.json.d.ts +15 -6
  192. package/components/registry.json.js +1 -1
  193. package/package.json +7 -2
  194. package/tokens/presets/contrast.css +4 -4
  195. package/tokens/presets/coral.css +3 -4
  196. package/tokens/presets/forest.css +16 -4
  197. package/tokens/presets/gold.css +4 -3
  198. package/tokens/presets/marquee.css +2 -3
  199. package/tokens/presets/mono.css +28 -28
  200. package/tokens/presets/pink.css +5 -4
  201. package/tokens/presets/terminal.css +4 -3
  202. package/tokens/presets/violet.css +3 -4
  203. package/tokens/presets/warm.css +16 -4
  204. package/tokens/presets/zest.css +11 -13
  205. package/tokens/registry.json +1 -0
  206. package/tokens/registry.json.d.ts +1 -0
  207. package/tokens/registry.json.js +1 -1
  208. package/tokens/tokens-dark.css +4 -0
  209. package/tokens/tokens-light.css +4 -0
  210. package/tokens/values.d.ts +24 -4
  211. package/tokens/values.js +25 -6
  212. package/tokens/values.json.js +1 -1
@@ -98,6 +98,8 @@
98
98
  flex-direction: column;
99
99
  gap: var(--gap-050); /* 4px */
100
100
  min-width: 0;
101
+ /* Takes the row, so a heading's meta reaches the end of the line. */
102
+ flex: 1 1 auto;
101
103
  }
102
104
 
103
105
  .ds-selection-card__label {
@@ -118,6 +120,33 @@
118
120
  color: var(--color-text-secondary);
119
121
  }
120
122
 
123
+ /* ============================================
124
+ HEADING — the label's line when a card carries
125
+ a badge or meta: the badge sits beside the
126
+ label, the meta at the line's end.
127
+ ============================================ */
128
+
129
+ .ds-selection-card__heading {
130
+ display: flex;
131
+ flex-wrap: wrap;
132
+ align-items: center;
133
+ gap: var(--gap-050) var(--gap-200);
134
+ }
135
+
136
+ .ds-selection-card__badge {
137
+ display: inline-flex;
138
+ }
139
+
140
+ .ds-selection-card__meta {
141
+ margin-inline-start: auto;
142
+ font-family: var(--font-paragraph-emphasis-family);
143
+ font-size: var(--font-paragraph-emphasis-size);
144
+ font-weight: var(--font-paragraph-emphasis-weight);
145
+ line-height: var(--font-paragraph-emphasis-line-height);
146
+ letter-spacing: var(--font-paragraph-emphasis-letter-spacing);
147
+ color: var(--color-text-primary);
148
+ }
149
+
121
150
  /* ============================================
122
151
  INDICATOR — the control's own, seated at the end
123
152
  ============================================ */
@@ -6,6 +6,13 @@ export interface SelectionCardOption {
6
6
  label: string;
7
7
  /** Optional description text below the label */
8
8
  description?: string;
9
+ /**
10
+ * Content at the end of the label's line, set apart from it: a price, a
11
+ * plan's seat count, a figure. Read as part of the card's name.
12
+ */
13
+ meta?: React.ReactNode;
14
+ /** A mark beside the label, such as a `Badge` saying "Current". Read as part of the card's name. */
15
+ badge?: React.ReactNode;
9
16
  /** Whether this option is disabled */
10
17
  disabled?: boolean;
11
18
  }
@@ -4,6 +4,7 @@ import React from "react";
4
4
  import { CheckboxIndicator } from "../Checkbox/Checkbox.js";
5
5
  import { RadioIndicator } from "../RadioButton/RadioButton.js";
6
6
  import { SwitchIndicator } from "../ToggleSwitch/ToggleSwitch.js";
7
+ import { logicalArrowKey } from "../../behaviors/direction.js";
7
8
  import "./SelectionCard.css";
8
9
  const SelectionCard = React.forwardRef(
9
10
  ({
@@ -34,8 +35,26 @@ const SelectionCard = React.forwardRef(
34
35
  if (e.key === " " || e.key === "Enter") {
35
36
  e.preventDefault();
36
37
  handleSelect(option);
38
+ return;
37
39
  }
40
+ if (mode !== "radio") return;
41
+ const group = e.currentTarget.parentElement;
42
+ if (!group) return;
43
+ const cards = Array.from(
44
+ group.querySelectorAll(':scope > [role="radio"]:not([aria-disabled="true"])')
45
+ );
46
+ const enabledOptions = options.filter((item) => !item.disabled);
47
+ const at = cards.indexOf(e.currentTarget);
48
+ if (at === -1 || cards.length !== enabledOptions.length) return;
49
+ const key = logicalArrowKey(e.key, group);
50
+ const to = key === "ArrowRight" || key === "ArrowDown" ? (at + 1) % cards.length : key === "ArrowLeft" || key === "ArrowUp" ? (at - 1 + cards.length) % cards.length : key === "Home" ? 0 : key === "End" ? cards.length - 1 : -1;
51
+ if (to === -1) return;
52
+ e.preventDefault();
53
+ cards[to].focus();
54
+ handleSelect(enabledOptions[to]);
38
55
  };
56
+ const firstEnabled = options.find((item) => !item.disabled);
57
+ const radioTabStop = options.find((item) => !item.disabled && isSelected(item.value))?.value ?? firstEnabled?.value;
39
58
  const groupRole = mode === "radio" ? "radiogroup" : "group";
40
59
  const itemRole = mode === "radio" ? "radio" : mode === "toggle" ? "switch" : "checkbox";
41
60
  const groupClasses = [`${baseClass}-group`, className].filter(Boolean).join(" ");
@@ -62,12 +81,16 @@ const SelectionCard = React.forwardRef(
62
81
  role: itemRole,
63
82
  "aria-checked": selected,
64
83
  "aria-disabled": option.disabled,
65
- tabIndex: option.disabled ? -1 : 0,
84
+ tabIndex: option.disabled || mode === "radio" && option.value !== radioTabStop ? -1 : 0,
66
85
  onClick: () => handleSelect(option),
67
86
  onKeyDown: (e) => handleKeyDown(e, option),
68
87
  children: [
69
88
  /* @__PURE__ */ jsxs("div", { className: `${baseClass}__content`, children: [
70
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: option.label }),
89
+ option.meta || option.badge ? /* @__PURE__ */ jsxs("span", { className: `${baseClass}__heading`, children: [
90
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: option.label }),
91
+ option.badge && /* @__PURE__ */ jsx("span", { className: `${baseClass}__badge`, children: option.badge }),
92
+ option.meta && /* @__PURE__ */ jsx("span", { className: `${baseClass}__meta`, children: option.meta })
93
+ ] }) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: option.label }),
71
94
  option.description && /* @__PURE__ */ jsx("span", { className: `${baseClass}__description`, children: option.description })
72
95
  ] }),
73
96
  /* @__PURE__ */ jsx("div", { className: `${baseClass}__indicator`, children: mode === "radio" ? /* @__PURE__ */ jsx(RadioIndicator, { checked: selected }) : mode === "toggle" ? /* @__PURE__ */ jsx(SwitchIndicator, { checked: selected }) : /* @__PURE__ */ jsx(CheckboxIndicator, { checked: selected }) }),
@@ -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`,
@@ -27,6 +27,9 @@
27
27
  font-weight: var(--font-sub-display-weight);
28
28
  line-height: var(--font-sub-display-line-height);
29
29
  letter-spacing: var(--font-sub-display-letter-spacing);
30
+ /* A reading sits on the baseline and keeps its width as it changes,
31
+ whatever figures the theme's display face draws by default. */
32
+ font-variant-numeric: lining-nums tabular-nums;
30
33
  color: var(--color-text-display);
31
34
  }
32
35
 
@@ -52,6 +55,9 @@
52
55
  display: flex;
53
56
  align-items: center;
54
57
  justify-content: space-between;
58
+ /* In a narrow tile the caption drops under the icon rather than running
59
+ past the tile's edge. */
60
+ flex-wrap: wrap;
55
61
  gap: var(--gap-200);
56
62
  align-self: stretch;
57
63
  /* The head sits --gap-300 above the value: the stat's own row gap
@@ -65,7 +71,9 @@
65
71
  }
66
72
 
67
73
  .ds-stat__caption {
74
+ min-width: 0;
68
75
  margin-inline-start: auto;
76
+ overflow-wrap: anywhere;
69
77
  font-family: var(--font-caption-family);
70
78
  font-size: var(--font-caption-size);
71
79
  font-weight: var(--font-caption-weight);
@@ -146,6 +154,18 @@
146
154
  color: var(--color-text-tertiary);
147
155
  }
148
156
 
157
+ /* A stated sentiment owns the colour and leaves the arrow to the trend, so
158
+ a fall that is good news is a down arrow in the positive colour. These
159
+ follow the trend rules at the same weight, so they win. `--neutral` above
160
+ serves both: a neutral sentiment is the neutral trend's colour. */
161
+ .ds-stat__delta--positive {
162
+ color: var(--color-trend-up);
163
+ }
164
+
165
+ .ds-stat__delta--negative {
166
+ color: var(--color-trend-down);
167
+ }
168
+
149
169
  /* ============================================
150
170
  INLINE DELTA — delta to the right of the
151
171
  value, bottom-aligned to its baseline
@@ -264,4 +284,23 @@
264
284
  color: inherit;
265
285
  }
266
286
 
287
+ /* ============================================
288
+ LOADING — a placeholder where the value and
289
+ the delta go, each one text line tall, so
290
+ the tile keeps its height when they land
291
+ ============================================ */
292
+
293
+ .ds-stat__value > .ds-skeleton {
294
+ width: 5ch;
295
+ max-width: 100%;
296
+ height: calc(1lh - var(--padding-300));
297
+ margin-block: var(--padding-150);
298
+ }
299
+
300
+ .ds-stat__delta > .ds-skeleton {
301
+ width: 8ch;
302
+ height: calc(1lh - var(--padding-200));
303
+ margin-block: var(--padding-100);
304
+ }
305
+
267
306
  } /* @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
 
@@ -190,10 +220,65 @@
190
220
  without this the table crushes to the viewport and cells clip. */
191
221
  /* The plain table's scroll container: no surface of its own. */
192
222
  .ds-table__scroll {
223
+ /* The containing block for anything absolutely placed inside the table (a
224
+ visually hidden column header): without it such a node is placed against
225
+ the page, outside this scroller, and widens the page by the columns that
226
+ are scrolled out of view. */
227
+ position: relative;
193
228
  overflow-x: auto;
194
229
  max-width: 100%;
195
230
  }
196
231
 
232
+ /* The scroll cue: while a table is wider than its container, the edge it
233
+ continues past fades out, so columns off screen are never a surprise.
234
+ ScrollRegion marks the sides that hold more (data-scroll-start and
235
+ data-scroll-end, written on scroll); each fades over --ds-table-cue
236
+ (an override hook; --ds-table-cue-start and --ds-table-cue-end set one
237
+ side) and comes back sharp once that side is scrolled to
238
+ its end. The fade is a mask on the scroll container, so it sits over
239
+ whatever the table is drawn on. A focused region drops it: a mask would
240
+ clip the focus ring drawn outside the box. */
241
+ .ds-table__scroll,
242
+ .ds-table__wrapper {
243
+ transition:
244
+ --ds-table-cue-left var(--motion-duration-fast) var(--motion-ease-standard),
245
+ --ds-table-cue-right var(--motion-duration-fast) var(--motion-ease-standard);
246
+ }
247
+
248
+ :is(.ds-table__scroll, .ds-table__wrapper):is([data-scroll-start], [data-scroll-end]):not(:focus-visible) {
249
+ /* ds-allow(color): mask alpha keywords (black/transparent), not palette colours */
250
+ -webkit-mask-image: linear-gradient(
251
+ to right, /* ds-allow(physical): the two fades are assigned by reading direction below */
252
+ transparent,
253
+ black var(--ds-table-cue-left),
254
+ black calc(100% - var(--ds-table-cue-right)),
255
+ transparent
256
+ );
257
+ mask-image: linear-gradient(
258
+ to right, /* ds-allow(physical): the two fades are assigned by reading direction below */
259
+ transparent,
260
+ black var(--ds-table-cue-left),
261
+ black calc(100% - var(--ds-table-cue-right)),
262
+ transparent
263
+ );
264
+ }
265
+
266
+ :is(.ds-table__scroll, .ds-table__wrapper)[data-scroll-start]:dir(ltr) {
267
+ --ds-table-cue-left: var(--ds-table-cue-start, var(--ds-table-cue, var(--gap-1000)));
268
+ }
269
+
270
+ :is(.ds-table__scroll, .ds-table__wrapper)[data-scroll-end]:dir(ltr) {
271
+ --ds-table-cue-right: var(--ds-table-cue-end, var(--ds-table-cue, var(--gap-1000)));
272
+ }
273
+
274
+ :is(.ds-table__scroll, .ds-table__wrapper)[data-scroll-start]:dir(rtl) {
275
+ --ds-table-cue-right: var(--ds-table-cue-start, var(--ds-table-cue, var(--gap-1000)));
276
+ }
277
+
278
+ :is(.ds-table__scroll, .ds-table__wrapper)[data-scroll-end]:dir(rtl) {
279
+ --ds-table-cue-left: var(--ds-table-cue-end, var(--ds-table-cue, var(--gap-1000)));
280
+ }
281
+
197
282
  @media (max-width: 768px) {
198
283
  .ds-table__scroll .ds-table,
199
284
  .ds-table__wrapper .ds-table {
@@ -222,11 +307,6 @@
222
307
  background: var(--color-table-header-bg);
223
308
  }
224
309
 
225
- /* Remove row-level border — border-collapse: separate ignores it */
226
- .ds-table--bordered .ds-table__row {
227
- border-bottom: none;
228
- }
229
-
230
310
  /* Header cells: bottom divider */
231
311
  .ds-table--bordered .ds-table__header-cell {
232
312
  border-bottom: var(--border-025) solid var(--color-table-divider);
@@ -373,7 +453,7 @@
373
453
  /* Rows paint nothing; their cells paint the tile. */
374
454
  .ds-table--frameless .ds-table__body .ds-table__row,
375
455
  .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),
456
+ .ds-table.ds-table--frameless.ds-table--striped .ds-table__body .ds-table__row:nth-child(even of :where(:not([data-group-row]))),
377
457
  .ds-table.ds-table--frameless .ds-table__body .ds-table__row.ds-table__row--selected:nth-child(n) {
378
458
  background-color: transparent;
379
459
  }
@@ -466,7 +546,7 @@
466
546
  /* A tint with no edge (stripe, selection) covers its own line. Striped,
467
547
  hovered and selected share a weight, so the later one wins: selected
468
548
  over hovered over striped. */
469
- .ds-table.ds-table--frameless.ds-table--striped .ds-table__body .ds-table__row:nth-child(even) > * {
549
+ .ds-table.ds-table--frameless.ds-table--striped .ds-table__body .ds-table__row:nth-child(even of :where(:not([data-group-row]))) > * {
470
550
  --ds-table-fill: var(--color-table-row-stripe-bg);
471
551
  --ds-table-line: transparent;
472
552
  }
@@ -596,4 +676,14 @@
596
676
  }
597
677
  }
598
678
 
679
+ /* ============================================
680
+ LOADING — placeholder rows under the header,
681
+ each line in a box one text line tall, so a
682
+ loading row is as tall as a row of text
683
+ ============================================ */
684
+
685
+ .ds-table__cell-content--loading {
686
+ min-height: 1lh;
687
+ }
688
+
599
689
  } /* @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
  };