@lilt-ui/charts 0.4.0 → 0.6.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 (45) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/activity-ring.d.ts +5 -2
  3. package/dist/cards/activity-ring-card.d.ts +5 -2
  4. package/dist/cards/bar-chart-card.d.ts +5 -2
  5. package/dist/cards/box-plot-card.d.ts +3 -1
  6. package/dist/cards/cartesian-card.d.ts +22 -3
  7. package/dist/cards/combo-chart-card.d.ts +4 -2
  8. package/dist/cards/funnel-chart-card.d.ts +27 -2
  9. package/dist/cards/heatmap-chart-card.d.ts +8 -2
  10. package/dist/cards/horizontal-bar-chart-card.d.ts +9 -4
  11. package/dist/cards/progress-card.d.ts +8 -2
  12. package/dist/cards/radar-chart-card.d.ts +10 -2
  13. package/dist/cards/radial-chart-card.d.ts +16 -5
  14. package/dist/cards/range-chart-card.d.ts +3 -1
  15. package/dist/cards/sankey-chart-card.d.ts +8 -2
  16. package/dist/cards/scatter-chart-card.d.ts +12 -2
  17. package/dist/cards/slope-chart-card.d.ts +8 -2
  18. package/dist/cards/stat-card.d.ts +9 -3
  19. package/dist/chart.d.ts +1 -1
  20. package/dist/engine/depth.d.ts +42 -0
  21. package/dist/engine/isometric-bars.d.ts +25 -0
  22. package/dist/engine/ranges.d.ts +31 -0
  23. package/dist/finance/candle-geometry.d.ts +13 -2
  24. package/dist/finance/candles.d.ts +5 -0
  25. package/dist/finance/cards/candlestick-chart-card.d.ts +6 -1
  26. package/dist/finance/cards/depth-chart-card.d.ts +5 -2
  27. package/dist/finance/order-book.d.ts +7 -3
  28. package/dist/finance.js +547 -440
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +3081 -2162
  31. package/dist/interaction/legend-meter.d.ts +11 -0
  32. package/dist/interaction/value-legend.d.ts +8 -2
  33. package/dist/lifecycle/loading-layer.d.ts +14 -3
  34. package/dist/lifecycle/skeleton-block.d.ts +6 -0
  35. package/dist/lifecycle/skeleton-sheen.d.ts +15 -2
  36. package/dist/lifecycle/use-skeleton-clock.d.ts +5 -0
  37. package/dist/marks/contract.d.ts +15 -0
  38. package/dist/marks/range-loading-mark.d.ts +3 -0
  39. package/dist/marks/use-range-mark.d.ts +8 -0
  40. package/dist/primitives/depth-paint.d.ts +107 -0
  41. package/dist/primitives/isometric-bar.d.ts +18 -0
  42. package/dist/{cartesian-card-Cj1o38DC.js → skeleton-block-Uf1lywJi.js} +2580 -1936
  43. package/dist/styles.css +1 -1
  44. package/dist/types.d.ts +38 -4
  45. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactElement, ReactNode } from 'react';
2
- import { ChartBarAppearance, ChartMotion, ChartPalette, ChartStyle, ChartSurface } from '../types';
2
+ import { ChartBarAppearance, ChartLoadingStyle, ChartMotion, ChartPalette, ChartStyle, ChartSurface } from '../types';
3
3
  import { NumericKey, XKey, XKind } from './keys';
4
4
  import { CardAggregate } from './format';
5
5
  import { AnimatedNumberVariant } from '../motion/animated-number';
