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
@@ -579,7 +579,8 @@
579
579
  /* ============================================
580
580
  LOADING
581
581
  Keeps the variant's full-colour appearance (no disabled dim);
582
- the spinner occupies the left icon slot and inherits its colour.
582
+ the spinner occupies the left icon slot and inherits its colour, or
583
+ sits over the label when the button has no left icon.
583
584
  ============================================ */
584
585
 
585
586
  .ds-button--loading {
@@ -597,6 +598,24 @@
597
598
  justify-content: center;
598
599
  }
599
600
 
601
+ /* A button with text and no left icon keeps its width while loading: the
602
+ spinner sits centred over the label, and the label and any trailing icon
603
+ keep their room unseen. Opacity, never visibility: a hidden label would
604
+ leave the button with no accessible name. */
605
+ .ds-button--loading-over {
606
+ position: relative;
607
+ }
608
+
609
+ .ds-button--loading-over .ds-button__spinner {
610
+ position: absolute;
611
+ inset: 0;
612
+ }
613
+
614
+ .ds-button--loading-over .ds-button__text,
615
+ .ds-button--loading-over .ds-button__icon--right {
616
+ opacity: 0;
617
+ }
618
+
600
619
  /* The generic icon-slot svg sizing must not distort the spinner —
601
620
  it sizes itself from the Spinner size prop */
