@sybilion/uilib 1.3.98 → 1.3.100

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 (61) hide show
  1. package/dist/esm/components/ui/AnalysesSelector/AnalysesSelector.js +61 -14
  2. package/dist/esm/components/ui/AnalysesSelector/AnalysesSelector.styl.js +2 -2
  3. package/dist/esm/components/ui/AnalysesSelector/SelectInlineRenamer.js +102 -0
  4. package/dist/esm/components/ui/Button/Button.styl.js +1 -1
  5. package/dist/esm/components/ui/Chart/Chart.js +9 -5
  6. package/dist/esm/components/ui/Chart/chartForecastVisualization.constants.js +23 -0
  7. package/dist/esm/components/ui/Chart/components/BaseChartWrapper.js +12 -10
  8. package/dist/esm/components/ui/Chart/components/BaseChartWrapper.styl.js +2 -2
  9. package/dist/esm/components/ui/Chart/components/ConfidenceBands.js +9 -0
  10. package/dist/esm/components/ui/Chart/components/CustomChartLegend/CustomChartLegend.js +2 -2
  11. package/dist/esm/components/ui/Chart/components/ForecastBoundaries.js +32 -0
  12. package/dist/esm/components/ui/Chart/components/ForecastLine.js +24 -0
  13. package/dist/esm/components/ui/Chart/components/HistoricalLine.js +24 -0
  14. package/dist/esm/components/ui/Chart/hooks/useChartAnimation.js +17 -0
  15. package/dist/esm/components/ui/Chart/hooks/useChartColors.js +12 -0
  16. package/dist/esm/components/ui/Chart/hooks/useLegendState.js +30 -0
  17. package/dist/esm/components/ui/Chart/tools/formatters.js +19 -3
  18. package/dist/esm/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.js +1 -10
  19. package/dist/esm/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.js +19 -7
  20. package/dist/esm/components/ui/Select/Select.js +3 -3
  21. package/dist/esm/components/widgets/DriverCard/DriverCard.js +6 -6
  22. package/dist/esm/components/widgets/DriverCard/DriverPerformanceChart.js +9 -5
  23. package/dist/esm/components/widgets/DriversComparisonChart/DriversComparisonChart.styl.js +1 -1
  24. package/dist/esm/components/widgets/PerformanceChart/PerformanceChart.styl.js +1 -1
  25. package/dist/esm/index.js +10 -1
  26. package/dist/esm/types/src/components/ui/AnalysesSelector/AnalysesSelector.d.ts +1 -1
  27. package/dist/esm/types/src/components/ui/AnalysesSelector/AnalysesSelector.types.d.ts +7 -1
  28. package/dist/esm/types/src/components/ui/AnalysesSelector/SelectInlineRenamer.d.ts +12 -0
  29. package/dist/esm/types/src/components/ui/Chart/Chart.d.ts +11 -2
  30. package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.d.ts +7 -1
  31. package/dist/esm/types/src/components/ui/Chart/components/index.d.ts +1 -1
  32. package/dist/esm/types/src/components/ui/Chart/tools/formatters.d.ts +3 -1
  33. package/dist/esm/types/src/components/ui/ChartAreaInteractive/index.d.ts +1 -1
  34. package/dist/esm/types/src/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.d.ts +1 -1
  35. package/dist/esm/types/src/components/ui/Select/Select.d.ts +1 -1
  36. package/dist/esm/types/src/components/ui/Select/Select.types.d.ts +1 -0
  37. package/dist/esm/types/src/components/ui/SmartTextTruncate/SmartTextTruncate.types.d.ts +1 -3
  38. package/package.json +1 -1
  39. package/src/components/ui/AnalysesSelector/AnalysesSelector.styl +62 -1
  40. package/src/components/ui/AnalysesSelector/AnalysesSelector.styl.d.ts +8 -0
  41. package/src/components/ui/AnalysesSelector/AnalysesSelector.tsx +136 -27
  42. package/src/components/ui/AnalysesSelector/AnalysesSelector.types.ts +7 -2
  43. package/src/components/ui/AnalysesSelector/SelectInlineRenamer.tsx +191 -0
  44. package/src/components/ui/Button/Button.styl +5 -8
  45. package/src/components/ui/Chart/Chart.tsx +21 -1
  46. package/src/components/ui/Chart/components/BaseChartWrapper.styl +9 -0
  47. package/src/components/ui/Chart/components/BaseChartWrapper.styl.d.ts +2 -0
  48. package/src/components/ui/Chart/components/BaseChartWrapper.tsx +62 -14
  49. package/src/components/ui/Chart/components/CustomChartLegend/CustomChartLegend.tsx +2 -3
  50. package/src/components/ui/Chart/components/index.ts +5 -1
  51. package/src/components/ui/Chart/tools/formatters.ts +20 -2
  52. package/src/components/ui/ChartAreaInteractive/index.ts +15 -1
  53. package/src/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.test.tsx +17 -0
  54. package/src/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.tsx +23 -7
  55. package/src/components/ui/Select/Select.tsx +13 -5
  56. package/src/components/ui/Select/Select.types.ts +1 -0
  57. package/src/components/ui/SmartTextTruncate/SmartTextTruncate.types.ts +1 -3
  58. package/src/components/widgets/DriverCard/DriverCard.tsx +7 -8
  59. package/src/components/widgets/DriversComparisonChart/DriversComparisonChart.styl +0 -1
  60. package/src/components/widgets/PerformanceChart/PerformanceChart.styl +1 -1
  61. package/src/docs/components/DocsSidebar/DocsSidebar.tsx +7 -2