@@ -32,8 +32,13 @@ export interface StatCardProps<Row, Key extends NumericKey<Row>> {
32
32
  * `ring` beside the value, both filling toward `target`; or `none`.
33
33
  */
34
34
  chart?: StatCardChart;
35
- /** Bar treatment for `chart="bars"`: `solid` (default), `segmented`, `needle`, `gradient`, `outline`. */
35
+ /** Bar treatment for `chart="bars"`: `solid` (default), `segmented`, `needle`, `gradient`, `outline`, or `isometric`. */
36
36
  barStyle?: ChartBarAppearance;
37
+ /**
38
+ * Gives the small chart depth: lines and the ring become lit tubes, the meter a solid bar, and bars default
39
+ * to `isometric`. Values still read from the front faces.
40
+ */
41
+ depth?: boolean;
37
42
  /** Goal for `chart="meter"` or `chart="ring"`, in the same unit as the value. */
38
43
  target?: number;
39
44
  /**
@@ -59,10 +64,11 @@ export interface StatCardProps<Row, Key extends NumericKey<Row>> {
59
64
  numberStyle?: AnimatedNumberVariant;
60
65
  palette?: ChartPalette;
61
66
  loading?: boolean;
67
+ loadingStyle?: ChartLoadingStyle;
62
68
  motion?: ChartMotion;
63
69
  className?: string;
64
70
  style?: CSSProperties | ChartStyle;
65
71
  }
66
72
  /** Cells of a meter: whole cells up to the value, then one cell trimmed to the exact remainder. */
67
73
  export declare function meterCells(ratio: number, count?: number): number[];
68
- export declare function StatCard<Row, const Key extends NumericKey<Row>>({ title, data, value: valueKey, x, xType, headline: suppliedHeadline, aggregate, delta, deltaTone, caption, chart, barStyle, target, sync, height, color, aside, valueFormat, locale, formatValue: suppliedFormatValue, formatX, surface, badge, numberStyle, palette, loading, motion, className, style, }: StatCardProps<Row, Key>): ReactElement;
74
+ export declare function StatCard<Row, const Key extends NumericKey<Row>>({ title, data, value: valueKey, x, xType, headline: suppliedHeadline, aggregate, delta, deltaTone, caption, chart, depth, barStyle, target, sync, height, color, aside, valueFormat, locale, formatValue: suppliedFormatValue, formatX, surface, badge, numberStyle, palette, loading, motion, loadingStyle, className, style, }: StatCardProps<Row, Key>): ReactElement;
package/dist/chart.d.ts CHANGED
@@ -15,5 +15,5 @@ type ChartPlotRendererProps<T> = Omit<ChartProps<T>, 'className' | 'style'> & Om
15
15
  controllerLinked?: boolean;
16
16
  tooltipNode?: ReactNode;
17
17
  };
18
- export declare function ChartPlotRenderer<T>({ data, x, y, series, height, compactHeight, margins: marginProps, arrangement, marks, barLayout: barsProps, compact, tooltipNode, inspectionSeries: plotInspectionSeries, className, style, 'aria-label': ariaLabel, children, status, interactive, error, renderRetry, motion: motionPreference, animateIn, resetKey, onSelectionChange, controller, linkedSelection, selectedCategoryId, onSelectedCategoryIdChange, compare, focus, live, brush, visibleSeries, onVisibleSeriesChange, toolkit, model, controllerLinked, axis: axisProp, pill, pillSeries, pillValue, pillPosition, axisInset, runoff, labelOverhang, }: ChartPlotRendererProps<T>): ReactElement;
18
+ export declare function ChartPlotRenderer<T>({ data, x, y, series, height, compactHeight, margins: marginProps, arrangement, marks, barLayout: barsProps, compact, tooltipNode, inspectionSeries: plotInspectionSeries, className, style, 'aria-label': ariaLabel, children, status, loadingStyle, interactive, error, renderRetry, motion: motionPreference, animateIn, resetKey, onSelectionChange, controller, linkedSelection, selectedCategoryId, onSelectedCategoryIdChange, compare, focus, live, brush, visibleSeries, onVisibleSeriesChange, toolkit, model, controllerLinked, axis: axisProp, pill, pillSeries, pillValue, pillPosition, axisInset, runoff, labelOverhang, }: ChartPlotRendererProps<T>): ReactElement;
19
19
  export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shared geometry for charts drawn with depth. Every family recedes the same way: up and to the
