col-browser 2.3.10 → 2.5.0

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 (55) hide show
  1. package/README.md +54 -2
  2. package/es/bibtex.js +2 -2
  3. package/es/chunks/{BibTex-CPaVr-5w.js → BibTex-CyUpSmpY.js} +2 -2
  4. package/es/chunks/{BibTex-CPaVr-5w.js.map → BibTex-CyUpSmpY.js.map} +1 -1
  5. package/es/chunks/{DatasetCitation-JpNSTWz-.js → DatasetCitation-BnOkKDTv.js} +2 -2
  6. package/es/chunks/{DatasetCitation-JpNSTWz-.js.map → DatasetCitation-BnOkKDTv.js.map} +1 -1
  7. package/es/chunks/{DatasetlogoWithFallback-BhWvpgDn.js → DatasetlogoWithFallback-DJEkjMJ1.js} +2 -2
  8. package/es/chunks/{DatasetlogoWithFallback-BhWvpgDn.js.map → DatasetlogoWithFallback-DJEkjMJ1.js.map} +1 -1
  9. package/es/chunks/Distributions-Dwjo7KhA.js +1173 -0
  10. package/es/chunks/Distributions-Dwjo7KhA.js.map +1 -0
  11. package/es/chunks/{MergedDataBadge-DK4XUXsL.js → MergedDataBadge-FvHUdT7B.js} +2 -2
  12. package/es/chunks/{MergedDataBadge-DK4XUXsL.js.map → MergedDataBadge-FvHUdT7B.js.map} +1 -1
  13. package/es/chunks/{TaxonBreakdown-BYRnP8bH.js → TaxonBreakdown-D9g3tYXL.js} +2 -2
  14. package/es/chunks/{TaxonBreakdown-BYRnP8bH.js.map → TaxonBreakdown-D9g3tYXL.js.map} +1 -1
  15. package/es/chunks/{XrGutter-CORP2r5Y.js → XrGutter-D3PMq-Dn.js} +2 -2
  16. package/es/chunks/{XrGutter-CORP2r5Y.js.map → XrGutter-D3PMq-Dn.js.map} +1 -1
  17. package/es/chunks/config-D4b3a4Yi.js +27 -0
  18. package/es/chunks/config-D4b3a4Yi.js.map +1 -0
  19. package/es/chunks/{dataset-BuF063rn.js → dataset-D_gmg2Zv.js} +2 -2
  20. package/es/chunks/{dataset-BuF063rn.js.map → dataset-D_gmg2Zv.js.map} +1 -1
  21. package/es/chunks/{enumeration-CC8SblcI.js → enumeration-B-nIqCor.js} +2 -2
  22. package/es/chunks/{enumeration-CC8SblcI.js.map → enumeration-B-nIqCor.js.map} +1 -1
  23. package/es/chunks/{sector-Behb-WCC.js → sector-CE-w32Gs.js} +2 -2
  24. package/es/chunks/{sector-Behb-WCC.js.map → sector-CE-w32Gs.js.map} +1 -1
  25. package/es/chunks/withTheme-Dh6PRuII.js +17 -0
  26. package/es/chunks/withTheme-Dh6PRuII.js.map +1 -0
  27. package/es/config.js +5 -0
  28. package/es/config.js.map +1 -0
  29. package/es/index.js +4 -2
  30. package/es/index.js.map +1 -1
  31. package/es/search.js +14 -13
  32. package/es/search.js.map +1 -1
  33. package/es/sourceDataset.js +7 -6
  34. package/es/sourceDataset.js.map +1 -1
  35. package/es/sourceDatasetList.js +16 -15
  36. package/es/sourceDatasetList.js.map +1 -1
  37. package/es/taxon.js +746 -741
  38. package/es/taxon.js.map +1 -1
  39. package/es/taxonBreakdown.js +23 -22
  40. package/es/taxonBreakdown.js.map +1 -1
  41. package/es/taxonDistribution.js +32 -29
  42. package/es/taxonDistribution.js.map +1 -1
  43. package/es/tree.js +8 -7
  44. package/es/tree.js.map +1 -1
  45. package/package.json +5 -1
  46. package/types/config.d.ts +1 -0
  47. package/types/index.d.ts +39 -0
  48. package/umd/col-browser.js +57 -30
  49. package/umd/col-browser.js.map +1 -1
  50. package/umd/col-browser.min.js +4 -4
  51. package/umd/col-browser.min.js.map +1 -1
  52. package/es/chunks/Distributions-CKn1-Qze.js +0 -1169
  53. package/es/chunks/Distributions-CKn1-Qze.js.map +0 -1
  54. package/es/chunks/config-B2Z9BaEd.js +0 -30
  55. package/es/chunks/config-B2Z9BaEd.js.map +0 -1
