@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.
- package/CHANGELOG.md +41 -0
- package/dist/activity-ring.d.ts +5 -2
- package/dist/cards/activity-ring-card.d.ts +5 -2
- package/dist/cards/bar-chart-card.d.ts +5 -2
- package/dist/cards/box-plot-card.d.ts +3 -1
- package/dist/cards/cartesian-card.d.ts +22 -3
- package/dist/cards/combo-chart-card.d.ts +4 -2
- package/dist/cards/funnel-chart-card.d.ts +27 -2
- package/dist/cards/heatmap-chart-card.d.ts +8 -2
- package/dist/cards/horizontal-bar-chart-card.d.ts +9 -4
- package/dist/cards/progress-card.d.ts +8 -2
- package/dist/cards/radar-chart-card.d.ts +10 -2
- package/dist/cards/radial-chart-card.d.ts +16 -5
- package/dist/cards/range-chart-card.d.ts +3 -1
- package/dist/cards/sankey-chart-card.d.ts +8 -2
- package/dist/cards/scatter-chart-card.d.ts +12 -2
- package/dist/cards/slope-chart-card.d.ts +8 -2
- package/dist/cards/stat-card.d.ts +9 -3
- package/dist/chart.d.ts +1 -1
- package/dist/engine/depth.d.ts +42 -0
- package/dist/engine/isometric-bars.d.ts +25 -0
- package/dist/engine/ranges.d.ts +31 -0
- package/dist/finance/candle-geometry.d.ts +13 -2
- package/dist/finance/candles.d.ts +5 -0
- package/dist/finance/cards/candlestick-chart-card.d.ts +6 -1
- package/dist/finance/cards/depth-chart-card.d.ts +5 -2
- package/dist/finance/order-book.d.ts +7 -3
- package/dist/finance.js +547 -440
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3081 -2162
- package/dist/interaction/legend-meter.d.ts +11 -0
- package/dist/interaction/value-legend.d.ts +8 -2
- package/dist/lifecycle/loading-layer.d.ts +14 -3
- package/dist/lifecycle/skeleton-block.d.ts +6 -0
- package/dist/lifecycle/skeleton-sheen.d.ts +15 -2
- package/dist/lifecycle/use-skeleton-clock.d.ts +5 -0
- package/dist/marks/contract.d.ts +15 -0
- package/dist/marks/range-loading-mark.d.ts +3 -0
- package/dist/marks/use-range-mark.d.ts +8 -0
- package/dist/primitives/depth-paint.d.ts +107 -0
- package/dist/primitives/isometric-bar.d.ts +18 -0
- package/dist/{cartesian-card-Cj1o38DC.js → skeleton-block-Uf1lywJi.js} +2580 -1936
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +38 -4
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
/** The largest positive value a `bars` legend measures against, or null when there is none. */
|
|
3
|
+
export declare function legendMeterScale(values: readonly (number | null)[]): number | null;
|
|
4
|
+
/**
|
|
5
|
+
* A thin bar under a legend value, as long as the value against the largest one shown. Missing,
|
|
6
|
+
* zero and negative values draw an empty track rather than a false sliver.
|
|
7
|
+
*/
|
|
8
|
+
export declare function LegendMeter({ value, scale, }: {
|
|
9
|
+
value: number | null;
|
|
10
|
+
scale: number | null;
|
|
11
|
+
}): ReactElement;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { CardLegend, ChartLegendSwatch, ChartLegendVariant } from '../types';
|
|
2
3
|
export interface ValueLegendEntry {
|
|
3
4
|
id: string;
|
|
4
5
|
label: string;
|
|
@@ -6,9 +7,14 @@ export interface ValueLegendEntry {
|
|
|
6
7
|
value: number | null;
|
|
7
8
|
formattedValue: string;
|
|
8
9
|
}
|
|
10
|
+
/** The legend layout a card's `legend` prop names: its value tiles are the `cards` layout. */
|
|
11
|
+
export declare const cardLegendVariant: (legend: CardLegend) => ChartLegendVariant;
|
|
9
12
|
export interface ValueLegendProps<Entries extends readonly ValueLegendEntry[]> {
|
|
10
13
|
items: Entries;
|
|
11
|
-
|
|
14
|
+
/** `cards` (default), `inline`, `list`, `pills`, or `bars`. */
|
|
15
|
+
variant?: ChartLegendVariant;
|
|
16
|
+
/** The mark beside each label: `square` (default), `dot`, or `line`. */
|
|
17
|
+
swatch?: ChartLegendSwatch;
|
|
12
18
|
activeId?: NoInfer<Entries[number]['id']> | null;
|
|
13
19
|
selectedId?: NoInfer<Entries[number]['id']> | null;
|
|
14
20
|
onHoverIdChange?: (id: NoInfer<Entries[number]['id']> | null) => void;
|
|
@@ -29,4 +35,4 @@ export interface ValueLegendProps<Entries extends readonly ValueLegendEntry[]> {
|
|
|
29
35
|
style?: CSSProperties;
|
|
30
36
|
}
|
|
31
37
|
/** Family-neutral values and layout. The consumer supplies measurements and interaction ownership. */
|
|
32
|
-
export declare function ValueLegend<const Entries extends readonly ValueLegendEntry[]>({ items, variant, activeId, selectedId, onHoverIdChange, onSelectedIdChange, hiddenIds, onHiddenIdsChange, renderLabel, renderValue, renderSwatch, renderItem, 'aria-label': ariaLabel, className, style, }: ValueLegendProps<Entries>): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare function ValueLegend<const Entries extends readonly ValueLegendEntry[]>({ items, variant, swatch, activeId, selectedId, onHoverIdChange, onSelectedIdChange, hiddenIds, onHiddenIdsChange, renderLabel, renderValue, renderSwatch, renderItem, 'aria-label': ariaLabel, className, style, }: ValueLegendProps<Entries>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { ChartAxisStyle } from '../types';
|
|
2
|
+
import { ChartAxisStyle, ChartBarAppearance, ChartLoadingStyle } from '../types';
|
|
3
|
+
import { LoadingMark } from '../marks/contract';
|
|
4
|
+
export { skeletonClock, SKELETON_CYCLE } from './use-skeleton-clock';
|
|
3
5
|
export interface LoadingLayerProps {
|
|
4
6
|
width: number;
|
|
5
7
|
height: number;
|
|
@@ -12,17 +14,26 @@ export interface LoadingLayerProps {
|
|
|
12
14
|
reducedMotion: boolean;
|
|
13
15
|
id: string;
|
|
14
16
|
/** The marks the skeleton stands in for. */
|
|
15
|
-
marks?: 'line' | 'bars' | 'area-stack' | 'bar-stack';
|
|
17
|
+
marks?: 'line' | 'bars' | 'area-stack' | 'bar-stack' | 'columns';
|
|
18
|
+
mark?: LoadingMark;
|
|
16
19
|
compact?: boolean;
|
|
17
20
|
barCount?: number;
|
|
18
21
|
seriesCount?: number;
|
|
22
|
+
barAppearances?: readonly ChartBarAppearance[];
|
|
23
|
+
barWidth?: number;
|
|
19
24
|
showLine?: boolean;
|
|
25
|
+
lineDepth?: boolean;
|
|
20
26
|
/** Mirror the real axis: which placeholders and grid rows to draw. Defaults to `classic`. */
|
|
21
27
|
axis?: ChartAxisStyle;
|
|
22
28
|
/** Padding between the plot edges and label placeholders, as on the real axis. */
|
|
23
29
|
inset?: number;
|
|
24
30
|
/** Gap between the plot edges and the skeleton shape; 0 when marks run edge to edge. */
|
|
25
31
|
edge?: number;
|
|
32
|
+
/**
|
|
33
|
+
* How the skeleton moves: `shimmer` (default) sweeps a highlight over still shapes, `draw`
|
|
34
|
+
* reveals bars or contours in order, and `breathe` lets them rise and settle.
|
|
35
|
+
*/
|
|
36
|
+
loadingStyle?: ChartLoadingStyle;
|
|
26
37
|
}
|
|
27
38
|
export declare const SKELETON_CONTOUR: number[];
|
|
28
39
|
export interface SkeletonGeometry {
|
|
@@ -35,4 +46,4 @@ export interface SkeletonGeometry {
|
|
|
35
46
|
xBars: string;
|
|
36
47
|
}
|
|
37
48
|
export declare function buildSkeletonGeometry({ width, height, left, right, top, bottom, axis, inset, edge, }: Pick<LoadingLayerProps, 'width' | 'height' | 'left' | 'right' | 'top' | 'bottom' | 'axis' | 'inset' | 'edge'>): SkeletonGeometry;
|
|
38
|
-
export declare function LoadingLayer({ width, height, left, right, top, bottom, visible, opacity, reducedMotion, id, marks, compact, barCount, seriesCount, showLine, axis, inset: labelInset, edge, }: LoadingLayerProps): ReactElement | null;
|
|
49
|
+
export declare function LoadingLayer({ width, height, left, right, top, bottom, visible, opacity, reducedMotion, id, marks, mark, compact, barCount, seriesCount, barAppearances, barWidth, showLine, lineDepth, axis, inset: labelInset, edge, loadingStyle, }: LoadingLayerProps): ReactElement | null;
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { ChartLoadingStyle } from '../types';
|
|
3
|
+
export declare const SKELETON_INK = "color-mix(in srgb, var(--lilt-skeleton) 64%, var(--lilt-surface))";
|
|
2
4
|
export interface SkeletonSheenProps {
|
|
3
5
|
/** The skeleton shapes. Their CSS paints them with `--lilt-skeleton-paint`. */
|
|
4
6
|
children: ReactNode;
|
|
7
|
+
/** A plain silhouette when shaded children contain their own SVG definitions. */
|
|
8
|
+
mask?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* For rings: a white path with `pathLength={1}`, `strokeDasharray="1"`, and the
|
|
11
|
+
* `lilt-skeleton__sweep` class. Drawing sweeps it round; breathing fills and empties part of
|
|
12
|
+
* it. Other skeletons move each mark on its own with `data-skeleton` (see loading.css).
|
|
13
|
+
*/
|
|
14
|
+
sweep?: ReactNode;
|
|
15
|
+
loadingStyle?: ChartLoadingStyle;
|
|
16
|
+
depth?: boolean;
|
|
5
17
|
/** The area the sheen sweeps across, in the SVG's own units. */
|
|
6
18
|
width: number;
|
|
7
19
|
height: number;
|
|
@@ -13,6 +25,7 @@ export interface SkeletonSheenProps {
|
|
|
13
25
|
/**
|
|
14
26
|
* Skeleton shapes with the same moving highlight as the Cartesian loading state. The shapes are
|
|
15
27
|
* drawn once for the eye and once more, in white, as the mask the highlight shows through, so
|
|
16
|
-
* the sheen lights only the placeholder and never the space around it.
|
|
28
|
+
* the sheen lights only the placeholder and never the space around it. With `draw` or `breathe`
|
|
29
|
+
* the highlight gives way to the marks' own motion.
|
|
17
30
|
*/
|
|
18
|
-
export declare function SkeletonSheen({ children, width, height, x, y, reduced, }: SkeletonSheenProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function SkeletonSheen({ children, mask, sweep, loadingStyle, depth, width, height, x, y, reduced, }: SkeletonSheenProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ChartLoadingStyle } from '../types';
|
|
2
|
+
export declare const SKELETON_CYCLE = 2800;
|
|
3
|
+
export declare function skeletonClock(now: number): string;
|
|
4
|
+
/** Read the shared wall clock after hydration, including when the selected style changes. */
|
|
5
|
+
export declare function useSkeletonClock<Element extends HTMLElement | SVGElement>(active: boolean, style: ChartLoadingStyle): import('react').RefObject<Element | null>;
|
package/dist/marks/contract.d.ts
CHANGED
|
@@ -2,6 +2,19 @@ import { ReactElement, ReactNode } from 'react';
|
|
|
2
2
|
import { ChartSnapshot } from '../chart-context';
|
|
3
3
|
import { NormalizedRow } from '../engine/normalize';
|
|
4
4
|
import { ChartSeries } from '../types';
|
|
5
|
+
import { RangeScales } from '../engine/ranges';
|
|
6
|
+
/** A neutral column uses the mark's own geometry, never an accepted observation. */
|
|
7
|
+
export interface LoadingMark {
|
|
8
|
+
kind: string;
|
|
9
|
+
depth?: boolean;
|
|
10
|
+
render: (input: {
|
|
11
|
+
cx: number;
|
|
12
|
+
low: number;
|
|
13
|
+
high: number;
|
|
14
|
+
scales: RangeScales;
|
|
15
|
+
mask: boolean;
|
|
16
|
+
}) => ReactNode;
|
|
17
|
+
}
|
|
5
18
|
/**
|
|
6
19
|
* The private contract every range mark is built on. A mark is an ordinary primitive that
|
|
7
20
|
* draws from the chart context; its spec tells the plot how to lay it out and inspect it.
|
|
@@ -17,6 +30,7 @@ export interface MarkSpec<P> {
|
|
|
17
30
|
series: (props: P) => string;
|
|
18
31
|
/** Field IDs the mark reads from its series. */
|
|
19
32
|
fields: (props: P) => readonly string[];
|
|
33
|
+
loading?: (props: P) => LoadingMark;
|
|
20
34
|
/** Draws one observation emphasized, over the dimmed marks, while it is inspected. */
|
|
21
35
|
highlight?: (props: P, input: MarkHighlightInput) => ReactNode;
|
|
22
36
|
}
|
|
@@ -31,6 +45,7 @@ export interface PlotMark {
|
|
|
31
45
|
series: string;
|
|
32
46
|
layout: MarkSpec<unknown>['layout'];
|
|
33
47
|
fields: readonly string[];
|
|
48
|
+
loading?: LoadingMark;
|
|
34
49
|
highlight?: (input: MarkHighlightInput) => ReactNode;
|
|
35
50
|
}
|
|
36
51
|
export declare function defineMark<P>(component: (props: P) => ReactElement, spec: MarkSpec<P>): (props: P) => ReactElement;
|
|
@@ -11,6 +11,14 @@ export interface RangeMarkState {
|
|
|
11
11
|
/** The reveal mask while the entrance sweeps in. */
|
|
12
12
|
mask: string | undefined;
|
|
13
13
|
clipPath: string;
|
|
14
|
+
/** Like `clipPath`, with headroom above the plot for the tops of marks drawn with depth. */
|
|
15
|
+
depthClip: {
|
|
16
|
+
id: string;
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
14
22
|
reducedMotion: boolean;
|
|
15
23
|
inspecting: boolean;
|
|
16
24
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ReactElement, SVGProps } from 'react';
|
|
2
|
+
/** Positive lightens toward white, negative darkens toward black, in oklab to keep chroma. */
|
|
3
|
+
export declare const shade: (color: string, amount: number) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Gradient stops through `[offset, shade]` keys, eased between each pair. Linear ramps between
|
|
6
|
+
* a few stops leave visible bands where the slope changes; smoothstep keeps every join soft.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ramp(color: string, keys: readonly (readonly [number, number])[]): import("react/jsx-runtime").JSX.Element[];
|
|
9
|
+
/** Flat face colors for marks drawn in batches, where one gradient per shape would cost too much. */
|
|
10
|
+
export declare const prismShades: (color: string) => {
|
|
11
|
+
front: string;
|
|
12
|
+
top: string;
|
|
13
|
+
side: string;
|
|
14
|
+
};
|
|
15
|
+
/** Batched prism faces: every side, then every top, then every front, each in its own shade. */
|
|
16
|
+
export declare function PrismPaths({ batches, front, }: {
|
|
17
|
+
batches: {
|
|
18
|
+
sides: {
|
|
19
|
+
entries(): {
|
|
20
|
+
color: string;
|
|
21
|
+
d: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
tops: {
|
|
25
|
+
entries(): {
|
|
26
|
+
color: string;
|
|
27
|
+
d: string;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
fronts: {
|
|
31
|
+
entries(): {
|
|
32
|
+
color: string;
|
|
33
|
+
d: string;
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/** Front paint for a color; defaults to the color itself. */
|
|
38
|
+
front?: (color: string) => SVGProps<SVGPathElement>;
|
|
39
|
+
}): ReactElement;
|
|
40
|
+
/** A clip with headroom for the tops of marks drawn with depth. */
|
|
41
|
+
export declare function DepthClip({ clip, }: {
|
|
42
|
+
clip: {
|
|
43
|
+
id: string;
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
}): ReactElement;
|
|
50
|
+
export interface TubeLayer {
|
|
51
|
+
strokeWidth: number;
|
|
52
|
+
/** Shade applied to the band's color, as in `shade`. */
|
|
53
|
+
amount: number;
|
|
54
|
+
transform: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The cross-section of a band lit as a tube or a groove, as stacked strokes of its centerline:
|
|
58
|
+
* the full width first, then ever narrower strokes moved toward the light. Every layer stays
|
|
59
|
+
* inside the full stroke, round caps included, so the band's outline never changes: a ring,
|
|
60
|
+
* arc, or progress track keeps its exact angle and length.
|
|
61
|
+
*
|
|
62
|
+
* A `tube` bulges toward the reader: a shaded rim, a lit crown, and a narrow highlight toward
|
|
63
|
+
* the upper left. A `groove` is cut into the card: its upper-left wall is in shadow.
|
|
64
|
+
*/
|
|
65
|
+
export declare function tubeLayers(width: number, kind?: 'tube' | 'groove',
|
|
66
|
+
/** Where the light falls from, as a unit vector; the upper left by default. */
|
|
67
|
+
light?: readonly [number, number]): TubeLayer[];
|
|
68
|
+
/** A soft shadow under a drawing lit from the upper left, lifting it off the card. */
|
|
69
|
+
export declare function DropShadow({ id, size, region, }: {
|
|
70
|
+
id: string;
|
|
71
|
+
size: number;
|
|
72
|
+
/**
|
|
73
|
+
* The area the shadow may cover, in the SVG's units. Defaults to a margin around the shape,
|
|
74
|
+
* which is too tight for a thin, nearly flat line.
|
|
75
|
+
*/
|
|
76
|
+
region?: {
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
};
|
|
82
|
+
}): ReactElement;
|
|
83
|
+
/**
|
|
84
|
+
* A line drawn as a lit tube: every layer of `tubeLayers` along one path. The centerline stays
|
|
85
|
+
* the line's own path, so every point reads exactly where the flat line puts it.
|
|
86
|
+
*/
|
|
87
|
+
export declare function TubePath({ d, color, width, dasharray, opacity, pathLength, className, }: {
|
|
88
|
+
d: string;
|
|
89
|
+
color: string;
|
|
90
|
+
width: number;
|
|
91
|
+
dasharray?: string;
|
|
92
|
+
opacity?: number;
|
|
93
|
+
/** With `dasharray`, lets every layer draw along the line together, e.g. a loading pen. */
|
|
94
|
+
pathLength?: number;
|
|
95
|
+
/** Set on every layer. */
|
|
96
|
+
className?: string;
|
|
97
|
+
}): ReactElement;
|
|
98
|
+
/** The width a line takes as a tube: wide enough for its light to read. */
|
|
99
|
+
export declare const tubeWidth: (lineWidth?: number) => number;
|
|
100
|
+
/**
|
|
101
|
+
* A lit sphere for any circle, mapped to the circle's own bounds: a highlight toward the upper
|
|
102
|
+
* left, the series color through the middle, and shade at the far rim.
|
|
103
|
+
*/
|
|
104
|
+
export declare function SphereGradient({ id, color }: {
|
|
105
|
+
id: string;
|
|
106
|
+
color: string;
|
|
107
|
+
}): ReactElement;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { barMarkPath, BarGeometry } from '../engine/bars';
|
|
2
|
+
/**
|
|
3
|
+
* Paint only: the chart still measures, inspects, and animates the original bar geometry.
|
|
4
|
+
* One key light sits above, in front, and to the left: the roof is brightest, the front is lit
|
|
5
|
+
* and falls off toward the floor, and the side turns away into shade. Edges come from the faces
|
|
6
|
+
* meeting, never from stroked lines. `active` raises the light on the inspected bar.
|
|
7
|
+
*/
|
|
8
|
+
export declare function IsometricBar({ bar, mark, id, color, fill, fillOpacity, stroke, strokeWidth, active, }: {
|
|
9
|
+
bar: BarGeometry;
|
|
10
|
+
mark: Parameters<typeof barMarkPath>[1];
|
|
11
|
+
id: string;
|
|
12
|
+
color: string;
|
|
13
|
+
fill: string;
|
|
14
|
+
fillOpacity: number;
|
|
15
|
+
stroke?: string;
|
|
16
|
+
strokeWidth?: number;
|
|
17
|
+
active?: boolean;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|