@bicharts/chart-host 0.6.76 → 0.6.78
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/adapters.mjs +75 -0
- package/dist/card.mjs +234 -0
- package/dist/chunk-BFN4NY22.mjs +3286 -0
- package/dist/{chunk-ZEXMBZHP.mjs → chunk-L554L6HF.mjs} +40 -3830
- package/dist/chunk-M7VM6F73.mjs +614 -0
- package/dist/chunk-MGAO2DR7.mjs +543 -0
- package/dist/index.mjs +72 -664
- package/dist/react.mjs +3 -1
- package/dist/types/adapters/d3.d.ts +3 -0
- package/dist/types/adapters/index.d.ts +3 -0
- package/dist/types/adapters/types.d.ts +108 -0
- package/dist/types/card.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/selectionCardChrome.d.ts +29 -0
- package/package.json +11 -1
package/dist/react.mjs
CHANGED
|
@@ -22,7 +22,9 @@ import {
|
|
|
22
22
|
loadGeo,
|
|
23
23
|
syncMemberSelection,
|
|
24
24
|
toSourceRows
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-BFN4NY22.mjs";
|
|
26
|
+
import "./chunk-L554L6HF.mjs";
|
|
27
|
+
import "./chunk-MGAO2DR7.mjs";
|
|
26
28
|
import "./chunk-A2GMXZP7.mjs";
|
|
27
29
|
import "./chunk-7JWL6LYE.mjs";
|
|
28
30
|
import "./chunk-GHODWOAL.mjs";
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { RendererId } from "../host/services";
|
|
2
|
+
import type { SelectionModifiers, SelectionPaintPlan, SelectionRule, GlyphCenter } from "../selection";
|
|
3
|
+
/** What a renderer calls a mark. Opaque to the core: D3 an Element, Plotly {curve, point}, Vega a scenegraph item. */
|
|
4
|
+
export type MarkHandle = unknown;
|
|
5
|
+
/** What a mark is for: a data mark, a legend swatch, or an axis label that filters. */
|
|
6
|
+
export type MarkRole = "mark" | "legend" | "axis";
|
|
7
|
+
/** Which renderer an adapter binds: the same vocabulary a host declares it supports (host/services.ts). */
|
|
8
|
+
export type AdapterId = RendererId | "NONE";
|
|
9
|
+
/** The rows a renderer that works in values (Vega) resolves a click against. */
|
|
10
|
+
export interface RowTable {
|
|
11
|
+
rows: readonly Record<string, unknown>[];
|
|
12
|
+
columns: readonly {
|
|
13
|
+
name?: string;
|
|
14
|
+
isMeasure?: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
/** Everything an adapter may need about the chart it is bound to. */
|
|
18
|
+
export interface AdapterScene {
|
|
19
|
+
container: HTMLElement;
|
|
20
|
+
doc: Document;
|
|
21
|
+
/** How many rows the chart has: the bound a renderer that reads row numbers from its own data must check. */
|
|
22
|
+
rowCount?: number;
|
|
23
|
+
/** The row table, for a renderer whose marks name values. */
|
|
24
|
+
table?: RowTable;
|
|
25
|
+
/** The diagnostics sink; the resolution logic logs through it and never throws. */
|
|
26
|
+
log(tag: string, data?: object): void;
|
|
27
|
+
}
|
|
28
|
+
/** One mark as the core sees it. */
|
|
29
|
+
export interface MarkInfo<H = MarkHandle> {
|
|
30
|
+
handle: H;
|
|
31
|
+
role: MarkRole;
|
|
32
|
+
/** The data rows the mark stands for. */
|
|
33
|
+
rows: readonly number[];
|
|
34
|
+
/** The mark's identity under the "clicked-marks" selection rule. */
|
|
35
|
+
key: string;
|
|
36
|
+
}
|
|
37
|
+
/** A click as the core hands it over. `native` is whatever the renderer's own event is. */
|
|
38
|
+
export interface AdapterEvent {
|
|
39
|
+
native: unknown;
|
|
40
|
+
clientX?: number;
|
|
41
|
+
clientY?: number;
|
|
42
|
+
modifiers: SelectionModifiers;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What a click turned out to be. The four are different gestures and the core answers each differently, so an
|
|
46
|
+
* adapter must say which:
|
|
47
|
+
* mark - a mark (furniture included; `role` says which);
|
|
48
|
+
* control - inside a control the chart drew: neither a selection nor a click on empty canvas;
|
|
49
|
+
* empty - the empty canvas: the core MAY clear the selection (D3);
|
|
50
|
+
* ignored - a click that resolves to nothing the adapter can use: log it and change nothing (Vega).
|
|
51
|
+
*/
|
|
52
|
+
export type AdapterHit<H = MarkHandle> = {
|
|
53
|
+
kind: "mark";
|
|
54
|
+
mark: MarkInfo<H>;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "control";
|
|
57
|
+
} | {
|
|
58
|
+
kind: "empty";
|
|
59
|
+
} | {
|
|
60
|
+
kind: "ignored";
|
|
61
|
+
reason: string;
|
|
62
|
+
};
|
|
63
|
+
/** A request to draw a selection. `plan` is present when the renderer's marks can be listed (D3). */
|
|
64
|
+
export interface PaintRequest<H = MarkHandle> {
|
|
65
|
+
selection: ReadonlySet<number>;
|
|
66
|
+
active: boolean;
|
|
67
|
+
dimOpacity: number;
|
|
68
|
+
plan?: {
|
|
69
|
+
marks: readonly MarkInfo<H>[];
|
|
70
|
+
result: SelectionPaintPlan;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* One renderer's binding. Every capability but identity is optional, because renderers differ in what they own: a
|
|
75
|
+
* renderer that subscribes to its own click events implements `bind` and leaves `hit` out; one the core's container
|
|
76
|
+
* listener serves implements `hit`.
|
|
77
|
+
*/
|
|
78
|
+
export interface RendererAdapter<H = MarkHandle> {
|
|
79
|
+
readonly id: AdapterId;
|
|
80
|
+
/** Who delivers clicks: the core's container listener, the adapter's own subscription, or nobody. */
|
|
81
|
+
readonly input: "container-click" | "adapter-bound" | "none";
|
|
82
|
+
/** Subscribe to the renderer's own click events; returns the unsubscribe. */
|
|
83
|
+
bind?(scene: AdapterScene, onHit: (hit: AdapterHit<H>, modifiers: SelectionModifiers) => void): () => void;
|
|
84
|
+
/** Every mark the chart drew, as opaque handles. */
|
|
85
|
+
marks?(scene: AdapterScene): readonly MarkInfo<H>[];
|
|
86
|
+
/** Resolve a click to what it hit. */
|
|
87
|
+
hit?(event: AdapterEvent, scene: AdapterScene): AdapterHit<H>;
|
|
88
|
+
/** The data rows a mark stands for. */
|
|
89
|
+
rowsOf?(handle: H, scene: AdapterScene, role?: MarkRole): number[];
|
|
90
|
+
/** How a selection lights this chart's marks; "any-row" when the chart declared nothing. */
|
|
91
|
+
declaredRule?(scene: AdapterScene): SelectionRule;
|
|
92
|
+
/** Draw a selection. */
|
|
93
|
+
paint?(request: PaintRequest<H>, scene: AdapterScene): void | Promise<void>;
|
|
94
|
+
/** Where each selected mark's glyph goes, in pixels from `base`. */
|
|
95
|
+
glyphAnchors?(base: {
|
|
96
|
+
left: number;
|
|
97
|
+
top: number;
|
|
98
|
+
}, scene: AdapterScene): GlyphCenter[];
|
|
99
|
+
/** Make the render hittable after it draws; returns what it changed. */
|
|
100
|
+
prepare?(scene: AdapterScene): unknown;
|
|
101
|
+
/** A behavior tag and detail for the render, or null when there is nothing to say. */
|
|
102
|
+
census?(scene: AdapterScene): {
|
|
103
|
+
flag: string;
|
|
104
|
+
detail: object;
|
|
105
|
+
} | null;
|
|
106
|
+
}
|
|
107
|
+
/** No marks and no binding: legal, and what a chart that cannot be selected from is. */
|
|
108
|
+
export declare const NULL_ADAPTER: RendererAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSelectionCards, type SelectionCards, type SelectionCardsDeps } from "./selectionCardChrome";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type { Controls, ControlInfo, ControlsAttachment } from "./controls";
|
|
|
14
14
|
export { createChartGroup, toSourceRows, syncMemberSelection, type ChartGroup, type ChartGroupMember, type ChartGroupSelection, type ChartGroupChange, type ChartGroupMemberOptions, type ChartGroupSourceOptions, type ChartGroupPayload } from "./group";
|
|
15
15
|
export type { Filter, FilterScope, FilterOptions, FilterKey, FilterChangeReason, FilterBinding, BindFilterOptions, VegaInteractionEvent, PageView } from "./filterScope";
|
|
16
16
|
export { createMarkResolver, isInsideControl, rowIdxsFromMark, nextSelection, selectionRuleOf, markKeyOf, planSelectionPaint, nextClickedMarks, sameRowSet, type SelectionRule, type ClickedMarks, type SelectionPaintMark, type SelectionPaintMode, type SelectionPaintPlan, collectD3GlyphCenters, clearSelectionGlyphs, paintSelectionGlyphs, SELECTION_GLYPH_CLASS, type MarkResolver, type MarkResolverEnv, type GlyphCenter, type SelectionGlyphStyle, type SelectionModifiers, } from "./selection";
|
|
17
|
+
export type { AdapterEvent, AdapterHit, AdapterId, AdapterScene, MarkHandle, MarkInfo, MarkRole, PaintRequest, RendererAdapter, RowTable, } from "./adapters/types";
|
|
17
18
|
export { planTrivialChart, compileTrivialSource, type TrivialPlan, type TrivialShapeKind } from "./trivial";
|
|
18
19
|
export { captureSvgSnapshot, svgToDataUrl, svgNaturalSize, rasterizeSvgToPngDataUrl, tableHostOf, chartSvgOf, htmlToSvgDataUrl, htmlNaturalSize, type SnapshotOptions } from "./snapshot";
|
|
19
20
|
export { shouldReview, buildReviewWire, bareBase64, actionFor, type ReviewGate, type ReviewWire, type ReviewVerdict, type ReviewAction } from "./review";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SourceFormats } from "./sourceDateFormat";
|
|
2
|
+
export interface SelectionCardsDeps {
|
|
3
|
+
/** The positioned ancestor the cards live inside. Nothing the visual draws escapes its
|
|
4
|
+
* frame, and a card is visual-drawn, so this is a hard boundary rather than a preference. */
|
|
5
|
+
container: HTMLElement;
|
|
6
|
+
/** The payload the chart was drawn from. A getter, not a value: the chart is redrawn on
|
|
7
|
+
* resize, on a cell edit and on a live restyle, and a captured payload would age out. */
|
|
8
|
+
getPayload: () => any;
|
|
9
|
+
/** The chart's own aggregation, so the card cannot contradict the picture it sits on. */
|
|
10
|
+
getAggregation: () => string;
|
|
11
|
+
/** The source's own per-column date formats (a worksheet's number formats, a model's format
|
|
12
|
+
* strings), so a click on a date is answered in the reader's formatting rather than in the
|
|
13
|
+
* payload's ISO instant. A getter for the same reason `getPayload` is one - the source is
|
|
14
|
+
* re-read on every resize and every edit. Optional: without it the card still renders a
|
|
15
|
+
* locale date, never the ISO. */
|
|
16
|
+
getSourceFormats?: () => SourceFormats | null;
|
|
17
|
+
getEnabled: () => boolean;
|
|
18
|
+
getPinLimit: () => number;
|
|
19
|
+
cultureCode?: string;
|
|
20
|
+
log?: (tag: string, detail?: unknown) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface SelectionCards {
|
|
23
|
+
/** Hand it the row set chart-host resolved. Empty clears. */
|
|
24
|
+
onSelect(rowIdxs: number[]): void;
|
|
25
|
+
/** Drop the transient card AND every pin - used when the chart itself goes away. */
|
|
26
|
+
clear(): void;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function createSelectionCards(deps: SelectionCardsDeps): SelectionCards;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-host",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.78",
|
|
4
4
|
"description": "Run a BIC-generated D3 chart in any web host: compiles the generated render() function, applies the shared option defaults, resolves mark clicks (through tooltip overlays), owns the selection affordance, and translates row indices between cross-filtered charts. The same contract the BIC Power BI visual implements, minus Power BI. React bindings at @bicharts/chart-host/react.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -44,6 +44,16 @@
|
|
|
44
44
|
"import": "./dist/page.mjs",
|
|
45
45
|
"default": "./dist/page.mjs"
|
|
46
46
|
},
|
|
47
|
+
"./card": {
|
|
48
|
+
"types": "./dist/types/card.d.ts",
|
|
49
|
+
"import": "./dist/card.mjs",
|
|
50
|
+
"default": "./dist/card.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./adapters": {
|
|
53
|
+
"types": "./dist/types/adapters/index.d.ts",
|
|
54
|
+
"import": "./dist/adapters.mjs",
|
|
55
|
+
"default": "./dist/adapters.mjs"
|
|
56
|
+
},
|
|
47
57
|
"./dax": {
|
|
48
58
|
"types": "./dist/types/dax.d.ts",
|
|
49
59
|
"import": "./dist/dax.mjs",
|