package/types/index.d.ts CHANGED
@@ -82,6 +82,12 @@ export interface TaxonProps
82
82
  identifierLabel?: string;
83
83
  showDistributionMap?: boolean;
84
84
  gbifChecklistKey?: string | number;
85
+ /**
86
+ * MapLibre basemap for the distribution map: a style URL (with your
87
+ * provider's API key baked in) or an inline style object. Overrides the
88
+ * global `configure({ basemapStyle })` default for this instance.
89
+ */
90
+ basemapStyle?: string | Record<string, unknown>;
85
91
  /** HTTP Basic Auth credentials in `user:password` form. */
86
92
  auth?: string;
87
93
  }
@@ -126,11 +132,44 @@ export interface TaxonDistributionProps extends ThemeProps, NavigationProps {
126
132
  taxonId?: string;
127
133
  datasetKey?: string | number;
128
134
  gbifChecklistKey?: string | number;
135
+ /**
136
+ * MapLibre basemap for the distribution map: a style URL (with your
137
+ * provider's API key baked in) or an inline style object. Overrides the
138
+ * global `configure({ basemapStyle })` default for this instance.
139
+ */
140
+ basemapStyle?: string | Record<string, unknown>;
129
141
  style?: React.CSSProperties;
130
142
  /** HTTP Basic Auth credentials in `user:password` form. */
131
143
  auth?: string;
132
144
  }
133
145
 
146
+ /** Base URLs the components talk to. Override them with `configure`. */
147
+ export interface ColBrowserConfig {
148
+ /** ChecklistBank API base. Defaults to "https://api.checklistbank.org/". */
149
+ dataApi: string;
150
+ /** Human-facing ChecklistBank portal, for outbound dataset/publisher links. */
151
+ clbPortal: string;
152
+ /** GBIF API base, for the occurrence count and map tiles. */
153
+ gbifApi: string;
154
+ /** GBIF portal the occurrence attribution link points at. */
155
+ gbifPortal: string;
156
+ /**
157
+ * MapLibre basemap for the distribution map: a style URL (with your
158
+ * provider's API key baked in) or an inline style object. Defaults to
159
+ * CARTO's keyless Positron CDN. Stored verbatim — not URL-normalised.
160
+ */
161
+ basemapStyle: string | Record<string, unknown>;
162
+ }
163
+
164
+ /**
165
+ * Override the base URLs the components talk to, e.g. to point them at the
166
+ * ChecklistBank dev API. Merges into the shared config — keys left out keep
167
+ * their current value. Call once before rendering.
168
+ */
169
+ export function configure(
170
+ overrides: Partial<ColBrowserConfig>
171
+ ): ColBrowserConfig;
172
+
134
173
  export const Tree: React.FC<TreeProps>;
135
174
  export const Search: React.FC<SearchProps>;
136
175
  export const Taxon: React.FC<TaxonProps>;
@@ -29818,7 +29818,7 @@ html body {
29818
29818
  });
29819
29819
  }
29820
29820
  const SPLIT = "__@field_split__";
