@bicharts/chart-host 0.6.109 → 0.6.111

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.
Files changed (34) hide show
  1. package/dist/adapters.mjs +3 -3
  2. package/dist/card.mjs +2 -2
  3. package/dist/{chunk-ABGDJ3NJ.mjs → chunk-3JCWTEEH.mjs} +11 -1
  4. package/dist/{chunk-TN5JRULV.mjs → chunk-7XT5OJ6M.mjs} +1 -1
  5. package/dist/{chunk-GQLEU3VC.mjs → chunk-AEO5SFEQ.mjs} +1 -1
  6. package/dist/{chunk-JQ7FFCOE.mjs → chunk-CASW2BIB.mjs} +64 -17
  7. package/dist/{chunk-QAPZIFOB.mjs → chunk-FT75ONSB.mjs} +17 -1
  8. package/dist/{chunk-4DOKJ3R3.mjs → chunk-IL5M7K6Z.mjs} +2 -2
  9. package/dist/{chunk-3ER4C7TG.mjs → chunk-KGVNZR23.mjs} +1 -1
  10. package/dist/{chunk-USZSHKIB.mjs → chunk-KY4FI2HA.mjs} +1 -1
  11. package/dist/{chunk-TH577JHI.mjs → chunk-NJWR3DFK.mjs} +110 -109
  12. package/dist/{chunk-3EQOJHRA.mjs → chunk-PELRAFYZ.mjs} +1 -1
  13. package/dist/{chunk-G4CKILIL.mjs → chunk-Q43WOKSV.mjs} +1 -1
  14. package/dist/{chunk-5WTQN5DL.mjs → chunk-S564YXNE.mjs} +1 -1
  15. package/dist/geo-world.mjs +1 -1
  16. package/dist/geo.mjs +1 -1
  17. package/dist/{geoWorld110m.generated-TD2TA7S7.mjs → geoWorld110m-3PRV3V4G.mjs} +1 -1
  18. package/dist/index.mjs +14 -12
  19. package/dist/legend-fit.mjs +3 -3
  20. package/dist/page.mjs +6 -4
  21. package/dist/provinces.mjs +2 -2
  22. package/dist/react.mjs +33 -11
  23. package/dist/testing.mjs +1 -1
  24. package/dist/types/contract.d.ts +14 -1
  25. package/dist/types/defaults.d.ts +2 -1
  26. package/dist/types/filterScope.d.ts +8 -0
  27. package/dist/types/geo-world.d.ts +1 -1
  28. package/dist/types/geoWorld110m.d.ts +1 -0
  29. package/dist/types/index.d.ts +2 -2
  30. package/dist/types/keyboardMarks.d.ts +3 -2
  31. package/dist/types/page.d.ts +1 -1
  32. package/dist/types/react.d.ts +10 -1
  33. package/dist/zoom-memory.mjs +1 -1
  34. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CONTAINER_SLOT_SCROLL,
4
4
  SNAPSHOT_SVG_ATTR
5
- } from "./chunk-USZSHKIB.mjs";
5
+ } from "./chunk-KY4FI2HA.mjs";
6
6
 
7
7
  // src/fit.ts
8
8
  var SCROLL_SLACK_PX = 8;
@@ -4,7 +4,7 @@ import {
4
4
  LEGEND_MARK_CLASS,
5
5
  MARK_CLASS,
6
6
  ROW_IDX_ATTR
7
- } from "./chunk-USZSHKIB.mjs";
7
+ } from "./chunk-KY4FI2HA.mjs";
8
8
 
9
9
  // src/hitTargets.ts
10
10
  var SVG_NS = "http://www.w3.org/2000/svg";
