@graphysdk/react-renderer 1.9.0-beta.1792400629887 → 1.9.0-beta.1792407460425

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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AnchorPlacement } from '@graphysdk/viz-engine';
2
+ import { BoxSize } from '@graphysdk/viz-engine';
2
3
  import { BrandMarkVariant } from '@graphysdk/viz-engine';
3
4
  import { CartesianCoordSystem } from '@graphysdk/viz-engine';
4
5
  import { ColorScheme } from '@graphysdk/viz-engine';
@@ -22,6 +23,8 @@ import { FormattedAxis } from '@graphysdk/viz-engine';
22
23
  import { FormattedHeadline } from '@graphysdk/viz-engine';
23
24
  import { FormattedLegend } from '@graphysdk/viz-engine';
24
25
  import { Geom } from '@graphysdk/viz-engine';
26
+ import { GeomCornerRadius } from '@graphysdk/viz-engine';
27
+ import { GeomEffects } from '@graphysdk/viz-engine';
25
28
  import { GeomName } from '@graphysdk/viz-engine';
26
29
  import { GeomStyleReaders } from '@graphysdk/viz-engine';
27
30
  import { GraphLayout } from '@graphysdk/viz-engine';
@@ -62,6 +65,7 @@ import { StylePointSymbol } from '@graphysdk/viz-engine';
62
65
  import { StyleReadersForLayer } from '@graphysdk/viz-engine';
63
66
  import { StyleReaderTree } from '@graphysdk/viz-engine';
64
67
  import { StyleResolver } from '@graphysdk/viz-engine';
68
+ import { StyleState } from '@graphysdk/viz-engine';
65
69
  import { SVGProps } from 'react';
66
70
  import { TextContent } from '@graphysdk/viz-engine';
67
71
  import { TextMeasurer } from '@graphysdk/viz-engine';
