@bicharts/chart-host 0.6.77 → 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/index.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  formatSourceDateFor,
6
6
  isExcelDateFormat,
7
7
  normaliseAggregation
8
- } from "./chunk-QOKQUXVV.mjs";
8
+ } from "./chunk-M7VM6F73.mjs";
9
9
  import {
10
10
  ANNOTATION_CLASS,
11
11
  ANNOTATION_LAYER_CLASS,
@@ -28,7 +28,6 @@ import {
28
28
  LIGHT_TEXT,
29
29
  MAX_FRAME_GROW_FACTOR,
30
30
  MIN_CONTRAST,
31
- MIN_HIT_BAND_PX,
32
31
  MIN_RAMP_FILLS,
33
32
  PAGE_MATCH_TOLERANCE,
34
33
  PHANTOM_FRACTION,
@@ -37,7 +36,6 @@ import {
37
36
  PILL_OPAQUE_ALPHA,
38
37
  SAME_SHADE_DELTA_E,
39
38
  SCROLL_SLACK_PX,
40
- SELECTION_GLYPH_CLASS,
41
39
  STRADDLE_COLS,
42
40
  STRADDLE_MIN_SHARE,
43
41
  STRADDLE_PILL_ALPHA,
@@ -56,13 +54,10 @@ import {
56
54
  cellSuppressesNormalize,
57
55
  censusClippedText,
58
56
  censusColourSpread,
59
- censusHitBands,
60
57
  censusMarks,
61
58
  censusValuePlacement,
62
59
  clearGeoCache,
63
- clearSelectionGlyphs,
64
60
  clippedTextFlag,
65
- collectD3GlyphCenters,
66
61
  colourSpreadFlag,
67
62
  compileRenderFn,
68
63
  compositeOver,
@@ -70,53 +65,41 @@ import {
70
65
  contrastRatio,
71
66
  createChartGroup,
72
67
  createChartHost,
73
- createMarkResolver,
74
68
  ctmScaleOf,
75
69
  decideLabelColor,
76
70
  deltaEHex,
77
- ensureCrossfilterHitTargets,
78
71
  explainRenderFailure,
79
72
  fitReadingFor,
80
73
  fitRenderedChart,
81
74
  geoAssetFor,
82
75
  geoFromCache,
83
76
  glyphSampleGrid,
84
- hitBandFlag,
85
77
  invalidSentinelReason,
86
78
  isBlankRender,
87
79
  isHorizontalLabelRow,
88
- isInsideControl,
89
80
  isInvalidSentinelError,
90
81
  isPhantomBox,
91
82
  isPillBackdropAlpha,
92
83
  labelBand,
93
84
  loadGeo,
94
- markKeyOf,
95
85
  measureContainerBoxes,
96
86
  minContrastOver,
97
87
  needsScroll,
98
88
  newIdScope,
99
- nextClickedMarks,
100
- nextSelection,
101
89
  noopViewStateProvider,
102
- paintSelectionGlyphs,
103
90
  pickColorOver,
104
91
  pillBacksGlyph,
105
92
  pinScrolledAxis,
106
93
  planAxisPin,
107
94
  planFrameGrow,
108
- planSelectionPaint,
109
95
  registerGeo,
110
96
  registerGeoAsset,
111
97
  relativeLuminance,
112
98
  requiredD3Plugins,
113
99
  resolveAutoColorScale,
114
100
  resolveOptions,
115
- rowIdxsFromMark,
116
- sameRowSet,
117
101
  scopeChartIds,
118
102
  scrollFitFor,
119
- selectionRuleOf,
120
103
  sessionViewStateProvider,
121
104
  straddleSampleGrid,
122
105
  straddles,
@@ -128,12 +111,31 @@ import {
128
111
  toSourceRows,
129
112
  unpinScrolledAxis,
130
113
  valuePlacementFlag
131
- } from "./chunk-IMNZYSIC.mjs";
114
+ } from "./chunk-BFN4NY22.mjs";
132
115
  import {
133
116
  _3,
134
117
  l,
135
118
  o
136
- } from "./chunk-H2P63UMG.mjs";
119
+ } from "./chunk-L554L6HF.mjs";
120
+ import {
121
+ MIN_HIT_BAND_PX,
122
+ SELECTION_GLYPH_CLASS,
123
+ censusHitBands,
124
+ clearSelectionGlyphs,
125
+ collectD3GlyphCenters,
126
+ createMarkResolver,
127
+ ensureCrossfilterHitTargets,
128
+ hitBandFlag,
129
+ isInsideControl,
130
+ markKeyOf,
131
+ nextClickedMarks,
132
+ nextSelection,
133
+ paintSelectionGlyphs,
134
+ planSelectionPaint,
135
+ rowIdxsFromMark,
136
+ sameRowSet,
137
+ selectionRuleOf
138
+ } from "./chunk-MGAO2DR7.mjs";
137
139
  import "./chunk-A2GMXZP7.mjs";
138
140
  import {
139
141
  ACTIVE_TICK_CLASS,
package/dist/react.mjs CHANGED
@@ -22,8 +22,9 @@ import {
22
22
  loadGeo,
23
23
  syncMemberSelection,
24
24
  toSourceRows
25
- } from "./chunk-IMNZYSIC.mjs";
26
- import "./chunk-H2P63UMG.mjs";
25
+ } from "./chunk-BFN4NY22.mjs";
26
+ import "./chunk-L554L6HF.mjs";
27
+ import "./chunk-MGAO2DR7.mjs";
27
28
  import "./chunk-A2GMXZP7.mjs";
28
29
  import "./chunk-7JWL6LYE.mjs";
29
30
  import "./chunk-GHODWOAL.mjs";
@@ -0,0 +1,3 @@
1
+ import type { RendererAdapter } from "./types";
2
+ /** The adapter for a chart drawn with D3: a mark is a DOM element, and its rows are in `data-row-idx`. */
3
+ export declare function createD3Adapter(): RendererAdapter<Element>;
@@ -0,0 +1,3 @@
1
+ export { NULL_ADAPTER } from "./types";
2
+ export type { AdapterEvent, AdapterHit, AdapterScene, MarkHandle, MarkInfo, MarkRole, PaintRequest, RendererAdapter, AdapterId, RowTable, } from "./types";
3
+ export { createD3Adapter } from "./d3";
@@ -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;
@@ -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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.6.77",
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",
@@ -49,6 +49,11 @@
49
49
  "import": "./dist/card.mjs",
50
50
  "default": "./dist/card.mjs"
51
51
  },
52
+ "./adapters": {
53
+ "types": "./dist/types/adapters/index.d.ts",
54
+ "import": "./dist/adapters.mjs",
55
+ "default": "./dist/adapters.mjs"
56
+ },
52
57
  "./dax": {
53
58
  "types": "./dist/types/dax.d.ts",
54
59
  "import": "./dist/dax.mjs",