@lilt-ui/charts 0.5.0 → 0.7.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 (36) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/activity-ring.d.ts +3 -2
  3. package/dist/cards/activity-ring-card.d.ts +3 -2
  4. package/dist/cards/cartesian-card.d.ts +15 -2
  5. package/dist/cards/funnel-chart-card.d.ts +3 -2
  6. package/dist/cards/heatmap-chart-card.d.ts +3 -2
  7. package/dist/cards/horizontal-bar-chart-card.d.ts +3 -2
  8. package/dist/cards/progress-card.d.ts +3 -2
  9. package/dist/cards/radar-chart-card.d.ts +3 -2
  10. package/dist/cards/radial-chart-card.d.ts +4 -2
  11. package/dist/cards/sankey-chart-card.d.ts +3 -2
  12. package/dist/cards/scatter-chart-card.d.ts +3 -2
  13. package/dist/cards/slope-chart-card.d.ts +3 -2
  14. package/dist/cards/stat-card.d.ts +3 -2
  15. package/dist/chart-context.d.ts +8 -1
  16. package/dist/chart.d.ts +1 -1
  17. package/dist/engine/decimate.d.ts +25 -0
  18. package/dist/finance/cards/depth-chart-card.d.ts +3 -2
  19. package/dist/finance/order-book.d.ts +4 -2
  20. package/dist/finance.js +467 -404
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +2488 -2080
  23. package/dist/lifecycle/loading-layer.d.ts +14 -3
  24. package/dist/lifecycle/skeleton-block.d.ts +6 -0
  25. package/dist/lifecycle/skeleton-sheen.d.ts +15 -2
  26. package/dist/lifecycle/use-skeleton-clock.d.ts +5 -0
  27. package/dist/marks/contract.d.ts +15 -0
  28. package/dist/marks/range-loading-mark.d.ts +3 -0
  29. package/dist/primitives/depth-paint.d.ts +5 -1
  30. package/dist/primitives/runoff.d.ts +6 -7
  31. package/dist/{report-context-Cz0AYdV2.js → report-context-CkzH-r8B.js} +130 -129
  32. package/dist/{cartesian-card-7DAiMU3w.js → skeleton-block-C110l-2a.js} +2223 -1856
  33. package/dist/styles.css +1 -1
  34. package/dist/types.d.ts +14 -0
  35. package/dist/watch.js +1 -1
  36. package/package.json +1 -1
@@ -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;
@@ -0,0 +1,6 @@
1
+ /** A neutral HTML bar; its container chooses motion and flat or solid paint. */
2
+ export declare function SkeletonBlock({ width, height, step, }: {
3
+ width?: string;
4
+ height?: number;
5
+ step?: number;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -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>;
@@ -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;
@@ -0,0 +1,3 @@
1
+ import { LoadingMark } from './contract';
2
+ /** Range placeholders draw through the same geometry as the measured marks. */
3
+ export declare function rangeLoadingMark(kind: 'range' | 'error' | 'boxplot', depth?: boolean): LoadingMark;
@@ -84,12 +84,16 @@ export declare function DropShadow({ id, size, region, }: {
84
84
  * A line drawn as a lit tube: every layer of `tubeLayers` along one path. The centerline stays
85
85
  * the line's own path, so every point reads exactly where the flat line puts it.
86
86
  */
87
- export declare function TubePath({ d, color, width, dasharray, opacity, }: {
87
+ export declare function TubePath({ d, color, width, dasharray, opacity, pathLength, className, }: {
88
88
  d: string;
89
89
  color: string;
90
90
  width: number;
91
91
  dasharray?: string;
92
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;
93
97
  }): ReactElement;
94
98
  /** The width a line takes as a tube: wide enough for its light to read. */
95
99
  export declare const tubeWidth: (lineWidth?: number) => number;
@@ -20,19 +20,17 @@ export declare function segmentEdges(edges: RunoffEdges | null, index: number, c
20
20
  left?: number;
21
21
  right?: number;
22
22
  };
23
- /** One continuous line path, so the extension meets the curve without a seam. */
24
- export declare function extendLinePath(segment: GeometrySegment, { left, right }: {
23
+ type Edges = {
25
24
  left?: number;
26
25
  right?: number;
27
- }): string;
26
+ };
27
+ /** One continuous line path, so the extension meets the curve without a seam. */
28
+ export declare function extendLinePath(segment: GeometrySegment, edges: Edges): string;
28
29
  /**
29
30
  * One continuous area outline. Area paths trace the upper line forward and the lower boundary
30
31
  * back, so the extension adds flat runs at both ends of each boundary.
31
32
  */
32
- export declare function extendAreaPath(segment: GeometrySegment, { left, right }: {
33
- left?: number;
34
- right?: number;
35
- }): string;
33
+ export declare function extendAreaPath(segment: GeometrySegment, edges: Edges): string;
36
34
  /**
37
35
  * A mask ID that changes with the fade geometry. Chrome can keep painting a stale, empty mask
38
36
  * after the gradient inside it changes; a new ID forces a fresh mask on every geometry change.
@@ -47,3 +45,4 @@ export declare function RunoffFade({ id, snapshot, edges, }: {
47
45
  snapshot: ChartSnapshot<unknown>;
48
46
  edges: RunoffEdges;
49
47
  }): ReactElement;
48
+ export {};