col-browser 2.2.5 → 2.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "col-browser",
3
- "version": "2.2.5",
3
+ "version": "2.3.0",
4
4
  "description": "Catalogue of Life browse and search React components",
5
5
  "main": "umd/col-browser.js",
6
6
  "module": "es/index.js",
@@ -77573,7 +77573,7 @@ html body {
77573
77573
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { style: indent ? { marginLeft: "10px" } : null, children: [
77574
77574
  homotypic === true ? "≡ " : "= ",
77575
77575
  " ",
77576
- /* @__PURE__ */ jsxRuntimeExports.jsx(
77576
+ /* @__PURE__ */ jsxRuntimeExports.jsx(LinkTo, { to: "taxon", args: get(s, "id"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
77577
77577
  "span",
77578
77578
  {
77579
77579
  dangerouslySetInnerHTML: {
@@ -77588,7 +77588,7 @@ html body {
77588
77588
  )
77589
77589
  }
77590
77590
  }
77591
- )
77591
+ ) })
77592
77592
  ] }),
77593
77593
  " ",
77594
77594
  (s == null ? void 0 : s.sourceDatasetKey) && get(primarySource, "key") !== (s == null ? void 0 : s.sourceDatasetKey) && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -87045,108 +87045,12 @@ html body {
87045
87045
  const { taxonKey } = this.props;
87046
87046
  this.getCatalogue();
87047
87047
  if (taxonKey) {
87048
- this.getTaxon(taxonKey);
87049
87048
  this.getInfo(taxonKey);
87050
87049
  this.getRank(taxonKey);
87051
87050
  this.getIncludes(taxonKey);
87052
87051
  this.getNomStatus(taxonKey);
87053
87052
  }
87054
87053
  });
