col-browser 2.5.0 → 2.6.1

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 (43) hide show
  1. package/README.md +9 -0
  2. package/es/bibtex.js +1 -1
  3. package/es/chunks/{BibTex-CyUpSmpY.js → BibTex-DRE71Hg-.js} +2 -2
  4. package/es/chunks/{BibTex-CyUpSmpY.js.map → BibTex-DRE71Hg-.js.map} +1 -1
  5. package/es/chunks/{DatasetCitation-BnOkKDTv.js → DatasetCitation-Cep2dces.js} +2 -2
  6. package/es/chunks/{DatasetCitation-BnOkKDTv.js.map → DatasetCitation-Cep2dces.js.map} +1 -1
  7. package/es/chunks/{DatasetlogoWithFallback-DJEkjMJ1.js → DatasetlogoWithFallback-Bb-kmHts.js} +2 -2
  8. package/es/chunks/{DatasetlogoWithFallback-DJEkjMJ1.js.map → DatasetlogoWithFallback-Bb-kmHts.js.map} +1 -1
  9. package/es/chunks/{Distributions-Dwjo7KhA.js → Distributions-Czffme5Y.js} +422 -410
  10. package/es/chunks/Distributions-Czffme5Y.js.map +1 -0
  11. package/es/chunks/{MergedDataBadge-FvHUdT7B.js → MergedDataBadge-DK53L3R8.js} +2 -2
  12. package/es/chunks/{MergedDataBadge-FvHUdT7B.js.map → MergedDataBadge-DK53L3R8.js.map} +1 -1
  13. package/es/chunks/{TaxonBreakdown-D9g3tYXL.js → TaxonBreakdown-DqdQ18QM.js} +2 -2
  14. package/es/chunks/{TaxonBreakdown-D9g3tYXL.js.map → TaxonBreakdown-DqdQ18QM.js.map} +1 -1
  15. package/es/chunks/{XrGutter-D3PMq-Dn.js → XrGutter-COJhHpia.js} +2 -2
  16. package/es/chunks/{XrGutter-D3PMq-Dn.js.map → XrGutter-COJhHpia.js.map} +1 -1
  17. package/es/chunks/{config-D4b3a4Yi.js → config--bs_09I6.js} +12 -7
  18. package/es/chunks/config--bs_09I6.js.map +1 -0
  19. package/es/chunks/{dataset-D_gmg2Zv.js → dataset-BZpjo3Yq.js} +2 -2
  20. package/es/chunks/{dataset-D_gmg2Zv.js.map → dataset-BZpjo3Yq.js.map} +1 -1
  21. package/es/chunks/enumeration-CsrJrIIR.js +24 -0
  22. package/es/chunks/{enumeration-B-nIqCor.js.map → enumeration-CsrJrIIR.js.map} +1 -1
  23. package/es/chunks/{sector-CE-w32Gs.js → sector-ucUgPp75.js} +2 -2
  24. package/es/chunks/{sector-CE-w32Gs.js.map → sector-ucUgPp75.js.map} +1 -1
  25. package/es/config.js +1 -1
  26. package/es/index.js +1 -1
  27. package/es/search.js +5 -5
  28. package/es/sourceDataset.js +4 -4
  29. package/es/sourceDatasetList.js +4 -4
  30. package/es/taxon.js +734 -704
  31. package/es/taxon.js.map +1 -1
  32. package/es/taxonBreakdown.js +2 -2
  33. package/es/taxonDistribution.js +2 -2
  34. package/es/tree.js +5 -5
  35. package/package.json +1 -1
  36. package/types/index.d.ts +7 -0
  37. package/umd/col-browser.js +92 -18
  38. package/umd/col-browser.js.map +1 -1
  39. package/umd/col-browser.min.js +4 -4
  40. package/umd/col-browser.min.js.map +1 -1
  41. package/es/chunks/Distributions-Dwjo7KhA.js.map +0 -1
  42. package/es/chunks/config-D4b3a4Yi.js.map +0 -1
  43. package/es/chunks/enumeration-B-nIqCor.js +0 -12
@@ -1,9 +1,9 @@
1
1
  import { w } from "./chunks/withTheme-Dh6PRuII.js";
2
2
  import { j as o } from "./chunks/jsx-runtime-BzflLqGi.js";
3
- import { T } from "./chunks/TaxonBreakdown-D9g3tYXL.js";
3
+ import { T } from "./chunks/TaxonBreakdown-DqdQ18QM.js";
4
4
  import { useState as e, useEffect as A } from "react";
5
5
  import { s as b, c as r, R as v, b as B } from "./chunks/router-CssZk5qZ.js";
6
- import { c as s } from "./chunks/config-D4b3a4Yi.js";
6
+ import { c as s } from "./chunks/config--bs_09I6.js";
7
7
  import { Row as D, Col as C, Spin as E } from "antd";
