@bicharts/chart-host 0.6.7 → 0.6.8

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.
@@ -3848,9 +3848,27 @@ function toSourceRows(rowMap, payloadRowIdxs) {
3848
3848
  if (!rowMap) return payloadRowIdxs.slice();
3849
3849
  return payloadRowIdxs.map((i) => rowMap[i]).filter((i) => i !== void 0);
3850
3850
  }
3851
- function syncMemberSelection(host, selection, id, highlight, incoming) {
3851
+ function toPayloadRows(rowMap, sourceRowIdxs) {
3852
+ const at3 = /* @__PURE__ */ new Map();
3853
+ rowMap.forEach((src, k3) => {
3854
+ if (!at3.has(src)) at3.set(src, k3);
3855
+ });
3856
+ return sourceRowIdxs.map((s) => at3.get(s)).filter((k3) => k3 !== void 0);
3857
+ }
3858
+ var sameRows = (a4, b4) => {
3859
+ if (a4.length !== b4.length) return false;
3860
+ const x2 = a4.slice().sort((p2, q3) => p2 - q3), y5 = b4.slice().sort((p2, q3) => p2 - q3);
3861
+ return x2.every((v4, i) => v4 === y5[i]);
3862
+ };
3863
+ function syncMemberSelection(host, selection, id, highlight, incoming, rowMap) {
3852
3864
  const mine = selection.sourceId === id && selection.rows.length > 0;
3853
- if (mine) return;
3865
+ if (mine) {
3866
+ if (rowMap) {
3867
+ const want = toPayloadRows(rowMap, selection.rows);
3868
+ if (!sameRows(want, host.selection.current ?? [])) host.selection.highlight(want);
3869
+ }
3870
+ return;
3871
+ }
3854
3872
  if (highlight && incoming && incoming.length) {
3855
3873
  host.selection.highlight(incoming.slice());
3856
3874
  return;
@@ -3929,7 +3947,7 @@ function createChartGroup(columns, rows, opts = {}) {
3929
3947
  const next = payloadFor(highlight ? null : incoming);
3930
3948
  rowMap = next.rowMap;
3931
3949
  host.setData(next.payload);
3932
- syncMemberSelection(host, sel, id, highlight, incoming);
3950
+ syncMemberSelection(host, sel, id, highlight, incoming, rowMap);
3933
3951
  });
3934
3952
  const member = {
3935
3953
  get rowMap() {
package/dist/index.mjs CHANGED
@@ -139,7 +139,7 @@ import {
139
139
  unpinScrolledAxis,
140
140
  valuePlacementFlag,
141
141
  withoutViewOnlyKeys
142
- } from "./chunk-RKOFRMS4.mjs";
142
+ } from "./chunk-EPEVGRL6.mjs";
143
143
  import "./chunk-A2GMXZP7.mjs";
144
144
  import "./chunk-GHODWOAL.mjs";
145
145
 
package/dist/react.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  loadGeo,
8
8
  syncMemberSelection,
9
9
  toSourceRows
10
- } from "./chunk-RKOFRMS4.mjs";
10
+ } from "./chunk-EPEVGRL6.mjs";
11
11
  import "./chunk-A2GMXZP7.mjs";
12
12
  import "./chunk-GHODWOAL.mjs";
13
13
 
@@ -140,7 +140,7 @@ function BicChart(props) {
140
140
  useEffect(() => {
141
141
  const host = hostRef.current;
142
142
  if (!host || !ctx) return;
143
- syncMemberSelection(host, ctx.selection, id, highlightMode, incoming);
143
+ syncMemberSelection(host, ctx.selection, id, highlightMode, incoming, rowMapRef.current);
144
144
  }, [ctx?.selection, id, ctx, highlightMode, incoming && incoming.join(",")]);
145
145
  return /* @__PURE__ */ jsx("div", { ref, className, style });
146
146
  }
@@ -74,13 +74,20 @@ export interface ChartGroup {
74
74
  /** Payload row indices -> source row indices, dropping any the map does not cover. */
75
75
  export declare function toSourceRows(rowMap: readonly number[] | null | undefined, payloadRowIdxs: readonly number[]): number[];
76
76
  /**
77
- * Make a member's painted selection agree with the group's. A member that made the selection
78
- * keeps what its host already painted. A highlight member with an incoming selection paints it.
79
- * Any other member that still shows a selection clears it - a stale highlight left on the origin
80
- * after the selection moved elsewhere, or after a clear. Both paths notify with source "host",
81
- * so nothing done here is republished.
77
+ * Make a member's painted selection agree with the group's. A highlight member with an incoming
78
+ * selection paints it. Any other member that still shows a selection clears it - a stale
79
+ * highlight left on the origin after the selection moved elsewhere, or after a clear.
80
+ *
81
+ * THE MEMBER THAT MADE THE SELECTION keeps it, repainted in the payload it draws NOW when
82
+ * `rowMap` (that payload's row map) is given. Its host holds the selection as PAYLOAD rows, and
83
+ * a member that was filtered when it was clicked stops filtering the moment it becomes the
84
+ * origin - its payload grows back to the whole table and renumbers, so the payload rows its
85
+ * host holds would name different records. The group's selection is in source rows, so it is
86
+ * translated through the new map and repainted when it differs.
87
+ *
88
+ * Every path notifies with source "host", so nothing done here is republished.
82
89
  */
83
- export declare function syncMemberSelection(host: ChartHost, selection: ChartGroupSelection, id: string | undefined, highlight: boolean, incoming: readonly number[] | null): void;
90
+ export declare function syncMemberSelection(host: ChartHost, selection: ChartGroupSelection, id: string | undefined, highlight: boolean, incoming: readonly number[] | null, rowMap?: readonly number[] | null): void;
84
91
  /**
85
92
  * Create a cross-filter group over one source table: `rows` are objects keyed by column name,
86
93
  * `columns` the column descriptors (`ingest()` returns both).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
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",