87055
- __publicField(this, "getTaxon", (taxonKey) => {
87056
- const { datasetKey, pageTitleTemplate } = this.props;
87057
- this.setState({ loading: true });
87058
- client(`${config.dataApi}dataset/${datasetKey}/taxon/${taxonKey}`).then((res) => {
87059
- let promises = [res];
87060
- if (pageTitleTemplate && get(res, "data.label")) {
87061
- document.title = pageTitleTemplate.replace(
87062
- "__taxon__",
87063
- res.data.label
87064
- );
87065
- }
87066
- if (get(res, "data.name.publishedInId")) {
87067
- promises.push(
87068
- client(
87069
- `${config.dataApi}dataset/${datasetKey}/reference/${get(
87070
- res,
87071
- "data.name.publishedInId"
87072
- )}`
87073
- ).then((publishedIn) => {
87074
- res.data.name.publishedIn = publishedIn.data;
87075
- return res;
87076
- })
87077
- );
87078
- }
87079
- if (get(res, "data.name")) {
87080
- promises.push(
87081
- client(
87082
- `${config.dataApi}dataset/${datasetKey}/name/${get(
87083
- res,
87084
- "data.name.id"
87085
- )}/relations`
87086
- ).then((relations) => {
87087
- res.data.name.relations = relations.data;
87088
- return Promise.allSettled(
87089
- relations.data.map((r2) => {
87090
- return client(
87091
- `${config.dataApi}dataset/${datasetKey}/name/${r2.relatedNameId}`
87092
- ).then((n2) => {
87093
- r2.relatedName = n2.data;
87094
- });
87095
- })
87096
- ).then((results) => {
87097
- return results.filter((r2) => r2.status = "fulfilled").map((r2) => r2.value);
87098
- });
87099
- })
87100
- );
87101
- }
87102
- if (get(res, "data.sectorKey")) {
87103
- client(
87104
- `${config.dataApi}dataset/${datasetKey}/sector/${get(
87105
- res,
87106
- "data.sectorKey"
87107
- )}`
87108
- ).then((sector) => {
87109
- client(
87110
- `${config.dataApi}dataset/${datasetKey}/logo/source/${get(
87111
- sector,
87112
- "data.subjectDatasetKey"
87113
- )}`
87114
- ).then(() => {
87115
- this.setState({
87116
- logoUrl: `${config.dataApi}dataset/${datasetKey}/logo/source/${get(
87117
- sector,
87118
- "data.subjectDatasetKey"
87119
- )}?size=MEDIUM`
87120
- });
87121
- }).catch(() => {
87122
- });
87123
- client(
87124
- `${config.dataApi}dataset/${datasetKey}/source/${get(
87125
- sector,
87126
- "data.subjectDatasetKey"
87127
- )}`
87128
- ).then((dataset) => {
87129
- this.setState({ sourceDataset: dataset.data });
87130
- });
87131
- });
87132
- }
87133
- return Promise.allSettled(promises).then((results) => {
87134
- return results.filter((r2) => r2.status = "fulfilled").map((r2) => r2.value);
87135
- });
87136
- }).then((res) => {
87137
- this.setState({
87138
- taxonLoading: false,
87139
- taxon: res[0].data,
87140
- taxonError: null
87141
- });
87142
- }).catch((err) => {
87143
- if (get(err, "response.status") === 404) {
87144
- this.fetchSynonymAndRedirect(taxonKey);
87145
- } else {
87146
- this.setState({ taxonLoading: false, taxonError: err, taxon: null });
87147
- }
87148
- });
87149
- });
87150
87054
  __publicField(this, "getCatalogue", () => {
87151
87055
  const { datasetKey } = this.props;
87152
87056
  client(`${config.dataApi}dataset/${datasetKey}`).then((res) => {
@@ -87197,11 +87101,50 @@ html body {
87197
87101
  });
87198
87102
  __publicField(this, "getInfo", async (taxonKey) => {
87199
87103
  var _a2, _b2, _c, _d, _e2, _f;
87200
- const { datasetKey } = this.props;
87104
+ const { datasetKey, pageTitleTemplate } = this.props;
87201
87105
  try {
87202
87106
  const res = await client(
87203
87107
  `${config.dataApi}dataset/${datasetKey}/taxon/${taxonKey}/info`
87204
87108
  );
87109
+ const usage = get(res, "data.usage");
87110
+ if (pageTitleTemplate && get(usage, "label")) {
87111
+ document.title = pageTitleTemplate.replace("__taxon__", usage.label);
87112
+ }
87113
+ const publishedInId = get(usage, "name.publishedInId");
87114
+ if (publishedInId && usage.name) {
87115
+ const cited = get(res, "data.references") && res.data.references[publishedInId];
87116
+ if (cited) {
87117
+ usage.name.publishedIn = cited;
87118
+ } else {
87119
+ try {
87120
+ const pub = await client(
87121
+ `${config.dataApi}dataset/${datasetKey}/reference/${publishedInId}`
87122
+ );
87123
+ usage.name.publishedIn = pub.data;
87124
+ } catch (e2) {
87125
+ }
87126
+ }
87127
+ }
87128
+ if (get(usage, "sectorKey")) {
87129
+ client(
87130
+ `${config.dataApi}dataset/${datasetKey}/sector/${get(usage, "sectorKey")}`
87131
+ ).then((sector) => {
87132
+ const subjectDatasetKey = get(sector, "data.subjectDatasetKey");
87133
+ client(
87134
+ `${config.dataApi}dataset/${datasetKey}/logo/source/${subjectDatasetKey}`
87135
+ ).then(() => {
87136
+ this.setState({
87137
+ logoUrl: `${config.dataApi}dataset/${datasetKey}/logo/source/${subjectDatasetKey}?size=MEDIUM`
87138
+ });
87139
+ }).catch(() => {
87140
+ });
87141
+ client(
87142
+ `${config.dataApi}dataset/${datasetKey}/source/${subjectDatasetKey}`
87143
+ ).then((dataset) => {
87144
+ this.setState({ sourceDataset: dataset.data });
87145
+ });
87146
+ });
87147
+ }
87205
87148
  let referenceIndexMap = {};
87206
87149
  if (get(res, "data.references")) {
87207
87150
  Object.keys(res.data.references).forEach((k, i) => {
@@ -87249,6 +87192,7 @@ html body {
87249
87192
  this.setState({
87250
87193
  infoLoading: false,
87251
87194
  info: res.data,
87195
+ taxon: usage,
87252
87196
  classification: (_f = res == null ? void 0 : res.data) == null ? void 0 : _f.classification,
87253
87197
  infoError: null,
87254
87198
  referenceIndexMap,
@@ -87256,7 +87200,7 @@ html body {
87256
87200
  });
87257
87201
  } catch (err) {
87258
87202
  if (get(err, "response.status") === 404) {
87259
- this.fetchSynonymAndRedirect(taxonKey);
87203
+ this.setState({ infoLoading: false, info: null, taxon: null, status: 404 });
87260
87204
  } else {
87261
87205
  this.setState({ infoLoading: false, infoError: err, info: null });
87262
87206
  }
@@ -87290,19 +87234,6 @@ html body {
87290
87234
  });
87291
87235
  });
87292
87236
  });
87293
- __publicField(this, "fetchSynonymAndRedirect", (taxonKey) => {
87294
- var _a2, _b2;
87295
- const { datasetKey } = this.props;
87296
- const navigateToTaxon = (_b2 = (_a2 = this.context) == null ? void 0 : _a2.taxon) == null ? void 0 : _b2.onNavigate;
87297
- client(`${config.dataApi}dataset/${datasetKey}/synonym/${taxonKey}`).then((res) => {
87298
- const acceptedId = get(res, "data.accepted.id");
87299
- if (acceptedId && navigateToTaxon) navigateToTaxon(acceptedId);
87300
- }).catch((err) => {
87301
- if (get(err, "response.status") === 404) {
87302
- this.setState({ status: 404 });
87303
- }
87304
- });
87305
- });
87306
87237
  setAuth(this.props.auth);
87307
87238
  this.state = {
87308
87239
  taxon: null,
@@ -87328,7 +87259,6 @@ html body {
87328
87259
  componentDidUpdate(prevProps) {
87329
87260
  if (prevProps.taxonKey !== this.props.taxonKey && this.props.taxonKey) {
87330
87261
  const taxonKey = this.props.taxonKey;
87331
- this.getTaxon(taxonKey);
87332
87262
  this.getInfo(taxonKey);
87333
87263
  this.getRank(taxonKey);
87334
87264
  this.getIncludes(taxonKey);
@@ -87359,6 +87289,9 @@ html body {
87359
87289
  referenceIndexMap
87360
87290
  } = this.state;
87361
87291
  const genusRankIndex = rank ? rank.indexOf("genus") : -1;
87292
+ const isSynonym = ["synonym", "ambiguous synonym", "misapplied"].includes(
87293
+ get(taxon, "status")
87294
+ );
87362
87295
  const homotypic = get(info, "synonyms.homotypic", []);
87363
87296
  const heterotypic = get(info, "synonyms.heterotypic", []);
87364
87297
  get(info, "synonyms.misapplied", []);
@@ -87425,6 +87358,31 @@ html body {
87425
87358
  }
87426
87359
  ) })
87427
87360
  ] }),
87361
+ isSynonym && get(taxon, "accepted.id") && /* @__PURE__ */ jsxRuntimeExports.jsxs(
87362
+ "div",
87363
+ {
87364
+ style: {
87365
+ paddingLeft: "10px",
87366
+ marginTop: "2px",
87367
+ marginBottom: "10px",
87368
+ fontSize: "16px"
87369
+ },
87370
+ children: [
87371
+ get(taxon, "status"),
87372
+ " ",
87373
+ get(taxon, "status") === "misapplied" ? "to" : "of",
87374
+ " ",
87375
+ /* @__PURE__ */ jsxRuntimeExports.jsx(LinkTo, { to: "taxon", args: get(taxon, "accepted.id"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87376
+ "span",
87377
+ {
87378
+ dangerouslySetInnerHTML: {
87379
+ __html: get(taxon, "accepted.labelHtml")
87380
+ }
87381
+ }
87382
+ ) })
87383
+ ]
87384
+ }
87385
+ ),
87428
87386
  get(taxon, "id") && /* @__PURE__ */ jsxRuntimeExports.jsxs(
87429
87387
  PresentationItem$1,
87430
87388
  {
@@ -87466,6 +87424,10 @@ html body {
87466
87424
  ]
87467
87425
  }
87468
87426
  ),
87427
+ Array.isArray(get(taxon, "identifier")) && get(taxon, "identifier").length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Identifiers", children: get(taxon, "identifier").map((id, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs(React.Fragment, { children: [
87428
+ i > 0 && ", ",
87429
+ String(id)
87430
+ ] }, i)) }),
87469
87431
  get(taxon, "labelHtml") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Name", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87470