@@ -4,11 +4,11 @@ import {
4
4
  claimParkedLasso,
5
5
  installLasso,
6
6
  lassoEffect
7
- } from "./chunk-4DOKJ3R3.mjs";
7
+ } from "./chunk-IL5M7K6Z.mjs";
8
8
  import {
9
9
  censusHitBands,
10
10
  ensureCrossfilterHitTargets
11
- } from "./chunk-GQLEU3VC.mjs";
11
+ } from "./chunk-AEO5SFEQ.mjs";
12
12
  import {
13
13
  clearPress,
14
14
  clearSelectionGlyphs,
@@ -25,25 +25,25 @@ import {
25
25
  selectionRuleOf,
26
26
  trackPress,
27
27
  validRowSet
28
- } from "./chunk-3ER4C7TG.mjs";
28
+ } from "./chunk-KGVNZR23.mjs";
29
29
  import {
30
30
  clipWindowOf,
31
31
  fitRenderedChart,
32
32
  rememberScroll,
33
33
  takeScroll,
34
34
  unpinScrolledAxis
35
- } from "./chunk-TN5JRULV.mjs";
35
+ } from "./chunk-7XT5OJ6M.mjs";
36
36
  import {
37
37
  geoFromCache
38
- } from "./chunk-5WTQN5DL.mjs";
38
+ } from "./chunk-S564YXNE.mjs";
39
39
  import {
40
- Dt,
41
40
  Fn,
42
41
  Q,
43
42
  Rr,
44
43
  Yn,
45
- tt
46
- } from "./chunk-TH577JHI.mjs";
44
+ tt,
45
+ xt
46
+ } from "./chunk-NJWR3DFK.mjs";
47
47
  import {
48
48
  ACTIVE_TICK_CLASS,
49
49
  ANIM_LOOP_DELAY_DEFAULT,
@@ -88,7 +88,7 @@ import {
88
88
  XFILTER_REFRESH_EVENT,
89
89
  chartOwnsTimeline,
90
90
  periodTickSuppressesFeedback
91
- } from "./chunk-USZSHKIB.mjs";
91
+ } from "./chunk-KY4FI2HA.mjs";
92
92
 
93
93
  // src/labelContrast.ts
94
94
  function parseRGBA(c) {
@@ -1071,6 +1071,21 @@ function cleanHostSelection(v) {
1071
1071
  }
1072
1072
  return out;
1073
1073
  }
1074
+ function cleanFilterScope(v) {
1075
+ if (!v || typeof v !== "object" || !Array.isArray(v.values)) return void 0;
1076
+ const values = [];
1077
+ for (const x of v.values) {
1078
+ if (typeof x !== "string" && typeof x !== "number" && typeof x !== "boolean" && typeof x !== "bigint") continue;
1079
+ const s = String(x).trim();
1080
+ if (s && !values.includes(s)) values.push(s);
1081
+ }
1082
+ if (!values.length) return void 0;
1083
+ const field = typeof v.field === "string" ? v.field.trim() : "";
1084
+ const out = { field, values };
1085
+ const label = typeof v.label === "string" ? v.label.trim() : "";
1086
+ if (label) out.label = label;
1087
+ return out;
1088
+ }
1074
1089
  var clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