602
621
  .ds-button .ds-button__icon .ds-spinner__circle {
@@ -65,13 +65,17 @@ const Button = React.forwardRef(
65
65
  const resolvedState = state ?? (isDisabled ? "disabled" : "default");
66
66
  const isLoading = Boolean(loading);
67
67
  const spinnerSize = size === "compact" ? "sm" : "md";
68
- const leftIcon = isLoading ? /* @__PURE__ */ jsx(Spinner, { size: spinnerSize, tone: "inherit" }) : iconLeft || icon;
68
+ const spinner = /* @__PURE__ */ jsx(Spinner, { size: spinnerSize, tone: "inherit" });
69
+ const startIcon = iconLeft || icon;
70
+ const spinnerOverLabel = isLoading && !startIcon && text && Boolean(label);
71
+ const leftIcon = isLoading && !spinnerOverLabel ? spinner : startIcon;
69
72
  const classes = [
70
73
  baseClass,
71
74
  `${baseClass}--${resolvedVariant}`,
72
75
  `${baseClass}--${resolvedState}`,
73
76
  `${baseClass}--${size}`,
74
77
  isLoading && `${baseClass}--loading`,
78
+ spinnerOverLabel && `${baseClass}--loading-over`,
75
79
  glass && `${baseClass}--glass`,
76
80
  text && label && leftIcon && `${baseClass}--icon-start`,
77
81
  text && label && iconRight && `${baseClass}--icon-end`,
@@ -89,6 +93,7 @@ const Button = React.forwardRef(
89
93
  const fallbackAriaLabel = needsAccessibleName && label && !rest["aria-label"] ? label : void 0;
90
94
  const content = /* @__PURE__ */ jsxs(Fragment, { children: [
91
95
  leftIcon && renderIcon(leftIcon),
96
+ spinnerOverLabel && /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon ${baseClass}__spinner`, "aria-hidden": "true", children: spinner }),
92
97
  text && /* @__PURE__ */ jsx("span", { className: `${baseClass}__text`, children: label }),
93
98
  iconRight && renderIcon(iconRight, "right")
94
99
  ] });
@@ -106,6 +106,17 @@
106
106
  box-shadow: none;
107
107
  }
108
108
 
109
+ /* A case-study card with no href goes nowhere, so it does not lift or
110
+ offer a pointer; it keeps its full colour, unlike a placeholder. */
111
+ .ds-card--case-study--static {
112
+ cursor: default;
113
+ }
114
+
115
+ .ds-card--case-study--static:hover {
116
+ transform: none;
117
+ box-shadow: none;
118
+ }
119
+
109
120
  .ds-card--case-study__cover-wrap {
110
121
  width: 100%;
111
122
  aspect-ratio: 940 / 480;
@@ -15,7 +15,13 @@ type CardOwnProps = {
15
15
  interactive?: boolean;
16
16
  /** Additional CSS classes */
17
17
  className?: string;
18
- /** Navigation href — renders the card as an <a> tag */
18
+ /**
19
+ * Where the card goes. With it the card renders as a link in either
20
+ * variant, through `linkComponent`: the default variant becomes a link
21
+ * named by its title and wears the interactive lift, and the case-study
22
+ * variant links its whole tile. A case-study card without it, or one
23
+ * marked `placeholder`, is a still tile that does not lift.
24
+ */
19
25
  href?: string;
20
26
  /** Cover image src */
21
27
  coverSrc?: string;
@@ -47,8 +53,8 @@ export interface CardProps extends CardOwnProps, Omit<React.ComponentPropsWithou
47
53
  /**
48
54
  * Card renders a preview tile, or a case-study tile when `variant="case-study"`.
49
55
  *
50
- * Renders a `<div>`, or an `<a>` in the case-study variant when `href` is
51
- * supplied. Forwards a ref to whichever element it renders and spreads
56
+ * Renders a `<div>`, or a link in either variant when `href` is supplied.
57
+ * Forwards a ref to whichever element it renders and spreads
52
58
  * unrecognised props onto it.
53
59
  */
54
60
  export declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement | HTMLAnchorElement>>;
@@ -4,6 +4,7 @@ import React from "react";
4
4
  import { useLinkComponent } from "../../behaviors/LinkProvider.js";
5
5
  import "./Card.css";
6
6
  import "../../fonts/material-symbols.css";
7
+ import { LoadingImage } from "../../behaviors/LoadingImage.js";
7
8
  const Card = React.forwardRef(
8
9
  ({
9
10
  variant = "default",
@@ -28,7 +29,7 @@ const Card = React.forwardRef(
28
29
  if (variant === "case-study") {
29
30
  const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
30
31
  /* @__PURE__ */ jsx("div", { className: "ds-card--case-study__cover-wrap", children: cover ? /* @__PURE__ */ jsx("div", { className: "ds-card--case-study__cover-slot", children: cover }) : coverSrc ? /* @__PURE__ */ jsx(
31
- "img",
32
+ LoadingImage,
32
33
  {
33
34
  src: coverSrc,
34
35
  alt: coverAlt ?? `${title} cover`,
@@ -55,6 +56,8 @@ const Card = React.forwardRef(
55
56
  "ds-card",
56
57
  "ds-card--case-study",
57
58
  placeholder ? "ds-card--case-study--placeholder" : "",
59
+ // A card that goes nowhere stays still under the pointer.
60
+ !placeholder && !href ? "ds-card--case-study--static" : "",
58
61
  className
59
62
  ].filter(Boolean).join(" ");
60
63
  if (placeholder || !href) {
@@ -82,7 +85,23 @@ const Card = React.forwardRef(
82
85
  );
83
86
  }
84
87
  const baseClass = "ds-card";
85
- const classes = [baseClass, interactive ? `${baseClass}--interactive` : "", className].filter(Boolean).join(" ");
88
+ const classes = [baseClass, interactive || href ? `${baseClass}--interactive` : "", className].filter(Boolean).join(" ");
89
+ if (href) {
90
+ return /* @__PURE__ */ jsxs(
91
+ Link,
92
+ {
93
+ ...rest,
94
+ ref,
95
+ href,
96
+ className: classes,
97
+ onClick,
98
+ children: [
99
+ /* @__PURE__ */ jsx("div", { className: `${baseClass}__preview`, children }),
100
+ /* @__PURE__ */ jsx("h3", { className: `${baseClass}__title`, children: title })
101
+ ]
102
+ }
103
+ );
104
+ }
86
105
  const handleKeyDown = (e) => {
87
106
  onKeyDown?.(e);
88
107
  if (!interactive) return;
@@ -45,6 +45,13 @@ type AreaChartOwnProps = {
45
45
  * neither is on the plot. For a headline figure that follows the cursor.
46
46
  */
47
47
  onActiveChange?: ChartActiveHandler;
48
+ /**
49
+ * Holds the chart's placeholder, the outline of this chart type, in place of the chart while its data is still being fetched.
50
+ * Before its first draw the chart shows the same placeholder by itself, so this is only for a wait the host knows about.
51
+ */
52
+ loading?: boolean;
53
+ /** Accessible name announced while `loading`. */
54
+ loadingLabel?: string;
48
55
  /** Additional CSS classes on the wrapper */
49
56
  className?: string;
50
57
  };
@@ -5,6 +5,7 @@ import { ResponsiveContainer, AreaChart as AreaChart$1, CartesianGrid, XAxis, YA
5
5
  import { ActiveReporter } from "./ActiveReporter.js";
6
6
  import { readTokenPx, getChartSeriesColors } from "./palette.js";
7
7
  import { useChartAnimation } from "./useChartAnimation.js";
8
+ import { ChartSkeleton } from "./ChartSkeleton.js";
8
9
  import "./Chart.css";
9
10
  import { useLocale } from "../../behaviors/LocaleProvider.js";
10
11
  import { formatAxisNumber, formatNumber } from "../../behaviors/locale.js";
@@ -33,6 +34,8 @@ const AreaChart = React.forwardRef(({
33
34
  height = 350,
34
35
  showLegend = true,
35
36
  bare = false,
37
+ loading = false,
38
+ loadingLabel = "Loading chart",
36
39
  className = "",
37
40
  onActiveChange,
38
41
  yAxisFormatter,
@@ -81,51 +84,54 @@ const AreaChart = React.forwardRef(({
81
84
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
82
85
  ] }, i)) })
83
86
  ] }),
84
- /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(AreaChart$1, { data, margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
85
- /* @__PURE__ */ jsx("defs", { children: series.map((s, i) => {
86
- const color = s.color || seriesColors[i % seriesColors.length];
87
- return /* @__PURE__ */ jsxs("linearGradient", { id: `area-gradient-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
88
- /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0.4 }),
89
- /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 0.05 })
90
- ] }, `grad-${s.dataKey}`);
91
- }) }),
92
- /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: gridColor }),
93
- /* @__PURE__ */ jsx(
94
- XAxis,
95
- {
96
- dataKey: xKey,
97
- tick: { fill: textSecondary, fontSize: textSize },
98
- tickLine: false,
99
- axisLine: { stroke: gridColor }
100
- }
101
- ),
102
- /* @__PURE__ */ jsx(
103
- YAxis,
104
- {
105
- tickFormatter: yAxisFormatter ?? formatTick,
106
- tick: { fill: textSecondary, fontSize: textSize },
107
- tickLine: false,
108
- axisLine: false
109
- }
110
- ),
111
- /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
112
- series.map((s, i) => /* @__PURE__ */ jsx(
113
- Area,
114
- {
115
- ...animation,
116
- type: "monotone",
117
- dataKey: s.dataKey,
118
- name: s.label,
119
- stroke: s.color || seriesColors[i % seriesColors.length],
120
- strokeWidth: 2,
121
- fill: `url(#area-gradient-${s.dataKey})`,
122
- fillOpacity: s.fillOpacity ?? 1,
123
- stackId: stacked ? "stack" : void 0
124
- },
125
- s.dataKey
126
- )),
127
- showLegend && series.length > 1 && /* @__PURE__ */ jsx(Legend, { wrapperStyle: { color: textSecondary, fontSize: textSize } })
128
- ] }) }) })
87
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
88
+ /* @__PURE__ */ jsx(ChartSkeleton, { shape: "area", height, loading, loadingLabel }),
89
+ !loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(AreaChart$1, { data, margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
90
+ /* @__PURE__ */ jsx("defs", { children: series.map((s, i) => {
91
+ const color = s.color || seriesColors[i % seriesColors.length];
92
+ return /* @__PURE__ */ jsxs("linearGradient", { id: `area-gradient-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
93
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0.4 }),
94
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 0.05 })
95
+ ] }, `grad-${s.dataKey}`);
96
+ }) }),
97
+ /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: gridColor }),
98
+ /* @__PURE__ */ jsx(
99
+ XAxis,
100
+ {
101
+ dataKey: xKey,
102
+ tick: { fill: textSecondary, fontSize: textSize },
103
+ tickLine: false,
104
+ axisLine: { stroke: gridColor }
105
+ }
106
+ ),
107
+ /* @__PURE__ */ jsx(
108
+ YAxis,
109
+ {
110
+ tickFormatter: yAxisFormatter ?? formatTick,
111
+ tick: { fill: textSecondary, fontSize: textSize },
112
+ tickLine: false,
113
+ axisLine: false
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
117
+ series.map((s, i) => /* @__PURE__ */ jsx(
118
+ Area,
119
+ {
120
+ ...animation,
121
+ type: "monotone",
122
+ dataKey: s.dataKey,
123
+ name: s.label,
124
+ stroke: s.color || seriesColors[i % seriesColors.length],
125
+ strokeWidth: 2,
126
+ fill: `url(#area-gradient-${s.dataKey})`,
127
+ fillOpacity: s.fillOpacity ?? 1,
128
+ stackId: stacked ? "stack" : void 0
129
+ },
130
+ s.dataKey
131
+ )),
132
+ showLegend && series.length > 1 && /* @__PURE__ */ jsx(Legend, { wrapperStyle: { color: textSecondary, fontSize: textSize } })
133
+ ] }) })
134
+ ] })
129
135
  ]