87432
  "span",
87471
87433
  {
@@ -87503,7 +87465,7 @@ html body {
87503
87465
  ] }),
87504
87466
  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"] }),
87505
87467
  infoError && /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { message: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorMsg, { error: infoError }), type: "error" }),
87506
- get(info, "synonyms") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Synonyms and combinations", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87468
+ !isSynonym && get(info, "synonyms") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Synonyms and combinations", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87507
87469
  SynonymsTable,
87508
87470
  {
87509
87471
  primarySource: sourceDataset,
@@ -87561,7 +87523,7 @@ html body {
87561
87523
  datasetKey
87562
87524
  }
87563
87525
  ) }),
87564
- (taxon && rank.indexOf(get(taxon, "name.rank")) < genusRankIndex && rank.indexOf(get(taxon, "name.rank")) > -1 || get(taxon, "name.rank") === "unranked" && get(taxon, "name.scientificName") === "Biota") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Breakdown", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87526
+ !isSynonym && (taxon && rank.indexOf(get(taxon, "name.rank")) < genusRankIndex && rank.indexOf(get(taxon, "name.rank")) > -1 || get(taxon, "name.rank") === "unranked" && get(taxon, "name.scientificName") === "Biota") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Breakdown", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87565
87527
  TaxonBreakdown$1,