3
+ * right at about 30°, so a bar, a candle, a ring, and a funnel side by side share one light and
4
+ * one camera. The front face always keeps the measured geometry; depth only adds paint behind it.
5
+ */
6
+ /** The deepest a column recedes, in pixels. */
7
+ export declare const MAX_DEPTH = 14;
8
+ /** Rise per unit of depth. */
9
+ export declare const DEPTH_SLOPE: number;
10
+ /** Extra paint above the tallest front face; clips reserve this much headroom. */
11
+ export declare const MAX_RISE: number;
12
+ /** Screen offset of the back face for a given depth. */
13
+ export declare function depthOffset(depth: number): {
14
+ dx: number;
15
+ dy: number;
16
+ };
17
+ /**
18
+ * Depth for a column of a given footprint. Tiny readings and dense charts get proportionately
19
+ * less, never a false minimum.
20
+ */
21
+ export declare function columnDepth(width: number, height: number): number;
22
+ export interface PrismFaces {
23
+ /** The front, left edge at `x`: the footprint minus the depth, so the prism fits its slot. */
24
+ front: string;
25
+ /** The whole silhouette; drawn first in the side's shade, it also fills every seam. */
26
+ side: string;
27
+ top: string | null;
28
+ frontWidth: number;
29
+ depth: number;
30
+ rise: number;
31
+ }
32
+ /**
33
+ * A square prism inside a `width`-wide footprint. The faces overlap underneath the front by a
34
+ * pixel so antialiased edges never show the plot through a seam.
35
+ */
36
+ export declare function prismFaces(x: number, y: number, width: number, height: number, depth?: number, showTop?: boolean): PrismFaces;
37
+ /**
38
+ * A prism for a column centered on `cx`, such as a range bar or a candle body. The front stays
39
+ * centered on the reading, so the crosshair and any whisker or wick pass through its middle;
40
+ * the depth extends to the right.
41
+ */
42
+ export declare function centeredPrism(cx: number, y: number, width: number, height: number): PrismFaces;
@@ -0,0 +1,25 @@
1
+ import { barMarkPath, BarGeometry } from './bars';
2
+ /** Extra paint above the measured front face; shared by resting and inspection clips. */
3
+ export declare const ISOMETRIC_BAR_RISE: number;
4
+ type MarkOptions = Parameters<typeof barMarkPath>[1];
5
+ /**
6
+ * A square prism inside the original horizontal slot. The front keeps the real y values; corner
7
+ * radius does not apply, because a rounded front reads as a plate stuck on a box.
8
+ */
9
+ export declare function isometricBarGeometry(bar: BarGeometry, options: MarkOptions): {
10
+ x: number;
11
+ y: number;
12
+ width: number;
13
+ height: number;
14
+ depth: number;
15
+ rise: number;
16
+ /** Square: an extruded bar has no rounded plate on its front. */
17
+ front: string;
18
+ side: string;
19
+ top: string | null;
20
+ grounded: boolean;
21
+ /** A short contact shadow on the floor band, behind and to the right of the footprint. */
22
+ shadow: string | null;
23
+ cast: number;
24
+ } | null;
25
+ export {};
@@ -1,3 +1,4 @@
1
+ import { PrismFaces } from './depth';
1
2
  import { NormalizedRow } from './normalize';
2
3
  /** Pixel mappings a range mark draws with. */
3
4
  export interface RangeScales {
@@ -29,6 +30,13 @@ export declare class ColorBatches {
29
30
  d: string;
30
31
  }[];
31
32
  }
33
+ /** Prism faces batched by color: every side, then every top, then every front. */
34
+ export declare class PrismBatches {
35
+ readonly sides: ColorBatches;
36
+ readonly tops: ColorBatches;
37
+ readonly fronts: ColorBatches;
38
+ add(color: string, faces: PrismFaces): void;
39
+ }
32
40
  /** Column geometry shared by candles and range marks: center and body width per row. */
33
41
  export declare function columnFrame(scales: RangeScales): {
34
42
  width: number;
@@ -40,6 +48,8 @@ export interface RangeColumn<T> {
40
48
  }
41
49
  /** Rows in view with their pixel centers. */
42
50
  export declare function columnsInView<T>(rows: readonly NormalizedRow<T>[], scales: RangeScales): RangeColumn<T>[];
51
+ /** One floating bar from low to high as a prism; its front spans exactly low to high. */
52
+ export declare function rangeBarPrism(cx: number, low: number, high: number, scales: RangeScales): PrismFaces;
43
53
  /** One floating bar from low to high. */
44
54
  export declare function rangeBarPath(cx: number, low: number, high: number, scales: RangeScales): string;
45
55
  /** A whisker from low to high with caps a little narrower than the column. */
@@ -57,3 +67,24 @@ export declare function boxShape(cx: number, values: {
57
67
  q3: number;
58
68
  max: number;
59
69
  }, scales: RangeScales): BoxShape;
70
+ /**
71
+ * A box plot drawn as a solid block. The block's middle, not its front, sits on the reading, so
72
+ * the whiskers run through the center of its top and bottom faces, half the depth back. The
73
+ * front still spans exactly Q1 to Q3, and the median wraps from the front around the side.
74
+ */
75
+ export declare function boxBlock(cx: number, values: {
76
+ min: number;
77
+ q1: number;
78
+ median: number;
79
+ q3: number;
80
+ max: number;
81
+ }, scales: RangeScales): {
82
+ faces: PrismFaces;
83
+ /** How far the whiskers and outliers sit above their values: half the depth back. */
84
+ lift: number;
85
+ median: string;
86
+ /** Drawn before the block, which hides where it leaves the bottom face. */
87
+ lower: string;
88
+ /** Drawn after the block, rising from the middle of its top face. */
89
+ upper: string;
90
+ };
@@ -36,6 +36,15 @@ export interface CandlePaths {
36
36
  color: string;
37
37
  d: string;
38
38
  }[];
39
+ /** With depth: the receding side and top of every body, one path per color. */
40
+ sides: {
41
+ color: string;
42
+ d: string;
43
+ }[];
44
+ tops: {
45
+ color: string;
46
+ d: string;
47
+ }[];
39
48
  }