@@ -247,23 +251,23 @@ export declare const DefaultFooter: ({ ref, footerRect, mode, caption, isCaption
247
251
  * at its position rather than traveling to it from an unset attribute at the panel's origin. An
248
252
  * entrance is the layer's to play, through {@link IntroFade} or {@link IntroWipeClip}.
249
253
  */
250
- export declare const DefaultGeomCircle: ({ shouldAnimateTransitions, cx, cy, r, ...paint }: GeomCircleProps) => JSX.Element;
254
+ export declare const DefaultGeomCircle: ({ shouldAnimateTransitions, cx, cy, r, effects, ...paint }: GeomCircleProps) => JSX.Element;
251
255
 
252
256
  /** A straight line whose endpoints spring to their new positions — {@link GeomCircle} for a segment. */
253
- export declare const DefaultGeomLine: ({ shouldAnimateTransitions, x1, y1, x2, y2, ...paint }: GeomLineProps) => JSX.Element;
257
+ export declare const DefaultGeomLine: ({ shouldAnimateTransitions, x1, y1, x2, y2, effects, ...paint }: GeomLineProps) => JSX.Element;
254
258
 
255
259
  /**
256
260
  * A path whose shape morphs to its new one — {@link GeomCircle} for a free shape, such as a polygon between two
257
261
  * bars. A path is drawn in pixels, so it takes the layer it is drawn from as `source`: a resize redraws it where
258
262
  * the percentage marks already are, rather than morphing behind them.
259
263
  */
260
- export declare const DefaultGeomPath: ({ shouldAnimateTransitions, d, source, ...paint }: GeomPathProps) => JSX.Element;
264
+ export declare const DefaultGeomPath: ({ shouldAnimateTransitions, d, source, effects, ...paint }: GeomPathProps) => JSX.Element;
261
265
 
262
266
  /**
263
- * A rect whose origin and size spring to their new values — {@link GeomCircle} for a box. Motion reads `x`
267
+ * A rect whose origin, size and corners spring to their new values — {@link GeomCircle} for a box. Motion reads `x`
264
268
  * and `y` on an SVG element as a transform, so the origin springs through `attrX` and `attrY`, the attributes.
265
269
  */
266
- export declare const DefaultGeomRect: ({ shouldAnimateTransitions, x, y, width, height, ...paint }: GeomRectProps) => JSX.Element;
270
+ export declare const DefaultGeomRect: ({ shouldAnimateTransitions, x, y, width, height, rx, ry, effects, ...paint }: GeomRectShapeProps) => JSX.Element;
267
271
 
268
272
  /**
269
273
  * Default paint for the grid region — per-tick grid lines, drawn inside the panel frame rect. Where a press
@@ -432,6 +436,8 @@ export declare interface GeomCircleProps {
432
436
  stroke?: string;
433
437
  strokeOpacity?: number;
434
438
  strokeWidth?: number;
439
+ /** Shadow, blend mode and filters from `readGeomEffects`. The resting shadow is `'none'` when the layer casts it. */
440
+ effects?: GeomEffects;
435
441
  /** Whether a change of center or radius springs to the new one. Snaps when false. */
436
442
  shouldAnimateTransitions: boolean;
437
443
  /** A geom's own test hook, since the primitive owns the painted element. */
@@ -452,9 +458,9 @@ export declare interface GeomHoverCursor {
452
458
 
453
459
  /**
454
460
  * Pushes a hovered observation key into the central hover, or clears this layer's hover with `null`.
455
- * A non-null key requires a `cursor` — the overlay intercepts the pointer events the cursor-follow
461
+ * A non-null key requires a `cursor` — a live geom takes the pointer events the cursor-follow
456
462
  * tooltip would otherwise read, so the anchor can only come from the geom's own handler. Consumed by
457
- * {@link InteractiveOverlayApi.pushHover} and returned by `useGeomHover`.
463
+ * {@link LiveGeomApi.pushHover} and returned by `useGeomHover`.
458
464
  */
459
465
  export declare interface GeomHoverPush {
460
466
  (key: string, cursor: GeomHoverCursor): void;
@@ -476,24 +482,54 @@ export declare interface GeomLineProps {
476
482
  strokeWidth?: number;
477
483
  strokeDasharray?: string;
478
484
  strokeLinecap?: 'butt' | 'round' | 'square';
485
+ /** Shadow, blend mode and filters from `readGeomEffects`. The resting shadow is `'none'` when the layer casts it. */
486
+ effects?: GeomEffects;
479
487
  /** Whether a change of either endpoint springs to the new one. Snaps when false. */
480
488
  shouldAnimateTransitions: boolean;
481
489
  'data-testid'?: string;
482
490
  }
483
491
 
492
+ /** A live geom's paint function — receives the guaranteed wiring on `input.live`. */
493
+ export declare type GeomLiveRenderFn<G extends GeomName | string = string, C extends CoordKind = CoordKind> = (input: GeomLiveRenderInput<G, C>) => ReactNode;
494
+
495
+ /**
496
+ * The input a live render (`{ fn, options: { live: true } }`) receives: the standard render
497
+ * input plus a guaranteed {@link LiveGeomApi}.
498
+ */
499
+ export declare interface GeomLiveRenderInput<G extends GeomName | string = string, C extends CoordKind = CoordKind> extends GeomRenderInput<G, C> {
500
+ live: LiveGeomApi;
501
+ }
502
+
484
503
  /** A custom geom `getOverlayAnchor` handler's input: the layer, coord system, and the matched observation. */
485
504
  export declare type GeomOverlayAnchorRendererInput = OverlayAnchorInput;
486
505
 
487
- /** An overlay-hosted geom's paint function — receives the guaranteed overlay wiring on `input.overlay`. */
488
- export declare type GeomOverlayRenderFn<G extends GeomName | string = string, C extends CoordKind = CoordKind> = (input: GeomOverlayRenderInput<G, C>) => ReactNode;
489
-
490
506
  /**
491
- * The input an overlay-hosted render (`{ fn, options: { overlay: true } }`) receives: the standard render
492
- * input plus a guaranteed {@link InteractiveOverlayApi}. The renderer always supplies it, so the geom's
493
- * render uses `overlay` unconditionally — it never decides where it is mounted, only what it paints.
494
- */
495
- export declare interface GeomOverlayRenderInput<G extends GeomName | string = string, C extends CoordKind = CoordKind> extends GeomRenderInput<G, C> {
496
- overlay: InteractiveOverlayApi;
507
+ * Draws a geom's overpaint over `children` alone, masked by their alpha. It shares their parents, so their
508
+ * transforms, clips and opacity. Patterns are laid out in panel pixels, so wrap a nested view box, not the shapes
509
+ * inside it.
510
+ *
511
+ * Use it in a geom that sets `overpaintPlacement: 'manual'`. Under the default `'layer'` the renderer already
512
+ * overpaints the hook, so a wrapper there paints its shapes twice. Do not nest one wrapper inside another, for the
513
+ * same reason.
514
+ *
515
+ * @example
516
+ * // In a renderer defined with `overpaintPlacement: 'manual'`:
517
+ * <>
518
+ * {whiskers}
519
+ * <GeomOverpaint styleReaders={styleReaders}>
520
+ * {boxes}
521
+ * </GeomOverpaint>
522
+ * {medians}
523
+ * </>
524
+ */
525
+ export declare const GeomOverpaint: (props: GeomOverpaintProps) => JSX.Element;
526
+
527
+ export declare interface GeomOverpaintProps {
528
+ /** The geom's readers; the overpaint is read from them. */
529
+ styleReaders: Pick<GeomStyleReaders, 'get'>;
530
+ state?: StyleState;
531
+ /** The shapes the overpaint covers. */
532
+ children: ReactNode;
497
533
  }
498
534
 
499
535
  export declare const GeomPath: (props: GeomPathProps) => JSX.Element;
@@ -513,12 +549,14 @@ export declare interface GeomPathProps {
513
549
  strokeOpacity?: number;
514
550
  strokeWidth?: number;
515
551
  strokeDasharray?: string;
552
+ /** Shadow, blend mode and filters from `readGeomEffects`. The resting shadow is `'none'` when the layer casts it. */
553
+ effects?: GeomEffects;
516
554
  /** Whether a change of shape morphs to the new one. Snaps when false. */
517
555
  shouldAnimateTransitions: boolean;
518
556
  'data-testid'?: string;
519
557
  }
520
558
 
521
- export declare const GeomRect: (props: GeomRectProps) => JSX.Element;
559
+ export declare const GeomRect: ({ cornerRadius, ...props }: GeomRectProps) => JSX.Element;
522
560
 
523
561
  export declare interface GeomRectProps {
524
562
  x: ShapePosition;
@@ -531,20 +569,32 @@ export declare interface GeomRectProps {
531
569
  stroke?: string;
532
570
  strokeOpacity?: number;
533
571
  strokeWidth?: number;
572
+ /** A token or pixels, as `cornerRadius` reads from the geom's style. `'full'` rounds the shorter side. */
573
+ cornerRadius?: GeomCornerRadius;
574
+ /** Shadow, blend mode and filters from `readGeomEffects`. The resting shadow is `'none'` when the layer casts it. */
575
+ effects?: GeomEffects;
534
576
  /** Whether a change of origin or size springs to the new one. Snaps when false. */
535
577
  shouldAnimateTransitions: boolean;
536
578
  'data-testid'?: string;
537
579
  }
538
580
 
581
+ /** The rect a theme's `Rect` draws, its corner radius resolved to the user units it is placed in. */
582
+ export declare type GeomRectShapeProps = Omit<GeomRectProps, 'cornerRadius'> & {
583
+ /**
584
+ * Corner radii in user units, clamped to half the rect's shorter side on screen when its size is known. They differ
585
+ * inside a `UnitSpaceSvg`, whose units stretch to the panel, so the corner stays round.
586
+ */
587
+ rx?: number;
588
+ ry?: number;
589
+ };
590
+
539
591
  /**
540
- * A geom's `render`: either a plain panel-SVG paint function, or an overlay-hosted one paired with
541
- * `options` — so a geom that must paint into the interactive overlay declares
542
- * `{ fn, options: { overlay: true } }` without a second render entry point. The
543
- * renderer decides where each is mounted; the geom only decides what it paints. `render` is the single
544
- * paint declaration either way.
592
+ * A geom's `render`: either a plain paint function, or a live one paired with `options`, so a geom
593
+ * that owns its pointer events declares `{ fn, options: { live: true } }` without a second render
594
+ * entry point.
545
595
  */
546
596
  export declare type GeomRender<G extends GeomName | string = string, C extends CoordKind = CoordKind> = GeomRenderFn<G, C> | {
547
- fn: GeomOverlayRenderFn<G, C>;
597
+ fn: GeomLiveRenderFn<G, C>;
548
598
  options: GeomRenderOptions;
549
599
  };
550
600
 
@@ -571,9 +621,16 @@ export declare interface GeomRenderContract<G extends GeomName | string = string
571
621
  */
572
622
  guideMode?: HoverGuideMode | null;
573
623
  /**
574
- * The geom's paint. A plain function paints into the panel SVG; the `{ fn, options: { overlay: true } }`
575
- * form paints into a screen-aligned portal above the central capture layer for a live/drag-driven geom
576
- * that owns its pointer events (force-directed), with the wiring on `input.overlay`.
624
+ * Where a geom `overpaint` lands. `'layer'`, the default, lays it over everything each hook draws.
625
+ * `'manual'` leaves it to the geom, which wraps its main shapes in `GeomOverpaint` itself so what it draws
626
+ * before or after them stays clear (a boxplot's whiskers and medians). A manual geom with no wrapper draws
627
+ * no overpaint.
628
+ */
629
+ overpaintPlacement?: OverpaintPlacement;
630
+ /**
631
+ * The geom's paint. A plain function paints with the other geoms; the `{ fn, options: { live: true } }`
632
+ * form paints above the central capture layer for a live or drag-driven geom that owns its pointer events
633
+ * (force-directed), with the wiring on `input.live`.
577
634
  */
578
635
  render: GeomRender<G, C>;
579
636
  /**
@@ -651,17 +708,14 @@ export declare interface GeomRenderInputBase {
651
708
  styleReaders: GeomStyleReaders;
652
709
  }
653
710
 
654
- /**
655
- * Hosting options for an overlay render. The presence of the object form already declares overlay hosting;
656
- * `overlay: true` makes the call site read explicitly (and leaves room for further hosting options later).
657
- */
711
+ /** Options for the object form of `render`. */
658
712
  export declare interface GeomRenderOptions {
659
713
  /**
660
- * Mount this render's output in a screen-aligned portal above the central capture layer, rather than in
661
- * the panel SVG — for a live or drag-driven geom that must own its pointer events (force-directed). The
662
- * renderer then supplies {@link GeomOverlayRenderInput.overlay}.
714
+ * Paint this render above the central capture layer rather than with the other geoms, for a live or
715
+ * drag-driven geom that must own its pointer events (force-directed). It still paints in the panel SVG, in
716
+ * the same units as every other geom. The renderer then supplies {@link GeomLiveRenderInput.live}.
663
717
  */
664
- overlay: true;
718
+ live: true;
665
719
  }
666
720
 
667
721
  /**
@@ -671,7 +725,7 @@ export declare interface GeomRenderOptions {
671
725
  export declare interface GeomShapes {
672
726
  Circle?: ComponentType<GeomCircleProps>;
673
727
  Line?: ComponentType<GeomLineProps>;
674
- Rect?: ComponentType<GeomRectProps>;
728
+ Rect?: ComponentType<GeomRectShapeProps>;
675
729
  Path?: ComponentType<GeomPathProps>;
676
730
  }
677
731
 
@@ -1112,21 +1166,6 @@ declare interface HoverStoreActions {
1112
1166
  /** State of the hover store: the current {@link HoverState} plus its setter. */
1113
1167
  declare type HoverStoreState = HoverSlice & HoverStoreActions;
1114
1168
 
1115
- /**
1116
- * The overlay wiring handed to an overlay-hosted render via {@link GeomOverlayRenderInput.overlay}. The
1117
- * geom writes only its simulation, marks, and drag handlers; the renderer owns the on-screen rect
1118
- * measurement, the portal alignment, and the push wiring.
1119
- */
1120
- export declare interface InteractiveOverlayApi {
1121
- /** Feeds the hovered observation's identity key into the unified hover store — the push path. */
1122
- pushHover: GeomHoverPush;
1123
- /**
1124
- * The panel's on-screen rect in client pixels, so the overlay can place its marks. Distinct from
1125
- * {@link GeomRenderInput.panelRect} (layout pixels).
1126
- */
1127
- panelRect: ScreenRect;
1128
- }
1129
-
1130
1169
  declare interface IntroAnimationOptions {
1131
1170
  /** Whether the entrance plays at all */
1132
1171
  enabled: boolean;
@@ -1214,6 +1253,20 @@ export declare const lightenCss: (colorString: string, amount: number) => string
1214
1253
  /** vanilla-extract class that binds the light token values; the default theme. */
1215
1254
  export declare const lightTheme: string;
1216
1255
 
1256
+ /**
1257
+ * The wiring handed to a live render via {@link GeomLiveRenderInput.live}. The geom
1258
+ * writes only its simulation, marks, and drag handlers; the renderer owns the push wiring.
1259
+ */
1260
+ export declare interface LiveGeomApi {
1261
+ /** Feeds the hovered observation's identity key into the unified hover store — the push path. */
1262
+ pushHover: GeomHoverPush;
1263
+ /**
1264
+ * A pointer's client coordinates in the panel's units, whatever the graph's on-screen scale, so a drag
1265
+ * moves a mark to the pointer. `null` before the panel mounts.
1266
+ */
1267
+ readPanelPoint: (cursor: GeomHoverCursor) => PanelPoint | null;
1268
+ }
1269
+
1217
1270
  declare interface MorphingEditOutlineShape {
1218
1271
  /** SVG path data in panel pixels. */
1219
1272
  pathData: string;
@@ -1238,6 +1291,9 @@ declare interface OverlayAnchorInput<G extends GeomName | string = string, C ext
1238
1291
  observation: Observation;
1239
1292
  }
1240
1293
 
1294
+ /** Where a geom `overpaint` lands: over everything a hook draws, or where the geom wraps it itself. */
1295
+ export declare type OverpaintPlacement = 'layer' | 'manual';
1296
+
1241
1297
  export declare interface PaintDefs {
1242
1298
  /** The `fill` attribute for a paint: the color itself, or a `url(#id)` into the defs this SVG renders. */
1243
1299
  fillFor: (paint: ResolvedPaint) => string;
@@ -1259,6 +1315,12 @@ export declare interface PaintGridOrigin {
1259
1315
  y: number;
1260
1316
  }
1261
1317
 
1318
+ /** A point in the panel's own units, the space a geom's `render` paints in. */
1319
+ export declare interface PanelPoint {
1320
+ x: number;
1321
+ y: number;
1322
+ }
1323
+
1262
1324
  /** The stroke a line or an area edge paints, named as SVG props so it spreads onto a `<path>` as is. */
1263
1325
  export declare interface PathStroke {
1264
1326
  strokeWidth: number;
@@ -1286,6 +1348,18 @@ export declare const projectPointCartesian: PointProjection;
1286
1348
  */
1287
1349
  export declare const pruneSelection: (selection: readonly EditTarget[], spec: ResolvedSpec) => readonly EditTarget[];
1288
1350
 
1351
+ /**
1352
+ * A shared rect's box in pixels from the top-left of the panel (or `UnitBoxSvg`) it is drawn in, not from the graph
1353
+ * container as a layout rect is. `null` when any side is a unit-space coordinate, as in {@link readShapePixels}.
1354
+ */
1355
+ export declare const readShapePixelRect: ({ x, y, width, height }: Pick<GeomRectProps, "x" | "y" | "width" | "height">, panel: BoxSize) => Rect | null;
1356
+
1357
+ /**
1358
+ * A position in pixels along a panel `extent` pixels long. `null` for a unit-space coordinate, which the
1359
+ * panel's size does not scale, so a theme shape draws the default there.
1360
+ */
1361
+ export declare const readShapePixels: (position: ShapePosition, extent: number) => number | null;
1362
+
1289
1363
  export { RenderHitTester }
1290
1364
 
1291
1365
  /** Fires on each deduped size change — the shape of `GraphRenderer`'s `onResize` callback. */
@@ -1623,6 +1697,7 @@ export declare interface UnitBox {
1623
1697
  /**
1624
1698
  * A nested SVG over a unit-space box, placed in panel percentages, with no viewBox. Children live in the
1625
1699
  * box's own unscaled space (`50%` is the center, a pixel radius is a pixel) and are clipped by the viewport.
1700
+ * A theme shape inside reads the box's pixel size from `useGeomPanelSize`, since its percentages resolve against the box.
1626
1701
  */
1627
1702
  export declare const UnitBoxSvg: ({ box, children }: {
1628
1703
  box: UnitBox;
@@ -1633,7 +1708,8 @@ export declare const UnitBoxSvg: ({ box, children }: {
1633
1708
  * A nested SVG that establishes a `[0, 1]` unit coordinate space (top-left origin) stretched to fill
1634
1709
  * the geom panel. A layout geom paints its geometry in raw unit coords so paint and hit-test never re-project against each
1635
1710
  * other. `preserveAspectRatio="none"` maps the unit square onto the (usually non-square) panel exactly.
1636
- * Circles and glyphs stretch here — put them in {@link UnitBoxSvg}.
1711
+ * Circles and glyphs stretch here — put them in {@link UnitBoxSvg}. A theme shape inside reads no panel size, since a
1712
+ * user unit there is the whole panel; a shared rect still reads it, to keep its corners round.
1637
1713
  */
1638
1714
  export declare const UnitSpaceSvg: ({ children, ...rest }: UnitSpaceSvgProps) => ReactNode;
1639
1715
 
@@ -1676,15 +1752,23 @@ export declare function useGeomHitTest(layerId: string, tester: RenderHitTester)
1676
1752
  * drawn (a live simulation) and so owns its own pointer surface above the central capture layer. The
1677
1753
  * geom's pointer handlers call the returned setter with the hovered observation's `identityKey`; the
1678
1754
  * engine resolves it through the same `byKey` lookup the pull path uses, so the geom inherits the tooltip
1679
- * and `renderHover`. Since the overlay intercepts the pointer events, the tooltip is anchored at the
1680
- * supplied cursor. Pass `null` to clear. Geoms with geometry fixed once drawn use `useGeomHitTest`.
1755
+ * and `renderHover`. Since the geom takes the pointer events, the tooltip is anchored at the supplied
1756
+ * cursor. Pass `null` to clear. Geoms with geometry fixed once drawn use `useGeomHitTest`.
1681
1757
  *
1682
- * Escape hatch: an interactive geom should instead declare an overlay-hosted `render`
1683
- * (`{ fn, options: { overlay: true } }`), which the renderer portals into a screen-aligned overlay and
1684
- * hands a ready `pushHover` via `input.overlay`. Reach for this hook only when that form is not enough.
1758
+ * Escape hatch: a live geom should instead declare a live `render`
1759
+ * (`{ fn, options: { live: true } }`), which the renderer paints above the capture layer and
1760
+ * hands a ready `pushHover` via `input.live`. Reach for this hook only when that form is not enough.
1685
1761
  */
1686
1762
  export declare function useGeomHover(layerId: string): GeomHoverPush;
1687
1763
 
1764
+ /**
1765
+ * The pixel size of the panel the shape is drawn in, for a theme shape whose drawing depends on pixels (chalk
1766
+ * strokes a set distance apart, a grid of typed characters). `null` outside a geom layer and inside a `UnitSpaceSvg`,
1767
+ * whose unit coordinates no pixel size scales. Inside a `UnitBoxSvg` it is the box's size, since a shape's percentages
1768
+ * resolve against the nearest `<svg>`.
1769
+ */
1770
+ export declare const useGeomPanelSize: () => BoxSize | null;
1771
+
1688
1772
  /** The resolver's `geom` subtree, one object per resolver, so the selector never re-renders on a chrome change. */
1689
1773
  export declare const useGeomReaderTree: () => StyleReaderTree["geom"];
1690
1774