@@ -1,8 +1,16 @@
1
- import type {
2
- AnalysesSelectorItem,
3
- AnalysesSelectorProps,
4
- } from './AnalysesSelector.types';
5
- import { EyeClosedIcon, EyeIcon } from '@phosphor-icons/react';
1
+ import cn from 'classnames';
2
+ import {
3
+ type KeyboardEvent,
4
+ useEffect,
5
+ useMemo,
6
+ useRef,
7
+ useState,
8
+ } from 'react';
9
+
10
+ import { AnalysisLineIcon } from '#uilib/components/ui/AnalysisLineIcon';
11
+ import { Badge } from '#uilib/components/ui/Badge';
12
+ import { Button } from '#uilib/components/ui/Button';
13
+ import { LabelWithId } from '#uilib/components/ui/LabelWithId';
6
14
  import {
7
15
  Select,
8
16
  SelectContent,
@@ -10,16 +18,16 @@ import {
10
18
  SelectTrigger,
11
19
  SelectValue,
12
20
  } from '#uilib/components/ui/Select';
13
- import { useEffect, useMemo, useRef } from 'react';
14
-
15
- import { AnalysisLineIcon } from '#uilib/components/ui/AnalysisLineIcon';
16
- import { Badge } from '#uilib/components/ui/Badge';
17
- import { Button } from '#uilib/components/ui/Button';
18
- import { LabelWithId } from '#uilib/components/ui/LabelWithId';
19
- import S from './AnalysesSelector.styl';
20
21
  import { TextShimmer } from '#uilib/components/ui/TextShimmer/TextShimmer';
21
- import cn from 'classnames';
22
22
  import { getLatestByUpdatedAt } from '#uilib/utils/analysisDate';
23
+ import { EyeClosedIcon, EyeIcon } from '@phosphor-icons/react';
24
+
25
+ import S from './AnalysesSelector.styl';
26
+ import type {
27
+ AnalysesSelectorItem,
28
+ AnalysesSelectorProps,
29
+ } from './AnalysesSelector.types';
30
+ import { SelectInlineRenamer } from './SelectInlineRenamer';
23
31
 
24
32
  const isFailed = (item: AnalysesSelectorItem) =>
25
33
  item.status?.toLowerCase() === 'fail';
@@ -29,12 +37,25 @@ const isDashedIcon = (item: AnalysesSelectorItem) => item.id !== -1;
29
37
  const defaultIsAnalysisInProgress = (status?: string) =>
30
38
  ['pending', 'running', 'cancelling'].includes(status?.toLowerCase() ?? '');
31
39
 
40
+ const shouldBlockSelectKeydownWhileRenaming = (e: KeyboardEvent) => {
41
+ if (!(e.target instanceof HTMLInputElement)) {
42
+ return true;
43
+ }
44
+
45
+ return (
46
+ e.key === 'ArrowUp' ||
47
+ e.key === 'ArrowDown' ||
48
+ e.key === ' ' ||
49
+ e.key === 'Enter'
50
+ );
51
+ };
52
+
32
53
  function renderItemContent(item: AnalysesSelectorItem) {
33
54
  const failed = isFailed(item);
34
55
 
35
56
  if (failed) {
36
57
  return (
37
- <Badge variant="red" squared>
58
+ <Badge variant="red" className={S.itemBadge}>
38
59
  failed
39
60
  </Badge>
40
61
  );
@@ -91,6 +112,7 @@ export function AnalysesSelector({
91
112
  hiddenSeries: hiddenSeriesProp = new Set(),
92
113
  onToggleSeries = () => {},
93
114
  isAnalysisInProgress: isAnalysisInProgressProp = defaultIsAnalysisInProgress,
115
+ rename,
94
116
  }: AnalysesSelectorProps) {
95
117
  const historicalAutoSelectedRef = useRef(false);
96
118
  const hiddenSeries = hiddenSeriesProp;
@@ -215,6 +237,22 @@ export function AnalysesSelector({
215
237
  }
216
238
  }, [showHistorical, selectedIds, onItemToggle]);
217
239
 
240
+ const selectedItem = items.find(item => selectedSet.has(item.id)) ?? items[0];
241
+ const selectedId = selectedItem?.id;
242
+
243
+ const [isRenaming, setIsRenaming] = useState(false);
244
+ const [selectOpen, setSelectOpen] = useState(false);
245
+
246
+ useEffect(() => {
247
+ setIsRenaming(false);
248
+ }, [selectedId, rename?.value]);
249
+
250
+ useEffect(() => {
251
+ if (isRenaming) {
252
+ setSelectOpen(false);
253
+ }
254
+ }, [isRenaming]);
255
+
218
256
  const handleSelectValue = (value: string) => {
219
257
  if (!value) return;
220
258
  const id = /^-?\d+$/.test(value) ? parseInt(value, 10) : value;
@@ -337,9 +375,48 @@ export function AnalysesSelector({
337
375
 
338
376
  if (items.length === 0) return null;
339
377
 
340
- const selectedId =
341
- items.find(item => selectedSet.has(item.id))?.id ?? items[0]?.id;
342
378
  const selectValue = selectedId != null ? String(selectedId) : '';
379
+ const showRenamer =
380
+ rename && selectedItem && rename.renameableItemIds.has(selectedItem.id);
381
+ const singleItemSelect = items.length < 2;
382
+
383
+ const { className: triggerClassName, ...restTriggerProps } =
384
+ triggerProps ?? {};
385
+
386
+ const triggerStyle = {
387
+ minWidth: 'auto',
388
+ height: 'auto',
389
+ fontSize: 'var(--text-xs)',
390
+ pointerEvents:
391
+ singleItemSelect && !showRenamer ? ('none' as const) : undefined,
392
+ };
393
+
394
+ const triggerClassNameMerged = cn(
395
+ S.selectTrigger,
396
+ isRenaming && S.selectTriggerRenaming,
397
+ triggerClassName,
398
+ );
399
+
400
+ const renamerTriggerContent = showRenamer ? (
401
+ <div
402
+ className={cn(
403
+ S.selectTriggerContent,
404
+ disabled && S.selectTriggerRenamerDisabled,
405
+ )}
406
+ >
407
+ {renderItemContent(selectedItem)}
408
+ {renderIcon(selectedItem.icon)}
409
+ <SelectInlineRenamer
410
+ value={rename.value}
411
+ displayLabel={selectedItem.label}
412
+ onChange={rename.onChange}
413
+ disabled={disabled}
414
+ className={S.selectTriggerRenamer}
415
+ isRenaming={isRenaming}
416
+ onEnterRenaming={() => setIsRenaming(prev => !prev)}
417
+ />
418
+ </div>
419
+ ) : null;
343
420
 
344
421
  return (
345
422
  <div className={cn(S.root, className)}>
@@ -347,29 +424,61 @@ export function AnalysesSelector({
347
424
  value={selectValue}
348
425
  onValueChange={handleSelectValue}
349
426
  disabled={disabled}
427
+ open={isRenaming || singleItemSelect ? false : selectOpen}
428
+ onOpenChange={open => {
429
+ if (!isRenaming && !singleItemSelect) {
430
+ setSelectOpen(open);
431
+ }
432
+ }}
350
433
  >
351
434
  <SelectTrigger
435
+ asChild={showRenamer}
352
436
  size={size}
353
437
  variant={variant}
354
438
  darker={darker}
355
- className={S.selectTrigger}
356
- hideChevron={items.length < 2}
357
- style={{
358
- minWidth: 'auto',
359
- height: 'auto',
360
- fontSize: 'var(--text-xs)',
361
- pointerEvents: items.length < 2 ? 'none' : undefined,
362
- }}
363
- {...triggerProps}
439
+ hideChevron={singleItemSelect}
440
+ {...restTriggerProps}
441
+ {...(showRenamer
442
+ ? {}
443
+ : {
444
+ style: triggerStyle,
445
+ className: triggerClassNameMerged,
446
+ onKeyDown: (e: KeyboardEvent) => {
447
+ if (isRenaming && shouldBlockSelectKeydownWhileRenaming(e)) {
448
+ e.preventDefault();
449
+ e.stopPropagation();
450
+ }
451
+ },
452
+ })}
364
453
  >
365
- <SelectValue placeholder={selectPlaceholder} />
454
+ {showRenamer ? (
455
+ <div
456
+ className={triggerClassNameMerged}
457
+ style={triggerStyle}
458
+ onKeyDown={e => {
459
+ if (isRenaming && shouldBlockSelectKeydownWhileRenaming(e)) {
460
+ e.preventDefault();
461
+ e.stopPropagation();
462
+ }
463
+ }}
464
+ >
465
+ {renamerTriggerContent}
466
+ </div>
467
+ ) : (
468
+ <LabelWithId
469
+ className={S.selectTriggerLabelWithId}
470
+ id={selectValue}
471
+ label={<SelectValue placeholder={selectPlaceholder} />}
472
+ />
473
+ )}
366
474
  </SelectTrigger>
367
475
  <SelectContent>
368
476
  {items.map(item => (
369
477
  <SelectItem
370
478
  key={item.id}
371
479
  value={String(item.id)}
372
- selected={String(item.id) === selectValue}
480
+ selected={selectedSet.has(item.id)}
481
+ textValue={item.label}
373
482
  >
374
483
  {renderSelectItem(item)}
375
484
  </SelectItem>
@@ -1,5 +1,4 @@
1
1
  import { ReactNode } from 'react';
2
-
3
2
  import { SelectTriggerProps } from '#uilib/components/ui/Select/Select.types';
4
3
 
5
4
  export interface AnalysesSelectorItem {
@@ -19,7 +18,7 @@ export interface AnalysesSelectorProps {
19
18
  inlineMode?: boolean;
20
19
  placeholder?: string;
21
20
  disabled?: boolean;
22
- size?: 'sm' | 'md' | 'lg';
21
+ size?: SelectTriggerProps['size'];
23
22
  variant?: 'default' | 'clear';
24
23
  darker?: boolean;
25
24
  className?: string;
@@ -38,4 +37,10 @@ export interface AnalysesSelectorProps {
38
37
  onToggleSeries?: (analysisId: number | string) => void;
39
38
  /** Override default pending/running/cancelling detection for labels. */
40
39
  isAnalysisInProgress?: (status?: string) => boolean;
40
+ rename?: {
41
+ value: string;
42
+ onChange: (value: string) => void | Promise<void>;
43
+ /** Only show Renamer when selected item id is in this set */
44
+ renameableItemIds: Set<number>;
45
+ };
41
46
  }
@@ -0,0 +1,191 @@
1
+ import cn from 'classnames';
2
+ import { useCallback, useEffect, useState } from 'react';
3
+
4
+ import { Button } from '#uilib/components/ui/Button';
5
+ import { Input } from '#uilib/components/ui/Input';
6
+ import { TextShimmer } from '#uilib/components/ui/TextShimmer/TextShimmer';
7
+ import {
8
+ Tooltip,
9
+ TooltipContent,
10
+ TooltipTrigger,
11
+ } from '#uilib/components/ui/Tooltip';
12
+ import { PencilSimpleIcon } from '@phosphor-icons/react';
13
+
14
+ import S from './AnalysesSelector.styl';
15
+
16
+ const LABEL_MAX = 64;
17
+ const MANUALLY_ADJUSTED_NAME = 'Manually adjusted';
18
+ const MANUALLY_ADJUSTED_RENAME_MAX =
19
+ LABEL_MAX - MANUALLY_ADJUSTED_NAME.length;
20
+
21
+ type SelectInlineRenamerProps = {
22
+ value: string;
23
+ /** Shown in trigger when not editing; defaults to `value`. */
24
+ displayLabel?: string;
25
+ onChange: (value: string) => void | Promise<void>;
26
+ disabled?: boolean;
27
+ className?: string;
28
+ isRenaming: boolean;
29
+ onEnterRenaming: () => void;
30
+ };
31
+
32
+ const stopSelectBubble = (e: React.SyntheticEvent) => {
33
+ e.stopPropagation();
34
+ };
35
+
36
+ const stopSelectOpen = (e: React.SyntheticEvent) => {
37
+ e.preventDefault();
38
+ e.stopPropagation();
39
+ };
40
+
41
+ const stopRenamerKeyboardBubble = (e: React.KeyboardEvent) => {
42
+ e.stopPropagation();
43
+ e.nativeEvent.stopImmediatePropagation();
44
+ };
45
+
46
+ export function SelectInlineRenamer({
47
+ value,
48
+ displayLabel,
49
+ onChange,
50
+ onEnterRenaming,
51
+ disabled,
52
+ className,
53
+ isRenaming,
54
+ }: SelectInlineRenamerProps) {
55
+ const [draft, setDraft] = useState(value);
56
+ const [isSaving, setIsSaving] = useState(false);
57
+
58
+ useEffect(() => {
59
+ if (!isSaving) {
60
+ setDraft(value);
61
+ }
62
+ }, [value, isSaving]);
63
+
64
+ const exitRenaming = useCallback(() => {
65
+ if (isRenaming) {
66
+ onEnterRenaming();
67
+ }
68
+ }, [isRenaming, onEnterRenaming]);
69
+
70
+ const persistRename = useCallback(
71
+ async (trimmed: string) => {
72
+ setIsSaving(true);
73
+ setDraft(trimmed);
74
+ exitRenaming();
75
+ try {
76
+ await onChange(trimmed);
77
+ } catch {
78
+ setDraft(value);
79
+ } finally {
80
+ setIsSaving(false);
81
+ }
82
+ },
83
+ [exitRenaming, onChange, value],
84
+ );
85
+
86
+ const commit = useCallback(() => {
87
+ const trimmed = draft.trim();
88
+ if (trimmed && trimmed !== value) {
89
+ void persistRename(trimmed);
90
+ return;
91
+ }
92
+ exitRenaming();
93
+ setDraft(value);
94
+ }, [draft, exitRenaming, persistRename, value]);
95
+
96
+ const cancel = useCallback(() => {
97
+ exitRenaming();
98
+ setDraft(value);
99
+ }, [exitRenaming, value]);
100
+
101
+ const onKeyDown = useCallback(
102
+ (e: React.KeyboardEvent<HTMLInputElement>) => {
103
+ stopRenamerKeyboardBubble(e);
104
+
105
+ if (e.key === 'Enter' && draft.trim()) {
106
+ e.preventDefault();
107
+ const trimmed = draft.trim();
108
+ if (trimmed !== value) {
109
+ void persistRename(trimmed);
110
+ return;
111
+ }
112
+ exitRenaming();
113
+ setDraft(trimmed);
114
+ }
115
+
116
+ if (e.key === 'Escape') {
117
+ e.preventDefault();
118
+ cancel();
119
+ }
120
+ },
121
+ [cancel, draft, exitRenaming, persistRename, value],
122
+ );
123
+
124
+ const onKeyUp = useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
125
+ if (e.key !== ' ') return;
126
+
127
+ e.preventDefault();
128
+ e.stopPropagation();
129
+ }, []);
130
+
131
+ const onDraftChange = useCallback(
132
+ (e: React.ChangeEvent<HTMLInputElement>) => {
133
+ setDraft(e.target.value.slice(0, MANUALLY_ADJUSTED_RENAME_MAX));
134
+ },
135
+ [],
136
+ );
137
+
138
+ if (isRenaming) {
139
+ return (
140
+ <Input
141
+ className={cn(S.selectInlineRenamerInput, className)}
142
+ autoFocus
143
+ variant="clean"
144
+ size="sm"
145
+ value={draft}
146
+ maxLength={MANUALLY_ADJUSTED_RENAME_MAX}
147
+ onChange={onDraftChange}
148
+ onBlur={commit}
149
+ onKeyDown={onKeyDown}
150
+ onKeyUp={onKeyUp}
151
+ onPointerDown={stopSelectBubble}
152
+ onClick={stopSelectBubble}
153
+ />
154
+ );
155
+ }
156
+
157
+ const triggerLabel = isSaving ? draft : (displayLabel ?? value);
158
+
159
+ return (
160
+ <div className={cn(S.selectInlineRenamer, className)}>
161
+ {isSaving ? (
162
+ <TextShimmer as="span" className={S.label}>
163
+ {triggerLabel}
164
+ </TextShimmer>
165
+ ) : (
166
+ <span className={S.label}>{triggerLabel}</span>
167
+ )}
168
+ {!disabled && !isSaving && (
169
+ <Tooltip>
170
+ <TooltipTrigger asChild>
171
+ <Button
172
+ variant="ghost"
173
+ size="sm"
174
+ type="button"
175
+ className={S.renamerEditButton}
176
+ onPointerDown={stopSelectOpen}
177
+ onClick={e => {
178
+ e.stopPropagation();
179
+ setDraft(value);
180
+ onEnterRenaming();
181
+ }}
182
+ >
183
+ <PencilSimpleIcon size={16} />
184
+ </Button>
185
+ </TooltipTrigger>
186
+ <TooltipContent side="bottom">Rename</TooltipContent>
187
+ </Tooltip>
188
+ )}
189
+ </div>
190
+ );
191
+ }
@@ -44,19 +44,16 @@
44
44
  background-color var(--sb-gray-800)
45
45
 
46
46
  .destructive
47
- background-color var(--destructive)
47
+ background-color var(--destructive-900)
48
48
  color white
49
49
 
50
50
  &:hover
51
- background-color var(--destructive-900)
51
+ background-color var(--destructive-600)
52
52
 
53
53
  &:focus-visible
54
- ring 3px var(--destructive-200)
55
-
56
- :global(.dark) &
57
- background-color var(--destructive-600)
54
+ ring 3px var(--destructive-200)
58
55
 
59
- &:focus-visible
56
+ :global(.dark) &
60
57
  ring 3px var(--destructive-400)
61
58
 
62
59
  .outline
@@ -107,7 +104,7 @@
107
104
 
108
105
  .sizeMd
109
106
  height 44px
110
- padding var(--p-3) var(--p-4)
107
+ padding 0 var(--p-4)
111
108
  border-radius var(--p-4)
112
109
 
113
110
  .sizeLg
@@ -1,6 +1,9 @@
1
1
  import * as RechartsPrimitive from 'recharts';
2
2
 
3
- import { BaseChartWrapper } from './components/BaseChartWrapper';
3
+ import {
4
+ BaseChartWrapper,
5
+ type BaseChartWrapperProps,
6
+ } from './components/BaseChartWrapper';
4
7
  import { ChartContainer, ChartStyle } from './components/ChartContainer';
5
8
  import { ChartLegendContent } from './components/ChartLegendContent';
6
9
  import { ChartTooltipContent } from './components/ChartTooltipContent';
@@ -20,6 +23,7 @@ export {
20
23
  ChartLegendContent,
21
24
  ChartStyle,
22
25
  BaseChartWrapper,
26
+ type BaseChartWrapperProps,
23
27
  };
24
28
  export {
25
29
  LightweightForecastChart,
@@ -30,3 +34,19 @@ export {
30
34
  type ChartEmptyStateProps,
31
35
  type ChartEmptyStatusTone,
32
36
  } from './components/ChartEmptyState/ChartEmptyState';
37
+ export { ConfidenceBands } from './components/ConfidenceBands';
38
+ export { ForecastBoundaries } from './components/ForecastBoundaries';
39
+ export { ForecastLine } from './components/ForecastLine';
40
+ export { HistoricalLine } from './components/HistoricalLine';
41
+ export {
42
+ DEFAULT_QUANTILE_BAND_COLOR,
43
+ QuantileBands,
44
+ } from './components/QuantileBands';
45
+ export {
46
+ formatCompactAxisNumber,
47
+ formatDate,
48
+ formatNumber,
49
+ } from './tools/formatters';
50
+ export { useChartAnimation } from './hooks/useChartAnimation';
51
+ export { useChartColors } from './hooks/useChartColors';
52
+ export { useLegendState } from './hooks/useLegendState';
@@ -62,6 +62,11 @@
62
62
  align-items center
63
63
  justify-content center
64
64
 
65
+ .loadingChartSlot
66
+ position relative
67
+ width 100%
68
+ height 100%
69
+
65
70
  .loadingOverlay
66
71
  position absolute
67
72
  inset 0
@@ -86,6 +91,10 @@
86
91
  min-height 250px
87
92
  color var(--destructive)
88
93
 
94
+ .emptyChartSizer
95
+ width 100%
96
+ min-height var(--chart-height)
97
+
89
98
  .errorMessage
90
99
  color var(--destructive)
91
100
 
@@ -4,6 +4,7 @@ interface CssExports {
4
4
  'chartContainer': string;
5
5
  'chartLayer': string;
6
6
  'chartLoadingContainer': string;
7
+ 'emptyChartSizer': string;
7
8
  'errorContainer': string;
8
9
  'errorMessage': string;
9
10
  'footer': string;
@@ -12,6 +13,7 @@ interface CssExports {
12
13
  'invisibleAxis': string;
13
14
  'legend': string;
14
15
  'loaded': string;
16
+ 'loadingChartSlot': string;
15
17
  'loadingOverlay': string;
16
18
  'noLegend': string;
17
19
  'noLineDrawAnimation': string;
@@ -28,6 +28,10 @@ import { formatDate } from '../tools/formatters';
28
28
  import S from './BaseChartWrapper.styl';
29
29
  import { ChartAxes } from './ChartAxes';
30
30
  import { ChartContainer } from './ChartContainer';
31
+ import {
32
+ ChartEmptyState,
33
+ type ChartEmptyStatusTone,
34
+ } from './ChartEmptyState/ChartEmptyState';
31
35
  import { ChartGrid } from './ChartGrid';
32
36
  import { ChartTooltipContent } from './ChartTooltipContent';
33
37
  import { CustomChartLegend } from './CustomChartLegend/CustomChartLegend';
@@ -138,7 +142,12 @@ export interface BaseChartWrapperProps {
138
142
  >;
139
143
  error?: string | null;
140
144
  loadingMessage?: ReactNode;
141
- noDataMessage?: string;
145
+ /** Shown above `noDataMessage` when the chart has no series (muted). */
146
+ noDataHint?: ReactNode;
147
+ noDataMessage?: ReactNode;
148
+ noDataStatusTone?: ChartEmptyStatusTone;
149
+ /** When true, no placeholder UI for empty `chartData` (parent renders overlay). */
150
+ suppressNoDataState?: boolean;
142
151
  onGridHeightChange?: (height: number) => void;
143
152
  forecastLineStyle?: 'dashed' | 'solid';
144
153
  disableHistoricalAnimation?: boolean;
@@ -156,21 +165,24 @@ const BaseChartWrapperLoading = forwardRef<
156
165
  HTMLDivElement,
157
166
  {
158
167
  className?: string;
168
+ loadingComponentClassName?: string;
159
169
  height?: number;
160
170
  loadingMessage?: ReactNode;
161
171
  }
162
- >(({ className, height, loadingMessage }, ref) => {
172
+ >(({ className, loadingComponentClassName, height, loadingMessage }, ref) => {
163
173
  return (
164
174
  <div ref={ref} className={cn(S.root, className)}>
165
175
  <div
166
176
  className={S.chartLoadingContainer}
167
177
  style={height ? { height: `${height}px` } : undefined}
168
178
  >
169
- {loadingMessage || (
170
- <div className={S.loadingOverlay}>
171
- <Skeleton style={{ width: '100%', height: '100%' }} />
172
- </div>
173
- )}
179
+ <div data-slot="chart" className={S.loadingChartSlot}>
180
+ {loadingMessage || (
181
+ <div className={cn(S.loadingOverlay, loadingComponentClassName)}>
182
+ <Skeleton style={{ width: '100%', height: '100%' }} />
183
+ </div>
184
+ )}
185
+ </div>
174
186
  </div>
175
187
  </div>
176
188
  );
@@ -235,7 +247,10 @@ const BaseChartWrapperContent = forwardRef<
235
247
  containerProps,
236
248
  error,
237
249
  loadingMessage,
250
+ noDataHint,
238
251
  noDataMessage = 'No data available',
252
+ noDataStatusTone = 'muted',
253
+ suppressNoDataState = false,
239
254
  onGridHeightChange,
240
255
  forecastLineStyle = 'dashed',
241
256
  disableHistoricalAnimation = false,
@@ -547,17 +562,48 @@ const BaseChartWrapperContent = forwardRef<
547
562
  if (!chartData.length) {
548
563
  // If hasCombinedData is true but chartData is empty, data is being processed - wait instead of showing "No data"
549
564
  if (hasCombinedData) {
550
- // Return empty div to wait for chartData to be populated
551
- return <div className={cn(S.root, className)}></div>;
565
+ return (
566
+ <div className={cn(S.root, className)}>
567
+ <div
568
+ className={S.emptyChartSizer}
569
+ style={height ? { minHeight: height } : undefined}
570
+ aria-hidden
571
+ />
572
+ </div>
573
+ );
552
574
  }
553
575
  // If renderId is undefined/null, we're still initializing - wait instead of showing "No data"
554
576
  if (!renderId) {
555
- // Return empty div to wait for initialization to complete
556
- return <div className={cn(S.root, className)}></div>;
577
+ return (
578
+ <div className={cn(S.root, className)}>
579
+ <div
580
+ className={S.emptyChartSizer}
581
+ style={height ? { minHeight: height } : undefined}
582
+ aria-hidden
583
+ />
584
+ </div>
585
+ );
586
+ }
587
+ if (suppressNoDataState) {
588
+ return (
589
+ <div className={cn(S.root, className)}>
590
+ <div
591
+ className={S.emptyChartSizer}
592
+ style={height ? { minHeight: height } : undefined}
593
+ aria-hidden
594
+ />
595
+ </div>
596
+ );
557
597
  }
558
598
  return (
559
599
  <div className={cn(S.root, className)}>
560
- <div className={S.errorContainer}>{noDataMessage}</div>
600
+ <ChartEmptyState
601
+ variant="panel"
602
+ align="center"
603
+ hint={noDataHint}
604
+ status={noDataMessage}
605
+ statusTone={noDataStatusTone}
606
+ />
561
607
  </div>
562
608
  );
563
609
  }
@@ -837,7 +883,8 @@ export function BaseChartWrapper(props: BaseChartWrapperProps) {
837
883
  return (
838
884
  <BaseChartWrapperLoading
839
885
  ref={containerRef}
840
- className={cn(props.className, props.loadingComponentClassName)}
886
+ className={props.className}
887
+ loadingComponentClassName={props.loadingComponentClassName}
841
888
  height={props.height}
842
889
  loadingMessage={props.loadingMessage}
843
890
  />
@@ -849,7 +896,8 @@ export function BaseChartWrapper(props: BaseChartWrapperProps) {
849
896
  return (
850
897
  <BaseChartWrapperLoading
851
898
  ref={containerRef}
852
- className={cn(props.className, props.loadingComponentClassName)}
899
+ className={props.className}
900
+ loadingComponentClassName={props.loadingComponentClassName}
853
901
  height={props.height}
854
902
  loadingMessage={props.loadingMessage}
855
903
  />