@sybilion/uilib 1.8.5 → 1.8.7

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 (46) hide show
  1. package/dist/agent-glossary/content-prompt.generated.ts +27 -0
  2. package/dist/agent-glossary/content.generated.ts +27 -0
  3. package/dist/agent-glossary/content.index.md +1 -0
  4. package/dist/agent-glossary/content.md +27 -0
  5. package/dist/agent-glossary/content.prompt.md +27 -0
  6. package/dist/agent-glossary/workspace.generated.ts +1 -0
  7. package/dist/agent-glossary/workspace.index.md +1 -0
  8. package/dist/agent-glossary/workspace.md +1 -0
  9. package/dist/esm/src/components/ui/Chart/components/BaseChartWrapper.js +3 -1
  10. package/dist/esm/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.js +5 -1
  11. package/dist/esm/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.styl.js +2 -2
  12. package/dist/esm/src/components/ui/ChartAreaInteractive/ChartLines.js +15 -5
  13. package/dist/esm/src/components/ui/DropdownMenu/DropdownMenu.styl.js +2 -2
  14. package/dist/esm/src/components/ui/WorkspaceAppSwitcher/WorkspaceAppSwitcher.styl.js +1 -1
  15. package/dist/esm/src/components/widgets/BacktestChart/BacktestChart.js +113 -0
  16. package/dist/esm/src/components/widgets/BacktestChart/BacktestChart.styl.js +7 -0
  17. package/dist/esm/src/components/widgets/BacktestChart/backtestChart.helpers.js +134 -0
  18. package/dist/esm/src/index.js +3 -1
  19. package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.d.ts +3 -2
  20. package/dist/esm/types/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.d.ts +2 -0
  21. package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartLines.d.ts +16 -1
  22. package/dist/esm/types/src/components/widgets/BacktestChart/BacktestChart.d.ts +37 -0
  23. package/dist/esm/types/src/components/widgets/BacktestChart/backtestChart.helpers.d.ts +61 -0
  24. package/dist/esm/types/src/components/widgets/BacktestChart/index.d.ts +2 -0
  25. package/dist/esm/types/src/docs/pages/BacktestChartPage.d.ts +1 -0
  26. package/dist/esm/types/src/index.d.ts +1 -0
  27. package/dist/esm/types/tests/backtestChart.test.d.ts +1 -0
  28. package/package.json +1 -1
  29. package/src/components/ui/Chart/components/BaseChartWrapper.tsx +6 -2
  30. package/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.styl +4 -0
  31. package/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.styl.d.ts +1 -0
  32. package/src/components/ui/Chart/components/SeriesLegend/SeriesLegend.tsx +7 -1
  33. package/src/components/ui/ChartAreaInteractive/ChartLines.tsx +30 -4
  34. package/src/components/ui/DropdownMenu/AGENT.md +2 -0
  35. package/src/components/ui/DropdownMenu/DropdownMenu.styl +17 -4
  36. package/src/components/ui/WorkspaceAppSwitcher/WorkspaceAppSwitcher.styl +0 -1
  37. package/src/components/widgets/BacktestChart/AGENT.md +24 -0
  38. package/src/components/widgets/BacktestChart/BacktestChart.styl +23 -0
  39. package/src/components/widgets/BacktestChart/BacktestChart.styl.d.ts +9 -0
  40. package/src/components/widgets/BacktestChart/BacktestChart.tsx +247 -0
  41. package/src/components/widgets/BacktestChart/backtestChart.helpers.ts +172 -0
  42. package/src/components/widgets/BacktestChart/index.ts +8 -0
  43. package/src/docs/pages/BacktestChartPage.tsx +94 -0
  44. package/src/docs/pages/DropdownMenuPage.tsx +128 -14
  45. package/src/docs/registry.ts +6 -0
  46. package/src/index.ts +1 -0
@@ -24,7 +24,7 @@ export { ChartLegend, ChartTooltip } from './components/ui/Chart/Chart.js';
24
24
  export { THEMES } from './components/ui/Chart/Chart.types.js';
25
25
  export { ChartAreaInteractive, chartConfig } from './components/ui/ChartAreaInteractive/ChartAreaInteractive.js';
