col-browser 2.2.5 → 2.3.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.2.5",
3
+ "version": "2.3.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",
@@ -77539,7 +77539,8 @@ html body {
77539
77539
  decisions,
77540
77540
  typeMaterial,
77541
77541
  referenceIndexMap,
77542
- primarySource
77542
+ primarySource,
77543
+ misapplied
77543
77544
  }) => {
77544
77545
  const [showAll, setShowAll] = reactExports.useState(false);
77545
77546
  const getNomStatus = (taxon) => !nomStatus ? get(taxon, "name.nomStatus") : nomStatus[get(taxon, "name.nomStatus")][get(taxon, "name.code"), "zoological"];
@@ -77555,25 +77556,33 @@ html body {
77555
77556
  }
77556
77557
  };
77557
77558
  const items = [];
77558
- if (data.homotypic) {
77559
- [...data.homotypic].sort(sorter).forEach((s) => {
77560
- items.push({ syn: s, homotypic: true, indent: false });
77561
- });
77562
- }
77563
- if (data.heterotypicGroups) {
77564
- [...data.heterotypicGroups].sort((a, b2) => sorter(a[0], b2[0])).forEach((group) => {
77565
- group.forEach((s, i) => {
77566
- items.push({ syn: s, homotypic: i > 0, indent: i > 0 });
77559
+ if (misapplied) {
77560
+ if (data.misapplied) {
77561
+ [...data.misapplied].sort(sorter).forEach((s) => {
77562
+ items.push({ syn: s, homotypic: false, indent: false });
77567
77563
  });
77568
- });
77564
+ }
77565
+ } else {
77566
+ if (data.homotypic) {
77567
+ [...data.homotypic].sort(sorter).forEach((s) => {
77568
+ items.push({ syn: s, homotypic: true, indent: false });
77569
+ });
77570
+ }
77571
+ if (data.heterotypicGroups) {
77572
+ [...data.heterotypicGroups].sort((a, b2) => sorter(a[0], b2[0])).forEach((group) => {
77573
+ group.forEach((s, i) => {
77574
+ items.push({ syn: s, homotypic: i > 0, indent: i > 0 });
77575
+ });
77576
+ });
77577
+ }
77569
77578
  }
77570
77579
  const total = items.length;
77571
77580
  const visibleItems = showAll ? items : items.slice(0, TOP_N);
77572
77581
  const renderItem = ({ syn: s, homotypic, indent }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(BorderedListItem$1, { children: [
77573
77582
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { style: indent ? { marginLeft: "10px" } : null, children: [
77574
- homotypic === true ? "≡ " : "= ",
77583
+ misapplied ? "" : homotypic === true ? "≡ " : "= ",
77575
77584
  " ",
77576
- /* @__PURE__ */ jsxRuntimeExports.jsx(
77585
+ /* @__PURE__ */ jsxRuntimeExports.jsx(LinkTo, { to: "taxon", args: get(s, "id"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
77577
77586
  "span",
77578
77587
  {
77579
77588
  dangerouslySetInnerHTML: {
@@ -77588,7 +77597,7 @@ html body {
77588
77597
  )
77589
77598
  }
77590
77599
  }
77591
- )
77600
+ ) })
77592
77601
  ] }),
77593
77602
  " ",
77594
77603
  (s == null ? void 0 : s.sourceDatasetKey) && get(primarySource, "key") !== (s == null ? void 0 : s.sourceDatasetKey) && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -87045,108 +87054,12 @@ html body {
87045
87054
  const { taxonKey } = this.props;
87046
87055
  this.getCatalogue();
87047
87056
  if (taxonKey) {
87048
- this.getTaxon(taxonKey);
87049
87057
  this.getInfo(taxonKey);
87050
87058
  this.getRank(taxonKey);
87051
87059
  this.getIncludes(taxonKey);
87052
87060
  this.getNomStatus(taxonKey);
87053
87061
  }
87054
87062
  });
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
87063
  __publicField(this, "getCatalogue", () => {
87151
87064
  const { datasetKey } = this.props;
87152
87065
  client(`${config.dataApi}dataset/${datasetKey}`).then((res) => {
@@ -87197,11 +87110,50 @@ html body {
87197
87110
  });
87198
87111
  __publicField(this, "getInfo", async (taxonKey) => {
87199
87112
  var _a2, _b2, _c, _d, _e2, _f;
87200
- const { datasetKey } = this.props;
87113
+ const { datasetKey, pageTitleTemplate } = this.props;
87201
87114
  try {
87202
87115
  const res = await client(
87203
87116
  `${config.dataApi}dataset/${datasetKey}/taxon/${taxonKey}/info`
87204
87117
  );
87118
+ const usage = get(res, "data.usage");
87119
+ if (pageTitleTemplate && get(usage, "label")) {
87120
+ document.title = pageTitleTemplate.replace("__taxon__", usage.label);
87121
+ }
87122
+ const publishedInId = get(usage, "name.publishedInId");
87123
+ if (publishedInId && usage.name) {
87124
+ const cited = get(res, "data.references") && res.data.references[publishedInId];
87125
+ if (cited) {
87126
+ usage.name.publishedIn = cited;
87127
+ } else {
87128
+ try {
87129
+ const pub = await client(
87130
+ `${config.dataApi}dataset/${datasetKey}/reference/${publishedInId}`
87131
+ );
87132
+ usage.name.publishedIn = pub.data;
87133
+ } catch (e2) {
87134
+ }
87135
+ }
87136
+ }
87137
+ if (get(usage, "sectorKey")) {
87138
+ client(
87139
+ `${config.dataApi}dataset/${datasetKey}/sector/${get(usage, "sectorKey")}`
87140
+ ).then((sector) => {
87141
+ const subjectDatasetKey = get(sector, "data.subjectDatasetKey");
87142
+ client(
87143
+ `${config.dataApi}dataset/${datasetKey}/logo/source/${subjectDatasetKey}`
87144
+ ).then(() => {
87145
+ this.setState({
87146
+ logoUrl: `${config.dataApi}dataset/${datasetKey}/logo/source/${subjectDatasetKey}?size=MEDIUM`
87147
+ });
87148
+ }).catch(() => {
87149
+ });
87150
+ client(
87151
+ `${config.dataApi}dataset/${datasetKey}/source/${subjectDatasetKey}`
87152
+ ).then((dataset) => {
87153
+ this.setState({ sourceDataset: dataset.data });
87154
+ });
87155
+ });
87156
+ }
87205
87157
  let referenceIndexMap = {};
87206
87158
  if (get(res, "data.references")) {
87207
87159
  Object.keys(res.data.references).forEach((k, i) => {
@@ -87249,6 +87201,7 @@ html body {
87249
87201
  this.setState({
87250
87202
  infoLoading: false,
87251
87203
  info: res.data,
87204
+ taxon: usage,
87252
87205
  classification: (_f = res == null ? void 0 : res.data) == null ? void 0 : _f.classification,
87253
87206
  infoError: null,
87254
87207
  referenceIndexMap,
@@ -87256,7 +87209,7 @@ html body {
87256
87209
  });
87257
87210
  } catch (err) {
87258
87211
  if (get(err, "response.status") === 404) {
87259
- this.fetchSynonymAndRedirect(taxonKey);
87212
+ this.setState({ infoLoading: false, info: null, taxon: null, status: 404 });
87260
87213
  } else {
87261
87214
  this.setState({ infoLoading: false, infoError: err, info: null });
87262
87215
  }
@@ -87290,19 +87243,6 @@ html body {
87290
87243
  });
87291
87244
  });
87292
87245
  });
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
87246
  setAuth(this.props.auth);
87307
87247
  this.state = {
87308
87248
  taxon: null,
@@ -87328,7 +87268,6 @@ html body {
87328
87268
  componentDidUpdate(prevProps) {
87329
87269
  if (prevProps.taxonKey !== this.props.taxonKey && this.props.taxonKey) {
87330
87270
  const taxonKey = this.props.taxonKey;
87331
- this.getTaxon(taxonKey);
87332
87271
  this.getInfo(taxonKey);
87333
87272
  this.getRank(taxonKey);
87334
87273
  this.getIncludes(taxonKey);
@@ -87359,9 +87298,12 @@ html body {
87359
87298
  referenceIndexMap
87360
87299
  } = this.state;
87361
87300
  const genusRankIndex = rank ? rank.indexOf("genus") : -1;
87301
+ const isSynonym = ["synonym", "ambiguous synonym", "misapplied"].includes(
87302
+ get(taxon, "status")
87303
+ );
87362
87304
  const homotypic = get(info, "synonyms.homotypic", []);
87363
87305
  const heterotypic = get(info, "synonyms.heterotypic", []);
87364
- get(info, "synonyms.misapplied", []);
87306
+ const misapplied = get(info, "synonyms.misapplied", []);
87365
87307
  [
87366
87308
  ...homotypic.map((h) => ({ ...h, __homotypic: true })),
87367
87309
  ...heterotypic
@@ -87425,6 +87367,31 @@ html body {
87425
87367
  }
87426
87368
  ) })
87427
87369
  ] }),
87370
+ isSynonym && get(taxon, "accepted.id") && /* @__PURE__ */ jsxRuntimeExports.jsxs(
87371
+ "div",
87372
+ {
87373
+ style: {
87374
+ paddingLeft: "10px",
87375
+ marginTop: "2px",
87376
+ marginBottom: "10px",
87377
+ fontSize: "16px"
87378
+ },
87379
+ children: [
87380
+ get(taxon, "status"),
87381
+ " ",
87382
+ get(taxon, "status") === "misapplied" ? "to" : "of",
87383
+ " ",
87384
+ /* @__PURE__ */ jsxRuntimeExports.jsx(LinkTo, { to: "taxon", args: get(taxon, "accepted.id"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87385
+ "span",
87386
+ {
87387
+ dangerouslySetInnerHTML: {
87388
+ __html: get(taxon, "accepted.labelHtml")
87389
+ }
87390
+ }
87391
+ ) })
87392
+ ]
87393
+ }
87394
+ ),
87428
87395
  get(taxon, "id") && /* @__PURE__ */ jsxRuntimeExports.jsxs(
87429
87396
  PresentationItem$1,
87430
87397
  {
@@ -87466,6 +87433,10 @@ html body {
87466
87433
  ]
87467
87434
  }
87468
87435
  ),
87436
+ 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: [
87437
+ i > 0 && ", ",
87438
+ String(id)
87439
+ ] }, i)) }),
87469
87440
  get(taxon, "labelHtml") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Name", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87470
87441
  "span",
87471
87442
  {
@@ -87503,9 +87474,23 @@ html body {
87503
87474
  ] }),
87504
87475
  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
87476
  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(
87477
+ !isSynonym && get(info, "synonyms") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Synonyms and combinations", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87478
+ SynonymsTable,
87479
+ {
87480
+ primarySource: sourceDataset,
87481
+ data: get(info, "synonyms"),
87482
+ decisions: get(info, "decisions"),
87483
+ references: get(info, "references"),
87484
+ typeMaterial: get(info, "typeMaterial"),
87485
+ referenceIndexMap,
87486
+ style: { marginTop: "-3px" },
87487
+ datasetKey
87488
+ }
87489
+ ) }),
87490
+ !isSynonym && misapplied.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Misapplied names", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87507
87491
  SynonymsTable,
87508
87492
  {
87493
+ misapplied: true,
87509
87494
  primarySource: sourceDataset,
87510
87495
  data: get(info, "synonyms"),
87511
87496
  decisions: get(info, "decisions"),
@@ -87561,7 +87546,7 @@ html body {
87561
87546
  datasetKey
87562
87547
  }
87563
87548
  ) }),
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(
87549
+ !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
87550
  TaxonBreakdown$1,
87566
87551
  {
87567
87552
  taxon,
@@ -87571,7 +87556,7 @@ html body {
87571
87556
  showLevelSwitch: true
87572
87557
  }
87573
87558
  ) }),