130
136
  }
131
137
  );
@@ -46,6 +46,13 @@ type BarChartOwnProps = {
46
46
  * neither is on the plot. For a headline figure that follows the cursor.
47
47
  */
48
48
  onActiveChange?: ChartActiveHandler;
49
+ /**
50
+ * Holds the chart's placeholder, the outline of this chart type, in place of the chart while its data is still being fetched.
51
+ * Before its first draw the chart shows the same placeholder by itself, so this is only for a wait the host knows about.
52
+ */
53
+ loading?: boolean;
54
+ /** Accessible name announced while `loading`. */
55
+ loadingLabel?: string;
49
56
  /** Additional CSS classes on the wrapper */
50
57
  className?: string;
51
58
  };
@@ -3,6 +3,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
3
  import React, { useCallback, useId } from "react";
4
4
  import { ResponsiveContainer, BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Bar } from "recharts";
5
5
  import { useChartAnimation } from "./useChartAnimation.js";
6
+ import { ChartSkeleton } from "./ChartSkeleton.js";
6
7
  import "./Chart.css";
7
8
  import { ActiveReporter } from "./ActiveReporter.js";
8
9
  import { readTokenPx } from "./palette.js";
@@ -40,6 +41,8 @@ const BarChart = React.forwardRef(({
40
41
  barColor,
41
42
  height = 350,
42
43
  bare = false,
44
+ loading = false,
45
+ loadingLabel = "Loading chart",
43
46
  className = "",
44
47
  onActiveChange,
45
48
  yAxisFormatter,
@@ -89,52 +92,55 @@ const BarChart = React.forwardRef(({
89
92
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
90
93
  ] }, i)) })
