col-browser 2.3.9 → 2.3.10
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/es/tree.js +421 -411
- package/es/tree.js.map +1 -1
- package/package.json +1 -1
- package/umd/col-browser.js +28 -11
- package/umd/col-browser.js.map +1 -1
- package/umd/col-browser.min.js +4 -4
- package/umd/col-browser.min.js.map +1 -1
package/es/tree.js
CHANGED
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { a as
|
|
5
|
-
import { c as
|
|
6
|
-
import { j as
|
|
7
|
-
import j, { createContext as
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { sortBy as
|
|
10
|
-
import { L, c as
|
|
11
|
-
import
|
|
12
|
-
import { c as
|
|
13
|
-
import { M as
|
|
14
|
-
import { E as
|
|
15
|
-
import { g as
|
|
16
|
-
import { C as
|
|
17
|
-
import { r as
|
|
18
|
-
const
|
|
1
|
+
var Y = Object.defineProperty;
|
|
2
|
+
var tt = (x, y, t) => y in x ? Y(x, y, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[y] = t;
|
|
3
|
+
var u = (x, y, t) => tt(x, typeof y != "symbol" ? y + "" : y, t);
|
|
4
|
+
import { a as et } from "./chunks/withDatasetKey-BgMY05XE.js";
|
|
5
|
+
import { c as D, w as st } from "./chunks/config-B2Z9BaEd.js";
|
|
6
|
+
import { j as e } from "./chunks/jsx-runtime-BzflLqGi.js";
|
|
7
|
+
import j, { createContext as at } from "react";
|
|
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
|
+
import { sortBy as _, get as m, isUndefined as A, flatten as ct, isArray as O } from "lodash-es";
|
|
10
|
+
import { L as P, c as K, R as H, s as ut, b as pt } from "./chunks/router-CssZk5qZ.js";
|
|
11
|
+
import L from "dataloader";
|
|
12
|
+
import { c as V, b as z, g as ft } from "./chunks/dataset-BuF063rn.js";
|
|
13
|
+
import { M as xt } from "./chunks/MergedDataBadge-DK4XUXsL.js";
|
|
14
|
+
import { E as gt } from "./chunks/ErrorMsg-K8k5PPTp.js";
|
|
15
|
+
import { g as yt } from "./chunks/sector-Behb-WCC.js";
|
|
16
|
+
import { C as R, N as mt } from "./chunks/DatasetCitation-JpNSTWz-.js";
|
|
17
|
+
import { r as F, w as M } from "./chunks/storage-BgdCo9fV.js";
|
|
18
|
+
const E = at({
|
|
19
19
|
datasetLoader: null,
|
|
20
20
|
publisherLoader: null
|
|
21
|
-
}), B = (
|
|
22
|
-
datasetLoader: new
|
|
23
|
-
publisherLoader: new
|
|
24
|
-
(
|
|
21
|
+
}), B = (x) => ({
|
|
22
|
+
datasetLoader: new L((y) => z(y, x)),
|
|
23
|
+
publisherLoader: new L(
|
|
24
|
+
(y) => V(y, x)
|
|
25
25
|
)
|
|
26
26
|
});
|
|
27
|
-
class
|
|
28
|
-
constructor(
|
|
29
|
-
super(
|
|
27
|
+
class G extends j.Component {
|
|
28
|
+
constructor(t) {
|
|
29
|
+
super(t);
|
|
30
30
|
// Returns the shared cache from TreeCacheContext if available, or a
|
|
31
31
|
// throwaway local DataLoader so the popover still works even if context
|
|
32
32
|
// doesn't reach this instance (which used to leave the spinner stuck
|
|
33
33
|
// because getData early-returned with no loading state set).
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
const { datasetKey:
|
|
37
|
-
return (
|
|
38
|
-
(o) =>
|
|
34
|
+
u(this, "getDatasetLoader", () => {
|
|
35
|
+
var a;
|
|
36
|
+
const { datasetKey: t } = this.props;
|
|
37
|
+
return (a = this.context) != null && a.datasetLoader ? this.context.datasetLoader : (this._localDatasetLoader || (this._localDatasetLoader = new L(
|
|
38
|
+
(o) => z(o, t)
|
|
39
39
|
)), this._localDatasetLoader);
|
|
40
40
|
});
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
const { datasetKey:
|
|
44
|
-
return (
|
|
45
|
-
(o) =>
|
|
41
|
+
u(this, "getPublisherLoader", () => {
|
|
42
|
+
var a;
|
|
43
|
+
const { datasetKey: t } = this.props;
|
|
44
|
+
return (a = this.context) != null && a.publisherLoader ? this.context.publisherLoader : (this._localPublisherLoader || (this._localPublisherLoader = new L(
|
|
45
|
+
(o) => V(o, t)
|
|
46
46
|
)), this._localPublisherLoader);
|
|
47
47
|
});
|
|
48
|
-
|
|
49
|
-
const { sourceDatasetKeys:
|
|
50
|
-
|
|
48
|
+
u(this, "componentDidMount", () => {
|
|
49
|
+
const { sourceDatasetKeys: t } = this.props;
|
|
50
|
+
t && t.length < 4 && this.setState({ showInNode: !0 }, this.getData);
|
|
51
51
|
});
|
|
52
|
-
|
|
53
|
-
const { sourceDatasetKeys:
|
|
54
|
-
if (!(
|
|
52
|
+
u(this, "getData", () => {
|
|
53
|
+
const { sourceDatasetKeys: t } = this.props;
|
|
54
|
+
if (!(t != null && t.length)) return;
|
|
55
55
|
this.setState({ loading: !0 });
|
|
56
|
-
const
|
|
56
|
+
const a = this.getDatasetLoader();
|
|
57
57
|
Promise.all(
|
|
58
|
-
|
|
58
|
+
t.map((o) => a.load(o).catch(() => null))
|
|
59
59
|
).then((o) => {
|
|
60
|
-
this.setState({ data:
|
|
60
|
+
this.setState({ data: _(o, ["alias"]), loading: !1 });
|
|
61
61
|
}).catch(() => {
|
|
62
62
|
this.setState({ data: [], loading: !1 });
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
|
-
|
|
66
|
-
const { publisherDatasetKeys:
|
|
67
|
-
if (!
|
|
68
|
-
const
|
|
65
|
+
u(this, "getPublisherData", () => {
|
|
66
|
+
const { publisherDatasetKeys: t } = this.props;
|
|
67
|
+
if (!t) return;
|
|
68
|
+
const a = this.getPublisherLoader();
|
|
69
69
|
Promise.all(
|
|
70
|
-
Object.keys(
|
|
71
|
-
(o) =>
|
|
70
|
+
Object.keys(t).map(
|
|
71
|
+
(o) => a.load(o).then((r) => ({
|
|
72
72
|
...r,
|
|
73
|
-
datasets:
|
|
73
|
+
datasets: t[o]
|
|
74
74
|
})).catch(() => null)
|
|
75
75
|
)
|
|
76
76
|
).then((o) => {
|
|
77
|
-
this.setState({ publishers:
|
|
77
|
+
this.setState({ publishers: _(o.filter(Boolean), ["alias"]) });
|
|
78
78
|
}).catch(() => {
|
|
79
79
|
this.setState({ publishers: [] });
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
|
-
|
|
83
|
-
const { data:
|
|
84
|
-
return
|
|
85
|
-
|
|
82
|
+
u(this, "render", () => {
|
|
83
|
+
const { data: t, showInNode: a, popOverVisible: o, loading: r } = this.state, { taxon: l, datasetKey: d } = this.props, i = { color: "orange", fontSize: "11px" }, f = (s) => `${D.clbPortal}/dataset/${d}/publisher/${s}`;
|
|
84
|
+
return a ? t.filter((s) => !!s).map((s, n) => /* @__PURE__ */ e.jsx(
|
|
85
|
+
P,
|
|
86
86
|
{
|
|
87
87
|
to: "source",
|
|
88
|
-
args:
|
|
88
|
+
args: s.key,
|
|
89
89
|
className: "col-tree-data-source",
|
|
90
|
-
style:
|
|
91
|
-
children: (
|
|
90
|
+
style: i,
|
|
91
|
+
children: (n ? ", " : "") + (s.alias || s.key)
|
|
92
92
|
},
|
|
93
|
-
|
|
94
|
-
)) : /* @__PURE__ */
|
|
95
|
-
|
|
93
|
+
s.key
|
|
94
|
+
)) : /* @__PURE__ */ e.jsx("div", { style: { display: "inline" }, id: `taxon_sources_${l.id}`, children: /* @__PURE__ */ e.jsx(
|
|
95
|
+
ot,
|
|
96
96
|
{
|
|
97
|
-
getPopupContainer: () => document.getElementById(`taxon_sources_${
|
|
98
|
-
content: r ||
|
|
97
|
+
getPopupContainer: () => document.getElementById(`taxon_sources_${l.id}`),
|
|
98
|
+
content: r || t.length === 0 ? /* @__PURE__ */ e.jsx(
|
|
99
99
|
"div",
|
|
100
100
|
{
|
|
101
101
|
style: { minWidth: "200px", textAlign: "center", padding: "8px 0" },
|
|
102
|
-
children: /* @__PURE__ */
|
|
102
|
+
children: /* @__PURE__ */ e.jsx(q, { size: "small" })
|
|
103
103
|
}
|
|
104
|
-
) : /* @__PURE__ */
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
) : /* @__PURE__ */ e.jsxs("div", { style: { maxWidth: "500px" }, children: [
|
|
105
|
+
t.length > 0 && /* @__PURE__ */ e.jsx("div", { children: t.filter((s) => !!s).map((s, n) => /* @__PURE__ */ e.jsx(
|
|
106
|
+
P,
|
|
107
107
|
{
|
|
108
108
|
to: "source",
|
|
109
|
-
args:
|
|
109
|
+
args: s.key,
|
|
110
110
|
className: "col-tree-data-source",
|
|
111
|
-
style:
|
|
112
|
-
children: (
|
|
111
|
+
style: i,
|
|
112
|
+
children: (n ? ", " : "") + (s.alias || s.key)
|
|
113
113
|
},
|
|
114
|
-
|
|
114
|
+
s.key
|
|
115
115
|
)) }),
|
|
116
|
-
this.state.publishers && this.state.publishers.length > 0 && /* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
var
|
|
120
|
-
return /* @__PURE__ */
|
|
116
|
+
this.state.publishers && this.state.publishers.length > 0 && /* @__PURE__ */ e.jsxs("div", { style: { marginTop: "12px" }, children: [
|
|
117
|
+
/* @__PURE__ */ e.jsx("strong", { children: "Publishers" }),
|
|
118
|
+
/* @__PURE__ */ e.jsx("div", { children: this.state.publishers.filter((s) => !!s).map((s, n) => {
|
|
119
|
+
var p;
|
|
120
|
+
return /* @__PURE__ */ e.jsxs(
|
|
121
121
|
"a",
|
|
122
122
|
{
|
|
123
|
-
href: f(
|
|
123
|
+
href: f(s.id),
|
|
124
124
|
target: "_blank",
|
|
125
125
|
rel: "noopener noreferrer",
|
|
126
|
-
style:
|
|
126
|
+
style: i,
|
|
127
127
|
children: [
|
|
128
|
-
(
|
|
129
|
-
(
|
|
128
|
+
(n ? ", " : "") + (s.alias || s.id),
|
|
129
|
+
(p = s.datasets) != null && p.length ? ` (${s.datasets.length.toLocaleString("en-GB")})` : ""
|
|
130
130
|
]
|
|
131
131
|
},
|
|
132
|
-
|
|
132
|
+
s.id
|
|
133
133
|
);
|
|
134
134
|
}) })
|
|
135
135
|
] })
|
|
136
136
|
] }),
|
|
137
|
-
title: /* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
/* @__PURE__ */
|
|
137
|
+
title: /* @__PURE__ */ e.jsxs("div", { style: { padding: "4px 0" }, children: [
|
|
138
|
+
/* @__PURE__ */ e.jsx("span", { style: { fontWeight: 500 }, children: "Sources for " }),
|
|
139
|
+
/* @__PURE__ */ e.jsx("em", { children: l == null ? void 0 : l.name }),
|
|
140
|
+
/* @__PURE__ */ e.jsx(it, { style: { margin: "8px 0 0" } })
|
|
141
141
|
] }),
|
|
142
142
|
open: o,
|
|
143
|
-
onOpenChange: (
|
|
144
|
-
|
|
143
|
+
onOpenChange: (s) => this.setState({ popOverVisible: s }, () => {
|
|
144
|
+
s && this.state.data.length === 0 && this.getData(), s && this.props.publisherDatasetKeys && !this.state.publishers && this.getPublisherData();
|
|
145
145
|
}),
|
|
146
146
|
trigger: "click",
|
|
147
147
|
placement: "rightTop",
|
|
148
|
-
children: /* @__PURE__ */
|
|
148
|
+
children: /* @__PURE__ */ e.jsx(
|
|
149
149
|
"a",
|
|
150
150
|
{
|
|
151
151
|
className: "col-tree-data-source",
|
|
152
152
|
role: "button",
|
|
153
153
|
tabIndex: 0,
|
|
154
154
|
style: { cursor: "pointer", color: "orange", fontSize: "11px" },
|
|
155
|
-
onClick: (
|
|
155
|
+
onClick: (s) => s.preventDefault(),
|
|
156
156
|
children: "Multiple sources"
|
|
157
157
|
}
|
|
158
158
|
)
|
|
@@ -166,44 +166,44 @@ class V extends j.Component {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
|
|
170
|
-
const
|
|
169
|
+
u(G, "contextType", E);
|
|
170
|
+
const X = j.createContext();
|
|
171
171
|
class k extends j.Component {
|
|
172
|
-
constructor(
|
|
173
|
-
super(
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
constructor(t) {
|
|
173
|
+
super(t);
|
|
174
|
+
u(this, "rankIsAboveSpecies", (t) => this.props.rank.indexOf(t) < this.props.rank.indexOf("species"));
|
|
175
|
+
u(this, "render", () => {
|
|
176
176
|
const {
|
|
177
|
-
taxon:
|
|
178
|
-
taxon: { sector:
|
|
179
|
-
datasetKey:
|
|
180
|
-
} = this.props,
|
|
181
|
-
|
|
182
|
-
const f = typeof
|
|
183
|
-
return /* @__PURE__ */
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
|
|
177
|
+
taxon: t,
|
|
178
|
+
taxon: { sector: a, sourceDatasetKeys: o, publisherDatasetKeys: r },
|
|
179
|
+
datasetKey: l
|
|
180
|
+
} = this.props, d = m(a, "dataset"), i = (o || []).filter((s) => (a == null ? void 0 : a.subjectDatasetKey) !== s).length > 0;
|
|
181
|
+
t.estimate && t.estimates && t.estimates.find((s) => s.estimate === t.estimate);
|
|
182
|
+
const f = typeof t.id == "string" && t.id.indexOf("incertae-sedis") > -1;
|
|
183
|
+
return /* @__PURE__ */ e.jsx(X.Consumer, { children: ({ showInfo: s }) => /* @__PURE__ */ e.jsxs("div", { id: t.id, children: [
|
|
184
|
+
/* @__PURE__ */ e.jsxs("span", { children: [
|
|
185
|
+
/* @__PURE__ */ e.jsxs("span", { className: "tree-node-rank", children: [
|
|
186
|
+
t.rank,
|
|
187
187
|
": "
|
|
188
188
|
] }),
|
|
189
|
-
f ? /* @__PURE__ */
|
|
190
|
-
(
|
|
189
|
+
f ? /* @__PURE__ */ e.jsx("span", { dangerouslySetInnerHTML: { __html: t.labelHtml } }) : /* @__PURE__ */ e.jsx(P, { to: "taxon", args: t.id, children: /* @__PURE__ */ e.jsx("span", { dangerouslySetInnerHTML: { __html: t.labelHtml } }) }),
|
|
190
|
+
(t == null ? void 0 : t.merged) && /* @__PURE__ */ e.jsx(xt, { style: { marginLeft: "4px" }, datasetKey: t == null ? void 0 : t.datasetKey, verbatimSourceKey: t == null ? void 0 : t.verbatimSourceKey })
|
|
191
191
|
] }),
|
|
192
|
-
|
|
192
|
+
s && t.status === "provisionally accepted" && /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
|
|
193
193
|
" • ",
|
|
194
|
-
/* @__PURE__ */
|
|
194
|
+
/* @__PURE__ */ e.jsx(nt, { color: "warning", style: { marginRight: 0 }, children: "prov." })
|
|
195
195
|
] }),
|
|
196
|
-
!
|
|
196
|
+
!A(t.count) && this.rankIsAboveSpecies(t == null ? void 0 : t.rank) && /* @__PURE__ */ e.jsxs("span", { children: [
|
|
197
197
|
" ",
|
|
198
198
|
"• ",
|
|
199
|
-
Number(
|
|
199
|
+
Number(t.count).toLocaleString(),
|
|
200
200
|
" ",
|
|
201
|
-
|
|
201
|
+
s && !A(t.speciesEstimate) && /* @__PURE__ */ e.jsxs("span", { children: [
|
|
202
202
|
" ",
|
|
203
203
|
"of",
|
|
204
204
|
" ",
|
|
205
205
|
Number(
|
|
206
|
-
|
|
206
|
+
t.speciesEstimate
|
|
207
207
|
).toLocaleString(),
|
|
208
208
|
" ",
|
|
209
209
|
"est.",
|
|
@@ -211,31 +211,31 @@ class k extends j.Component {
|
|
|
211
211
|
] }),
|
|
212
212
|
"spp."
|
|
213
213
|
] }),
|
|
214
|
-
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
/* @__PURE__ */
|
|
217
|
-
|
|
214
|
+
s && a && /* @__PURE__ */ e.jsxs("span", { children: [
|
|
215
|
+
/* @__PURE__ */ e.jsx("span", { children: " • " }),
|
|
216
|
+
/* @__PURE__ */ e.jsxs(
|
|
217
|
+
P,
|
|
218
218
|
{
|
|
219
219
|
to: "source",
|
|
220
|
-
args:
|
|
221
|
-
style:
|
|
220
|
+
args: a.subjectDatasetKey,
|
|
221
|
+
style: i ? { fontWeight: "bold" } : null,
|
|
222
222
|
className: "col-tree-data-source",
|
|
223
223
|
children: [
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
m(d, "alias") || a.subjectDatasetKey,
|
|
225
|
+
i && ", "
|
|
226
226
|
]
|
|
227
227
|
}
|
|
228
228
|
)
|
|
229
229
|
] }),
|
|
230
|
-
|
|
230
|
+
s && i && /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
|
|
231
231
|
" ",
|
|
232
|
-
/* @__PURE__ */
|
|
233
|
-
|
|
232
|
+
/* @__PURE__ */ e.jsx(
|
|
233
|
+
G,
|
|
234
234
|
{
|
|
235
235
|
sourceDatasetKeys: o,
|
|
236
236
|
publisherDatasetKeys: r,
|
|
237
|
-
taxon:
|
|
238
|
-
datasetKey:
|
|
237
|
+
taxon: t,
|
|
238
|
+
datasetKey: l
|
|
239
239
|
}
|
|
240
240
|
)
|
|
241
241
|
] })
|
|
@@ -248,46 +248,46 @@ class k extends j.Component {
|
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
const
|
|
252
|
-
class
|
|
253
|
-
constructor(
|
|
254
|
-
super(
|
|
255
|
-
|
|
251
|
+
const b = 1e3, Z = "__loadMoreBTN__", W = (x) => `${Z}${x}`, U = (x) => typeof x == "string" && x.startsWith(Z);
|
|
252
|
+
class Ct extends j.Component {
|
|
253
|
+
constructor(t) {
|
|
254
|
+
super(t);
|
|
255
|
+
u(this, "onClick", () => {
|
|
256
256
|
this.setState(
|
|
257
257
|
{ loading: !0 },
|
|
258
258
|
() => this.props.onClick().then(() => this.setState({ loading: !1 }))
|
|
259
259
|
);
|
|
260
260
|
});
|
|
261
|
-
|
|
262
|
-
const { loading:
|
|
263
|
-
return /* @__PURE__ */
|
|
264
|
-
|
|
265
|
-
!
|
|
261
|
+
u(this, "render", () => {
|
|
262
|
+
const { loading: t } = this.state;
|
|
263
|
+
return /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
|
|
264
|
+
t && /* @__PURE__ */ e.jsx(q, {}),
|
|
265
|
+
!t && /* @__PURE__ */ e.jsx("a", { onClick: this.onClick, children: /* @__PURE__ */ e.jsx("strong", { children: "Load more..." }) })
|
|
266
266
|
] });
|
|
267
267
|
});
|
|
268
268
|
this.state = { loading: !1 };
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
class
|
|
272
|
-
constructor(
|
|
273
|
-
super(
|
|
274
|
-
|
|
275
|
-
const { datasetKey:
|
|
276
|
-
this.loadRoot(), this.sectorLoader = new
|
|
277
|
-
(o) =>
|
|
271
|
+
class J extends j.Component {
|
|
272
|
+
constructor(t) {
|
|
273
|
+
super(t);
|
|
274
|
+
u(this, "componentDidMount", () => {
|
|
275
|
+
const { datasetKey: t } = this.props;
|
|
276
|
+
this.loadRoot(), this.sectorLoader = new L(
|
|
277
|
+
(o) => yt(o, t)
|
|
278
278
|
), this.getRank();
|
|
279
|
-
const { treeRef:
|
|
280
|
-
|
|
279
|
+
const { treeRef: a } = this.props;
|
|
280
|
+
a(this);
|
|
281
281
|
});
|
|
282
|
-
|
|
283
|
-
(
|
|
282
|
+
u(this, "componentDidUpdate", (t) => {
|
|
283
|
+
(t.defaultExpandKey !== this.props.defaultExpandKey || t.hideExtinct !== this.props.hideExtinct || t.insertPlaceholder !== this.props.insertPlaceholder) && this.reloadRoot();
|
|
284
284
|
});
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
(
|
|
285
|
+
u(this, "getRank", () => {
|
|
286
|
+
K(`${D.dataApi}vocab/rank`).then(
|
|
287
|
+
(t) => this.setState({ rank: t.data.map((a) => a.name) })
|
|
288
288
|
);
|
|
289
289
|
});
|
|
290
|
-
|
|
290
|
+
u(this, "reloadRoot", () => this.setState(
|
|
291
291
|
{
|
|
292
292
|
rootLoading: !0,
|
|
293
293
|
treeData: [],
|
|
@@ -298,245 +298,255 @@ class G extends j.Component {
|
|
|
298
298
|
},
|
|
299
299
|
this.loadRoot
|
|
300
300
|
));
|
|
301
|
-
|
|
301
|
+
// `append` is only set by the "Load more" button, which pages in the next
|
|
302
|
+
// batch of root taxa; every other caller loads page one from scratch.
|
|
303
|
+
// Each call takes a request id and a response is merged only while its id is
|
|
304
|
+
// still the current one. Without that, two overlapping loads — React
|
|
305
|
+
// StrictMode's double mount in dev, or a prop change while a load is in
|
|
306
|
+
// flight — both merged their page into treeData, so every root appeared
|
|
307
|
+
// twice and antd warned "Same 'key' exist in the Tree" (issue #59).
|
|
308
|
+
u(this, "loadRoot", async (t = !1) => {
|
|
302
309
|
const {
|
|
303
|
-
showSourceTaxon:
|
|
304
|
-
datasetKey:
|
|
305
|
-
hideExtinct:
|
|
306
|
-
insertPlaceholder:
|
|
307
|
-
type:
|
|
308
|
-
expandedTaxonKey:
|
|
309
|
-
} = this.props,
|
|
310
|
-
return this.setState(
|
|
311
|
-
|
|
312
|
-
)
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
310
|
+
showSourceTaxon: a,
|
|
311
|
+
datasetKey: o,
|
|
312
|
+
hideExtinct: r,
|
|
313
|
+
insertPlaceholder: l,
|
|
314
|
+
type: d,
|
|
315
|
+
expandedTaxonKey: i
|
|
316
|
+
} = this.props, f = i, { defaultTaxonKey: s } = this.props, n = ++this.rootRequestId, p = t ? this.state.treeData.length : 0;
|
|
317
|
+
return this.setState(
|
|
318
|
+
t ? { rootLoading: !0 } : { rootLoading: !0, treeData: [] }
|
|
319
|
+
), K(
|
|
320
|
+
`${D.dataApi}dataset/${o}/tree?projectKey=${o}${d ? "&type=" + d : ""}&limit=${b}&offset=${p}${r ? "&extinct=false&extinct=" : ""}${l ? "&insertPlaceholder=true" : ""}`
|
|
321
|
+
).then(this.decorateWithSectorsAndDataset).then((C) => {
|
|
322
|
+
if (n !== this.rootRequestId) return;
|
|
323
|
+
const c = C.data.result || [], h = C.data.total, g = c.map((S) => {
|
|
324
|
+
let T = {
|
|
325
|
+
taxon: S,
|
|
326
|
+
key: S.id,
|
|
327
|
+
datasetKey: o,
|
|
328
|
+
childCount: S.childCount,
|
|
329
|
+
isLeaf: S.childCount === 0,
|
|
320
330
|
childOffset: 0
|
|
321
331
|
};
|
|
322
|
-
return
|
|
332
|
+
return T.title = /* @__PURE__ */ e.jsx(
|
|
323
333
|
k,
|
|
324
334
|
{
|
|
325
|
-
taxon:
|
|
326
|
-
datasetKey:
|
|
327
|
-
showSourceTaxon:
|
|
328
|
-
reloadChildren: () => this.fetchChildPage(
|
|
335
|
+
taxon: S,
|
|
336
|
+
datasetKey: o,
|
|
337
|
+
showSourceTaxon: a,
|
|
338
|
+
reloadChildren: () => this.fetchChildPage(T, !0),
|
|
329
339
|
rank: this.state.rank
|
|
330
340
|
}
|
|
331
|
-
),
|
|
341
|
+
), T.ref = T, T;
|
|
332
342
|
});
|
|
333
343
|
this.setState(
|
|
334
|
-
{
|
|
335
|
-
rootTotal:
|
|
344
|
+
(S) => ({
|
|
345
|
+
rootTotal: h,
|
|
336
346
|
rootLoading: !1,
|
|
337
|
-
treeData: [...
|
|
347
|
+
treeData: t ? [...S.treeData, ...g] : g,
|
|
338
348
|
// Nothing is auto-expanded by default. Consumers open a specific root
|
|
339
349
|
// (or deep taxon) by passing `defaultTaxonKey`/`expandedTaxonKey` —
|
|
340
350
|
// e.g. defaultTaxonKey="CS5HF" opens Eukaryota in current COL releases.
|
|
341
351
|
expandedKeys: [],
|
|
342
352
|
error: null
|
|
343
|
-
},
|
|
353
|
+
}),
|
|
344
354
|
() => {
|
|
345
|
-
if (n)
|
|
346
|
-
return this.expandToTaxon(n);
|
|
347
355
|
if (f)
|
|
348
356
|
return this.expandToTaxon(f);
|
|
357
|
+
if (s)
|
|
358
|
+
return this.expandToTaxon(s);
|
|
349
359
|
}
|
|
350
360
|
), g.length === 1 && this.fetchChildPage(g[g.length - 1]);
|
|
351
|
-
}).catch((
|
|
352
|
-
this.setState({
|
|
361
|
+
}).catch((C) => {
|
|
362
|
+
n === this.rootRequestId && this.setState({
|
|
353
363
|
treeData: [],
|
|
354
364
|
rootLoading: !1,
|
|
355
365
|
expandedKeys: [],
|
|
356
|
-
error:
|
|
366
|
+
error: C
|
|
357
367
|
});
|
|
358
368
|
});
|
|
359
369
|
});
|
|
360
|
-
|
|
370
|
+
u(this, "expandToTaxon", async (t) => {
|
|
361
371
|
const {
|
|
362
|
-
showSourceTaxon:
|
|
372
|
+
showSourceTaxon: a,
|
|
363
373
|
datasetKey: o,
|
|
364
374
|
hideExtinct: r,
|
|
365
|
-
type:
|
|
375
|
+
type: l
|
|
366
376
|
} = this.props;
|
|
367
377
|
this.setState({
|
|
368
378
|
rootLoading: !0
|
|
369
379
|
/* , treeData: [] */
|
|
370
380
|
});
|
|
371
|
-
const { data:
|
|
372
|
-
`${
|
|
381
|
+
const { data: d } = await K(
|
|
382
|
+
`${D.dataApi}dataset/${o}/tree/${t}?projectKey=${o}&insertPlaceholder=true${l ? "&type=" + l : ""}${r ? "&extinct=false" : ""}`
|
|
373
383
|
).then(
|
|
374
|
-
(
|
|
375
|
-
data: { result:
|
|
376
|
-
}).then(() =>
|
|
384
|
+
(c) => this.decorateWithSectorsAndDataset({
|
|
385
|
+
data: { result: c.data }
|
|
386
|
+
}).then(() => c)
|
|
377
387
|
);
|
|
378
|
-
if (
|
|
388
|
+
if (d.length === 0)
|
|
379
389
|
return this.setState(
|
|
380
390
|
{
|
|
381
391
|
error: {
|
|
382
|
-
message: `No classification found for Taxon ID: ${
|
|
392
|
+
message: `No classification found for Taxon ID: ${t}`
|
|
383
393
|
}
|
|
384
394
|
},
|
|
385
395
|
this.loadRoot
|
|
386
396
|
);
|
|
387
|
-
const
|
|
397
|
+
const i = d[d.length - 1];
|
|
388
398
|
let f = {
|
|
389
|
-
taxon:
|
|
390
|
-
key:
|
|
399
|
+
taxon: i,
|
|
400
|
+
key: i.id,
|
|
391
401
|
datasetKey: o,
|
|
392
|
-
childCount:
|
|
393
|
-
isLeaf:
|
|
402
|
+
childCount: i.childCount,
|
|
403
|
+
isLeaf: i.childCount === 0,
|
|
394
404
|
childOffset: 0
|
|
395
405
|
};
|
|
396
|
-
f.title = /* @__PURE__ */
|
|
406
|
+
f.title = /* @__PURE__ */ e.jsx(
|
|
397
407
|
k,
|
|
398
408
|
{
|
|
399
|
-
taxon:
|
|
409
|
+
taxon: i,
|
|
400
410
|
datasetKey: o,
|
|
401
|
-
showSourceTaxon:
|
|
411
|
+
showSourceTaxon: a,
|
|
402
412
|
rank: this.state.rank,
|
|
403
413
|
reloadChildren: () => this.fetchChildPage(f, !0)
|
|
404
414
|
}
|
|
405
415
|
), f.ref = f;
|
|
406
|
-
const
|
|
407
|
-
for (let
|
|
408
|
-
const
|
|
409
|
-
taxon:
|
|
410
|
-
key:
|
|
416
|
+
const s = f;
|
|
417
|
+
for (let c = d.length - 2; c >= 0; c--) {
|
|
418
|
+
const h = d[c], g = {
|
|
419
|
+
taxon: h,
|
|
420
|
+
key: h.id,
|
|
411
421
|
datasetKey: o,
|
|
412
|
-
childCount:
|
|
413
|
-
isLeaf:
|
|
422
|
+
childCount: h.childCount,
|
|
423
|
+
isLeaf: h.childCount === 0,
|
|
414
424
|
childOffset: 0
|
|
415
425
|
};
|
|
416
|
-
|
|
426
|
+
g.ref = g, g.title = /* @__PURE__ */ e.jsx(
|
|
417
427
|
k,
|
|
418
428
|
{
|
|
419
|
-
taxon:
|
|
429
|
+
taxon: h,
|
|
420
430
|
datasetKey: o,
|
|
421
|
-
showSourceTaxon:
|
|
431
|
+
showSourceTaxon: a,
|
|
422
432
|
rank: this.state.rank,
|
|
423
|
-
reloadChildren: () => this.fetchChildPage(
|
|
433
|
+
reloadChildren: () => this.fetchChildPage(g, !0)
|
|
424
434
|
}
|
|
425
|
-
), f.children = [
|
|
435
|
+
), f.children = [g], f = g;
|
|
426
436
|
}
|
|
427
|
-
const { treeData:
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
const
|
|
437
|
+
const { treeData: n } = this.state;
|
|
438
|
+
var p = n.findIndex((c) => c.key == s.key);
|
|
439
|
+
n[p] = s;
|
|
440
|
+
const C = [...d.map((c) => c.id).reverse()];
|
|
431
441
|
this.setState(
|
|
432
|
-
{ treeData:
|
|
433
|
-
() => this.reloadLoadedKeys(
|
|
442
|
+
{ treeData: n },
|
|
443
|
+
() => this.reloadLoadedKeys(C, t)
|
|
434
444
|
);
|
|
435
445
|
});
|
|
436
|
-
|
|
446
|
+
u(this, "fetchChildPage", async (t, a, o) => {
|
|
437
447
|
const {
|
|
438
448
|
showSourceTaxon: r,
|
|
439
|
-
datasetKey:
|
|
440
|
-
hideExtinct:
|
|
441
|
-
insertPlaceholder:
|
|
449
|
+
datasetKey: l,
|
|
450
|
+
hideExtinct: d,
|
|
451
|
+
insertPlaceholder: i,
|
|
442
452
|
type: f
|
|
443
453
|
} = this.props;
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
`${
|
|
454
|
+
m(t, "childCount");
|
|
455
|
+
const s = b, n = m(t, "childOffset"), p = await K(
|
|
456
|
+
`${D.dataApi}dataset/${l}/tree/${t.taxon.id}/children?limit=${s}&offset=${n}&projectKey=${l}${f ? "&type=" + f : ""}${d ? "&extinct=false" : ""}${i ? "&insertPlaceholder=true" : ""}`
|
|
447
457
|
);
|
|
448
|
-
await this.decorateWithSectorsAndDataset(
|
|
449
|
-
const
|
|
450
|
-
let
|
|
451
|
-
taxon:
|
|
452
|
-
key:
|
|
453
|
-
datasetKey:
|
|
454
|
-
childCount:
|
|
455
|
-
isLeaf:
|
|
458
|
+
await this.decorateWithSectorsAndDataset(p);
|
|
459
|
+
const C = p.data.result ? p.data.result.map((c) => {
|
|
460
|
+
let h = {
|
|
461
|
+
taxon: c,
|
|
462
|
+
key: c.id,
|
|
463
|
+
datasetKey: l,
|
|
464
|
+
childCount: c.childCount,
|
|
465
|
+
isLeaf: c.childCount === 0,
|
|
456
466
|
childOffset: 0,
|
|
457
|
-
parent:
|
|
458
|
-
name:
|
|
467
|
+
parent: t,
|
|
468
|
+
name: c.name
|
|
459
469
|
};
|
|
460
|
-
return
|
|
470
|
+
return h.title = /* @__PURE__ */ e.jsx(
|
|
461
471
|
k,
|
|
462
472
|
{
|
|
463
|
-
taxon:
|
|
464
|
-
datasetKey:
|
|
473
|
+
taxon: c,
|
|
474
|
+
datasetKey: l,
|
|
465
475
|
showSourceTaxon: r,
|
|
466
476
|
rank: this.state.rank,
|
|
467
|
-
reloadChildren: () => this.fetchChildPage(
|
|
477
|
+
reloadChildren: () => this.fetchChildPage(h, !0)
|
|
468
478
|
}
|
|
469
|
-
),
|
|
479
|
+
), h.ref = h, h;
|
|
470
480
|
}) : [];
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
...
|
|
481
|
+
if (t.children = t.children && n !== 0 && !a ? [...t.children, ...C] : C, p.data.last && t.childCount > t.children.length && (t.childCount = t.children.length), !p.data.last) {
|
|
482
|
+
const c = () => (t.childOffset += b, U(m(t.children[t.children.length - 1], "key")) && (t.children = t.children.slice(0, -1)), this.fetchChildPage(t, !1));
|
|
483
|
+
t.children = [
|
|
484
|
+
...t.children,
|
|
475
485
|
{
|
|
476
|
-
title: /* @__PURE__ */
|
|
477
|
-
|
|
486
|
+
title: /* @__PURE__ */ e.jsx(
|
|
487
|
+
Ct,
|
|
478
488
|
{
|
|
479
|
-
onClick:
|
|
489
|
+
onClick: c
|
|
480
490
|
},
|
|
481
|
-
|
|
491
|
+
W(t.key)
|
|
482
492
|
),
|
|
483
|
-
key:
|
|
493
|
+
key: W(t.key),
|
|
484
494
|
childCount: 0,
|
|
485
495
|
isLeaf: !0
|
|
486
496
|
}
|
|
487
497
|
];
|
|
488
498
|
}
|
|
489
|
-
o || this.setState((
|
|
490
|
-
treeData: [...
|
|
491
|
-
loadedKeys: [.../* @__PURE__ */ new Set([...
|
|
499
|
+
o || this.setState((c) => ({
|
|
500
|
+
treeData: [...c.treeData],
|
|
501
|
+
loadedKeys: [.../* @__PURE__ */ new Set([...c.loadedKeys, t.key])]
|
|
492
502
|
}));
|
|
493
503
|
});
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
(
|
|
497
|
-
(o) =>
|
|
498
|
-
id:
|
|
499
|
-
subjectDatasetKey:
|
|
504
|
+
u(this, "decorateWithSectorsAndDataset", (t) => t.data.result ? Promise.all(
|
|
505
|
+
t.data.result.filter((a) => !!a.sectorDatasetKey).map(
|
|
506
|
+
(a) => this.datasetLoader.load(a.sectorDatasetKey).then(
|
|
507
|
+
(o) => a.sector = {
|
|
508
|
+
id: a.sectorKey,
|
|
509
|
+
subjectDatasetKey: a.sectorDatasetKey,
|
|
500
510
|
dataset: o
|
|
501
511
|
}
|
|
502
512
|
)
|
|
503
513
|
)
|
|
504
|
-
).then(() =>
|
|
505
|
-
|
|
506
|
-
|
|
514
|
+
).then(() => t) : t);
|
|
515
|
+
u(this, "onLoadData", (t, a = !1) => (a && (t.childOffset = 0), this.fetchChildPage(t.ref, a)));
|
|
516
|
+
u(this, "findNode", (t, a) => {
|
|
507
517
|
let o = null;
|
|
508
|
-
if (o =
|
|
518
|
+
if (o = a.find((r) => m(r, "taxon.id") === t), o)
|
|
509
519
|
return o;
|
|
510
520
|
{
|
|
511
|
-
const r =
|
|
512
|
-
return
|
|
521
|
+
const r = a.map((d) => m(d, "children") || []), l = ct(r);
|
|
522
|
+
return l.length === 0 ? null : this.findNode(t, l);
|
|
513
523
|
}
|
|
514
524
|
});
|
|
515
|
-
|
|
525
|
+
u(this, "pageThroughChildrenUntilTaxonFound", async (t, a) => {
|
|
516
526
|
let o;
|
|
517
|
-
for (; !o &&
|
|
518
|
-
|
|
519
|
-
return o || (o =
|
|
520
|
-
(r) =>
|
|
527
|
+
for (; !o && t.children.length < t.childCount; )
|
|
528
|
+
t.childOffset += b, U(m(t.children[t.children.length - 1], "key")) && (t.children = t.children.slice(0, -1)), await this.fetchChildPage(t, !1, !0), o = this.findNode(a, t.children);
|
|
529
|
+
return o || (o = t.children.find(
|
|
530
|
+
(r) => m(r, "taxon.id") ? r.taxon.id.indexOf("incertae-sedis") > -1 : !1
|
|
521
531
|
)), o;
|
|
522
532
|
});
|
|
523
|
-
|
|
533
|
+
u(this, "reloadLoadedKeys", async (t, a, o = !0) => {
|
|
524
534
|
this.setState({ rootLoading: !0 });
|
|
525
535
|
const { loadedKeys: r } = this.state;
|
|
526
|
-
let { treeData:
|
|
527
|
-
const
|
|
528
|
-
for (let
|
|
529
|
-
let
|
|
530
|
-
if (!
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
),
|
|
536
|
+
let { treeData: l } = this.state;
|
|
537
|
+
const d = a ? this.findNode(a, l) : null, i = t ? [...t] : [...r];
|
|
538
|
+
for (let s = 0; s < i.length; s++) {
|
|
539
|
+
let n = this.findNode(i[s], l);
|
|
540
|
+
if (!n && d && i[s - 1]) {
|
|
541
|
+
const p = this.findNode(i[s - 1], l);
|
|
542
|
+
p && O(m(p, "children")) && p.children.length > 0 && (n = await this.pageThroughChildrenUntilTaxonFound(
|
|
543
|
+
p,
|
|
544
|
+
i[s]
|
|
545
|
+
), n ? i.splice(s, 0, n.taxon.id) : this.setState(
|
|
536
546
|
{
|
|
537
|
-
nodeNotFoundErr: /* @__PURE__ */
|
|
547
|
+
nodeNotFoundErr: /* @__PURE__ */ e.jsxs("span", { children: [
|
|
538
548
|
"Cannot find taxon ",
|
|
539
|
-
|
|
549
|
+
a,
|
|
540
550
|
" in tree 😥"
|
|
541
551
|
] }),
|
|
542
552
|
rootLoading: !1
|
|
@@ -552,37 +562,37 @@ class G extends j.Component {
|
|
|
552
562
|
} */
|
|
553
563
|
));
|
|
554
564
|
}
|
|
555
|
-
if (
|
|
556
|
-
await this.fetchChildPage(
|
|
557
|
-
let
|
|
558
|
-
(
|
|
565
|
+
if (n) {
|
|
566
|
+
await this.fetchChildPage(n, !0, !0);
|
|
567
|
+
let p = n.children.find(
|
|
568
|
+
(C) => m(C, "taxon.id") === m(d, "taxon.id")
|
|
559
569
|
);
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
),
|
|
570
|
+
d && s === i.length - 2 && m(n, "taxon.id") !== m(d, "taxon.id") && O(n.children) && !p && n.children.length < n.childCount && (p = await this.pageThroughChildrenUntilTaxonFound(
|
|
571
|
+
n,
|
|
572
|
+
m(d, "taxon.id")
|
|
573
|
+
), p ? this.setState({ treeData: [...this.state.treeData] }, () => {
|
|
564
574
|
setTimeout(() => {
|
|
565
|
-
document.getElementById(
|
|
575
|
+
document.getElementById(a).scrollIntoView({ behavior: "smooth", block: "center" });
|
|
566
576
|
}, 100);
|
|
567
577
|
}) : this.setState(
|
|
568
578
|
{
|
|
569
|
-
nodeNotFoundErr: /* @__PURE__ */
|
|
579
|
+
nodeNotFoundErr: /* @__PURE__ */ e.jsxs("span", { children: [
|
|
570
580
|
"Cannot find taxon ",
|
|
571
|
-
|
|
581
|
+
a,
|
|
572
582
|
" in tree 😥"
|
|
573
583
|
] }),
|
|
574
584
|
rootLoading: !1
|
|
575
585
|
},
|
|
576
586
|
() => {
|
|
577
|
-
this.props.treeType === "CATALOGUE" && typeof this.props.addMissingTargetKey == "function" && this.props.addMissingTargetKey(
|
|
587
|
+
this.props.treeType === "CATALOGUE" && typeof this.props.addMissingTargetKey == "function" && this.props.addMissingTargetKey(a);
|
|
578
588
|
}
|
|
579
589
|
));
|
|
580
590
|
}
|
|
581
591
|
}
|
|
582
|
-
const f = { loadedKeys:
|
|
583
|
-
o && (f.expandedKeys =
|
|
584
|
-
|
|
585
|
-
document.getElementById(
|
|
592
|
+
const f = { loadedKeys: i, rootLoading: !1 };
|
|
593
|
+
o && (f.expandedKeys = i), this.setState(f, () => {
|
|
594
|
+
a && setTimeout(() => {
|
|
595
|
+
document.getElementById(a).scrollIntoView({ behavior: "smooth", block: "center" });
|
|
586
596
|
}, 100);
|
|
587
597
|
});
|
|
588
598
|
});
|
|
@@ -595,7 +605,7 @@ class G extends j.Component {
|
|
|
595
605
|
error: null,
|
|
596
606
|
nodeNotFoundErr: null,
|
|
597
607
|
rank: []
|
|
598
|
-
}, this.treeRef = j.createRef();
|
|
608
|
+
}, this.treeRef = j.createRef(), this.rootRequestId = 0;
|
|
599
609
|
}
|
|
600
610
|
// datasetLoader comes from the shared TreeCacheContext so multiple tree
|
|
601
611
|
// nodes (and TaxonSources instances) share one in-memory cache instead
|
|
@@ -605,222 +615,222 @@ class G extends j.Component {
|
|
|
605
615
|
}
|
|
606
616
|
render() {
|
|
607
617
|
const {
|
|
608
|
-
error:
|
|
609
|
-
rootTotal:
|
|
618
|
+
error: t,
|
|
619
|
+
rootTotal: a,
|
|
610
620
|
rootLoading: o,
|
|
611
621
|
treeData: r,
|
|
612
|
-
defaultExpandAll:
|
|
613
|
-
nodeNotFoundErr:
|
|
614
|
-
loadedKeys:
|
|
622
|
+
defaultExpandAll: l,
|
|
623
|
+
nodeNotFoundErr: d,
|
|
624
|
+
loadedKeys: i,
|
|
615
625
|
expandedKeys: f
|
|
616
|
-
} = this.state, { treeType:
|
|
617
|
-
return /* @__PURE__ */
|
|
618
|
-
|
|
619
|
-
|
|
626
|
+
} = this.state, { treeType: s, dataset: n, height: p, expandedTaxonKey: C } = this.props, c = C;
|
|
627
|
+
return /* @__PURE__ */ e.jsxs("div", { children: [
|
|
628
|
+
t && /* @__PURE__ */ e.jsx(j.Fragment, { children: m(t, "response.data.code") !== 404 ? /* @__PURE__ */ e.jsx(
|
|
629
|
+
w,
|
|
620
630
|
{
|
|
621
631
|
closable: !0,
|
|
622
632
|
onClose: () => this.setState({ error: null }),
|
|
623
633
|
style: { marginTop: "8px" },
|
|
624
|
-
message: /* @__PURE__ */
|
|
634
|
+
message: /* @__PURE__ */ e.jsx(gt, { error: t }),
|
|
625
635
|
type: "error"
|
|
626
636
|
}
|
|
627
|
-
) : /* @__PURE__ */
|
|
628
|
-
|
|
637
|
+
) : /* @__PURE__ */ e.jsx(
|
|
638
|
+
w,
|
|
629
639
|
{
|
|
630
640
|
closable: !0,
|
|
631
641
|
onClose: () => this.setState({ error: null }),
|
|
632
642
|
style: { marginTop: "8px" },
|
|
633
|
-
message: /* @__PURE__ */
|
|
643
|
+
message: /* @__PURE__ */ e.jsx(
|
|
634
644
|
Custom404,
|
|
635
645
|
{
|
|
636
|
-
error:
|
|
637
|
-
treeType:
|
|
638
|
-
dataset:
|
|
646
|
+
error: t,
|
|
647
|
+
treeType: s,
|
|
648
|
+
dataset: n,
|
|
639
649
|
loadRoot: this.loadRoot
|
|
640
650
|
}
|
|
641
651
|
),
|
|
642
652
|
type: "warning"
|
|
643
653
|
}
|
|
644
654
|
) }),
|
|
645
|
-
|
|
646
|
-
|
|
655
|
+
d && /* @__PURE__ */ e.jsx(
|
|
656
|
+
w,
|
|
647
657
|
{
|
|
648
658
|
closable: !0,
|
|
649
659
|
onClose: () => this.setState({ nodeNotFoundErr: null }),
|
|
650
660
|
style: { marginTop: "8px" },
|
|
651
|
-
message:
|
|
661
|
+
message: d,
|
|
652
662
|
type: "warning"
|
|
653
663
|
}
|
|
654
664
|
),
|
|
655
|
-
o && /* @__PURE__ */
|
|
656
|
-
!o && r.length > 0 && /* @__PURE__ */
|
|
657
|
-
|
|
665
|
+
o && /* @__PURE__ */ e.jsx(rt, { paragraph: { rows: 10 }, active: !0 }),
|
|
666
|
+
!o && r.length > 0 && /* @__PURE__ */ e.jsx(
|
|
667
|
+
lt,
|
|
658
668
|
{
|
|
659
669
|
ref: this.treeRef,
|
|
660
|
-
defaultExpandAll:
|
|
670
|
+
defaultExpandAll: l,
|
|
661
671
|
loadData: this.onLoadData,
|
|
662
|
-
onLoad: (
|
|
663
|
-
loadedKeys:
|
|
672
|
+
onLoad: (h) => this.setState({ loadedKeys: h }),
|
|
673
|
+
loadedKeys: i,
|
|
664
674
|
expandedKeys: f,
|
|
665
675
|
treeData: r,
|
|
666
|
-
filterTreeNode: (
|
|
667
|
-
onExpand: (
|
|
668
|
-
this.setState({ expandedKeys:
|
|
669
|
-
|
|
676
|
+
filterTreeNode: (h) => h.key === c,
|
|
677
|
+
onExpand: (h, g) => {
|
|
678
|
+
this.setState({ expandedKeys: h }), this.props.onExpandedTaxonKeyChange && this.props.onExpandedTaxonKeyChange(
|
|
679
|
+
g.expanded ? g.node.key : null
|
|
670
680
|
);
|
|
671
681
|
}
|
|
672
682
|
}
|
|
673
683
|
),
|
|
674
|
-
!
|
|
684
|
+
!t && r.length < a && /* @__PURE__ */ e.jsxs(dt, { loading: o, onClick: () => this.loadRoot(!0), children: [
|
|
675
685
|
"Load more",
|
|
676
686
|
" "
|
|
677
687
|
] })
|
|
678
688
|
] });
|
|
679
689
|
}
|
|
680
690
|
}
|
|
681
|
-
|
|
682
|
-
const
|
|
691
|
+
u(J, "contextType", E);
|
|
692
|
+
const jt = [
|
|
683
693
|
"infraspecific name",
|
|
684
694
|
"species",
|
|
685
695
|
"variety",
|
|
686
696
|
"form"
|
|
687
697
|
];
|
|
688
|
-
class
|
|
689
|
-
constructor(
|
|
690
|
-
super(
|
|
691
|
-
|
|
692
|
-
const { datasetKey:
|
|
693
|
-
if (
|
|
698
|
+
class Q extends j.Component {
|
|
699
|
+
constructor(t) {
|
|
700
|
+
super(t);
|
|
701
|
+
u(this, "componentDidMount", async () => {
|
|
702
|
+
const { datasetKey: t, citation: a } = this.props;
|
|
703
|
+
if (a)
|
|
694
704
|
try {
|
|
695
|
-
const { data: o } = await
|
|
705
|
+
const { data: o } = await ft(t);
|
|
696
706
|
this.setState({ dataset: o });
|
|
697
707
|
} catch {
|
|
698
708
|
}
|
|
699
709
|
});
|
|
700
|
-
|
|
710
|
+
u(this, "render", () => {
|
|
701
711
|
const {
|
|
702
|
-
datasetKey:
|
|
703
|
-
defaultTaxonKey:
|
|
712
|
+
datasetKey: t,
|
|
713
|
+
defaultTaxonKey: a,
|
|
704
714
|
expandedTaxonKey: o,
|
|
705
715
|
onExpandedTaxonKeyChange: r,
|
|
706
|
-
showTreeOptions:
|
|
707
|
-
linkToSpeciesPage:
|
|
708
|
-
citation:
|
|
716
|
+
showTreeOptions: l,
|
|
717
|
+
linkToSpeciesPage: d,
|
|
718
|
+
citation: i,
|
|
709
719
|
type: f,
|
|
710
|
-
insertPlaceholder:
|
|
711
|
-
} = this.props, { hideExtinct:
|
|
712
|
-
var
|
|
713
|
-
const
|
|
714
|
-
if (!
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
} else r && (r(
|
|
720
|
-
},
|
|
720
|
+
insertPlaceholder: s = !0
|
|
721
|
+
} = this.props, { hideExtinct: n, dataset: p } = this.state, C = (h) => {
|
|
722
|
+
var T, $;
|
|
723
|
+
const g = m(h, "key");
|
|
724
|
+
if (!g) return;
|
|
725
|
+
const S = m(h, "rank");
|
|
726
|
+
if (d && jt.includes(S)) {
|
|
727
|
+
const v = ($ = (T = this.context) == null ? void 0 : T.taxon) == null ? void 0 : $.onNavigate;
|
|
728
|
+
v && v(g);
|
|
729
|
+
} else r && (r(g), this.treeRef && this.treeRef.reloadRoot && this.treeRef.reloadRoot());
|
|
730
|
+
}, c = () => {
|
|
721
731
|
r && r(null);
|
|
722
732
|
};
|
|
723
|
-
return /* @__PURE__ */
|
|
724
|
-
|
|
725
|
-
/* @__PURE__ */
|
|
726
|
-
/* @__PURE__ */
|
|
727
|
-
/* @__PURE__ */
|
|
728
|
-
|
|
733
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "catalogue-of-life", children: [
|
|
734
|
+
i === "top" && p && /* @__PURE__ */ e.jsx(R, { dataset: p }),
|
|
735
|
+
/* @__PURE__ */ e.jsx(E.Provider, { value: this.cache, children: /* @__PURE__ */ e.jsxs(X.Provider, { value: this.state, children: [
|
|
736
|
+
/* @__PURE__ */ e.jsxs(ht, { children: [
|
|
737
|
+
/* @__PURE__ */ e.jsx(I, { flex: "auto", children: /* @__PURE__ */ e.jsx(
|
|
738
|
+
mt,
|
|
729
739
|
{
|
|
730
|
-
hideExtinct:
|
|
731
|
-
datasetKey:
|
|
740
|
+
hideExtinct: n,
|
|
741
|
+
datasetKey: t,
|
|
732
742
|
style: {
|
|
733
743
|
width: "100%",
|
|
734
744
|
paddingTop: "5px",
|
|
735
745
|
paddingBottom: "5px"
|
|
736
746
|
},
|
|
737
747
|
defaultTaxonKey: o || null,
|
|
738
|
-
onSelectName:
|
|
739
|
-
onResetSearch:
|
|
748
|
+
onSelectName: C,
|
|
749
|
+
onResetSearch: c
|
|
740
750
|
}
|
|
741
751
|
) }),
|
|
742
|
-
|
|
743
|
-
/* @__PURE__ */
|
|
744
|
-
|
|
752
|
+
l && /* @__PURE__ */ e.jsxs(I, { style: { paddingLeft: "8px" }, children: [
|
|
753
|
+
/* @__PURE__ */ e.jsx(
|
|
754
|
+
N,
|
|
745
755
|
{
|
|
746
756
|
defaultChecked: this.state.showInfo,
|
|
747
|
-
onChange: ({ target: { checked:
|
|
748
|
-
this.setState({ showInfo:
|
|
757
|
+
onChange: ({ target: { checked: h } }) => {
|
|
758
|
+
this.setState({ showInfo: h }), M("tree-show-source", h);
|
|
749
759
|
},
|
|
750
760
|
children: "Source"
|
|
751
761
|
}
|
|
752
762
|
),
|
|
753
|
-
/* @__PURE__ */
|
|
754
|
-
|
|
763
|
+
/* @__PURE__ */ e.jsx(
|
|
764
|
+
N,
|
|
755
765
|
{
|
|
756
766
|
defaultChecked: this.state.hideExtinct,
|
|
757
|
-
onChange: ({ target: { checked:
|
|
758
|
-
this.setState({ hideExtinct:
|
|
767
|
+
onChange: ({ target: { checked: h } }) => {
|
|
768
|
+
this.setState({ hideExtinct: h }), M("tree-extant-only", h);
|
|
759
769
|
},
|
|
760
770
|
children: "Extant only"
|
|
761
771
|
}
|
|
762
772
|
)
|
|
763
773
|
] })
|
|
764
774
|
] }),
|
|
765
|
-
/* @__PURE__ */
|
|
766
|
-
|
|
775
|
+
/* @__PURE__ */ e.jsx(
|
|
776
|
+
J,
|
|
767
777
|
{
|
|
768
|
-
insertPlaceholder:
|
|
769
|
-
hideExtinct:
|
|
770
|
-
datasetKey:
|
|
771
|
-
defaultTaxonKey:
|
|
778
|
+
insertPlaceholder: s,
|
|
779
|
+
hideExtinct: n,
|
|
780
|
+
datasetKey: t,
|
|
781
|
+
defaultTaxonKey: a,
|
|
772
782
|
expandedTaxonKey: o,
|
|
773
783
|
onExpandedTaxonKeyChange: r,
|
|
774
|
-
treeRef: (
|
|
784
|
+
treeRef: (h) => this.treeRef = h,
|
|
775
785
|
type: f
|
|
776
786
|
}
|
|
777
787
|
)
|
|
778
788
|
] }) }),
|
|
779
|
-
|
|
789
|
+
i === "bottom" && p && /* @__PURE__ */ e.jsx(R, { dataset: p })
|
|
780
790
|
] });
|
|
781
791
|
});
|
|
782
|
-
|
|
783
|
-
hideExtinct:
|
|
784
|
-
showInfo:
|
|
792
|
+
ut(this.props.auth), this.state = {
|
|
793
|
+
hideExtinct: F("tree-extant-only", !1),
|
|
794
|
+
showInfo: F("tree-show-source", !1),
|
|
785
795
|
dataset: null
|
|
786
796
|
}, this.cache = B(this.props.datasetKey);
|
|
787
797
|
}
|
|
788
|
-
componentDidUpdate(
|
|
789
|
-
|
|
798
|
+
componentDidUpdate(t) {
|
|
799
|
+
t.datasetKey !== this.props.datasetKey && (this.cache = B(this.props.datasetKey));
|
|
790
800
|
}
|
|
791
801
|
}
|
|
792
|
-
|
|
793
|
-
function
|
|
794
|
-
datasetKey:
|
|
795
|
-
defaultTaxonKey:
|
|
796
|
-
expandedTaxonKey:
|
|
797
|
-
onExpandedTaxonKeyChange:
|
|
802
|
+
u(Q, "contextType", H);
|
|
803
|
+
function St({
|
|
804
|
+
datasetKey: x,
|
|
805
|
+
defaultTaxonKey: y,
|
|
806
|
+
expandedTaxonKey: t,
|
|
807
|
+
onExpandedTaxonKeyChange: a,
|
|
798
808
|
showTreeOptions: o,
|
|
799
809
|
linkToSpeciesPage: r,
|
|
800
|
-
citation:
|
|
801
|
-
type:
|
|
802
|
-
insertPlaceholder:
|
|
810
|
+
citation: l,
|
|
811
|
+
type: d,
|
|
812
|
+
insertPlaceholder: i,
|
|
803
813
|
auth: f,
|
|
804
|
-
...
|
|
814
|
+
...s
|
|
805
815
|
}) {
|
|
806
|
-
return /* @__PURE__ */
|
|
807
|
-
|
|
816
|
+
return /* @__PURE__ */ e.jsx(H.Provider, { value: pt(s), children: /* @__PURE__ */ e.jsx(
|
|
817
|
+
Q,
|
|
808
818
|
{
|
|
809
|
-
datasetKey:
|
|
810
|
-
defaultTaxonKey:
|
|
811
|
-
expandedTaxonKey:
|
|
812
|
-
onExpandedTaxonKeyChange:
|
|
819
|
+
datasetKey: x,
|
|
820
|
+
defaultTaxonKey: y,
|
|
821
|
+
expandedTaxonKey: t,
|
|
822
|
+
onExpandedTaxonKeyChange: a,
|
|
813
823
|
showTreeOptions: o,
|
|
814
824
|
linkToSpeciesPage: r,
|
|
815
|
-
citation:
|
|
816
|
-
type:
|
|
817
|
-
insertPlaceholder:
|
|
825
|
+
citation: l,
|
|
826
|
+
type: d,
|
|
827
|
+
insertPlaceholder: i,
|
|
818
828
|
auth: f
|
|
819
829
|
}
|
|
820
830
|
) });
|
|
821
831
|
}
|
|
822
|
-
const
|
|
832
|
+
const Ot = st(et(St));
|
|
823
833
|
export {
|
|
824
|
-
|
|
834
|
+
Ot as Tree
|
|
825
835
|
};
|
|
826
836
|
//# sourceMappingURL=tree.js.map
|