26
26
  export { DRAG_TIME_RANGE_PREFIX, encodeDragTimeRange, filterDataForTimeRange, findPinPositionForDate, isAnalysisDone, isAnalysisFailed, isAnalysisNotFailed, isTimeRangePreset, longDateFormatter, parseDragTimeRange, shortDateFormatter } from './components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.js';
27
- export { ChartLines, FORECAST_COLORS_MAP, FORECAST_LINE_COLORS, getForecastColor, getForecastQuantileBandColor, getHistoryColor, resolveHistoryLines, resolveQuantileBandFillForForecastLine } from './components/ui/ChartAreaInteractive/ChartLines.js';
27
+ export { ChartLines, FORECAST_COLORS_MAP, FORECAST_LINE_COLORS, getForecastColor, getForecastQuantileBandColor, getHistoryColor, lineStyleDasharray, resolveHistoryLines, resolveQuantileBandFillForForecastLine } from './components/ui/ChartAreaInteractive/ChartLines.js';
28
28
  export { HISTORY_SERIES_KEY, forecastHistoryKey, historySeriesKey, historySeriesKeys, isHistorySeriesKey } from './components/ui/ChartAreaInteractive/chartHistories.js';
29
29
  export { DonutChart } from './components/ui/DonutChart/DonutChart.js';
30
30
  export { BarChart } from './components/ui/BarChart/BarChart.js';
@@ -141,6 +141,8 @@ export { PerformanceChart } from './components/widgets/PerformanceChart/Performa
141
141
  export { PerformanceTable } from './components/widgets/PerformanceChart/PerformanceTable.js';
142
142
  export { SPAGHETTI_DRIFT_PER_HORIZON_ID_BASE, SPAGHETTI_MODEL_PER_HORIZON_ID_BASE, averageForecastErrorsVsHistoricalForMatrixColumn, buildDriftSpaghettiMatrixForCustomDialog, buildPerHorizonSpaghettiEntries, buildSpaghettiMergedChartData, calculateYRangeFromChartData, extendCustomPerformanceDriftSeedToHistoricalEnd, extendCustomPerformanceMatrixWithDriftSeed, getForecastModelDisplayName, latestHistoricalMonthKey, spaghettiGridFromHistoricalPreviousMonth } from './components/widgets/PerformanceChart/performanceChart.helpers.js';
143
143
  export { SPAGHETTI_LOCAL_LS_USER_SERIES_ROW_ID, SPAGHETTI_TIME_SERIES_MATRIX_V, tryParseSpaghettiPerformanceMatrix } from './components/widgets/PerformanceChart/performanceChartUserSeries.js';
144
+ export { BacktestChart } from './components/widgets/BacktestChart/BacktestChart.js';
145
+ export { backtestScore, buildBacktestRows } from './components/widgets/BacktestChart/backtestChart.helpers.js';
144
146
  export { SybilionAuthLayout } from './components/widgets/SybilionAuthLayout/SybilionAuthLayout.js';
145
147
  export { SybilionAuthHeadline } from './components/widgets/SybilionAuthLayout/SybilionAuthHeadline.js';
146
148
  export { ChartTooltipItem } from './components/ui/Chart/components/ChartTooltipItem.js';
@@ -1,7 +1,7 @@
1
1
  import { ComponentProps, ReactNode } from 'react';
2
2
  import type { QuantileBandConfig } from '#uilib/components/ui/Chart/chartForecastVisualization.types';
3
3
  import { ChartDataPoint } from '#uilib/components/ui/ChartAreaInteractive/ChartAreaInteractive.types';
4
- import { ForecastItemData } from '#uilib/components/ui/ChartAreaInteractive/ChartLines';
4
+ import { ForecastItemData, type ForecastLineStyle } from '#uilib/components/ui/ChartAreaInteractive/ChartLines';
5
5
  import { HistoryItemData } from '#uilib/components/ui/ChartAreaInteractive/chartHistories';
6
6
  import { LegendPayload } from 'recharts/types/component/DefaultLegendContent';
7
7
  import type { ChartConfig } from '../Chart.types';