91
94
  ] }),
92
- /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(BarChart$1, { data, margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
93
- /* @__PURE__ */ jsx(
94
- CartesianGrid,
95
- {
96
- vertical: false,
97
- stroke: gridColor,
98
- strokeDasharray: ""
99
- }
100
- ),
101
- /* @__PURE__ */ jsx(
102
- XAxis,
103
- {
104
- dataKey: xKey,
105
- tick: { fill: textSecondary, fontSize: textSize },
106
- tickLine: false,
107
- axisLine: { stroke: gridColor }
108
- }
109
- ),
110
- /* @__PURE__ */ jsx(
111
- YAxis,
112
- {
113
- tickFormatter: yAxisFormatter ?? formatTick,
114
- tick: { fill: textSecondary, fontSize: textSize },
115
- tickLine: false,
116
- axisLine: false
117
- }
118
- ),
119
- /* @__PURE__ */ jsx(
120
- Tooltip,
121
- {
122
- content: renderTooltip,
123
- cursor: { fill: cursorColor, opacity: 0.4 }
124
- }
125
- ),
126
- /* @__PURE__ */ jsx(
127
- Bar,
128
- {
129
- ...animation,
130
- className: `${baseClass}__bar`,
131
- dataKey: yKey,
132
- fill: resolvedBarColor,
133
- radius: [3, 3, 0, 0],
134
- maxBarSize: 32
135
- }
136
- )
137
- ] }) }) })
95
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
96
+ /* @__PURE__ */ jsx(ChartSkeleton, { shape: "bar", height, loading, loadingLabel }),
97
+ !loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(BarChart$1, { data, margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
98
+ /* @__PURE__ */ jsx(
99
+ CartesianGrid,
100
+ {
101
+ vertical: false,
102
+ stroke: gridColor,
103
+ strokeDasharray: ""
104
+ }
105
+ ),
106
+ /* @__PURE__ */ jsx(
107
+ XAxis,
108
+ {
109
+ dataKey: xKey,
110
+ tick: { fill: textSecondary, fontSize: textSize },
111
+ tickLine: false,
112
+ axisLine: { stroke: gridColor }
113
+ }
114
+ ),
115
+ /* @__PURE__ */ jsx(
116
+ YAxis,
117
+ {
118
+ tickFormatter: yAxisFormatter ?? formatTick,
119
+ tick: { fill: textSecondary, fontSize: textSize },
120
+ tickLine: false,
121
+ axisLine: false
122
+ }
123
+ ),
124
+ /* @__PURE__ */ jsx(
125
+ Tooltip,
126
+ {
127
+ content: renderTooltip,
128
+ cursor: { fill: cursorColor, opacity: 0.4 }
129
+ }
130
+ ),
131
+ /* @__PURE__ */ jsx(
132
+ Bar,
133
+ {
134
+ ...animation,
135
+ className: `${baseClass}__bar`,
136
+ dataKey: yKey,
137
+ fill: resolvedBarColor,
138
+ radius: [3, 3, 0, 0],
139
+ maxBarSize: 32
140
+ }
141
+ )
142
+ ] }) })
143
+ ] })
138
144
  ]