29821
- function normalize(namePath) {
29821
+ function normalize$1(namePath) {
29822
29822
  return namePath.map((cell) => `${typeof cell}:${cell}`).join(SPLIT);
29823
29823
  }
29824
29824
  class NameMap {
@@ -29826,13 +29826,13 @@ html body {
29826
29826
  __publicField(this, "kvs", /* @__PURE__ */ new Map());
29827
29827
  }
29828
29828
  set(key2, value) {
29829
- this.kvs.set(normalize(key2), value);
29829
+ this.kvs.set(normalize$1(key2), value);
29830
29830
  }
29831
29831
  get(key2) {
29832
- return this.kvs.get(normalize(key2));
29832
+ return this.kvs.get(normalize$1(key2));
29833
29833
  }
29834
29834
  getAsPrefix(key2) {
29835
- const normalizedKey = normalize(key2);
29835
+ const normalizedKey = normalize$1(key2);
29836
29836
  const normalizedPrefix = normalizedKey + SPLIT;
29837
29837
  const results = [];
29838
29838
  const current = this.kvs.get(normalizedKey);
@@ -29856,7 +29856,7 @@ html body {
29856
29856
  }
29857
29857
  }
29858
29858
  delete(key2) {
29859
- this.kvs.delete(normalize(key2));
29859
+ this.kvs.delete(normalize$1(key2));
29860
29860
  }
29861
29861
  // Since we only use this in test, let simply realize this
29862
29862
  map(callback) {
@@ -67804,8 +67804,22 @@ html body {
67804
67804
  gbifApi: "https://api.gbif.org",
67805
67805
  // GBIF human-facing portal where the attribution link points. The
67806
67806
  // multitaxonomy occurrence search now ships on the production portal.
67807
- gbifPortal: "https://www.gbif.org"
67808
- };
67807
+ gbifPortal: "https://www.gbif.org",
67808
+ // MapLibre basemap for the distribution map. Anything MapLibre accepts as
67809
+ // `style` works: a style URL (bake your provider's API key into it) or an
67810
+ // inline style object. The default is CARTO's public Positron CDN, which
67811
+ // needs no key.
67812
+ basemapStyle: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
67813
+ };
67814
+ const SLASH_TERMINATED = /* @__PURE__ */ new Set(["dataApi"]);
67815
+ const VERBATIM = /* @__PURE__ */ new Set(["basemapStyle"]);
67816
+ const normalize = (key2, value) => SLASH_TERMINATED.has(key2) ? value.replace(/\/*$/, "/") : value.replace(/\/+$/, "");
67817
+ function configure(overrides = {}) {
67818
+ Object.entries(overrides).forEach(([key2, value]) => {
67819
+ config[key2] = typeof value === "string" && !VERBATIM.has(key2) ? normalize(key2, value) : value;
67820
+ });
67821
+ return config;
67822
+ }
67809
67823
  var dataloader;
67810
67824
  var hasRequiredDataloader;
67811
67825
  function requireDataloader() {
@@ -77972,6 +77986,7 @@ html body {
77972
77986
  });
77973
77987
  return out;
77974
77988
  };
77989
+ const resolveBasemapStyle = (prop) => prop ?? config.basemapStyle;
77975
77990
  const wrapStyle = {
77976
77991
  position: "absolute",
77977
77992
  bottom: 8,
@@ -78128,7 +78143,6 @@ html body {
78128
78143
  const k = resolveKey(record);
78129
78144
  return k == null ? MISSING_COLOR : ESTABLISHMENT_COLORS[k];
78130
78145
  };
78131
- const POSITRON_STYLE = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json";
78132
78146
  const GBIF_VISIBLE_KEY = "gbif-visible";
78133
78147
  const readStoredGbifVisible = (defaultValue) => readSetting(GBIF_VISIBLE_KEY, defaultValue);
78134
78148
  const writeStoredGbifVisible = (visible) => writeSetting(GBIF_VISIBLE_KEY, visible);
@@ -78241,7 +78255,10 @@ html body {
78241
78255
  // true | null → show GBIF layer; false → GBIF API returned 0 occurrences,
78242
78256
  // grey out the toggle and skip loading tiles. Defaults to true so the
78243
78257
  // component works without the count check.
78244
- gbifAvailable = true
78258
+ gbifAvailable = true,
78259
+ // MapLibre style URL or inline style object; falls back to the global
78260
+ // `configure({ basemapStyle })` value. Changing it rebuilds the map.
78261
+ basemapStyle
78245
78262
  }) => {
78246
78263
  var _a2;
78247
78264
  const containerRef = reactExports.useRef(null);
@@ -78254,7 +78271,7 @@ html body {
78254
78271
  const focalAttachedRef = reactExports.useRef(false);
78255
78272
  const gbifAttachedRef = reactExports.useRef(false);
78256
78273
  const descendantLayersRef = reactExports.useRef(/* @__PURE__ */ new Set());
78257
- const [styleReady, setStyleReady] = reactExports.useState(false);
78274
+ const [readyMap, setReadyMap] = reactExports.useState(null);
78258
78275
  const [focalReady, setFocalReady] = reactExports.useState(false);
78259
78276
  const [descendantState, setDescendantState] = reactExports.useState({
78260
78277
  status: "idle",
@@ -78327,12 +78344,14 @@ html body {
78327
78344
  return { visibleGroups, unmappableGroups };
78328
78345
  }, [descendantState, descendantColors, visibleTaxonIds]);
78329
78346
  const showDescendantLegend = descendantLegend.visibleGroups.length > 0;
78347
+ const styleSpec = resolveBasemapStyle(basemapStyle);
78348
+ const styleKey = typeof styleSpec === "string" ? styleSpec : JSON.stringify(styleSpec);
78330
78349
  reactExports.useEffect(() => {
78331
78350
  if (!containerRef.current || mapRef.current) return;
78332
78351
  if (!supported()) return;
78333
78352
  const map = new maplibregl.Map({
78334
78353
  container: containerRef.current,
78335
- style: POSITRON_STYLE,
78354
+ style: styleSpec,
78336
78355
  center: [0, 20],
78337
78356
  zoom: 1,
78338
78357
  minZoom: 0,
@@ -78353,7 +78372,7 @@ html body {
78353
78372
  );
78354
78373
  mapRef.current = map;
78355
78374
  map.on("load", () => {
78356
- setStyleReady(true);
78375
+ setReadyMap(map);
78357
78376
  const attrib = map.getContainer().querySelector(".maplibregl-ctrl-attrib");
78358
78377
  if (attrib) attrib.classList.remove("maplibregl-compact-show");
78359
78378
  });
@@ -78370,12 +78389,12 @@ html body {
78370
78389
  focalAttachedRef.current = false;
78371
78390
  gbifAttachedRef.current = false;
78372
78391
  descendantLayersRef.current = /* @__PURE__ */ new Set();
78392
+ setReadyMap(null);
78373
78393
  };
78374
- }, []);
78394
+ }, [styleKey]);
78375
78395
  reactExports.useEffect(() => {
78376
- if (!styleReady || !(records == null ? void 0 : records.length)) return;
78377
- const map = mapRef.current;
78378
- if (!map) return;
78396
+ const map = readyMap;
78397
+ if (!map || !(records == null ? void 0 : records.length)) return;
78379
78398
  let cancelled = false;
78380
78399
  setFocalReady(false);
78381
78400
  Promise.allSettled(
@@ -78386,7 +78405,7 @@ html body {
78386
78405
  }))
78387
78406
  )
78388
78407
  ).then((results) => {
78389
- if (cancelled) return;
78408
+ if (cancelled || mapRef.current !== map) return;
78390
78409
  const features = [];
78391
78410
  const recordMap = /* @__PURE__ */ new Map();
78392
78411
  let failures = 0;
@@ -78456,7 +78475,7 @@ html body {
78456
78475
  return () => {
78457
78476
  cancelled = true;
78458
78477
  };
78459
- }, [styleReady, records]);
78478
+ }, [readyMap, records]);
78460
78479
  const onFocalClick = (e2) => {
78461
78480
  var _a3, _b2;
78462
78481
  const map = mapRef.current;
@@ -78484,8 +78503,7 @@ html body {
78484
78503
  if (map.getLayer(FOCAL_LINE)) map.setLayoutProperty(FOCAL_LINE, "visibility", v2);
78485
78504
  }, [focalVisible, focalReady]);
78486
78505
  reactExports.useEffect(() => {
78487
- if (!styleReady) return;
78488
- const map = mapRef.current;
78506
+ const map = readyMap;
78489
78507
  if (!map) return;
78490
78508
  const removeGbif = () => {
78491
78509
  if (map.getLayer(GBIF_LAYER)) map.removeLayer(GBIF_LAYER);
@@ -78511,16 +78529,16 @@ html body {
78511
78529
  layout: { visibility: gbifVisible ? "visible" : "none" }
78512
78530
  });
78513
78531
  gbifAttachedRef.current = true;
78514
- }, [styleReady, gbifChecklistKey, focalTaxon == null ? void 0 : focalTaxon.id, gbifAvailable]);
78532
+ }, [readyMap, gbifChecklistKey, focalTaxon == null ? void 0 : focalTaxon.id, gbifAvailable]);
78515
78533
  reactExports.useEffect(() => {
78516
78534
  const map = mapRef.current;
78517
78535
  if (!map || !gbifAttachedRef.current) return;
78518
78536
  const v2 = gbifVisible ? "visible" : "none";
78519
78537
  if (map.getLayer(GBIF_LAYER)) map.setLayoutProperty(GBIF_LAYER, "visibility", v2);
78520
78538
  }, [gbifVisible]);