87574
- includes2.length > 1 && rank && taxon && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Statistics", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87559
+ !isSynonym && includes2.length > 1 && rank && taxon && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Statistics", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87575
87560
  IncludesTable,
87576
87561
  {
87577
87562
  style: { marginTop: "-3px", marginLeft: "-3px" },
@@ -87580,7 +87565,7 @@ html body {
87580
87565
  taxon
87581
87566
  }
87582
87567
  ) }),
87583
- get(info, "vernacularNames") && taxon && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Vernacular names", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87568
+ !isSynonym && get(info, "vernacularNames") && taxon && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Vernacular names", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87584
87569
  VernacularNamesTable,
87585
87570
  {
87586
87571
  style: { marginTop: "-3px", marginLeft: "-3px" },
@@ -87589,7 +87574,7 @@ html body {
87589
87574
  datasetKey: taxon.datasetKey
87590
87575
  }
87591
87576
  ) }),
87592
- (get(info, "distributions") || showDistributionMap && gbifChecklistKey && taxon) && // Distributions owns its labelled block so it can hide entirely
87577
+ !isSynonym && (get(info, "distributions") || showDistributionMap && gbifChecklistKey && taxon) && // Distributions owns its labelled block so it can hide entirely
87593
87578
  // (label included) when there is nothing to show — including after
87594
87579
  // the async GBIF occurrence lookup comes back empty.
87595
87580
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -87650,7 +87635,7 @@ html body {
87650
87635
  }
87651
87636
  )
87652
87637
  ] }) }),
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") }) }),
87638
+ 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
87639
  ((_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
87640
  get(info, "references") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "References", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87656
87641
  ReferencesTable,
@@ -89314,7 +89299,7 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
89314
89299
  /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "License", children: data.license || "-" }),
89315
89300
  /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "Checklist Confidence", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Rate, { value: data.confidence, disabled: true }) }),
89316
89301
  /* @__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 }) : "-" }),
89302
+ /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "Website", children: data.url ? /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: data.url, target: "_blank", children: data.url }) : "-" }),
89318
89303
  /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { label: "ISSN", children: data.issn ? /* @__PURE__ */ jsxRuntimeExports.jsx(
89319
89304
  "a",
89320
89305
  {