1075
1090
  var numberOr = (raw, dflt) => {
1076
1091
  const n = raw == null || raw === "" ? NaN : Number(raw);
@@ -1105,6 +1120,8 @@ function resolveOptions(p) {
1105
1120
  rowsFilteredOut: p.rowsFilteredOut,
1106
1121
  // A host FACT about its selection (contract 1.21.0), cleaned, never invented: absent stays absent.
1107
1122
  hostSelection: cleanHostSelection(p.hostSelection),
1123
+ // A host FACT about a filter applied before the rows arrived (contract 1.23.0), cleaned, never invented.
1124
+ filterScope: cleanFilterScope(p.filterScope),
1108
1125
  // Host services (contract 1.18.0): a FUNCTION or nothing, so a junk value never reaches a chart as something
1109
1126
  // it would try to call. Passed through untouched otherwise: the host owns what opening or copying means.
1110
1127
  openUrl: typeof p.openUrl === "function" ? p.openUrl : void 0,
@@ -1312,7 +1329,7 @@ function resolvePointChannel(cols, rowObjs, point) {
1312
1329
  const hasPointBind = !!bind && !!(bind.city || bind.state || bind.zip || bind.country || bind.lat && bind.lon);
1313
1330
  if (hasPointBind) {
1314
1331
  const p = bind;
1315
- const built = Dt(rowObjs.map((r) => ({
1332
+ const built = xt(rowObjs.map((r) => ({
1316
1333
  lat: p.lat ? r[p.lat] : null,
1317
1334
  lon: p.lon ? r[p.lon] : null,
1318
1335
  city: p.city ? r[p.city] : null,
@@ -2676,6 +2693,7 @@ function codeHasKeyboardStamp(code) {
2676
2693
  }
2677
2694
  var KEYBOARD_CLASS = "lch-keyboard";
2678
2695
  var WIRED_ATTR = "data-lch-kb";
2696
+ var isDate = (v) => Object.prototype.toString.call(v) === "[object Date]";
2679
2697
  function rowNameOf(columns, row, culture) {
2680
2698
  if (!row) return null;
2681
2699
  const parts = [];
@@ -2683,6 +2701,10 @@ function rowNameOf(columns, row, culture) {
2683
2701
  const name = typeof c === "string" ? c : c?.name;
2684
2702
  const v = row[i];
2685
2703
  if (parts.length >= 4 || v == null || v === "" || typeof name === "string" && name.startsWith("__")) return;
2704
+ if (isDate(v)) {
2705
+ if (!Number.isNaN(v.getTime())) parts.push(v.toLocaleDateString(culture || void 0));
2706
+ return;
2707
+ }
2686
2708
  parts.push(typeof v === "number" ? v.toLocaleString(culture || void 0, { maximumFractionDigits: 2 }) : String(v));
2687
2709
  });
2688
2710
  return parts.length ? parts.join(", ") : null;
@@ -2690,6 +2712,14 @@ function rowNameOf(columns, row, culture) {
2690
2712
  var isClearChord = (e) => !!e.ctrlKey && !!e.shiftKey && (e.key === "C" || e.key === "c");
2691
2713
  var NATIVE = /* @__PURE__ */ new Set(["input", "select", "textarea", "button", "a"]);
2692
2714
  var isNative = (el) => NATIVE.has((el.localName || "").toLowerCase()) || el.isContentEditable === true;
2715
+ var OWN_FOCUS = "input, select, textarea, button, a[href], [role=slider]";
2716
+ function isLeafControl(el, pressSelector) {
2717
+ try {
2718
+ return !el.querySelector(pressSelector) && !el.querySelector(OWN_FOCUS);
2719
+ } catch {
2720
+ return true;
2721
+ }
2722
+ }
2693
2723
  function installKeyboard(env) {
2694
2724
  const { container } = env;
2695
2725
  let rovingKey = null;
@@ -2736,7 +2766,7 @@ function installKeyboard(env) {
2736
2766
  setRoving(own, keep);
2737
2767
  }
2738
2768
  for (const c of Array.from(container.querySelectorAll(env.pressSelector))) {
2739
- if (isNative(c)) continue;
2769
+ if (isNative(c) || !isLeafControl(c, env.pressSelector)) continue;
2740
2770
  wire(c, "0", "button");
2741
2771
  }
2742
2772
  } catch {
@@ -3064,6 +3094,8 @@ function createChartHost(container, config) {
3064
3094
  let selectionIsPeriod = false;
3065
3095
  let selectionFromChart = false;
3066
3096
  let selectionPublished = true;
3097
+ let publishedRows = [];
3098
+ let publishedFromChart = false;
3067
3099
  const clickedMarks = () => container[CONTAINER_SLOT_CLICKED_MARKS] ?? null;
3068
3100
  const setClickedMarks = (c) => {
3069
3101
  try {
@@ -3430,6 +3462,10 @@ function createChartHost(container, config) {
3430
3462
  current = rowIdxs;
3431
3463
  selectionFromChart = rowIdxs.length > 0 && fromChart;
3432
3464
  selectionPublished = publish;
3465
+ if (publish) {
3466
+ publishedRows = rowIdxs;
3467
+ publishedFromChart = selectionFromChart;
3468
+ }
3433
3469
  activeTickEl = rowIdxs.length ? tick ?? null : null;
3434
3470
  selectionIsPeriod = rowIdxs.length > 0 && periodTickSuppressesFeedback(!!tick, chartOwnsTimeline(container));
3435
3471
  if (!rowIdxs.length && !meta?.keepHidden) hiddenHeld = 0;
@@ -3445,6 +3481,10 @@ function createChartHost(container, config) {
3445
3481
  }
3446
3482
  tellSelection();
3447
3483
  };
3484
+ const restorePublished = (source) => {
3485
+ notify(publishedRows, source, void 0, publishedFromChart, false);
3486
+ selectionPublished = true;
3487
+ };
3448
3488
  const selectFromLasso = (rows) => {
3449
3489
  if (lassoEffect(resolved.lasso) === "highlight") {
3450
3490
  notify(rows, "user", null, true, false);
@@ -3471,8 +3511,10 @@ function createChartHost(container, config) {
3471
3511
  const onXf = (e) => {
3472
3512
  const d = e?.detail || {};
3473
3513
  xfAt = Date.now();
3474
- if (d.clear) notify([], d.source || "chart", void 0, false, selectionPublished || !(current && current.length));
3475
- else if (marksInert()) return;
3514
+ if (d.clear) {
3515
+ if (!selectionPublished && current && current.length) restorePublished(d.source || "chart");
3516
+ else notify([], d.source || "chart", void 0, false, true);
3517
+ } else if (marksInert()) return;
3476
3518
  else if (d.mark) notify(parseRowIdxs(d.mark.getAttribute?.(ROW_IDX_ATTR)), d.source || "chart", d.mark, true);
3477
3519
  else if (Array.isArray(d.rows)) notify(validRowSet(d.rows), d.source || "chart", null, true, true, d.keepHidden === true ? { keepHidden: true } : void 0);
3478
3520
  };
@@ -3484,6 +3526,7 @@ function createChartHost(container, config) {
3484
3526
  });
3485
3527
  const clearFromGesture = () => {
3486
3528
  if (current && current.length) {
3529
+ const clearingHighlight = !selectionPublished;
3487
3530
  const slot = container[CONTAINER_SLOT_XF_CLEAR];
3488
3531
  if (selectionFromChart && typeof slot === "function") {
3489
3532
  try {
@@ -3491,7 +3534,9 @@ function createChartHost(container, config) {
3491
3534
  } catch {
3492
3535
  }
3493
3536
  }
3494
- if (current && current.length) notify([], "user", void 0, false, selectionPublished);
3537
+ if (clearingHighlight) {
3538
+ if (!selectionPublished) restorePublished("user");
3539
+ } else if (current && current.length) notify([], "user", void 0, false, true);
3495
3540
  }
3496
3541
  };
3497
3542
  let lasso = null;
@@ -3524,11 +3569,12 @@ function createChartHost(container, config) {
3524
3569
  if (!rows.length) return;
3525
3570
  const tick = el.classList?.contains?.(AXIS_FILTER_CLASS) ? el : null;
3526
3571
  const multi = !!(e?.ctrlKey || e?.metaKey || e?.shiftKey);
3527
- const next = nextSelection(current, rows, { ctrl: !!(e?.ctrlKey || e?.metaKey), shift: !!e?.shiftKey });
3572
+ const base = selectionPublished ? current : publishedRows;
3573
+ const next = nextSelection(base, rows, { ctrl: !!(e?.ctrlKey || e?.metaKey), shift: !!e?.shiftKey });
3528
3574
  const toggledOff = !multi && next.length === 0;
3529
3575
  setClickedMarks(nextClickedMarks(
3530
3576
  clickedMarks(),
3531
- current,
3577
+ base,
3532
3578
  markKeyOf(el),
3533
3579
  next,
3534
3580
  { ctrl: !!(e?.ctrlKey || e?.metaKey), shift: !!e?.shiftKey }
@@ -3773,10 +3819,10 @@ function createChartHost(container, config) {
3773
3819
  const seq2 = ++renderSeq;
3774
3820
  stopAnim();
3775
3821
  followGlyphs(false);
3822
+ focusWas = rememberFocus(container);
3776
3823
  disposeLasso();
3777
3824
  flushZoom();
3778
3825
  if (hasRendered && keepScroll) rememberScroll(container, scrollKey());
3779
- focusWas = rememberFocus(container);
3780
3826
  container.innerHTML = "";
3781
3827
  selfRedraw?.takeRecords();
3782
3828
  hasRendered = true;
@@ -4187,6 +4233,7 @@ export {
4187
4233
  exportTableService,
4188
4234
  browserSaveFile,
4189
4235
  cleanHostSelection,
4236
+ cleanFilterScope,
4190
4237
  resolveOptions,
4191
4238
  buildRenderPayload,
4192
4239
  stripJsComments,
@@ -1,7 +1,7 @@
1
1
  /*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
2
  import {
3
3
  LASSO_KNOB_KEY
4
- } from "./chunk-4DOKJ3R3.mjs";
4
+ } from "./chunk-IL5M7K6Z.mjs";
5
5
 
6
6
  // src/filterScope.ts
7
7
  function viewToken(view) {
@@ -283,6 +283,21 @@ function createFilterScope() {
283
283
  };
284
284
  return scope;
285
285
  }
286
+ function filterScopeOf(filters) {
287
+ const list = Array.isArray(filters) ? filters : filters ? [filters] : [];
288
+ const active = list.filter((f) => f && f.active);
289
+ const values = [];
290
+ for (const f of active) {
291
+ for (const k of f.keys) {
292
+ const t = f.textOf(k).trim();
293
+ if (t && !values.includes(t)) values.push(t);
294
+ }
295
+ }
296
+ if (!values.length) return void 0;
297
+ const fields = [];
298
+ for (const f of active) if (f.label && !fields.includes(f.label)) fields.push(f.label);
299
+ return { field: fields.join(", "), values };
300
+ }
286
301
  var LINKED_HOVER_CLASS = "bic-linked-hover";
287
302
  var hoverStyled = false;
288
303
  function ensureHoverStyle(doc) {
@@ -585,6 +600,7 @@ export {
585
600
  viewFromToken,
586
601
  createFilter,
587
602
  createFilterScope,
603
+ filterScopeOf,
588
604
  LINKED_HOVER_CLASS,
589
605
  payloadRowReader,
590
606
  bindFilter,
@@ -4,7 +4,7 @@ import {
4
4
  gestureWasDrag,
5
5
  isInsideControl,
6
6
  rowIdxsFromMark
7
- } from "./chunk-3ER4C7TG.mjs";
7
+ } from "./chunk-KGVNZR23.mjs";
8
8
  import {
9
9
  AXIS_FILTER_CLASS,
10
10
  CONTROL_CLASS,
@@ -12,7 +12,7 @@ import {
12
12
  MARK_CLASS,
13
13
  ROW_IDX_ATTR,
14
14
  SNAPSHOT_SVG_ATTR
15
- } from "./chunk-USZSHKIB.mjs";
15
+ } from "./chunk-KY4FI2HA.mjs";
16
16
 
17
17
  // src/lasso.ts
18
18
  var LASSO_ROW_CAP = 5e3;
@@ -8,7 +8,7 @@ import {
8
8
  SELECTION_RULE_ATTR,
9
9
  SELECTION_RULE_CLICKED_MARKS,
10
10
  XFILTER_REFRESH_EVENT
11
- } from "./chunk-USZSHKIB.mjs";
11
+ } from "./chunk-KY4FI2HA.mjs";
12
12
 
13
13
  // src/selection.ts
14
14
  function rowIdxsFromMark(el) {
@@ -1,7 +1,7 @@
1
1
  /*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
2
 
3
3
  // src/contract.ts
4
- var HOST_CONTRACT_VERSION = "1.22.0";
4
+ var HOST_CONTRACT_VERSION = "1.23.0";
5
5
  var GEO_POINT_PRECISIONS = ["latlon", "city", "zip3", "state", "country"];
6
6
  var MARK_CLASS = "d3-mark";
7
7
  var LEGEND_MARK_CLASS = "d3-legend-mark";