139
145
  }
140
146
  );
@@ -19,7 +19,9 @@
19
19
  width: 100%;
20
20
  padding: var(--padding-500); /* 24px */
21
21
  border: var(--border-025) solid var(--color-bg-container-border);
22
- border-radius: var(--radius-400); /* 16px */
22
+ /* The content-card corner, Panel's and Widget's, so a chart beside a
23
+ panel or a table reads as one family of surfaces. */
24
+ border-radius: var(--radius-600); /* 24px */
23
25
  background-color: var(--color-bg-container-primary);
24
26
  }
25
27
 
@@ -85,6 +87,21 @@
85
87
  color: var(--color-text-secondary);
86
88
  }
87
89
 
90
+ /* A summary figure keyed to a series: the tooltip's dot, in that series'
91
+ colour, ahead of the label. */
92
+ .ds-chart__summary-label:has(.ds-chart__summary-swatch) {
93
+ display: inline-flex;
94
+ align-items: center;
95
+ gap: var(--gap-100);
96
+ }
97
+
98
+ .ds-chart__summary-swatch {
99
+ width: 8px;
100
+ height: 8px;
101
+ border-radius: var(--radius-pill);
102
+ flex-shrink: 0;
103
+ }
104
+
88
105
  .ds-chart__summary-value {
89
106
  font-family: var(--font-heading-1-family);
90
107
  font-size: var(--font-heading-1-size);
@@ -110,6 +127,110 @@
110
127
  fill-opacity: 0.45;
111
128
  }
112
129
 