@@ -125,7 +125,8 @@ export interface BaseChartWrapperProps {
125
125
  /** When true, no placeholder UI for empty `chartData` (parent renders overlay). */
126
126
  suppressNoDataState?: boolean;
127
127
  onGridHeightChange?: (height: number) => void;
128
- forecastLineStyle?: 'dashed' | 'solid';
128
+ /** Every forecast line's style, unless the line sets its own `lineStyle`. */
129
+ forecastLineStyle?: ForecastLineStyle;
129
130
  disableHistoricalAnimation?: boolean;
130
131
  /** Clear all hidden series (legend “show all”). */
131
132
  onShowAll?: () => void;
@@ -6,6 +6,8 @@ export type SeriesLegendItem = {
6
6
  color: string;
7
7
  /** Draw the swatch as a dashed line (a forecast line). */
8
8
  dashed?: boolean;
9
+ /** Draw the swatch as a dotted line (a baseline, such as a value held flat). */
10
+ dotted?: boolean;
9
11
  /** Draw the swatch as a filled square (a bar or an area) instead of a line. */
10
12
  square?: boolean;
11
13
  };
@@ -24,7 +24,22 @@ export type ForecastItemData = {
24
24
  * `connectForecastNulls` decides.
25
25
  */
26
26
  connectNulls?: boolean;
27
+ /**
28
+ * This line's style, over the chart's `forecastLineStyle`. `dotted` is for
29
+ * a baseline (a last value held flat), not a forecast. Read by the
30
+ * Recharts charts (ChartLines) and their plain legend only.
31
+ */
32
+ lineStyle?: ForecastLineStyle;
33
+ /**
34
+ * Mark this line's last point with a dot, over the chart's `showEndDots`
35
+ * (a backtest's forecast lands on a dot; its baseline does not). Read by
36
+ * ChartLines only.
37
+ */
38
+ endDot?: boolean;
27
39
  };
40
+ export type ForecastLineStyle = 'dashed' | 'dotted' | 'solid';
41
+ /** The stroke pattern for a line style. */
42
+ export declare function lineStyleDasharray(style: ForecastLineStyle): string;
28
43
  export type Dot = {
29
44
  x: number;
30
45
  y: number;
@@ -67,7 +82,7 @@ export declare const ChartLines: import("react").MemoExoticComponent<({ chartDat
67
82
  shouldAnimate?: boolean;
68
83
  historicalLineColor?: string;
69
84
  showLegend?: boolean;
70
- forecastLineStyle?: "dashed" | "solid";
85
+ forecastLineStyle?: ForecastLineStyle;
71
86
  disableAnimation?: boolean;
72
87
  disableHistoricalAnimation?: boolean;
73
88
  /** Draw each history line across months it has no value for. */
@@ -0,0 +1,37 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type BacktestOrigin, type BacktestPoint, type BacktestScore } from './backtestChart.helpers';
3
+ export type BacktestChartProps = {
4
+ /** The actual values, one per month. */
5
+ actuals: BacktestPoint[];
6
+ /** The past months forecasts were made from, each cut to one horizon. */
7
+ origins: BacktestOrigin[];
8
+ /**
9
+ * The score windows under the chart: the last N calendar months up to the
10
+ * latest actual (default: 24 and 12).
11
+ */
12
+ windows?: number[];
13
+ actualLabel?: string;
14
+ forecastLabel?: string;
15
+ baselineLabel?: string;
16
+ actualColor?: string;
17
+ forecastColor?: string;
18
+ baselineColor?: string;
19
+ /** One score line; the default says "removes X% of the error". */
20
+ renderScore?: (score: BacktestScore) => ReactNode;
21
+ formatPercent?: (value: number) => string;
22
+ formatNumber?: (value: number) => string;
23
+ formatDate?: (value: string, detailed?: boolean) => string;
24
+ height?: number;
25
+ /** Draw the lines at once, with no animation. */
26
+ disableAnimation?: boolean;
27
+ isDarkTheme?: boolean;
28
+ renderId?: string;
29
+ className?: string;
30
+ };
31
+ /**
32
+ * A backtest: the actual values (solid), and from each origin the forecast
33
+ * out to its horizon (dashed, with a dot where it lands) and the last value
34
+ * held flat over the same months (dotted, the baseline). Under it, for each
35
+ * window, how much of the baseline's error the forecast removes.
36
+ */
37
+ export declare function BacktestChart({ actuals, origins, windows, actualLabel, forecastLabel, baselineLabel, actualColor, forecastColor, baselineColor, renderScore, formatPercent, formatNumber, formatDate, height, disableAnimation, isDarkTheme, renderId, className, }: BacktestChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,61 @@
1
+ import type { ChartDataPoint } from '#uilib/components/ui/ChartAreaInteractive/ChartAreaInteractive.types';
2
+ /** One month's value: `date` is a sortable ISO date (`2024-03-01`). */
3
+ export type BacktestPoint = {
4
+ date: string;
5
+ value: number;
6
+ };
7
+ /**
8
+ * One backtest origin: a past month a forecast was made from.
9
+ * The baseline holds `value`, the last price known then, flat over the
10
+ * forecast's months.
11
+ */
12
+ export type BacktestOrigin = {
13
+ /** The month the forecast was made in: the last month with a known value. */
14
+ date: string;
15
+ /** The value known at `date`, held flat as the baseline. */
16
+ value: number;
17
+ /**
18
+ * The forecast for the months after `date`, in date order. Its last point
19
+ * is where it lands: the month the scores compare with the actual value.
20
+ */
21
+ forecast: BacktestPoint[];
22
+ };
23
+ /** One window's scores: mean absolute percentage error at the landing month. */
24
+ export type BacktestScore = {
25
+ /** The window: the last `months` calendar months up to the latest actual. */
26
+ months: number;
27
+ /** How many forecasts landed in the window with an actual to compare. */
28
+ count: number;
29
+ /** The forecast's MAPE, in percent. */
30
+ forecastError: number;
31
+ /** The held-flat baseline's MAPE, in percent. */
32
+ baselineError: number;
33
+ /**
34
+ * How much of the baseline's error the forecast removes, in percent
35
+ * (negative: the forecast has more error). Null when the baseline has none.
36
+ */
37
+ errorRemoved: number | null;
38
+ };
39
+ /** The data key of origin `index`'s forecast line. */
40
+ export declare const backtestForecastKey: (index: number) => string;
41
+ /** The data key of origin `index`'s held-flat line. */
42
+ export declare const backtestBaselineKey: (index: number) => string;
43
+ export declare const backtestForecastId: (index: number) => number;
44
+ export declare const backtestBaselineId: (index: number) => number;
45
+ /**
46
+ * The chart's rows, one per calendar month from the first to the last, keyed
47
+ * `YYYY-MM-01` (a month with no value has a row of its own, so the x axis
48
+ * spaces months evenly): the actuals under `historical`, and for each origin
49
+ * its forecast (from the origin's value through every forecast month) and its
50
+ * baseline (the origin's value on the same months), each under its own key.
51
+ * A date that is not `YYYY-MM…` is left out.
52
+ */
53
+ export declare function buildBacktestRows(actuals: BacktestPoint[], origins: BacktestOrigin[]): ChartDataPoint[];
54
+ /**
55
+ * The scores for the last `months` calendar months up to the latest actual:
56
+ * every origin whose forecast lands in one of them, against that month's
57
+ * actual. Dates match by calendar month (`2024-03-01` and `2024-03-31` are
58
+ * one month). Null when the actuals span fewer months than the window, or
59
+ * no forecast lands in it with a non-zero actual to compare.
60
+ */
61
+ export declare function backtestScore(actuals: BacktestPoint[], origins: BacktestOrigin[], months: number): BacktestScore | null;
@@ -0,0 +1,2 @@
1
+ export { BacktestChart, type BacktestChartProps } from './BacktestChart';
2
+ export { type BacktestOrigin, type BacktestPoint, type BacktestScore, backtestScore, buildBacktestRows, } from './backtestChart.helpers';
@@ -0,0 +1 @@
1
+ export default function BacktestChartPage(): import("react/jsx-runtime").JSX.Element;
@@ -81,4 +81,5 @@ export * from './components/widgets/DriverCard';
81
81
  export * from './components/widgets/DriverMap';
82
82
  export * from './components/widgets/DriversComparisonChart';
83
83
  export * from './components/widgets/PerformanceChart';
84
+ export * from './components/widgets/BacktestChart';
84
85
  export * from './components/widgets/SybilionAuthLayout';
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybilion/uilib",
3
- "version": "1.8.5",
3
+ "version": "1.8.7",
4
4
  "description": "Sybilion Design System — React UI components (Vite + Stylus)",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -14,6 +14,7 @@ import { ChartDataPoint } from '#uilib/components/ui/ChartAreaInteractive/ChartA
14
14
  import {
15
15
  ChartLines,
16
16
  ForecastItemData,
17
+ type ForecastLineStyle,
17
18
  getForecastColor,
18
19
  resolveHistoryLines,
19
20
  } from '#uilib/components/ui/ChartAreaInteractive/ChartLines';
@@ -218,7 +219,8 @@ export interface BaseChartWrapperProps {
218
219
  /** When true, no placeholder UI for empty `chartData` (parent renders overlay). */
219
220
  suppressNoDataState?: boolean;
220
221
  onGridHeightChange?: (height: number) => void;
221
- forecastLineStyle?: 'dashed' | 'solid';
222
+ /** Every forecast line's style, unless the line sets its own `lineStyle`. */
223
+ forecastLineStyle?: ForecastLineStyle;
222
224
  disableHistoricalAnimation?: boolean;
223
225
  /** Clear all hidden series (legend “show all”). */
224
226
  onShowAll?: () => void;
@@ -597,6 +599,7 @@ const BaseChartWrapperContent = forwardRef<
597
599
  // tooltip: item.tooltip,
598
600
  dimmed: item.dimmed,
599
601
  updated_at: item.updated_at,
602
+ lineStyle: item.lineStyle,
600
603
  }));
601
604
  }, [forecastData, excludeLegendIds, showLegend]);