40
49
  export declare function candleAt(row: NormalizedRow<unknown>, series: string, fields: CandleFields): Candle | null;
41
50
  /** Throws on a candle whose high or low does not contain its open and close. */
@@ -44,12 +53,14 @@ interface CandleShape {
44
53
  body: string | null;
45
54
  hollow: string | null;
46
55
  stroke: string;
56
+ side: string | null;
57
+ top: string | null;
47
58
  }
48
59
  /** One candle's geometry. Wicks stop at the body, so a hollow body stays empty. */
49
- export declare function candleShape(cx: number, candle: Candle, scales: RangeScales, display: CandleDisplay): CandleShape;
60
+ export declare function candleShape(cx: number, candle: Candle, scales: RangeScales, display: CandleDisplay, depth?: boolean): CandleShape;
50
61
  /**
51
62
  * Every candle in view batched into a handful of paths: bodies, hollow bodies and strokes,
52
63
  * each grouped by color. Thousands of candles stay a few DOM nodes.
53
64
  */
54
- export declare function candlePaths(rows: readonly NormalizedRow<unknown>[], series: string, fields: CandleFields, scales: RangeScales, display: CandleDisplay, colorOf: (row: NormalizedRow<unknown>, candle: Candle) => string): CandlePaths;
65
+ export declare function candlePaths(rows: readonly NormalizedRow<unknown>[], series: string, fields: CandleFields, scales: RangeScales, display: CandleDisplay, colorOf: (row: NormalizedRow<unknown>, candle: Candle) => string, depth?: boolean): CandlePaths;
55
66
  export {};
@@ -9,6 +9,11 @@ export interface CandlesProps {
9
9
  low: string;
10
10
  /** `candle` (default), `hollow` rising bodies, or `ohlc` bars. */
11
11
  display?: CandleDisplay;
12
+ /**
13
+ * Draws each body as a solid block receding up and to the right; the front keeps open and
14
+ * close. OHLC bars stay flat.
15
+ */
16
+ depth?: boolean;
12
17
  className?: string;
13
18
  }
14
19
  /**
@@ -17,6 +17,11 @@ export interface CandlestickChartCardProps<Row, Key extends NumericKey<Row>> ext
17
17
  * colored by the period's direction.
18
18
  */
19
19
  display?: CandleDisplay | 'area';
20
+ /**
21
+ * Draws each candle body as a solid block receding up and to the right; the front keeps open
22
+ * and close. OHLC bars and the area stay flat.
23
+ */
24
+ depth?: boolean;
20
25
  /** `log` spaces prices by ratio, for long histories. Defaults to `linear`. */
21
26
  scale?: 'linear' | 'log';
22
27
  /** Names the price series in hover. Defaults to "Price". */
@@ -37,5 +42,5 @@ export declare function describeCandle(format: (value: number) => string): (insp
37
42
  * linked volume pane, a headline that follows the hovered candle, and its open, high and low
38
43
  * beside the date.
39
44
  */
40
- export declare function CandlestickChartCard<Row, const Key extends NumericKey<Row>>({ open, high, low, close, volume, display, scale, label, live, data, ranges, delta, valueFormat, locale, volumeHeight, ...props }: CandlestickChartCardProps<Row, Key>): ReactElement;
45
+ export declare function CandlestickChartCard<Row, const Key extends NumericKey<Row>>({ open, high, low, close, volume, display, depth, scale, label, live, data, ranges, delta, valueFormat, locale, volumeHeight, ...props }: CandlestickChartCardProps<Row, Key>): ReactElement;
41
46
  export {};
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactElement } from 'react';
2
- import { ChartAxis, ChartBackground, ChartHoverStyle, ChartMotion, ChartStyle, ChartSurface } from '../../types';
2
+ import { ChartAxis, ChartBackground, ChartHoverStyle, ChartLoadingStyle, ChartMotion, ChartStyle, ChartSurface } from '../../types';
3
3
  import { AnimatedNumberVariant } from '../../motion/animated-number';
