@graphysdk/react-renderer 0.0.1-plugins.3 → 0.0.1-plugins.5
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.cjs +2 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +287 -12
- package/dist/index.mjs +3338 -1716
- package/package.json +5 -10
- package/dist/extensions.cjs +0 -1
- package/dist/extensions.d.ts +0 -635
- package/dist/extensions.mjs +0 -153
- package/dist/tooltip-body-B4Mj-oru.cjs +0 -2
- package/dist/tooltip-body-Cp_va3oW.js +0 -1527
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AnimationPlaybackOptions } from 'motion/react';
|
|
2
|
+
import { AnnotationDef } from '@graphysdk/viz-engine';
|
|
1
3
|
import { AnnotationZOrder } from '@graphysdk/viz-engine';
|
|
2
4
|
import { AppearanceConfig } from '@graphysdk/viz-engine';
|
|
3
5
|
import { CartesianCoordSystem } from '@graphysdk/viz-engine';
|
|
@@ -10,7 +12,7 @@ import { CSSProperties } from 'react';
|
|
|
10
12
|
import { CustomPalettesInput } from '@graphysdk/viz-engine';
|
|
11
13
|
import { Data } from '@graphysdk/viz-engine';
|
|
12
14
|
import { FontSpec } from '@graphysdk/viz-engine';
|
|
13
|
-
import { Geom } from '@graphysdk/viz-engine
|
|
15
|
+
import { Geom } from '@graphysdk/viz-engine';
|
|
14
16
|
import { GeomIdentity } from '@graphysdk/viz-engine';
|
|
15
17
|
import { GeomName } from '@graphysdk/viz-engine';
|
|
16
18
|
import { GraphLayout } from '@graphysdk/viz-engine';
|
|
@@ -19,14 +21,21 @@ import { HighlightStrategy } from '@graphysdk/viz-engine';
|
|
|
19
21
|
import { HoverHit } from '@graphysdk/viz-engine';
|
|
20
22
|
import { HoverState } from '@graphysdk/viz-engine';
|
|
21
23
|
import { JSX } from 'react/jsx-runtime';
|
|
24
|
+
import { LineStyleType } from '@graphysdk/viz-engine';
|
|
22
25
|
import { Locale } from '@graphysdk/viz-engine';
|
|
23
26
|
import { MeasuredText } from '@graphysdk/viz-engine';
|
|
27
|
+
import { MotionValue } from 'motion/react';
|
|
24
28
|
import { Observation } from '@graphysdk/viz-engine';
|
|
29
|
+
import { PanelHitTester } from '@graphysdk/viz-engine';
|
|
25
30
|
import { PolarCoordSystem } from '@graphysdk/viz-engine';
|
|
26
31
|
import { ReactNode } from 'react';
|
|
32
|
+
import { RefCallback } from 'react';
|
|
27
33
|
import { ResolvedTarget } from '@graphysdk/viz-engine';
|
|
34
|
+
import { SVGProps } from 'react';
|
|
35
|
+
import { SwatchShape } from '@graphysdk/viz-engine';
|
|
28
36
|
import { TextMeasurer } from '@graphysdk/viz-engine';
|
|
29
37
|
import { TooltipContent } from '@graphysdk/viz-engine';
|
|
38
|
+
import { TooltipRow } from '@graphysdk/viz-engine';
|
|
30
39
|
|
|
31
40
|
/**
|
|
32
41
|
* The drawing surface a custom annotation paints into (ADR-035): a panel-positioned [0,1] frame.
|
|
@@ -34,7 +43,7 @@ import { TooltipContent } from '@graphysdk/viz-engine';
|
|
|
34
43
|
* for the cases [0,1] cannot express (text extents, fixed-length leaders); `params` is the kind's typed
|
|
35
44
|
* params. The draw function returns static nodes — annotations have no hover or tooltip.
|
|
36
45
|
*/
|
|
37
|
-
declare interface AnnotationDrawInput<TParams extends object = object> {
|
|
46
|
+
export declare interface AnnotationDrawInput<TParams extends object = object> {
|
|
38
47
|
targets: readonly ResolvedTarget[];
|
|
39
48
|
area: {
|
|
40
49
|
width: number;
|
|
@@ -49,12 +58,20 @@ declare interface AnnotationDrawInput<TParams extends object = object> {
|
|
|
49
58
|
* `draw` is a React render function that may reuse the render kit (theme tokens, `toPercent`, value
|
|
50
59
|
* readers) but never participates in hover.
|
|
51
60
|
*/
|
|
52
|
-
declare interface AnnotationPlugin {
|
|
61
|
+
export declare interface AnnotationPlugin {
|
|
53
62
|
type: string;
|
|
54
63
|
zOrder: AnnotationZOrder;
|
|
55
64
|
draw: (input: AnnotationDrawInput) => ReactNode;
|
|
56
65
|
}
|
|
57
66
|
|
|
67
|
+
/** The render half an author supplies to {@link defineAnnotationRenderer} — everything but `type`. */
|
|
68
|
+
declare interface AnnotationRenderHalf<TParams extends object> {
|
|
69
|
+
zOrder: AnnotationZOrder;
|
|
70
|
+
draw: (input: AnnotationDrawInput<TParams>) => ReactNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { AnnotationZOrder }
|
|
74
|
+
|
|
58
75
|
/**
|
|
59
76
|
* Browser text measurer backed by OffscreenCanvas.
|
|
60
77
|
*
|
|
@@ -109,13 +126,60 @@ export declare class CanvasTextMeasurer implements TextMeasurer {
|
|
|
109
126
|
private getEmojiCorrection;
|
|
110
127
|
}
|
|
111
128
|
|
|
112
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Hover-overlay dot drawn at a non-primary hit's `(x, y)`: a single circle at reduced opacity
|
|
131
|
+
* so it reads as secondary. Used for any companion hit — same-layer sibling (e.g. another
|
|
132
|
+
* series at the primary X) or cross-layer related.
|
|
133
|
+
*/
|
|
134
|
+
export declare const CompanionDot: ({ hit }: CompanionDotProps) => JSX.Element;
|
|
135
|
+
|
|
136
|
+
declare interface CompanionDotProps {
|
|
137
|
+
hit: HoverHit;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export declare type CoordKind = CoordSystem['type'];
|
|
113
141
|
|
|
114
142
|
/** Maps a coord-kind discriminator to the corresponding `CoordSystem` member. */
|
|
115
143
|
declare type CoordSystemFor<C extends CoordKind> = C extends 'cartesian' ? CartesianCoordSystem : C extends 'polar' ? PolarCoordSystem : never;
|
|
116
144
|
|
|
117
145
|
export declare const darkTheme: string;
|
|
118
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Binds a custom annotation's render half to its imported compile-half {@link AnnotationDef}: the kind
|
|
149
|
+
* name (`def.type`) and the params type (`def.defaultParams`) are read from `def`, so the half never
|
|
150
|
+
* re-declares them and cannot disagree with the definition — the construction-level handshake mirroring
|
|
151
|
+
* `defineGeomRenderer`. `draw` receives the resolved targets with `params` typed from the def.
|
|
152
|
+
*/
|
|
153
|
+
export declare function defineAnnotationRenderer<TParams extends object>(def: AnnotationDef<TParams>, half: AnnotationRenderHalf<TParams>): AnnotationPlugin;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Type-narrowing constructor for a plugin. Each plugin file declares its `(geom, coord)` pair and its
|
|
157
|
+
* `highlightStrategy` inline; TypeScript infers `G`/`C`/`S` from the object literal — handlers then
|
|
158
|
+
* receive `CompiledLayerFor<G>` / `CoordSystemFor<C>` with no `as` casts. Whether `getOverlayAnchor` is
|
|
159
|
+
* required follows from the declared `highlightStrategy` via {@link GeomPluginForStrategy}. A custom geom
|
|
160
|
+
* supplies its params type `TParams` (e.g. by annotating `render`'s input) to type `layer.params`.
|
|
161
|
+
*
|
|
162
|
+
* Returns the broad `GeomPlugin` type (with the type parameters erased) so all plugins fit into one
|
|
163
|
+
* registry. The cast inside this helper is safe because the registry routes every call to the plugin
|
|
164
|
+
* keyed by `(geom, coord)`.
|
|
165
|
+
*/
|
|
166
|
+
export declare function defineGeomPlugin<G extends string, C extends CoordKind, S extends GeomHighlightStrategy, TParams = PluginParams<G>>(plugin: GeomPluginForStrategy<G, C, S, TParams>): GeomPlugin;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Binds a geom's render half to its imported compile-half {@link Geom} definition: the geom name
|
|
170
|
+
* (`def.type`), the highlight strategy (`def.highlightStrategy`), and the params type
|
|
171
|
+
* (`def.defaultParams`) are all read from `def`, so the half never re-declares them and cannot disagree
|
|
172
|
+
* with the definition — the construction-level handshake. Whether `getOverlayAnchor` is required follows
|
|
173
|
+
* from the def's declared `highlightStrategy`, and `render`/`renderHover` receive `layer.params` typed
|
|
174
|
+
* from the def with no annotation. Built-in plugins keep {@link defineGeomPlugin}; reach for this only to
|
|
175
|
+
* pair a custom geom's two halves.
|
|
176
|
+
*
|
|
177
|
+
* Returns the broad {@link GeomPlugin} (type parameters erased) so every plugin fits one registry; the
|
|
178
|
+
* cast is the same variance bypass {@link defineGeomPlugin} performs, safe because the registry routes
|
|
179
|
+
* each call by `(geom, coord)`.
|
|
180
|
+
*/
|
|
181
|
+
export declare function defineGeomRenderer<Def extends Geom, C extends CoordKind>(def: Def, half: GeomRenderHalf<Def, C>): GeomPlugin;
|
|
182
|
+
|
|
119
183
|
export declare const DevToolsPanel: ({ width, style, className }?: DevToolsPanelProps) => JSX.Element;
|
|
120
184
|
|
|
121
185
|
/**
|
|
@@ -132,6 +196,16 @@ export declare interface DevToolsPanelProps {
|
|
|
132
196
|
className?: string;
|
|
133
197
|
}
|
|
134
198
|
|
|
199
|
+
export declare const emToPx: (em: number, textScale: number) => number;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Whether a region is large enough to carry a label: both dimensions must clear their minimum. Works in
|
|
203
|
+
* any single consistent space — pass unit dimensions with unit thresholds, or pixels with pixel
|
|
204
|
+
* thresholds. A space-filling geom (treemap) culls labels with it so a tile too small to fit text stays
|
|
205
|
+
* unlabelled rather than overflowing.
|
|
206
|
+
*/
|
|
207
|
+
export declare function fitsLabel(width: number, height: number, minWidth: number, minHeight: number): boolean;
|
|
208
|
+
|
|
135
209
|
/** A geom's declared highlight composition strategy, or `null` when it opts out of highlighting. */
|
|
136
210
|
declare type GeomHighlightStrategy = HighlightStrategy | null;
|
|
137
211
|
|
|
@@ -152,7 +226,7 @@ declare type GeomHighlightStrategy = HighlightStrategy | null;
|
|
|
152
226
|
* {@link defineGeomPlugin} boundary via {@link GeomPluginForStrategy}, keyed on the plugin's own
|
|
153
227
|
* declared `highlightStrategy` — so a custom geom is gated by what it declares, not a name lookup.
|
|
154
228
|
*/
|
|
155
|
-
declare type GeomPlugin<G extends string = GeomIdentity, C extends CoordKind = CoordKind> = NoOverlayAnchorGeomPlugin<G, C, GeomHighlightStrategy, PluginParams<G>> | OverlayAnchorGeomPlugin<G, C, GeomHighlightStrategy, PluginParams<G>>;
|
|
229
|
+
export declare type GeomPlugin<G extends string = GeomIdentity, C extends CoordKind = CoordKind> = NoOverlayAnchorGeomPlugin<G, C, GeomHighlightStrategy, PluginParams<G>> | OverlayAnchorGeomPlugin<G, C, GeomHighlightStrategy, PluginParams<G>>;
|
|
156
230
|
|
|
157
231
|
declare interface GeomPluginBase<G extends string, C extends CoordKind, S extends GeomHighlightStrategy, TParams> {
|
|
158
232
|
geom: G;
|
|
@@ -176,7 +250,26 @@ declare interface GeomPluginBase<G extends string, C extends CoordKind, S extend
|
|
|
176
250
|
renderTooltip?: (input: TooltipRenderInput<G, C, TParams>) => ReactNode;
|
|
177
251
|
}
|
|
178
252
|
|
|
179
|
-
|
|
253
|
+
/**
|
|
254
|
+
* Picks the plugin shape required for a plugin's own declared `highlightStrategy`. Only the
|
|
255
|
+
* `'overlay-anchor'` strategy demands the anchor reader; `'observation-rerender'` and `null` (no
|
|
256
|
+
* highlight) both resolve to {@link NoOverlayAnchorGeomPlugin}.
|
|
257
|
+
*
|
|
258
|
+
* Used by {@link defineGeomPlugin} to enforce the strategy→shape coupling at plugin-definition
|
|
259
|
+
* sites — `observation-rerender` plugins cannot declare `getOverlayAnchor`, `overlay-anchor` ones must
|
|
260
|
+
* — for any geom name, built-in or custom, with no closed geom-name lookup.
|
|
261
|
+
*/
|
|
262
|
+
declare type GeomPluginForStrategy<G extends string, C extends CoordKind, S extends GeomHighlightStrategy, TParams> = S extends 'overlay-anchor' ? OverlayAnchorGeomPlugin<G, C, S, TParams> : NoOverlayAnchorGeomPlugin<G, C, S, TParams>;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The render half an author supplies to {@link defineGeomRenderer}: every field of a plugin except the
|
|
266
|
+
* two its imported compile-half definition already declares — `geom` and `highlightStrategy`.
|
|
267
|
+
* `getOverlayAnchor` is gated on the def's declared strategy via {@link GeomPluginForStrategy}, so the
|
|
268
|
+
* render contract is bound to the definition rather than re-declared.
|
|
269
|
+
*/
|
|
270
|
+
declare type GeomRenderHalf<Def extends Geom, C extends CoordKind> = Omit<GeomPluginForStrategy<Def['type'] & string, C, Def['highlightStrategy'], Def['defaultParams']>, 'geom' | 'highlightStrategy'>;
|
|
271
|
+
|
|
272
|
+
export declare interface GeomRenderInput<G extends string = GeomName, C extends CoordKind = CoordKind, TParams = PluginParams<G>> {
|
|
180
273
|
layer: CompiledLayerFor<G, TParams>;
|
|
181
274
|
coordSystem: CoordSystemFor<C>;
|
|
182
275
|
isAnimated: boolean;
|
|
@@ -229,13 +322,13 @@ export declare interface GraphRendererProps {
|
|
|
229
322
|
mode?: GraphMode;
|
|
230
323
|
}
|
|
231
324
|
|
|
232
|
-
declare interface HoverCompanionsRenderInput<G extends string = GeomName, TParams = PluginParams<G>> {
|
|
325
|
+
export declare interface HoverCompanionsRenderInput<G extends string = GeomName, TParams = PluginParams<G>> {
|
|
233
326
|
layer: CompiledLayerFor<G, TParams>;
|
|
234
327
|
primary: HoverHit;
|
|
235
328
|
related: HoverHit[];
|
|
236
329
|
}
|
|
237
330
|
|
|
238
|
-
declare type HoverGuideMode = 'continuous' | 'bar';
|
|
331
|
+
export declare type HoverGuideMode = 'continuous' | 'bar';
|
|
239
332
|
|
|
240
333
|
/**
|
|
241
334
|
* Hosts the hover store + engine for the surrounding `<GraphProvider>`. Subscribes only to the
|
|
@@ -248,7 +341,7 @@ declare interface HoverProviderProps {
|
|
|
248
341
|
children: ReactNode;
|
|
249
342
|
}
|
|
250
343
|
|
|
251
|
-
declare interface HoverRenderInput<G extends string = GeomName, C extends CoordKind = CoordKind, TParams = PluginParams<G>> {
|
|
344
|
+
export declare interface HoverRenderInput<G extends string = GeomName, C extends CoordKind = CoordKind, TParams = PluginParams<G>> {
|
|
252
345
|
layer: CompiledLayerFor<G, TParams>;
|
|
253
346
|
coordSystem: CoordSystemFor<C>;
|
|
254
347
|
primary: HoverHit;
|
|
@@ -275,8 +368,18 @@ declare interface HoverStoreActions {
|
|
|
275
368
|
|
|
276
369
|
declare type HoverStoreState = HoverSlice & HoverStoreActions;
|
|
277
370
|
|
|
371
|
+
/** Lightens a hex colour by mixing it toward white by `amount` (`0` keeps the colour, `1` is white). */
|
|
372
|
+
export declare function lighten(hex: string, amount: number): string;
|
|
373
|
+
|
|
278
374
|
export declare const lightTheme: string;
|
|
279
375
|
|
|
376
|
+
/**
|
|
377
|
+
* Mixes a hex colour toward another by `amount` in `[0, 1]` (`0` keeps `hex`, `1` returns `towardHex`),
|
|
378
|
+
* channel-wise in sRGB. Returns an `rgb(...)` string. Used for within-group shading where leaves share a
|
|
379
|
+
* group hue and vary only in lightness.
|
|
380
|
+
*/
|
|
381
|
+
export declare function mixColor(hex: string, towardHex: string, amount: number): string;
|
|
382
|
+
|
|
280
383
|
/**
|
|
281
384
|
* Plugin shape for geoms that don't compute an overlay anchor — either `'observation-rerender'`
|
|
282
385
|
* geoms (matched rows re-render in place) or geoms that opt out of highlighting entirely
|
|
@@ -290,7 +393,7 @@ declare interface NoOverlayAnchorGeomPlugin<G extends string, C extends CoordKin
|
|
|
290
393
|
* Anchor point in normalized [0,1] coord-space where a highlight overlay marker
|
|
291
394
|
* should be painted for one observation. Renderer turns [0,1] into pixels.
|
|
292
395
|
*/
|
|
293
|
-
declare interface OverlayAnchor {
|
|
396
|
+
export declare interface OverlayAnchor {
|
|
294
397
|
x: number;
|
|
295
398
|
y: number;
|
|
296
399
|
}
|
|
@@ -300,15 +403,74 @@ declare interface OverlayAnchorGeomPlugin<G extends string, C extends CoordKind,
|
|
|
300
403
|
getOverlayAnchor: (input: OverlayAnchorInput<G, C, TParams>) => OverlayAnchor | null;
|
|
301
404
|
}
|
|
302
405
|
|
|
303
|
-
declare interface OverlayAnchorInput<G extends string = GeomName, C extends CoordKind = CoordKind, TParams = PluginParams<G>> {
|
|
406
|
+
export declare interface OverlayAnchorInput<G extends string = GeomName, C extends CoordKind = CoordKind, TParams = PluginParams<G>> {
|
|
304
407
|
layer: CompiledLayerFor<G, TParams>;
|
|
305
408
|
coordSystem: CoordSystemFor<C>;
|
|
306
409
|
observation: Observation;
|
|
307
410
|
}
|
|
308
411
|
|
|
412
|
+
export { PanelHitTester }
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Portals an interactive overlay to `document.body`, fixed over the given panel rect at the documented
|
|
416
|
+
* top `z-index`. Owns only the placement and chrome; the simulation canvas it wraps paints inside. Sized
|
|
417
|
+
* to the rect with `pointerEvents: 'none'` so gaps fall through to the chart — the overlay's own marks
|
|
418
|
+
* re-enable pointer events to capture drags.
|
|
419
|
+
*/
|
|
420
|
+
export declare function PanelOverlayPortal({ rect, children }: {
|
|
421
|
+
rect: PanelScreenRect;
|
|
422
|
+
children: ReactNode;
|
|
423
|
+
}): ReactNode;
|
|
424
|
+
|
|
425
|
+
/** The panel's on-screen rectangle in page-relative pixels — the frame a portalled overlay aligns to. */
|
|
426
|
+
export declare interface PanelScreenRect {
|
|
427
|
+
left: number;
|
|
428
|
+
top: number;
|
|
429
|
+
width: number;
|
|
430
|
+
height: number;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Walks a kind-tagged geom-layout dataset (the output of `createMarkTable`), yielding each observation paired
|
|
435
|
+
* with its discriminant `kind`. The render half switches on `kind` to build its per-kind marks, instead
|
|
436
|
+
* of re-reading the kind column inline in every plugin. `Kind` narrows the discriminant to the geom's own
|
|
437
|
+
* union (e.g. `'node' | 'link'`) for an exhaustive switch.
|
|
438
|
+
*/
|
|
439
|
+
export declare function partitionByKind<Kind extends string = string>(data: Iterable<Observation>, kindColumn: string): Generator<{
|
|
440
|
+
kind: Kind;
|
|
441
|
+
observation: Observation;
|
|
442
|
+
}>;
|
|
443
|
+
|
|
309
444
|
/** The compiled-layer params a plugin's handlers see — built-ins default from the geom name; a custom geom supplies its own. */
|
|
310
445
|
declare type PluginParams<G extends string> = CompiledLayerFor<G>['params'];
|
|
311
446
|
|
|
447
|
+
/**
|
|
448
|
+
* Hover-overlay dot drawn at the primary hit's `(x, y)`: colored disc with a thicker white
|
|
449
|
+
* border and an outer white ring offset by a 1px gap. Radius is data-driven so bubble charts
|
|
450
|
+
* whose size channel carries data don't distort under hover.
|
|
451
|
+
*/
|
|
452
|
+
export declare const PrimaryDot: ({ hit, ...rest }: PrimaryDotProps) => JSX.Element;
|
|
453
|
+
|
|
454
|
+
declare interface PrimaryDotProps {
|
|
455
|
+
hit: HoverHit;
|
|
456
|
+
'data-testid'?: string;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export { ResolvedTarget }
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Shared shape glyph used by both the tooltip and the legend.
|
|
463
|
+
*/
|
|
464
|
+
export declare const Swatch: ({ shape, color, lineType, width, height, }: SwatchProps) => JSX.Element;
|
|
465
|
+
|
|
466
|
+
declare interface SwatchProps {
|
|
467
|
+
shape: SwatchShape;
|
|
468
|
+
color: string;
|
|
469
|
+
lineType?: LineStyleType;
|
|
470
|
+
width?: number;
|
|
471
|
+
height?: number;
|
|
472
|
+
}
|
|
473
|
+
|
|
312
474
|
/**
|
|
313
475
|
* Creates a font-ready, cached text measurer and shares it with descendants via context.
|
|
314
476
|
* Renders nothing until the measurer resolves, so consumers reading the context always
|
|
@@ -348,13 +510,31 @@ declare interface ThemeProviderProps {
|
|
|
348
510
|
|
|
349
511
|
export declare type ThemeValues = Record<keyof typeof vars, string>;
|
|
350
512
|
|
|
513
|
+
/**
|
|
514
|
+
* The default tooltip body — the optional header and one row per hovered observation, with the
|
|
515
|
+
* in-place primary-row highlight. Presentational and engine-decoupled: it renders a
|
|
516
|
+
* {@link TooltipContent} and nothing else, so the built-in `Tooltip` and a custom geom's
|
|
517
|
+
* `renderTooltip` paint the same rows. The positioned, themed card around it stays the renderer's.
|
|
518
|
+
*/
|
|
519
|
+
export declare const TooltipBody: ({ content }: TooltipBodyProps) => JSX.Element;
|
|
520
|
+
|
|
521
|
+
declare interface TooltipBodyProps {
|
|
522
|
+
content: TooltipContent;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** Page-relative cursor position the tooltip anchors to. `null` when the pointer is outside the chart. */
|
|
526
|
+
export declare interface TooltipCursor {
|
|
527
|
+
clientX: number;
|
|
528
|
+
clientY: number;
|
|
529
|
+
}
|
|
530
|
+
|
|
351
531
|
/**
|
|
352
532
|
* Input a plugin's {@link GeomPluginBase.renderTooltip} receives when one of its observations is the
|
|
353
533
|
* primary hit. `content` is the body the built-in tooltip would render — feed it to `TooltipBody` to
|
|
354
534
|
* reproduce the default — while `primary.observation` carries the geom's own columns for a bespoke
|
|
355
535
|
* layout. The card around the body (positioning, theme) stays the renderer's.
|
|
356
536
|
*/
|
|
357
|
-
declare interface TooltipRenderInput<G extends string = GeomName, C extends CoordKind = CoordKind, TParams = PluginParams<G>> {
|
|
537
|
+
export declare interface TooltipRenderInput<G extends string = GeomName, C extends CoordKind = CoordKind, TParams = PluginParams<G>> {
|
|
358
538
|
content: TooltipContent;
|
|
359
539
|
layer: CompiledLayerFor<G, TParams>;
|
|
360
540
|
coordSystem: CoordSystemFor<C>;
|
|
@@ -363,6 +543,57 @@ declare interface TooltipRenderInput<G extends string = GeomName, C extends Coor
|
|
|
363
543
|
related: ReadonlyMap<string, HoverHit[]>;
|
|
364
544
|
}
|
|
365
545
|
|
|
546
|
+
/**
|
|
547
|
+
* One tooltip row — swatch, label, value, with the optional in-place highlight. Exposed so a custom
|
|
548
|
+
* geom's `renderTooltip` can map `content.rows` itself and interleave its own content between rows,
|
|
549
|
+
* rather than rendering the whole {@link TooltipBody} as an opaque block.
|
|
550
|
+
*/
|
|
551
|
+
export declare const TooltipRowView: ({ row, shouldHighlight }: TooltipRowViewProps) => JSX.Element;
|
|
552
|
+
|
|
553
|
+
declare interface TooltipRowViewProps {
|
|
554
|
+
row: TooltipRow;
|
|
555
|
+
shouldHighlight: boolean;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export declare const toPercent: (value: number) => string;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Converts a normalized [0,1] x-coordinate to viewBox coordinate (identity transform).
|
|
562
|
+
* Used inside nested SVGs with viewBox="0 0 1 1".
|
|
563
|
+
*/
|
|
564
|
+
export declare function toViewBoxX(normalized: number): number;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Converts a normalized [0,1] y-coordinate to viewBox coordinate (Y-inverted).
|
|
568
|
+
* SVG y=0 is at the top, but data y=0 is at the bottom, so we invert.
|
|
569
|
+
* Used inside nested SVGs with viewBox="0 0 1 1".
|
|
570
|
+
*/
|
|
571
|
+
export declare function toViewBoxY(normalized: number): number;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* An `<svg>` preset for painting geom-layout geometry in panel `[0,1]` unit space: `viewBox="0 0 1 1"`,
|
|
575
|
+
* `preserveAspectRatio="none"` (so unit coordinates stretch to fill the panel exactly, the way a bar
|
|
576
|
+
* chart's bars do), and `overflow: visible`.
|
|
577
|
+
*
|
|
578
|
+
* Chrome gotcha (documented once here, so geoms don't rediscover it): with a sub-unit `viewBox`, native
|
|
579
|
+
* SVG fill hit-testing is unreliable at this scale — which is why geom-layout geoms answer a numeric
|
|
580
|
+
* `useGeomHitTest` query instead of relying on pointer events landing on these shapes. Paint here; hit-test
|
|
581
|
+
* through the engine.
|
|
582
|
+
*/
|
|
583
|
+
export declare const UnitSpaceSvg: ({ children, style, ...rest }: SVGProps<SVGSVGElement>) => ReactNode;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Returns an `index → colour` resolver over the chart's default categorical palette — the same
|
|
587
|
+
* `DEFAULT_COLOR_PALETTE` the compiler bakes into a colour-encoded layer — so a custom geom that
|
|
588
|
+
* assigns its own colour indices draws from the chart's palette instead of inventing a private one.
|
|
589
|
+
* Colours therefore match what a sibling layer's colour scale would produce, and follow the engine's
|
|
590
|
+
* palette rather than a hardcoded array.
|
|
591
|
+
*
|
|
592
|
+
* Out of scope (ADR-034 open question #4): declaring a colour *aesthetic* with its own scale + legend,
|
|
593
|
+
* or honouring a per-spec custom palette. This primitive only ensures the colours match the default.
|
|
594
|
+
*/
|
|
595
|
+
export declare function useCategoricalColor(): (index: number) => string;
|
|
596
|
+
|
|
366
597
|
/**
|
|
367
598
|
* Subscribes to a derived slice of the compiled spec. The subscription only fires when the
|
|
368
599
|
* selector's result changes by reference, so combined with the compiler's per-stage memoization
|
|
@@ -376,6 +607,31 @@ declare interface TooltipRenderInput<G extends string = GeomName, C extends Coor
|
|
|
376
607
|
*/
|
|
377
608
|
export declare const useCompiledSelector: <Selected>(selector: (compiled: CompiledSpec) => Selected) => Selected;
|
|
378
609
|
|
|
610
|
+
/**
|
|
611
|
+
* Registers a geom-layout geom's render-side hit-test for its layer, so the central hover engine routes
|
|
612
|
+
* the cursor to it — the geom inherits the built-in hover, tooltip, and (in time) accessibility
|
|
613
|
+
* instead of hand-rolling a pointer overlay. The geom declares `spatialKind: 'render-hit-test'`; this
|
|
614
|
+
* hook supplies the matching closure.
|
|
615
|
+
*
|
|
616
|
+
* The `tester` receives the cursor in panel `[0, 1]` with a top-left origin (the frame the geom
|
|
617
|
+
* paints in) and returns the declared identity key of the observation under it, or `null`. It may
|
|
618
|
+
* close over freshly computed geometry each render — a stable wrapper reads the latest through a ref,
|
|
619
|
+
* so the registration effect runs once per layer rather than every render.
|
|
620
|
+
*/
|
|
621
|
+
export declare function useGeomHitTest(layerId: string, tester: PanelHitTester): void;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* The push counterpart to `useGeomHitTest`, for a geom-layout geom that owns its own pointer surface — a
|
|
625
|
+
* live simulation whose interactive overlay intercepts pointer events before the central capture
|
|
626
|
+
* layer sees them, so the engine cannot pull a hit. The geom already knows which observation is under
|
|
627
|
+
* the cursor and pushes its declared identity key; the engine resolves it to the same unified
|
|
628
|
+
* `HoverState` the pull path produces, and the cursor is forwarded so the central tooltip tracks.
|
|
629
|
+
*
|
|
630
|
+
* Returns a stable `setHovered(key, cursor?)`: a key with the page-relative cursor opens the tooltip
|
|
631
|
+
* on that observation; `null` clears it.
|
|
632
|
+
*/
|
|
633
|
+
export declare function useGeomHover(layerId: string): (key: string | null, cursor?: TooltipCursor) => void;
|
|
634
|
+
|
|
379
635
|
export declare const useGraphCommandDispatcher: () => ((command: Command) => void);
|
|
380
636
|
|
|
381
637
|
/**
|
|
@@ -383,6 +639,25 @@ export declare const useGraphCommandDispatcher: () => ((command: Command) => voi
|
|
|
383
639
|
*/
|
|
384
640
|
export declare function useHoverState<T>(selector: (state: HoverStoreState) => T): T;
|
|
385
641
|
|
|
642
|
+
/**
|
|
643
|
+
* Tracks the on-screen rect of the element the returned `ref` is attached to, across container resize and
|
|
644
|
+
* page scroll. Only a live-simulation geom needs this (ADR-034 decision 4): it paints and hit-tests
|
|
645
|
+
* render-side every frame, so its interactive overlay must sit above the chart in pixel space. Every other
|
|
646
|
+
* geom-layout geom routes hover through the engine (decision 2) and never tracks a screen rect.
|
|
647
|
+
*/
|
|
648
|
+
export declare function usePanelScreenRect(): {
|
|
649
|
+
ref: RefCallback<Element>;
|
|
650
|
+
rect: PanelScreenRect | null;
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Animates SVG path transitions using `d3-interpolate-path` for smooth morphing
|
|
655
|
+
* when data points are added or removed (Framer Motion doesn't support this natively).
|
|
656
|
+
*
|
|
657
|
+
* Based on: https://github.com/framer/motion/issues/451#issuecomment-761302824
|
|
658
|
+
*/
|
|
659
|
+
export declare const useSvgPathMorph: (pathDefinition: string, config: AnimationPlaybackOptions) => MotionValue<string>;
|
|
660
|
+
|
|
386
661
|
export declare const useTextMeasurer: () => TextMeasurer;
|
|
387
662
|
|
|
388
663
|
export declare const vars: {
|