@lilt-ui/charts 0.11.0 → 0.12.1

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.
@@ -13,6 +13,11 @@ export interface AxisCursor {
13
13
  * with the bars that light up, for marks that snap to a column rather than glide.
14
14
  */
15
15
  columnX: MotionValue<number>;
16
+ /**
17
+ * The color of the inspected column's mark: the hovered series' bar, or a candle's direction.
18
+ * Empty until a column is read; it keeps the last color while the band fades out.
19
+ */
20
+ columnColor: MotionValue<string>;
16
21
  y: MotionValue<number>;
17
22
  /** 1 while this chart owns an inspection with pills on its axes, else 0. */
18
23
  active: MotionValue<number>;
@@ -2,7 +2,11 @@ import { ReactElement, ReactNode } from 'react';
2
2
  import { ChartSelection, ChartSeries, ChartTooltipContext } from '../types';
3
3
  import { ChartSnapshot } from '../chart-context';
4
4
  import { PlotMark } from '../marks/contract';
5
- /** How the crosshair travels between points; pins travel the same way. */
5
+ /**
6
+ * How the crosshair travels between points; the band, pills, and pins travel the same way.
7
+ * Critically damped and quick (most of a column in about 130ms), so the readout lands with the column it reads
8
+ * instead of trailing it.
9
+ */
6
10
  export declare const SPRING_TRANSITION: {
7
11
  stiffness: number;
8
12
  damping: number;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Lets go of a card's pin the way a Cartesian chart does: on any press that misses the marks,
3
+ * whether on empty plot, elsewhere in the card, or off it, and on Escape while the card has the
4
+ * keyboard (focus inside it, or the last press landed in it). Presses on controls keep the pin,
5
+ * so a legend item or period menu decides for itself.
6
+ */
7
+ export declare function usePinRelease(root: Element | null, pinned: boolean, release: (() => void) | undefined,
8
+ /** Whether a press inside the plot landed on a mark. */
9
+ onMark: (event: PointerEvent, root: Element) => boolean): void;
@@ -12,6 +12,10 @@ export interface TouchGlideOptions<T> {
12
12
  /** A tap with no glide. Leave unset where the item's own click already handles taps. */
13
13
  onTap?: (value: T | null) => void;
14
14
  disabled?: boolean;
15
+ /** Whether the card holds a pin, so Escape or a press that misses the marks lets it go. */
16
+ pinned?: boolean;
17
+ /** Releases the pin. See `usePinRelease`. */
18
+ onRelease?: () => void;
15
19
  }
16
20
  /** Finds the nearest `data-glide-id` under a point, for families whose marks are elements. */
17
21
  export declare function glideTarget(clientX: number, clientY: number, root: Element): string | null;
@@ -33,6 +33,11 @@ export interface MarkSpec<P> {
33
33
  loading?: (props: P) => LoadingMark;
34
34
  /** Draws one observation emphasized, over the dimmed marks, while it is inspected. */
35
35
  highlight?: (props: P, input: MarkHighlightInput) => ReactNode;
36
+ /**
37
+ * The color one observation is drawn in, when the mark decides it (rising and falling
38
+ * candles). Otherwise the series' `colorAt`, then its color.
39
+ */
40
+ color?: (props: P, input: Omit<MarkHighlightInput, 'color'>) => string | undefined;
36
41
  }
37
42
  export interface MarkHighlightInput {
38
43
  row: NormalizedRow<unknown>;
@@ -47,6 +52,7 @@ export interface PlotMark {
47
52
  fields: readonly string[];
48
53
  loading?: LoadingMark;
49
54
  highlight?: (input: MarkHighlightInput) => ReactNode;
55
+ color?: (input: Omit<MarkHighlightInput, 'color'>) => string | undefined;
50
56
  }
51
57
  export declare function defineMark<P>(component: (props: P) => ReactElement, spec: MarkSpec<P>): (props: P) => ReactElement;
52
58
  /** Marks placed directly in a plot, or inside fragments there, in document order. */
@@ -46,9 +46,5 @@ export declare function numberCells(text: string, parts?: readonly Intl.NumberFo
46
46
  export declare function interpolationFrameValue(frame: number, target: number): number;
47
47
  /** The next stop on a digit reel that shows `digit`, turning from `from` in the direction of change. */
48
48
  export declare function reelTarget(from: number, digit: number, direction: 1 | -1): number;
49
- /**
50
- * A number that animates between values. Characters sit in slots keyed by meaning, so only the
51
- * places that change move, symbols hold still, and places that appear or leave ease the width
52
- * open or shut. Screen readers get the settled value once; the moving glyphs are hidden.
53
- */
54
- export declare function AnimatedNumber({ value, format, className, motion: motionMode, variant: requested, }: AnimatedNumberProps): ReactElement;
49
+ /** AnimatedNumber with its own MotionScope, so it animates wherever it is rendered. */
50
+ export declare function AnimatedNumber(props: AnimatedNumberProps): ReactElement;
@@ -0,0 +1,36 @@
1
+ import { NormalizedData } from '../engine/normalize';
2
+ /**
3
+ * Areas move with the same restraint as lines and bars. They arrive lifting a little from below
4
+ * on the bars' spring, softly blurred until they land. A new period moves on a line's clock with
5
+ * a slight lean in reading order, so the change runs left to right rather than all at once.
6
+ */
7
+ /** How long a period change takes to roll across an area chart. */
8
+ export declare const FLOW_DURATION = 480;
9
+ /** How far column `index` of `count` has moved toward its new value, at `progress` of the wave. */
10
+ export declare function flowProgress(progress: number, index: number, count: number): number;
11
+ /** One frame of a period change on an area chart: rows of the same shape, moving as a wave. */
12
+ export declare function flowFrame<T>(from: NormalizedData<T>, to: NormalizedData<T>, progress: number): NormalizedData<T>;
13
+ /**
14
+ * An area's first arrival at `elapsed` milliseconds into the chart's entrance: how far it has
15
+ * risen from its floor (the spring may pass 1 briefly) and the blur it still carries.
16
+ */
17
+ export declare function riseAt(elapsed: number): {
18
+ rise: number;
19
+ blur: number;
20
+ };
21
+ /**
22
+ * The SVG transform and filter that raise a mark from `floor` (its baseline in pixels), or
23
+ * nothing once it has landed.
24
+ */
25
+ export declare function riseStyle(elapsed: number, floor: number): {
26
+ transform?: string;
27
+ filter?: string;
28
+ };
29
+ /** Where an area stands: the zero line, kept inside the plot. */
30
+ export declare function areaFloor(snapshot: {
31
+ yToPixel: (value: number) => number;
32
+ plot: {
33
+ top: number;
34
+ bottom: number;
35
+ };
36
+ }): number;
@@ -0,0 +1 @@
1
+ export { domMax } from 'motion/react';
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Gives `m` elements their animation features. Lilt draws with `m` instead of `motion`, so a
4
+ * chart pays only for the Motion features it uses: value and enter/exit animation everywhere,
5
+ * and, with `layout`, layout animation where something reorders. Layout features load after
6
+ * first paint; until then the scope animates like any other, so nothing waits on them. Wrap
7
+ * every root that renders `m` elements; nesting is cheap.
8
+ */
9
+ export declare function MotionScope({ children, layout, }: {
10
+ children?: ReactNode;
11
+ layout?: boolean;
12
+ }): import("react/jsx-runtime").JSX.Element;
@@ -14,4 +14,4 @@ export interface GlideSpring {
14
14
  * linked charts re-render together, the glide carries on from where it was instead of jumping
15
15
  * ahead to where the clock says it should be.
16
16
  */
17
- export declare function useGlide(initial: number, spring: GlideSpring): readonly [MotionValue<number>, (to: number, instant?: boolean) => void];
17
+ export declare function useGlide(initial: number, spring: GlideSpring): readonly [MotionValue<number>, (to: number, instant?: boolean) => void, MotionValue<number>];
@@ -0,0 +1,6 @@
1
+ import { MotionValue } from 'motion/react';
2
+ /**
3
+ * A CSS `filter` that blurs with a glide's speed, the way a fast-moving object smears, and clears
4
+ * as it lands. Reduced motion never blurs.
5
+ */
6
+ export declare function useMotionBlur(speed: MotionValue<number>, reducedMotion: boolean, max?: number): MotionValue<string>;
@@ -0,0 +1,2 @@
1
+ import { domMax as e } from "motion/react";
2
+ export { e as domMax };
@@ -2,6 +2,7 @@ import { ReactElement } from 'react';
2
2
  /**
3
3
  * Behind a bar or column chart, the inspected column is lit as a whole: a soft band the height of
4
4
  * the plot, a little wider than its bars. A column is what a reader inspects on a bar chart, so
5
- * the band says so where a thin crosshair would not.
5
+ * the band says so where a thin crosshair would not. It takes the color of the column it holds,
6
+ * so a falling candle is lit in red and a rising one in green.
6
7
  */
7
8
  export declare function HoverBand(): ReactElement | null;