8
8
  const S = ({
9
9
  taxonId: n,
@@ -2,9 +2,9 @@ import { w as $ } from "./chunks/withTheme-Dh6PRuII.js";
2
2
  import { j as n } from "./chunks/jsx-runtime-BzflLqGi.js";
3
3
  import { useState as a, useEffect as D } from "react";
4
4
  import { s as T, c as s, R as g, b as k } from "./chunks/router-CssZk5qZ.js";
5
- import { c as l } from "./chunks/config-D4b3a4Yi.js";
5
+ import { c as l } from "./chunks/config--bs_09I6.js";
6
6
  import { Row as v, Col as w, Spin as A } from "antd";
7
- import { D as C } from "./chunks/Distributions-Dwjo7KhA.js";
7
+ import { D as C } from "./chunks/Distributions-Czffme5Y.js";
8
8
  const E = ({
9
9
  taxonId: o,
10
10
  datasetKey: i,
package/es/tree.js CHANGED
@@ -8,13 +8,13 @@ import j, { createContext as at } from "react";
8
8
  import { Popover as ot, Divider as it, Spin as q, Tag as nt, Alert as w, Skeleton as rt, Tree as lt, Button as dt, Row as ht, Col as I, Checkbox as N } from "antd";
9
9
  import { sortBy as _, get as m, isUndefined as A, flatten as ct, isArray as O } from "lodash-es";
10
10
  import { L as P, c as K, R as H, s as ut, b as pt } from "./chunks/router-CssZk5qZ.js";
11
- import { c as D } from "./chunks/config-D4b3a4Yi.js";
11
+ import { c as D } from "./chunks/config--bs_09I6.js";
12
12
  import L from "dataloader";
13
- import { c as V, b as z, g as ft } from "./chunks/dataset-D_gmg2Zv.js";
14
- import { M as xt } from "./chunks/MergedDataBadge-FvHUdT7B.js";
13
+ import { c as V, b as z, g as ft } from "./chunks/dataset-BZpjo3Yq.js";
14
+ import { M as xt } from "./chunks/MergedDataBadge-DK53L3R8.js";
15
15
  import { E as gt } from "./chunks/ErrorMsg-K8k5PPTp.js";
16
- import { g as yt } from "./chunks/sector-CE-w32Gs.js";
17
- import { C as R, N as mt } from "./chunks/DatasetCitation-BnOkKDTv.js";
16
+ import { g as yt } from "./chunks/sector-ucUgPp75.js";
17
+ import { C as R, N as mt } from "./chunks/DatasetCitation-Cep2dces.js";
18
18
  import { r as F, w as M } from "./chunks/storage-BgdCo9fV.js";
19
19
  const E = at({
20
20
  datasetLoader: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "col-browser",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
4
4
  "description": "Catalogue of Life browse and search React components",
5
5
  "main": "umd/col-browser.js",
6
6
  "module": "es/index.js",
package/types/index.d.ts CHANGED
@@ -159,6 +159,13 @@ export interface ColBrowserConfig {
159
159
  * CARTO's keyless Positron CDN. Stored verbatim — not URL-normalised.
160
160
  */
161
161
  basemapStyle: string | Record<string, unknown>;
162
+ /**
163
+ * CARTO Basemaps API key. When set, every cartocdn.com request the
164
+ * distribution map makes — style, vector tiles, glyphs, sprites — carries
165
+ * `?key=`. Defaults to "" (unauthenticated). Not needed if `basemapStyle`
166
+ * points at a non-CARTO provider.
167
+ */
168
+ cartoKey: string;
162
169
  }
163
170
 
164
171
  /**
@@ -67809,10 +67809,15 @@ html body {
67809
67809
  // `style` works: a style URL (bake your provider's API key into it) or an
67810
67810
  // inline style object. The default is CARTO's public Positron CDN, which
67811
67811
  // needs no key.
67812
- basemapStyle: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
67812
+ basemapStyle: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",
67813
+ // CARTO Basemaps API key. Empty means unauthenticated (fine today, but
67814
+ // CARTO is moving to enforce keys). Set it and every cartocdn.com request
67815
+ // the map makes — style, vector tiles, glyphs, sprites — carries `?key=`.
67816
+ // Not needed when `basemapStyle` points at a non-CARTO provider.
67817
+ cartoKey: ""
67813
67818
  };
67814
67819
  const SLASH_TERMINATED = /* @__PURE__ */ new Set(["dataApi"]);
67815
- const VERBATIM = /* @__PURE__ */ new Set(["basemapStyle"]);
67820
+ const VERBATIM = /* @__PURE__ */ new Set(["basemapStyle", "cartoKey"]);
67816
67821
  const normalize = (key2, value) => SLASH_TERMINATED.has(key2) ? value.replace(/\/*$/, "/") : value.replace(/\/+$/, "");
67817
67822
  function configure(overrides = {}) {
67818
67823
  Object.entries(overrides).forEach(([key2, value]) => {
@@ -69848,6 +69853,24 @@ html body {
69848
69853
  (res) => res.data
69849
69854
  );
69850
69855
  };
69856
+ const vocabCache = /* @__PURE__ */ new Map();
69857
+ const cachedVocab = (path, transform2) => {
69858
+ const url = `${config.dataApi}vocab/${path}`;
69859
+ if (!vocabCache.has(url)) {
69860
+ vocabCache.set(
69861
+ url,
69862
+ client(url).then((res) => transform2(res.data)).catch((err) => {
69863
+ vocabCache.delete(url);
69864
+ throw err;
69865
+ })
69866
+ );
69867
+ }
69868
+ return vocabCache.get(url);
69869
+ };
69870
+ const getNomStatusVocab = () => cachedVocab(
69871
+ "nomstatus",
69872
+ (data) => data.reduce((a, c) => (a[c.name] = c, a), {})
69873
+ );
69851
69874
  const token = "%[a-f0-9]{2}";
69852
69875
  const singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi");
69853
69876
  const multiMatcher = new RegExp("(" + token + ")+", "gi");
@@ -77533,12 +77556,43 @@ html body {
77533
77556
  if (total <= visible && !showAll) return null;
77534
77557
  return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: () => onChange(!showAll), style: { cursor: "pointer" }, children: showAll ? "Show less" : `Show all (${total})` });
77535
77558
  };
77559
+ const NOM_CODES = /* @__PURE__ */ new Set([
77560
+ "bacterial",
77561
+ "botanical",
77562
+ "cultivars",
77563
+ "phyto",
77564
+ "phylo",
77565
+ "virus",
77566
+ "zoological"
77567
+ ]);
77568
+ const nomStatusLabel = (vocab, nomStatus, code) => {
77569
+ if (!nomStatus) return "";
77570
+ const term = vocab == null ? void 0 : vocab[nomStatus];
77571
+ if (!term) return nomStatus;
77572
+ const key2 = NOM_CODES.has(code) && typeof term[code] === "string" ? code : "zoological";
77573
+ return term[key2] || term.name || nomStatus;
77574
+ };
77575
+ const NomStatus = ({ nomStatus, code, brackets }) => {
77576
+ const [vocab, setVocab] = reactExports.useState(null);
77577
+ reactExports.useEffect(() => {
77578
+ let cancelled = false;
77579
+ getNomStatusVocab().then((v2) => {
77580
+ if (!cancelled) setVocab(v2);
77581
+ }).catch(() => {
77582
+ });
77583
+ return () => {
77584
+ cancelled = true;
77585
+ };
77586
+ }, []);
77587
+ if (!nomStatus) return null;
77588
+ const label = nomStatusLabel(vocab, nomStatus, code);
77589
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: brackets ? `(${label})` : label });
77590
+ };
77536
77591
  const TOP_N = 5;
77537
77592
  const SynonymsTable = ({
77538
77593
  datasetKey,
77539
77594
  data,
77540
77595
  style: style2,
77541
- nomStatus,
77542
77596
  references,
77543
77597
  decisions,
77544
77598
  typeMaterial,
@@ -77547,7 +77601,6 @@ html body {
77547
77601
  misapplied
77548
77602
  }) => {
77549
77603
  const [showAll, setShowAll] = reactExports.useState(false);
77550
- const getNomStatus = (taxon) => !nomStatus ? get(taxon, "name.nomStatus") : nomStatus[get(taxon, "name.nomStatus")][get(taxon, "name.code"), "zoological"];
77551
77604
  const sorter = (a, b2) => {
77552
77605
  if (get(a, "name.combinationAuthorship.year") && get(b2, "name.combinationAuthorship.year")) {
77553
77606
  return get(b2, "name.combinationAuthorship.year") - get(a, "name.combinationAuthorship.year");
@@ -77625,7 +77678,14 @@ html body {
77625
77678
  }
77626
77679
  ),
77627
77680
  " ",
77628
- get(s, "name.nomStatus") ? `(${getNomStatus(s)})` : "",
77681
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
77682
+ NomStatus,
77683
+ {
77684
+ nomStatus: get(s, "name.nomStatus"),
77685
+ code: get(s, "name.code"),
77686
+ brackets: true
77687
+ }
77688
+ ),
77629
77689
  " ",
77630
77690
  get(s, "status") === "misapplied" && get(s, "accordingTo") ? get(s, "accordingTo") : "",
77631
77691
  get(s, "status") === "ambiguous synonym" && "(Ambiguous)",
@@ -77987,6 +78047,23 @@ html body {
77987
78047
  return out;
77988
78048
  };
77989
78049
  const resolveBasemapStyle = (prop) => prop ?? config.basemapStyle;
78050
+ const CARTO_HOST = /(^|\.)cartocdn\.com$/i;
78051
+ const cartoTransformRequest = (key2 = config.cartoKey) => {
78052
+ if (!key2) return void 0;
78053
+ return (url) => {
78054
+ let parsed;
78055
+ try {
78056
+ parsed = new URL(url);
78057
+ } catch {
78058
+ return { url };
78059
+ }
78060
+ if (!CARTO_HOST.test(parsed.hostname) || parsed.searchParams.has("key")) {
78061
+ return { url };
78062
+ }
78063
+ parsed.searchParams.set("key", key2);
78064
+ return { url: parsed.toString() };
78065
+ };
78066
+ };
77990
78067
  const wrapStyle = {
77991
78068
  position: "absolute",
77992
78069
  bottom: 8,
@@ -78345,13 +78422,15 @@ html body {
78345
78422
  }, [descendantState, descendantColors, visibleTaxonIds]);
78346
78423
  const showDescendantLegend = descendantLegend.visibleGroups.length > 0;
78347
78424
  const styleSpec = resolveBasemapStyle(basemapStyle);
78348
- const styleKey = typeof styleSpec === "string" ? styleSpec : JSON.stringify(styleSpec);
78425
+ const cartoKey = config.cartoKey;
78426
+ const styleKey = `${typeof styleSpec === "string" ? styleSpec : JSON.stringify(styleSpec)}|${cartoKey || ""}`;
78349
78427
  reactExports.useEffect(() => {
78350
78428
  if (!containerRef.current || mapRef.current) return;
78351
78429
  if (!supported()) return;
78352
78430
  const map = new maplibregl.Map({
78353
78431
  container: containerRef.current,
78354
78432
  style: styleSpec,
78433
+ transformRequest: cartoTransformRequest(cartoKey),
78355
78434
  center: [0, 20],
78356
78435
  zoom: 1,
78357
78436
  minZoom: 0,
@@ -88258,7 +88337,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88258
88337
  this.getInfo(taxonKey);
88259
88338
  this.getRank(taxonKey);
88260
88339
  this.getIncludes(taxonKey);
88261
- this.getNomStatus(taxonKey);
88262
88340
  }
88263
88341
  });
88264
88342
  __publicField(this, "getCatalogue", () => {
@@ -88421,13 +88499,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88421
88499
  (res) => this.setState({ rank: res.data.map((r2) => r2.name) })
88422
88500
  );
88423
88501
  });
88424
- __publicField(this, "getNomStatus", () => {
88425
- client(`${config.dataApi}vocab/nomstatus`).then(
88426
- (res) => this.setState({
88427
- nomStatus: res.data.reduce((a, c) => (a[c.name] = c, a), {})
88428
- })
88429
- );
88430
- });
88431
88502
  __publicField(this, "getIncludes", (taxonKey) => {
88432
88503
  const { datasetKey } = this.props;
88433
88504
  client(
@@ -88460,7 +88531,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88460
88531
  sourceDataset: null,
88461
88532
  includes: [],
88462
88533
  rank: [],
88463
- nomStatus: null,
88464
88534
  catalogue: null,
88465
88535
  referenceIndexMap: {},
88466
88536
  sourceDatasetKeyMap: null
@@ -88472,7 +88542,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88472
88542
  this.getInfo(taxonKey);
88473
88543
  this.getRank(taxonKey);
88474
88544
  this.getIncludes(taxonKey);
88475
- this.getNomStatus(taxonKey);
88476
88545
  }
88477
88546
  }
88478
88547
  render() {
@@ -88490,7 +88559,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88490
88559
  sourceDataset,
88491
88560
  includes: includes2,
88492
88561
  rank,
88493
- nomStatus,
88494
88562
  taxonError,
88495
88563
  synonymsError,
88496
88564
  classificationError,
@@ -88674,7 +88742,13 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88674
88742
  )
88675
88743
  ] })
88676
88744
  ] }),
88677
- get(taxon, "name.nomStatus") && nomStatus && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Nomenclatural Status", children: nomStatus[get(taxon, "name.nomStatus")][get(taxon, "name.code"), "zoological"] }),
88745
+ get(taxon, "name.nomStatus") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Nomenclatural Status", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
88746
+ NomStatus,
88747
+ {
88748
+ nomStatus: get(taxon, "name.nomStatus"),
88749
+ code: get(taxon, "name.code")
88750
+ }
88751
+ ) }),
88678
88752
  infoError && /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { message: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorMsg, { error: infoError }), type: "error" }),
88679
88753
  !isSynonym && get(info, "synonyms") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Synonyms and combinations", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
88680
88754
  SynonymsTable,