col-browser 2.2.1 → 2.2.3

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.
@@ -3,7 +3,7 @@ import { j as i } from "./chunks/jsx-runtime-BzflLqGi.js";
3
3
  import { useState as s, useEffect as $ } from "react";
4
4
  import { s as D, c as l, R as T, b as g } from "./chunks/router-CssZk5qZ.js";
5
5
  import { Row as k, Col as v, Spin as w } from "antd";
6
- import { D as A } from "./chunks/Distributions-CXIEJ6e6.js";
6
+ import { D as A } from "./chunks/Distributions-CLwWAH98.js";
7
7
  const C = ({
8
8
  taxonId: o,
9
9
  datasetKey: n,
package/es/tree.js CHANGED
@@ -80,7 +80,7 @@ class V extends j.Component {
80
80
  });
81
81
  });
82
82
  c(this, "render", () => {
83
- const { data: e, showInNode: s, popOverVisible: o, loading: r } = this.state, { taxon: l, datasetKey: h } = this.props, n = { color: "orange", fontSize: "11px" }, u = (a) => `${S.clbPortal}/dataset/${h}/publisher/${a}`;
83
+ const { data: e, showInNode: s, popOverVisible: o, loading: r } = this.state, { taxon: l, datasetKey: h } = this.props, n = { color: "orange", fontSize: "11px" }, p = (a) => `${S.clbPortal}/dataset/${h}/publisher/${a}`;
84
84
  return s ? e.filter((a) => !!a).map((a, d) => /* @__PURE__ */ t.jsx(
85
85
  L,
86
86
  {
@@ -116,17 +116,17 @@ class V extends j.Component {
116
116
  this.state.publishers && this.state.publishers.length > 0 && /* @__PURE__ */ t.jsxs("div", { style: { marginTop: "12px" }, children: [
117
117
  /* @__PURE__ */ t.jsx("strong", { children: "Publishers" }),
118
118
  /* @__PURE__ */ t.jsx("div", { children: this.state.publishers.filter((a) => !!a).map((a, d) => {
119
- var f;
119
+ var u;
120
120
  return /* @__PURE__ */ t.jsxs(
121
121
  "a",
122
122
  {
123
- href: u(a.id),
123
+ href: p(a.id),
124
124
  target: "_blank",
125
125
  rel: "noopener noreferrer",
126
126
  style: n,
127
127
  children: [
128
128
  (d ? ", " : "") + (a.alias || a.id),
129
- (f = a.datasets) != null && f.length ? ` (${a.datasets.length.toLocaleString("en-GB")})` : ""
129
+ (u = a.datasets) != null && u.length ? ` (${a.datasets.length.toLocaleString("en-GB")})` : ""
130
130
  ]
131
131
  },
132
132
  a.id
@@ -179,14 +179,14 @@ class k extends j.Component {
179
179
  datasetKey: l
180
180
  } = this.props, h = m(s, "dataset"), n = (o || []).filter((a) => (s == null ? void 0 : s.subjectDatasetKey) !== a).length > 0;
181
181
  e.estimate && e.estimates && e.estimates.find((a) => a.estimate === e.estimate);
182
- const u = typeof e.id == "string" && e.id.indexOf("incertae-sedis") > -1;
182
+ const p = typeof e.id == "string" && e.id.indexOf("incertae-sedis") > -1;
183
183
  return /* @__PURE__ */ t.jsx(z.Consumer, { children: ({ showInfo: a }) => /* @__PURE__ */ t.jsxs("div", { id: e.id, children: [
184
184
  /* @__PURE__ */ t.jsxs("span", { children: [
185
185
  /* @__PURE__ */ t.jsxs("span", { className: "tree-node-rank", children: [
186
186
  e.rank,
187
187
  ": "
188
188
  ] }),
189
- u ? /* @__PURE__ */ t.jsx("span", { dangerouslySetInnerHTML: { __html: e.labelHtml } }) : /* @__PURE__ */ t.jsx(L, { to: "taxon", args: e.id, children: /* @__PURE__ */ t.jsx("span", { dangerouslySetInnerHTML: { __html: e.labelHtml } }) }),
189
+ p ? /* @__PURE__ */ t.jsx("span", { dangerouslySetInnerHTML: { __html: e.labelHtml } }) : /* @__PURE__ */ t.jsx(L, { to: "taxon", args: e.id, children: /* @__PURE__ */ t.jsx("span", { dangerouslySetInnerHTML: { __html: e.labelHtml } }) }),
190
190
  (e == null ? void 0 : e.merged) && /* @__PURE__ */ t.jsx(pe, { style: { marginLeft: "4px" }, datasetKey: e == null ? void 0 : e.datasetKey, verbatimSourceKey: e == null ? void 0 : e.verbatimSourceKey })
191
191
  ] }),
192
192
  a && e.status === "provisionally accepted" && /* @__PURE__ */ t.jsxs(j.Fragment, { children: [
@@ -306,23 +306,23 @@ class G extends j.Component {
306
306
  insertPlaceholder: r,
307
307
  type: l,
308
308
  expandedTaxonKey: h
309
- } = this.props, n = h, { defaultTaxonKey: u } = this.props;
309
+ } = this.props, n = h, { defaultTaxonKey: p } = this.props;
310
310
  return this.setState({ rootLoading: !0, treeData: [] }), D(
311
311
  `${S.dataApi}dataset/${s}/tree?projectKey=${s}${l ? "&type=" + l : ""}&limit=${K}&offset=${this.state.treeData.length}${o ? "&extinct=false&extinct=" : ""}${r ? "&insertPlaceholder=true" : ""}`
312
312
  ).then(this.decorateWithSectorsAndDataset).then((a) => {
313
- const d = a.data.result || [], f = a.data.total, x = d.map((p) => {
313
+ const d = a.data.result || [], u = a.data.total, x = d.map((f) => {
314
314
  let i = {
315
- taxon: p,
316
- key: p.id,
315
+ taxon: f,
316
+ key: f.id,
317
317
  datasetKey: s,
318
- childCount: p.childCount,
319
- isLeaf: p.childCount === 0,
318
+ childCount: f.childCount,
319
+ isLeaf: f.childCount === 0,
320
320
  childOffset: 0
321
321
  };
322
322
  return i.title = /* @__PURE__ */ t.jsx(
323
323
  k,
324
324
  {
325
- taxon: p,
325
+ taxon: f,
326
326
  datasetKey: s,
327
327
  showSourceTaxon: e,
328
328
  reloadChildren: () => this.fetchChildPage(i, !0),
@@ -332,17 +332,20 @@ class G extends j.Component {
332
332
  });
333
333
  this.setState(
334
334
  {
335
- rootTotal: f,
335
+ rootTotal: u,
336
336
  rootLoading: !1,
337
337
  treeData: [...this.state.treeData, ...x],
338
- expandedKeys: x.length < 10 ? x.map((p) => p.taxon.id).filter((p) => p === "CS5HF") : [],
338
+ // Nothing is auto-expanded by default. Consumers open a specific root
339
+ // (or deep taxon) by passing `defaultTaxonKey`/`expandedTaxonKey` —
340
+ // e.g. defaultTaxonKey="CS5HF" opens Eukaryota in current COL releases.
341
+ expandedKeys: [],
339
342
  error: null
340
343
  },
341
344
  () => {
342
345
  if (n)
343
346
  return this.expandToTaxon(n);
344
- if (u)
345
- return this.expandToTaxon(u);
347
+ if (p)
348
+ return this.expandToTaxon(p);
346
349
  }
347
350
  ), x.length === 1 && this.fetchChildPage(x[x.length - 1]);
348
351
  }).catch((a) => {
@@ -368,9 +371,9 @@ class G extends j.Component {
368
371
  const { data: h } = await D(
369
372
  `${S.dataApi}dataset/${o}/tree/${e}?projectKey=${o}&insertPlaceholder=true${l ? "&type=" + l : ""}${r ? "&extinct=false" : ""}`
370
373
  ).then(
371
- (p) => this.decorateWithSectorsAndDataset({
372
- data: { result: p.data }
373
- }).then(() => p)
374
+ (f) => this.decorateWithSectorsAndDataset({
375
+ data: { result: f.data }
376
+ }).then(() => f)
374
377
  );
375
378
  if (h.length === 0)
376
379
  return this.setState(
@@ -382,7 +385,7 @@ class G extends j.Component {
382
385
  this.loadRoot
383
386
  );
384
387
  const n = h[h.length - 1];
385
- let u = {
388
+ let p = {
386
389
  taxon: n,
387
390
  key: n.id,
388
391
  datasetKey: o,
@@ -390,19 +393,19 @@ class G extends j.Component {
390
393
  isLeaf: n.childCount === 0,
391
394
  childOffset: 0
392
395
  };
393
- u.title = /* @__PURE__ */ t.jsx(
396
+ p.title = /* @__PURE__ */ t.jsx(
394
397
  k,
395
398
  {
396
399
  taxon: n,
397
400
  datasetKey: o,
398
401
  showSourceTaxon: s,
399
402
  rank: this.state.rank,
400
- reloadChildren: () => this.fetchChildPage(u, !0)
403
+ reloadChildren: () => this.fetchChildPage(p, !0)
401
404
  }
402
- ), u.ref = u;
403
- const a = u;
404
- for (let p = h.length - 2; p >= 0; p--) {
405
- const i = h[p], g = {
405
+ ), p.ref = p;
406
+ const a = p;
407
+ for (let f = h.length - 2; f >= 0; f--) {
408
+ const i = h[f], g = {
406
409
  taxon: i,
407
410
  key: i.id,
408
411
  datasetKey: o,
@@ -419,12 +422,12 @@ class G extends j.Component {
419
422
  rank: this.state.rank,
420
423
  reloadChildren: () => this.fetchChildPage(g, !0)
421
424
  }
422
- ), u.children = [g], u = g;
425
+ ), p.children = [g], p = g;
423
426
  }
424
427
  const { treeData: d } = this.state;
425
- var f = d.findIndex((p) => p.key == a.key);
426
- d[f] = a;
427
- const x = [...h.map((p) => p.id).reverse()];
428
+ var u = d.findIndex((f) => f.key == a.key);
429
+ d[u] = a;
430
+ const x = [...h.map((f) => f.id).reverse()];
428
431
  this.setState(
429
432
  { treeData: d },
430
433
  () => this.reloadLoadedKeys(x, e)
@@ -436,14 +439,14 @@ class G extends j.Component {
436
439
  datasetKey: l,
437
440
  hideExtinct: h,
438
441
  insertPlaceholder: n,
439
- type: u
442
+ type: p
440
443
  } = this.props, { treeData: a } = this.state;
441
444
  m(e, "childCount");
442
- const d = K, f = m(e, "childOffset"), x = await D(
443
- `${S.dataApi}dataset/${l}/tree/${e.taxon.id}/children?limit=${d}&offset=${f}&projectKey=${l}${u ? "&type=" + u : ""}${h ? "&extinct=false" : ""}${n ? "&insertPlaceholder=true" : ""}`
445
+ const d = K, u = m(e, "childOffset"), x = await D(
446
+ `${S.dataApi}dataset/${l}/tree/${e.taxon.id}/children?limit=${d}&offset=${u}&projectKey=${l}${p ? "&type=" + p : ""}${h ? "&extinct=false" : ""}${n ? "&insertPlaceholder=true" : ""}`
444
447
  );
445
448
  await this.decorateWithSectorsAndDataset(x);
446
- const p = x.data.result ? x.data.result.map((i) => {
449
+ const f = x.data.result ? x.data.result.map((i) => {
447
450
  let g = {
448
451
  taxon: i,
449
452
  key: i.id,
@@ -465,7 +468,7 @@ class G extends j.Component {
465
468
  }
466
469
  ), g.ref = g, g;
467
470
  }) : [];
468
- if (e.children = e.children && f !== 0 && !s ? [...e.children, ...p] : p, x.data.last && e.childCount > e.children.length && (e.childCount = e.children.length), !x.data.last) {
471
+ if (e.children = e.children && u !== 0 && !s ? [...e.children, ...f] : f, x.data.last && e.childCount > e.children.length && (e.childCount = e.children.length), !x.data.last) {
469
472
  const i = () => (e.childOffset += K, e.children[e.children.length - 1].key === "__loadMoreBTN__" && (e.children = e.children.slice(0, -1)), this.fetchChildPage(e, !1));
470
473
  e.children = [
471
474
  ...e.children,
@@ -525,9 +528,9 @@ class G extends j.Component {
525
528
  for (let a = 0; a < n.length; a++) {
526
529
  let d = this.findNode(n[a], l);
527
530
  if (!d && h && n[a - 1]) {
528
- const f = this.findNode(n[a - 1], l);
529
- f && A(m(f, "children")) && f.children.length > 0 && (d = await this.pageThroughChildrenUntilTaxonFound(
530
- f,
531
+ const u = this.findNode(n[a - 1], l);
532
+ u && A(m(u, "children")) && u.children.length > 0 && (d = await this.pageThroughChildrenUntilTaxonFound(
533
+ u,
531
534
  n[a]
532
535
  ), d ? n.splice(a, 0, d.taxon.id) : this.setState(
533
536
  {
@@ -551,13 +554,13 @@ class G extends j.Component {
551
554
  }
552
555
  if (d) {
553
556
  await this.fetchChildPage(d, !0, !0);
554
- let f = d.children.find(
557
+ let u = d.children.find(
555
558
  (x) => m(x, "taxon.id") === m(h, "taxon.id")
556
559
  );
557
- h && a === n.length - 2 && m(d, "taxon.id") !== m(h, "taxon.id") && A(d.children) && !f && d.children.length < d.childCount && (f = await this.pageThroughChildrenUntilTaxonFound(
560
+ h && a === n.length - 2 && m(d, "taxon.id") !== m(h, "taxon.id") && A(d.children) && !u && d.children.length < d.childCount && (u = await this.pageThroughChildrenUntilTaxonFound(
558
561
  d,
559
562
  m(h, "taxon.id")
560
- ), f ? this.setState({ treeData: [...this.state.treeData] }, () => {
563
+ ), u ? this.setState({ treeData: [...this.state.treeData] }, () => {
561
564
  setTimeout(() => {
562
565
  document.getElementById(s).scrollIntoView({ behavior: "smooth", block: "center" });
563
566
  }, 100);
@@ -576,8 +579,8 @@ class G extends j.Component {
576
579
  ));
577
580
  }
578
581
  }
579
- const u = { loadedKeys: n, rootLoading: !1 };
580
- o && (u.expandedKeys = n), this.setState(u, () => {
582
+ const p = { loadedKeys: n, rootLoading: !1 };
583
+ o && (p.expandedKeys = n), this.setState(p, () => {
581
584
  s && setTimeout(() => {
582
585
  document.getElementById(s).scrollIntoView({ behavior: "smooth", block: "center" });
583
586
  }, 100);
@@ -609,8 +612,8 @@ class G extends j.Component {
609
612
  defaultExpandAll: l,
610
613
  nodeNotFoundErr: h,
611
614
  loadedKeys: n,
612
- expandedKeys: u
613
- } = this.state, { treeType: a, dataset: d, height: f, expandedTaxonKey: x } = this.props, p = x;
615
+ expandedKeys: p
616
+ } = this.state, { treeType: a, dataset: d, height: u, expandedTaxonKey: x } = this.props, f = x;
614
617
  return /* @__PURE__ */ t.jsxs("div", { children: [
615
618
  e && /* @__PURE__ */ t.jsx(j.Fragment, { children: m(e, "response.data.code") !== 404 ? /* @__PURE__ */ t.jsx(
616
619
  b,
@@ -658,9 +661,9 @@ class G extends j.Component {
658
661
  loadData: this.onLoadData,
659
662
  onLoad: (i) => this.setState({ loadedKeys: i }),
660
663
  loadedKeys: n,
661
- expandedKeys: u,
664
+ expandedKeys: p,
662
665
  treeData: r,
663
- filterTreeNode: (i) => i.key === p,
666
+ filterTreeNode: (i) => i.key === f,
664
667
  onExpand: (i, g) => {
665
668
  this.setState({ expandedKeys: i }), this.props.onExpandedTaxonKeyChange && this.props.onExpandedTaxonKeyChange(
666
669
  g.expanded ? g.node.key : null
@@ -703,9 +706,9 @@ class Z extends j.Component {
703
706
  showTreeOptions: l,
704
707
  linkToSpeciesPage: h,
705
708
  citation: n,
706
- type: u,
709
+ type: p,
707
710
  insertPlaceholder: a = !0
708
- } = this.props, { hideExtinct: d, dataset: f } = this.state, x = (i) => {
711
+ } = this.props, { hideExtinct: d, dataset: u } = this.state, x = (i) => {
709
712
  var P, _;
710
713
  const g = m(i, "key");
711
714
  if (!g) return;
@@ -714,11 +717,11 @@ class Z extends j.Component {
714
717
  const E = (_ = (P = this.context) == null ? void 0 : P.taxon) == null ? void 0 : _.onNavigate;
715
718
  E && E(g);
716
719
  } else r && (r(g), this.treeRef && this.treeRef.reloadRoot && this.treeRef.reloadRoot());
717
- }, p = () => {
720
+ }, f = () => {
718
721
  r && r(null);
719
722
  };
720
723
  return /* @__PURE__ */ t.jsxs("div", { className: "catalogue-of-life", children: [
721
- n === "top" && f && /* @__PURE__ */ t.jsx(F, { dataset: f }),
724
+ n === "top" && u && /* @__PURE__ */ t.jsx(F, { dataset: u }),
722
725
  /* @__PURE__ */ t.jsx(w.Provider, { value: this.cache, children: /* @__PURE__ */ t.jsxs(z.Provider, { value: this.state, children: [
723
726
  /* @__PURE__ */ t.jsxs(re, { children: [
724
727
  /* @__PURE__ */ t.jsx(v, { flex: "auto", children: /* @__PURE__ */ t.jsx(
@@ -733,7 +736,7 @@ class Z extends j.Component {
733
736
  },
734
737
  defaultTaxonKey: o || null,
735
738
  onSelectName: x,
736
- onResetSearch: p
739
+ onResetSearch: f
737
740
  }
738
741
  ) }),
739
742
  l && /* @__PURE__ */ t.jsxs(v, { style: { paddingLeft: "8px" }, children: [
@@ -769,11 +772,11 @@ class Z extends j.Component {
769
772
  expandedTaxonKey: o,
770
773
  onExpandedTaxonKeyChange: r,
771
774
  treeRef: (i) => this.treeRef = i,
772
- type: u
775
+ type: p
773
776
  }
774
777
  )
775
778
  ] }) }),
776
- n === "bottom" && f && /* @__PURE__ */ t.jsx(F, { dataset: f })
779
+ n === "bottom" && u && /* @__PURE__ */ t.jsx(F, { dataset: u })
777
780
  ] });
778
781
  });
779
782
  de(this.props.auth), this.state = {
@@ -797,7 +800,7 @@ function me({
797
800
  citation: l,
798
801
  type: h,
799
802
  insertPlaceholder: n,
800
- auth: u,
803
+ auth: p,
801
804
  ...a
802
805
  }) {
803
806
  return /* @__PURE__ */ t.jsx(U.Provider, { value: he(a), children: /* @__PURE__ */ t.jsx(
@@ -812,7 +815,7 @@ function me({
812
815
  citation: l,
813
816
  type: h,
814
817
  insertPlaceholder: n,
815
- auth: u
818
+ auth: p
816
819
  }
817
820
  ) });
818
821
  }