78539
+ const descendantVisibility = (id) => visibleTaxonIds.has(id) ? "visible" : "none";
78521
78540
  reactExports.useEffect(() => {
78522
- if (!styleReady) return;
78523
- const map = mapRef.current;
78541
+ const map = readyMap;
78524
78542
  if (!map) return;
78525
78543
  descendantLayersRef.current.forEach((id) => {
78526
78544
  if (map.getLayer(descendantFillId(id))) map.removeLayer(descendantFillId(id));
@@ -78543,7 +78561,7 @@ html body {
78543
78561
  }))
78544
78562
  )
78545
78563
  ).then((results) => {
78546
- if (!mapRef.current) return;
78564
+ if (mapRef.current !== map) return;
78547
78565
  const features = [];
78548
78566
  results.forEach((res, i) => {
78549
78567
  if (res.status !== "fulfilled" || !res.value.geojson) return;
@@ -78576,7 +78594,7 @@ html body {
78576
78594
  type: "fill",
78577
78595
  source: srcId,
78578
78596
  paint: { "fill-color": color, "fill-opacity": 0.55 },
78579
- layout: { visibility: "none" }
78597
+ layout: { visibility: descendantVisibility(t2.id) }
78580
78598
  },
78581
78599
  beforeId
78582
78600
  );
@@ -78586,7 +78604,7 @@ html body {
78586
78604
  type: "line",
78587
78605
  source: srcId,
78588
78606
  paint: { "line-color": color, "line-width": 2 },
78589
- layout: { visibility: "none" }
78607
+ layout: { visibility: descendantVisibility(t2.id) }
78590
78608
  },
78591
78609
  beforeId
78592
78610
  );
@@ -78597,7 +78615,7 @@ html body {
78597
78615
  }
78598
78616
  });