130
+ /* ============================================
131
+ SKELETON — the outline of the chart type,
132
+ drawn in the body until the marks exist.
133
+ recharts draws nothing before it has measured
134
+ its container in the browser, so the server
135
+ markup carries this instead of an empty box;
136
+ it leaves the moment recharts mounts its
137
+ wrapper. With `loading` it holds the body
138
+ (ChartSkeleton.tsx).
139
+ ============================================ */
140
+
141
+ .ds-chart__skeleton {
142
+ position: absolute;
143
+ inset: 0;
144
+ pointer-events: none;
145
+ }
146
+
147
+ .ds-chart__body:has(.recharts-wrapper) > .ds-chart__skeleton {
148
+ display: none;
149
+ }
150
+
151
+ /* While the host is loading there is no chart under it, so the placeholder
152
+ is in flow and its own height holds the body. */
153
+ .ds-chart__skeleton--held {
154
+ position: relative;
155
+ inset: auto;
156
+ }
157
+
158
+ /* A cartesian drawing sits where the plot will: clear of the value axis on
159
+ the left and the category axis underneath. */
160
+ .ds-chart__skeleton--plotted {
161
+ /* ds-allow(spacing): recharts' own axis metrics (a 60px value axis less the charts' -12px margin, a 30px category axis), which no token carries */
162
+ padding: var(--padding-200) var(--padding-100) 30px 48px; /* ds-allow(physical): recharts draws the value axis on the screen's left in either reading direction */
163
+ }
164
+
165
+ .ds-chart__skeleton-drawing {
166
+ display: block;
167
+ width: 100%;
168
+ height: 100%;
169
+ overflow: visible;
170
+ /* ds-allow(motion): the pulse needs a symmetric in-out curve and no
171
+ --motion-ease-* token provides one; the duration is tokenized. */
172
+ animation: ds-chart-skeleton-pulse var(--motion-duration-loop-shimmer) ease-in-out infinite alternate;
173
+ }
174
+
175
+ .ds-chart__skeleton-mark {
176
+ fill: var(--color-bg-container-secondary);
177
+ }
178
+
179
+ .ds-chart__skeleton-mark--soft {
180
+ opacity: 0.6;
181
+ }
182
+
183
+ /* Tiles and funnel bands are parted by a surface-coloured stroke, as the
184
+ real ones are. */
185
+ .ds-chart__skeleton-mark--tile {
186
+ stroke: var(--color-bg-container-primary);
187
+ stroke-width: 2px;
188
+ vector-effect: non-scaling-stroke;
189
+ }
190
+
191
+ .ds-chart__skeleton-grid {
192
+ fill: none;
193
+ stroke: var(--color-divider);
194
+ stroke-width: 1px;
195
+ vector-effect: non-scaling-stroke;
196
+ }
197
+
198
+ .ds-chart__skeleton-line,
199
+ .ds-chart__skeleton-dots,
200
+ .ds-chart__skeleton-ring {
201
+ fill: none;
202
+ stroke: var(--color-bg-container-secondary);
203
+ }
204
+
205
+ /* A thin mark is too little ink to read in the Skeleton fill, so lines and
206
+ dots take the next container step. */
207
+ .ds-chart__skeleton-line,
208
+ .ds-chart__skeleton-dots {
209
+ stroke: var(--color-bg-container-tertiary);
210
+ }
211
+
212
+ .ds-chart__skeleton-line {
213
+ stroke-width: 3px;
214
+ stroke-linecap: round;
215
+ stroke-linejoin: round;
216
+ vector-effect: non-scaling-stroke;
217
+ }
218
+
219
+ .ds-chart__skeleton-dots {
220
+ stroke-width: 10px;
221
+ stroke-linecap: round;
222
+ vector-effect: non-scaling-stroke;
223
+ }
224
+
225
+ @keyframes ds-chart-skeleton-pulse {
226
+ from {
227
+ opacity: 1;
228
+ }
229
+ to {
230
+ opacity: 0.5;
231
+ }
232
+ }
233
+
113
234
  /* ============================================
114
235
  BARE MODE — the chart sits inside another
115
236
  panel that supplies the surface, so its own
@@ -0,0 +1,32 @@
1
+ import { default as React } from 'react';
2
+ /** The drawing a chart's placeholder takes: one per chart type. */
3
+ export type ChartSkeletonShape = 'area' | 'bar' | 'combo' | 'funnel' | 'line' | 'pie' | 'radar' | 'radial' | 'scatter' | 'stacked-bar' | 'treemap';
4
+ interface ChartSkeletonProps {
5
+ /** Which chart's outline to draw. */
6
+ shape: ChartSkeletonShape;
7
+ /** The chart area's height in pixels, the box the placeholder holds while the chart is loading. */
8
+ height: number;
9
+ /** True while the host is still fetching: the placeholder holds the body and is announced. */
10
+ loading: boolean;
11
+ /** The accessible name announced while `loading`. */
12
+ loadingLabel: string;
13
+ /** The inner radius of a pie's hole, in viewBox units out of 50; 0 draws a full disc. */
14
+ hole?: number;
15
+ }
16
+ /**
17
+ * The placeholder a chart draws in its body until its marks exist: the
18
+ * outline of that chart type, in the Skeleton fill, pulsing.
19
+ *
20
+ * It covers two waits. recharts draws nothing until its container has been
21
+ * measured in the browser, so server markup, and every frame before
22
+ * hydration, would otherwise be an empty box: the placeholder is in that
23
+ * markup, and Chart.css hides it the moment recharts mounts its wrapper,
24
+ * with no state and no re-render. And while a host is still fetching, the
25
+ * chart's `loading` prop holds the placeholder in place of the chart and
26
+ * announces it.
27
+ *
28
+ * Internal to the chart family (a row of INTERNAL_PARTS): the charts are the
29
+ * public surface, through `loading` and `loadingLabel`.
30
+ */
31
+ export declare function ChartSkeleton({ shape, height, loading, loadingLabel, hole }: ChartSkeletonProps): React.JSX.Element;
32
+ export {};