col-browser 2.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "col-browser",
3
- "version": "2.6.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",
@@ -69853,6 +69853,24 @@ html body {
69853
69853
  (res) => res.data
69854
69854
  );
69855
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
+ );
69856
69874
  const token = "%[a-f0-9]{2}";
69857
69875
  const singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi");
69858
69876
  const multiMatcher = new RegExp("(" + token + ")+", "gi");
@@ -77538,12 +77556,43 @@ html body {
77538
77556
  if (total <= visible && !showAll) return null;
77539
77557
  return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: () => onChange(!showAll), style: { cursor: "pointer" }, children: showAll ? "Show less" : `Show all (${total})` });
77540
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
+ };
77541
77591
  const TOP_N = 5;
77542
77592
  const SynonymsTable = ({
77543
77593
  datasetKey,
77544
77594
  data,
77545
77595
  style: style2,
77546
- nomStatus,
77547
77596
  references,
77548
77597
  decisions,
77549
77598
  typeMaterial,
@@ -77552,7 +77601,6 @@ html body {
77552
77601
  misapplied
77553
77602
  }) => {
77554
77603
  const [showAll, setShowAll] = reactExports.useState(false);
77555
- const getNomStatus = (taxon) => !nomStatus ? get(taxon, "name.nomStatus") : nomStatus[get(taxon, "name.nomStatus")][get(taxon, "name.code"), "zoological"];
77556
77604
  const sorter = (a, b2) => {
77557
77605
  if (get(a, "name.combinationAuthorship.year") && get(b2, "name.combinationAuthorship.year")) {
77558
77606
  return get(b2, "name.combinationAuthorship.year") - get(a, "name.combinationAuthorship.year");
@@ -77630,7 +77678,14 @@ html body {
77630
77678
  }
77631
77679
  ),
77632
77680
  " ",
77633
- 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
+ ),
77634
77689
  " ",
77635
77690
  get(s, "status") === "misapplied" && get(s, "accordingTo") ? get(s, "accordingTo") : "",
77636
77691
  get(s, "status") === "ambiguous synonym" && "(Ambiguous)",
@@ -88282,7 +88337,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88282
88337
  this.getInfo(taxonKey);
88283
88338
  this.getRank(taxonKey);
88284
88339
  this.getIncludes(taxonKey);
88285
- this.getNomStatus(taxonKey);
88286
88340
  }
88287
88341
  });
88288
88342
  __publicField(this, "getCatalogue", () => {
@@ -88445,13 +88499,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88445
88499
  (res) => this.setState({ rank: res.data.map((r2) => r2.name) })
88446
88500
  );
88447
88501
  });
88448
- __publicField(this, "getNomStatus", () => {
88449
- client(`${config.dataApi}vocab/nomstatus`).then(
88450
- (res) => this.setState({
88451
- nomStatus: res.data.reduce((a, c) => (a[c.name] = c, a), {})
88452
- })
88453
- );
88454
- });
88455
88502
  __publicField(this, "getIncludes", (taxonKey) => {
88456
88503
  const { datasetKey } = this.props;
88457
88504
  client(
@@ -88484,7 +88531,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88484
88531
  sourceDataset: null,
88485
88532
  includes: [],
88486
88533
  rank: [],
88487
- nomStatus: null,
88488
88534
  catalogue: null,
88489
88535
  referenceIndexMap: {},
88490
88536
  sourceDatasetKeyMap: null
@@ -88496,7 +88542,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88496
88542
  this.getInfo(taxonKey);
88497
88543
  this.getRank(taxonKey);
88498
88544
  this.getIncludes(taxonKey);
88499
- this.getNomStatus(taxonKey);
88500
88545
  }
88501
88546
  }
88502
88547
  render() {
@@ -88514,7 +88559,6 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88514
88559
  sourceDataset,
88515
88560
  includes: includes2,
88516
88561
  rank,
88517
- nomStatus,
88518
88562
  taxonError,
88519
88563
  synonymsError,
88520
88564
  classificationError,
@@ -88698,7 +88742,13 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88698
88742
  )
88699
88743
  ] })
88700
88744
  ] }),
88701
- 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
+ ) }),
88702
88752
  infoError && /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { message: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorMsg, { error: infoError }), type: "error" }),
88703
88753
  !isSynonym && get(info, "synonyms") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Synonyms and combinations", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
88704
88754
  SynonymsTable,