602
605
 
@@ -628,7 +631,8 @@ const BaseChartWrapperContent = forwardRef<
628
631
  dataKey: p.dataKey,
629
632
  label: p.value,
630
633
  color: p.color,
631
- dashed: forecastLineStyle === 'dashed',
634
+ dashed: (p.lineStyle ?? forecastLineStyle) === 'dashed',
635
+ dotted: (p.lineStyle ?? forecastLineStyle) === 'dotted',
632
636
  })),
633
637
  ];
634
638
  if (!legendOrder) return all;
@@ -25,6 +25,10 @@
25
25
  .dashed
26
26
  border-top-style dashed
27
27
 
28
+ // A baseline's swatch (a value held flat).
29
+ .dotted
30
+ border-top-style dotted
31
+
28
32
  // A bar's or an area's swatch.
29
33
  .square
30
34
  width 0.5rem
@@ -4,6 +4,7 @@ interface CssExports {
4
4
  button: string;
5
5
  dashed: string;
6
6
  dimmed: string;
7
+ dotted: string;
7
8
  root: string;
8
9
  square: string;
9
10
  swatch: string;
@@ -11,6 +11,8 @@ export type SeriesLegendItem = {
11
11
  color: string;
12
12
  /** Draw the swatch as a dashed line (a forecast line). */
13
13
  dashed?: boolean;
14
+ /** Draw the swatch as a dotted line (a baseline, such as a value held flat). */
15
+ dotted?: boolean;
14
16
  /** Draw the swatch as a filled square (a bar or an area) instead of a line. */
15
17
  square?: boolean;
16
18
  };
@@ -41,7 +43,11 @@ export function SeriesLegend({
41
43
  <span
42
44
  className={cn(
43
45
  S.swatch,
44
- item.square ? S.square : item.dashed && S.dashed,
46
+ item.square
47
+ ? S.square
48
+ : item.dotted
49
+ ? S.dotted
50
+ : item.dashed && S.dashed,
45
51
  )}
46
52
  style={{ color: item.color }}
47
53
  aria-hidden
@@ -35,8 +35,29 @@ export type ForecastItemData = {
35
35
  * `connectForecastNulls` decides.
36
36
  */
37
37
  connectNulls?: boolean;
38
+ /**
39
+ * This line's style, over the chart's `forecastLineStyle`. `dotted` is for
40
+ * a baseline (a last value held flat), not a forecast. Read by the
41
+ * Recharts charts (ChartLines) and their plain legend only.
42
+ */
43
+ lineStyle?: ForecastLineStyle;
44
+ /**
45
+ * Mark this line's last point with a dot, over the chart's `showEndDots`
46
+ * (a backtest's forecast lands on a dot; its baseline does not). Read by
47
+ * ChartLines only.
48
+ */
49
+ endDot?: boolean;
38
50
  };
39
51
 
52
+ export type ForecastLineStyle = 'dashed' | 'dotted' | 'solid';
53
+
54
+ /** The stroke pattern for a line style. */
55
+ export function lineStyleDasharray(style: ForecastLineStyle): string {
56
+ if (style === 'dashed') return '4 2';
57
+ if (style === 'dotted') return '1 3';
58
+ return '0';
59
+ }
60
+
40
61
  export type Dot = {
41
62
  x: number;
42
63
  y: number;
@@ -133,7 +154,7 @@ export const ChartLines = memo(
133
154
  shouldAnimate?: boolean;
134
155
  historicalLineColor?: string;
135
156
  showLegend?: boolean;
136
- forecastLineStyle?: 'dashed' | 'solid';
157
+ forecastLineStyle?: ForecastLineStyle;
137
158
  disableAnimation?: boolean;
138
159
  disableHistoricalAnimation?: boolean;
139
160
  /** Draw each history line across months it has no value for. */
@@ -238,6 +259,7 @@ export const ChartLines = memo(
238
259
  dataKey: string,
239
260
  color: string,
240
261
  connected: boolean,
262
+ endDot: boolean = showEndDots,
241
263
  ) => {
242
264
  const i = props.index;
243
265
  if (
@@ -248,7 +270,7 @@ export const ChartLines = memo(
248
270
  ) {
249
271
  return null;
250
272
  }
251
- const isEnd = showEndDots && lastIndex >= 0 && i === lastIndex;
273
+ const isEnd = endDot && lastIndex >= 0 && i === lastIndex;
252
274
  const isAlone =
253
275
  dotLonePoints &&
254
276
  (connected
@@ -330,6 +352,8 @@ export const ChartLines = memo(
330
352
  } = data;
331
353
  const dataKey = `forecast_${id}`;
332
354
  const connected = data.connectNulls ?? connectForecastNulls;
355
+ const endDot = data.endDot ?? showEndDots;
356
+ const lineStyle = data.lineStyle ?? forecastLineStyle;
333
357
 
334
358
  return (
335
359
  <Line
@@ -338,9 +362,10 @@ export const ChartLines = memo(
338
362
  dataKey={dataKey}
339
363
  stroke={color}
340
364
  strokeWidth={1}
341
- strokeDasharray={forecastLineStyle === 'dashed' ? '4 2' : '0'}
365
+ strokeDasharray={lineStyleDasharray(lineStyle)}
366
+ strokeLinecap={lineStyle === 'dotted' ? 'round' : undefined}
342
367
  dot={
343
- showEndDots || dotLonePoints
368
+ endDot || dotLonePoints
344
369
  ? props =>
345
370
  renderDot(
346
371
  props,
@@ -348,6 +373,7 @@ export const ChartLines = memo(
348
373
  dataKey,
349
374
  color,
350
375
  connected,
376
+ endDot,
351
377
  )
352
378
  : false
353
379
  }
@@ -14,3 +14,5 @@ DropdownMenu displays a list of actions or options in a floating panel opened fr
14
14
 
15
15
  - Order items by expected frequency of use and separate destructive actions from the rest.
16
16
  - Keep item labels short and verb-led, such as “Rename” or “Delete”.
17
+ - Nest a sub-menu with DropdownMenuSub, DropdownMenuSubTrigger and DropdownMenuSubContent. Wrap DropdownMenuSubContent in DropdownMenuPortal, since it is not portalled by default and the parent menu's scroll box would clip it.
18
+ - Keep a filter menu open while the user ticks several options by calling `event.preventDefault()` in the item's onSelect.
@@ -50,6 +50,18 @@
50
50
  &[data-state="closed"][data-side="top"]
51
51
  animation fade-out 0.1s ease-in, zoom-out 0.1s ease-in
52
52
 
53
+ // Menu rows draw no focus ring: the :focus background marks the focused row,
54
+ // and Radix focuses the row under the pointer, so a ring outside the row would
55
+ // show on hover and be clipped by the menu's rounded, scrolling box. base.css
56
+ // draws the ring with specificity (0,3,0); this beats it on the row only, so
57
+ // a control inside a row keeps its own ring.
58
+ .item
59
+ .checkboxItem
60
+ .radioItem
61
+ .subTrigger
62
+ &[data-slot]:focus-visible:not([data-disabled])
63
+ outline-color transparent
64
+
53
65
  .label
54
66
  .item
55
67
  padding 6px var(--p-2)
@@ -65,7 +77,6 @@
65
77
  outline-offset 2px
66
78
  user-select none
67
79
  cursor: pointer;
68
- focus-outline()
69
80
 
70
81
  a&
71
82
  text-decoration: none;
@@ -133,7 +144,6 @@
133
144
  outline 2px solid transparent
134
145
  outline-offset 2px
135
146
  user-select none
136
- focus-outline()
137
147
 
138
148
  &:focus
139
149
  background-color var(--accent)
@@ -162,7 +172,6 @@
162
172
  outline 2px solid transparent
163
173
  outline-offset 2px
164
174
  user-select none
165
- focus-outline()
166
175
 
167
176
  &:focus
168
177
  background-color var(--accent)
@@ -211,7 +220,6 @@
211
220
  outline 2px solid transparent
212
221
  outline-offset 2px
213
222
  user-select none
214
- focus-outline()
215
223
 
216
224
  &:focus
217
225
  background-color var(--accent)
@@ -279,6 +287,11 @@
279
287
  align-items center
280
288
  justify-content center
281
289
 
290
+ // Radix's ItemIndicator is an inline span, which puts the icon on the text
291
+ // baseline, a few px above the row's middle. A flex box centres it.
292
+ > span
293
+ display flex
294
+
282
295
  @keyframes fade-in
283
296
  from
284
297
  opacity 0
@@ -113,7 +113,6 @@
113
113
  padding var(--p-3)
114
114
  cursor pointer
115
115
  outline none
116
- focus-outline()
117
116
 
118
117
  .itemActive
119
118
  background-color var(--muted)
@@ -0,0 +1,24 @@
1
+ BacktestChart shows how a forecast did in the past against the simplest baseline, the last known value held flat. It draws the actual values (solid), and from each past month a forecast was made in (an origin) the forecast out to one horizon (dashed, with a dot where it lands) and the origin's value held flat over the same months (dotted grey). Under the chart, one line per window says how much of the baseline's error the forecast removes, with both mean absolute percentage errors (MAPE).
2
+
3
+ ## When to use
4
+
5
+ - To show that a forecast beats knowing only the last price, for one horizon at a time.
6
+
7
+ ## When not to use
8
+
9
+ - For the latest forecast with its range; use ChartAreaInteractive.
10
+ - For every horizon of every vintage at once; use PerformanceChart's spaghetti view.
11
+
12
+ ## Do
13
+
14
+ - Cut each origin's `forecast` to the horizon shown: its last point is the landing month the scores use.
15
+ - Set an origin's `value` to the actual value at the origin month (the last price known when the forecast was made), and leave out an origin with none.
16
+ - `windows` (default 24 and 12) are the last N calendar months up to the latest actual; a window longer than the actuals, or with no landing in it, has no line.
17
+ - Dates are matched by month (`2024-03-01` and `2024-03-28` are one month), and the chart has one column per month, missing months included.
18
+ - `backtestScore(actuals, origins, months)` is the same computation, for a score shown elsewhere.
19
+ - Only forecasts are dashed: the baseline is dotted and the actuals solid.
20
+
21
+ ## Requires
22
+
23
+ - `actuals`: one point per month, ISO dates (`2024-03-01`); a date that does not start `YYYY-MM` is left out.
24
+ - `origins`: `{ date, value, forecast: [{ date, value }] }`, forecast in date order.
@@ -0,0 +1,23 @@
1
+ .root
2
+ display flex
3
+ flex-direction column
4
+ width 100%
5
+
6
+ .scores
7
+ margin 0.75rem 0 0
8
+ padding 0
9
+ list-style none
10
+ display flex
11
+ flex-direction column
12
+ gap 0.25rem
13
+ font-size 0.875rem
14
+ color var(--muted-foreground)
15
+
16
+ strong
17
+ color var(--foreground)
18
+ font-weight 500
19
+
20
+ // BaseChartWrapper fills its parent's height (min-height 100%); here the
21
+ // legend and the scores share that height, so the chart keeps its own.
22
+ .root .chart
23
+ min-height 0
@@ -0,0 +1,9 @@
1
+ // This file is automatically generated.
2
+ // Please do not change this file!
3
+ interface CssExports {
4
+ chart: string;
5
+ root: string;
6
+ scores: string;
7
+ }
8
+ export const cssExports: CssExports;
9
+ export default cssExports;