@lilt-ui/charts 0.3.0 → 0.5.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 +45 -0
- package/dist/activity-ring.d.ts +3 -1
- package/dist/cards/activity-ring-card.d.ts +3 -1
- 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 +15 -3
- package/dist/cards/combo-chart-card.d.ts +4 -2
- package/dist/cards/funnel-chart-card.d.ts +26 -2
- package/dist/cards/heatmap-chart-card.d.ts +6 -1
- package/dist/cards/horizontal-bar-chart-card.d.ts +7 -3
- package/dist/cards/progress-card.d.ts +6 -1
- package/dist/cards/radar-chart-card.d.ts +9 -2
- package/dist/cards/radial-chart-card.d.ts +14 -5
- package/dist/cards/range-chart-card.d.ts +3 -1
- package/dist/cards/sankey-chart-card.d.ts +6 -1
- package/dist/cards/scatter-chart-card.d.ts +11 -2
- package/dist/cards/slope-chart-card.d.ts +6 -1
- package/dist/cards/stat-card.d.ts +7 -2
- package/dist/{cartesian-card-Dcd0ZnQL.js → cartesian-card-7DAiMU3w.js} +2112 -1678
- 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 +3 -1
- package/dist/finance/order-book.d.ts +4 -2
- package/dist/finance.js +492 -447
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2349 -1678
- package/dist/interaction/legend-meter.d.ts +11 -0
- package/dist/interaction/use-category-state.d.ts +2 -0
- package/dist/interaction/use-touch-glide.d.ts +26 -0
- package/dist/interaction/value-legend.d.ts +8 -2
- package/dist/marks/use-range-mark.d.ts +8 -0
- package/dist/motion/use-glide.d.ts +7 -3
- package/dist/primitives/depth-paint.d.ts +103 -0
- package/dist/primitives/isometric-bar.d.ts +18 -0
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +30 -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;
|
|
@@ -10,7 +10,9 @@ export declare function useAcceptedRows<R>(incoming: readonly R[] | null, status
|
|
|
10
10
|
export declare function useCategoryState<T>(rows: readonly RankingRow<T>[], interactive: boolean, onChange: ((selection: CategorySelection<T> | null) => void) | undefined, resetKey?: string | number, columns?: number, selectedId?: string | null, onSelectedIdChange?: (id: string | null) => void, hasAcceptedRows?: boolean, externalHoverId?: string | null): {
|
|
11
11
|
active: RankingRow<T> | undefined;
|
|
12
12
|
pinned: string | null;
|
|
13
|
+
glideRef: (node: Element | null) => void;
|
|
13
14
|
bind: (id: string, index: number) => {
|
|
15
|
+
'data-glide-id': string;
|
|
14
16
|
ref: (node: HTMLButtonElement | null) => void;
|
|
15
17
|
tabIndex: number;
|
|
16
18
|
'aria-pressed': boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** How long a still finger rests before it glides in any direction instead of scrolling. */
|
|
2
|
+
export declare const TOUCH_HOLD_MS = 320;
|
|
3
|
+
/** How far a finger travels before it counts as a swipe rather than a tap. */
|
|
4
|
+
export declare const TOUCH_SLOP = 8;
|
|
5
|
+
export interface TouchGlideOptions<T> {
|
|
6
|
+
/** What sits under the finger: an item id, a spoke index, or null for empty glass. */
|
|
7
|
+
resolve: (clientX: number, clientY: number, root: Element) => T | null;
|
|
8
|
+
/** Called as the finger glides, and with null when the gesture ends without a lift. */
|
|
9
|
+
onGlide: (value: T | null) => void;
|
|
10
|
+
/** A glide lifted over an item: pin it. */
|
|
11
|
+
onLift?: (value: T | null) => void;
|
|
12
|
+
/** A tap with no glide. Leave unset where the item's own click already handles taps. */
|
|
13
|
+
onTap?: (value: T | null) => void;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Finds the nearest `data-glide-id` under a point, for families whose marks are elements. */
|
|
17
|
+
export declare function glideTarget(clientX: number, clientY: number, root: Element): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Touch for charts whose marks are separate elements, or are found by position. A finger has no
|
|
20
|
+
* hover and a touch stays with the element it first landed on, so this follows the point under
|
|
21
|
+
* the finger instead. A sideways swipe glides at once (the plot pans only vertically); a press and
|
|
22
|
+
* hold glides in any direction without scrolling the page; lifting after a glide pins.
|
|
23
|
+
*
|
|
24
|
+
* Returns a callback ref for the plot, so a plot that mounts after loading is still wired.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useTouchGlide<T>(options: TouchGlideOptions<T>): (node: Element | null) => void;
|
|
@@ -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;
|
|
@@ -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
|
}
|
|
@@ -6,8 +6,12 @@ export interface GlideSpring {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* A motion value that springs to each target it is given and always lands exactly on it.
|
|
9
|
-
* Every move is its own
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Every move is its own glide to a known destination, rather than a spring that follows another
|
|
10
|
+
* value, so an interrupted gesture or a paused frame can never leave it resting short of its
|
|
11
|
+
* target. A new target takes over from wherever the value is, keeping its speed.
|
|
12
|
+
*
|
|
13
|
+
* The spring advances by at most one frame's time per frame. When the page stalls, such as while
|
|
14
|
+
* linked charts re-render together, the glide carries on from where it was instead of jumping
|
|
15
|
+
* ahead to where the clock says it should be.
|
|
12
16
|
*/
|
|
13
17
|
export declare function useGlide(initial: number, spring: GlideSpring): readonly [MotionValue<number>, (to: number, instant?: boolean) => void];
|
|
@@ -0,0 +1,103 @@
|
|
|
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, }: {
|
|
88
|
+
d: string;
|
|
89
|
+
color: string;
|
|
90
|
+
width: number;
|
|
91
|
+
dasharray?: string;
|
|
92
|
+
opacity?: number;
|
|
93
|
+
}): ReactElement;
|
|
94
|
+
/** The width a line takes as a tube: wide enough for its light to read. */
|
|
95
|
+
export declare const tubeWidth: (lineWidth?: number) => number;
|
|
96
|
+
/**
|
|
97
|
+
* A lit sphere for any circle, mapped to the circle's own bounds: a highlight toward the upper
|
|
98
|
+
* left, the series color through the middle, and shade at the far rim.
|
|
99
|
+
*/
|
|
100
|
+
export declare function SphereGradient({ id, color }: {
|
|
101
|
+
id: string;
|
|
102
|
+
color: string;
|
|
103
|
+
}): 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;
|