78599
78617
  });
78600
- }, [styleReady, descendantState, descendantColors]);
78618
+ }, [readyMap, descendantState, descendantColors]);
78601
78619
  const onDescendantClick = (e2) => {
78602
78620
  var _a3, _b2;
78603
78621
  const map = mapRef.current;
@@ -79070,6 +79088,7 @@ html body {
79070
79088
  focalTaxon,
79071
79089
  rankOrder,
79072
79090
  gbifChecklistKey,
79091
+ basemapStyle,
79073
79092
  label,
79074
79093
  md: md2
79075
79094
  }) => {
@@ -79148,7 +79167,8 @@ html body {
79148
79167
  focalTaxon,
79149
79168
  rankOrder,
79150
79169
  gbifChecklistKey,
79151
- gbifAvailable
79170
+ gbifAvailable,
79171
+ basemapStyle
79152
79172
  }
79153
79173
  ),
79154
79174
  showToggle && unmappable > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginTop: 6 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("a", { onClick: () => setView("list"), style: { cursor: "pointer" }, children: [
@@ -88460,7 +88480,8 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88460
88480
  const {
88461
88481
  datasetKey,
88462
88482
  showDistributionMap,
88463
- gbifChecklistKey
88483
+ gbifChecklistKey,
88484
+ basemapStyle
88464
88485
  } = this.props;
88465
88486
  const {
88466
88487
  taxon,
@@ -88768,7 +88789,8 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88768
88789
  showDistributionMap,
88769
88790
  focalTaxon: taxon,
88770
88791
  rankOrder: rank,
88771
- gbifChecklistKey
88792
+ gbifChecklistKey,
88793
+ basemapStyle
88772
88794
  }
88773
88795
  ),
88774
88796
  get(taxon, "environments") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Environment(s)", children: get(taxon, "environments").join(", ") }),
@@ -88848,6 +88870,7 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88848
88870
  identifierLabel,
88849
88871
  showDistributionMap,
88850
88872
  gbifChecklistKey,
88873
+ basemapStyle,
88851
88874
  auth,
88852
88875
  ...routerProps
88853
88876
  }) {
@@ -88860,6 +88883,7 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88860
88883
  identifierLabel,
88861
88884
  showDistributionMap,
88862
88885
  gbifChecklistKey,
88886
+ basemapStyle,
88863
88887
  auth
88864
88888
  }
88865
88889
  ) });
@@ -89820,6 +89844,7 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
89820
89844
  taxonId,
89821
89845
  datasetKey,
89822
89846
  gbifChecklistKey,
89847
+ basemapStyle,
89823
89848
  style: style2,
89824
89849
  auth,
89825
89850
  ...routerProps
@@ -89859,6 +89884,7 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
89859
89884
  focalTaxon: taxon,
89860
89885
  rankOrder: rank,
89861
89886
  gbifChecklistKey,
89887
+ basemapStyle,
89862
89888
  showDistributionMap: true,
89863
89889
  style: style2
89864
89890
  }
@@ -90001,6 +90027,7 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
90001
90027
  TaxonBreakdown,
90002
90028
  TaxonDistribution,
90003
90029
  Tree,
90030
+ configure,
90004
90031
  withRouting
90005
90032
  }, Symbol.toStringTag, { value: "Module" }));
90006
90033
  const umd = { ...components, React: React$1, ReactDOM: ReactDOMClient };