87566
87528
  {
87567
87529
  taxon,
@@ -87571,7 +87533,7 @@ html body {
87571
87533
  showLevelSwitch: true
87572
87534
  }
87573
87535
  ) }),
87574
- includes2.length > 1 && rank && taxon && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Statistics", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87536
+ !isSynonym && includes2.length > 1 && rank && taxon && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Statistics", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87575
87537
  IncludesTable,
87576
87538
  {
87577
87539
  style: { marginTop: "-3px", marginLeft: "-3px" },
@@ -87580,7 +87542,7 @@ html body {
87580
87542
  taxon
87581
87543
  }
87582
87544
  ) }),
87583
- get(info, "vernacularNames") && taxon && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Vernacular names", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87545
+ !isSynonym && get(info, "vernacularNames") && taxon && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Vernacular names", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87584
87546
  VernacularNamesTable,
87585
87547
  {
87586
87548
  style: { marginTop: "-3px", marginLeft: "-3px" },
@@ -87589,7 +87551,7 @@ html body {
87589
87551
  datasetKey: taxon.datasetKey
87590
87552
  }
87591
87553
  ) }),
87592
- (get(info, "distributions") || showDistributionMap && gbifChecklistKey && taxon) && // Distributions owns its labelled block so it can hide entirely
87554
+ !isSynonym && (get(info, "distributions") || showDistributionMap && gbifChecklistKey && taxon) && // Distributions owns its labelled block so it can hide entirely
87593
87555
  // (label included) when there is nothing to show — including after
87594
87556
  // the async GBIF occurrence lookup comes back empty.
87595
87557
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -87650,7 +87612,7 @@ html body {
87650
87612
  }
87651
87613
  )
87652
87614
  ] }) }),
87653
- get(taxon, "link") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Link to original resource", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: get(taxon, "link"), children: get(taxon, "link") }) }),
87615
+ get(taxon, "link") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Original record", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: get(taxon, "link"), children: get(taxon, "link") }) }),
87654
87616
  ((_x = info == null ? void 0 : info.source) == null ? void 0 : _x.secondarySources) && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Secondary Sources", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SecondarySources, { info, datasetKey }) }),
87655
87617
  get(info, "references") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "References", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87656
87618
  ReferencesTable,
@@ -89314,7 +89276,7 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
89314
89276
  /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "License", children: data.license || "-" }),
89315
89277
  /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "Checklist Confidence", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Rate, { value: data.confidence, disabled: true }) }),
89316
89278
  /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "Completeness", children: data.completeness }),
89317
- /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "Url (website)", children: data.url ? /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: data.url, target: "_blank", children: data.url }) : "-" }),
89279
+ /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "Website", children: data.url ? /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: data.url, target: "_blank", children: data.url }) : "-" }),
89318
89280
  /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "ISSN", children: data.issn ? /* @__PURE__ */ jsxRuntimeExports.jsx(
89319
89281
  "a",
89320
89282
  {