4
4
  import { BookLevel } from '../indicators';
5
5
  export interface DepthChartCardProps {
@@ -8,6 +8,8 @@ export interface DepthChartCardProps {
8
8
  bids: readonly BookLevel[];
9
9
  /** Resting sell orders. */
10
10
  asks: readonly BookLevel[];
11
+ /** Draws both sides' edges as lit tubes with a soft shadow; the steps keep their exact prices. */
12
+ depth?: boolean;
11
13
  /** Price format for the mid, spread and axis, e.g. `{ style: 'currency', currency: 'USD' }`. */
12
14
  valueFormat?: Intl.NumberFormatOptions;
13
15
  /** Size format for depth. Defaults to compact numbers. */
@@ -21,6 +23,7 @@ export interface DepthChartCardProps {
21
23
  surface?: ChartSurface;
22
24
  numberStyle?: AnimatedNumberVariant;
23
25
  loading?: boolean;
26
+ loadingStyle?: ChartLoadingStyle;
24
27
  motion?: ChartMotion;
25
28
  className?: string;
26
29
  style?: CSSProperties | ChartStyle;
@@ -29,4 +32,4 @@ export interface DepthChartCardProps {
29
32
  * Order book depth: how much could trade at each price, buying and selling, as stepped areas, with
30
33
  * the mid, spread and total depth in the header. Hover reads the size resting at each price.
31
34
  */
32
- export declare function DepthChartCard({ title, bids, asks, valueFormat, sizeFormat, locale, height, axis, background, hoverStyle, surface, numberStyle, loading, motion, className, style, }: DepthChartCardProps): ReactElement;
35
+ export declare function DepthChartCard({ title, bids, asks, valueFormat, sizeFormat, locale, height, axis, background, hoverStyle, surface, numberStyle, loading, loadingStyle, motion, className, style, depth, }: DepthChartCardProps): ReactElement;
@@ -1,12 +1,14 @@
1
1
  import { CSSProperties, ReactElement } from 'react';
2
- import { ChartMotion, ChartStyle, ChartSurface } from '../types';
2
+ import { ChartLoadingStyle, ChartMotion, ChartStyle, ChartSurface } from '../types';
3
3
  import { BookLevel } from './indicators';
4
4
  export interface OrderBookProps {
5
5
  title: string;
6
6
  bids: readonly BookLevel[];
7
7
  asks: readonly BookLevel[];
8
8
  /** Price levels shown on each side of the spread. Defaults to 8. */
9
- depth?: number;
9
+ levels?: number;
10
+ /** Draws each level's bar as a solid block with a lit roof and a shaded end. */
11
+ depth?: boolean;
10
12
  /** Price format, e.g. `{ style: 'currency', currency: 'USD' }`. */
11
13
  valueFormat?: Intl.NumberFormatOptions;
12
14
  /** Size format. Defaults to compact numbers. */
@@ -15,6 +17,8 @@ export interface OrderBookProps {
15
17
  /** Briefly highlight levels whose size changed. Defaults to true; reduced motion turns it off. */
16
18
  flash?: boolean;
17
19
  surface?: ChartSurface;
20
+ loading?: boolean;
21
+ loadingStyle?: ChartLoadingStyle;
18
22
  motion?: ChartMotion;
19
23
  className?: string;
20
24
  style?: CSSProperties | ChartStyle;
@@ -23,4 +27,4 @@ export interface OrderBookProps {
23
27
  * A price ladder: asks above, bids below, a spread row between, and a depth bar behind each
24
28
  * level sized by its running total. It is a real table, so screen readers read it row by row.
25
29
  */
26
- export declare function OrderBook({ title, bids, asks, depth, valueFormat, sizeFormat, locale, flash, surface, motion, className, style, }: OrderBookProps): ReactElement;
30
+ export declare function OrderBook({ title, bids, asks, levels, depth, valueFormat, sizeFormat, locale, flash, surface, loading, loadingStyle, motion, className, style, }: OrderBookProps): ReactElement;