col-browser 2.0.0 → 2.1.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.
Files changed (73) hide show
  1. package/README.md +17 -0
  2. package/es/bibtex.js +8 -0
  3. package/es/bibtex.js.map +1 -0
  4. package/es/chunks/AntdIcon-B1nMlqyh.js +984 -0
  5. package/es/chunks/AntdIcon-B1nMlqyh.js.map +1 -0
  6. package/es/chunks/BibTex-BqzD3qLB.js +13 -0
  7. package/es/chunks/BibTex-BqzD3qLB.js.map +1 -0
  8. package/es/chunks/DatasetCitation-bkPmDDYB.js +119 -0
  9. package/es/chunks/DatasetCitation-bkPmDDYB.js.map +1 -0
  10. package/es/chunks/DatasetlogoWithFallback-CbP7vRs_.js +823 -0
  11. package/es/chunks/DatasetlogoWithFallback-CbP7vRs_.js.map +1 -0
  12. package/es/chunks/Distributions-DDYEbGhW.js +1110 -0
  13. package/es/chunks/Distributions-DDYEbGhW.js.map +1 -0
  14. package/es/chunks/ErrorMsg-K8k5PPTp.js +26 -0
  15. package/es/chunks/ErrorMsg-K8k5PPTp.js.map +1 -0
  16. package/es/chunks/LinkOutlined-2IkQWTV7.js +22 -0
  17. package/es/chunks/LinkOutlined-2IkQWTV7.js.map +1 -0
  18. package/es/chunks/MergedDataBadge-DsTsn5Xu.js +134 -0
  19. package/es/chunks/MergedDataBadge-DsTsn5Xu.js.map +1 -0
  20. package/es/chunks/MetricsPresentation-U_CO8JoH.js +66 -0
  21. package/es/chunks/MetricsPresentation-U_CO8JoH.js.map +1 -0
  22. package/es/chunks/TaxonBreakdown-BshFaQql.js +205 -0
  23. package/es/chunks/TaxonBreakdown-BshFaQql.js.map +1 -0
  24. package/es/chunks/config-BPRXv9x8.js +31 -0
  25. package/es/chunks/config-BPRXv9x8.js.map +1 -0
  26. package/es/chunks/dataset-DvQG4NjA.js +30 -0
  27. package/es/chunks/dataset-DvQG4NjA.js.map +1 -0
  28. package/es/chunks/enumeration-yDQXSZsf.js +12 -0
  29. package/es/chunks/enumeration-yDQXSZsf.js.map +1 -0
  30. package/es/chunks/index-CNK3JADR.js +95 -0
  31. package/es/chunks/index-CNK3JADR.js.map +1 -0
  32. package/es/chunks/jsx-runtime-BzflLqGi.js +283 -0
  33. package/es/chunks/jsx-runtime-BzflLqGi.js.map +1 -0
  34. package/es/chunks/router-CssZk5qZ.js +109 -0
  35. package/es/chunks/router-CssZk5qZ.js.map +1 -0
  36. package/es/chunks/sector-BnVzMnMO.js +9 -0
  37. package/es/chunks/sector-BnVzMnMO.js.map +1 -0
  38. package/es/chunks/withDatasetKey-BgMY05XE.js +48 -0
  39. package/es/chunks/withDatasetKey-BgMY05XE.js.map +1 -0
  40. package/es/col-browser.css +1 -1
  41. package/es/index.js +18 -7964
  42. package/es/index.js.map +1 -1
  43. package/es/routing.js +5 -0
  44. package/es/routing.js.map +1 -0
  45. package/es/search.js +803 -0
  46. package/es/search.js.map +1 -0
  47. package/es/sourceDataset.js +453 -0
  48. package/es/sourceDataset.js.map +1 -0
  49. package/es/sourceDatasetList.js +366 -0
  50. package/es/sourceDatasetList.js.map +1 -0
  51. package/es/taxon.js +1643 -0
  52. package/es/taxon.js.map +1 -0
  53. package/es/taxonBreakdown.js +42 -0
  54. package/es/taxonBreakdown.js.map +1 -0
  55. package/es/taxonDistribution.js +48 -0
  56. package/es/taxonDistribution.js.map +1 -0
  57. package/es/tree.js +821 -0
  58. package/es/tree.js.map +1 -0
  59. package/package.json +51 -9
  60. package/types/bibtex.d.ts +1 -0
  61. package/types/index.d.ts +158 -0
  62. package/types/routing.d.ts +1 -0
  63. package/types/search.d.ts +1 -0
  64. package/types/sourceDataset.d.ts +1 -0
  65. package/types/sourceDatasetList.d.ts +1 -0
  66. package/types/taxon.d.ts +1 -0
  67. package/types/taxonBreakdown.d.ts +1 -0
  68. package/types/taxonDistribution.d.ts +1 -0
  69. package/types/tree.d.ts +1 -0
  70. package/umd/col-browser.js +20478 -27048
  71. package/umd/col-browser.js.map +1 -1
  72. package/umd/col-browser.min.js +5 -13
  73. package/umd/col-browser.min.js.map +1 -1
package/es/search.js ADDED
@@ -0,0 +1,803 @@
1
+ var ot = Object.defineProperty;
2
+ var rt = (r, i, a) => i in r ? ot(r, i, { enumerable: !0, configurable: !0, writable: !0, value: a }) : r[i] = a;
3
+ var c = (r, i, a) => rt(r, typeof i != "symbol" ? i + "" : i, a);
4
+ import { a as ut } from "./chunks/withDatasetKey-BgMY05XE.js";
5
+ import { c as j, w as ct } from "./chunks/config-BPRXv9x8.js";
6
+ import { j as s } from "./chunks/jsx-runtime-BzflLqGi.js";
7
+ import * as A from "react";
8
+ import f from "react";
9
+ import { L as S, c as C, s as ht, R as dt, b as pt } from "./chunks/router-CssZk5qZ.js";
10
+ import { a as mt } from "./chunks/dataset-DvQG4NjA.js";
11
+ import { a as gt } from "./chunks/enumeration-yDQXSZsf.js";
12
+ import { Input as F, Form as D, Select as k, Row as x, Col as g, AutoComplete as V, Radio as ft, Alert as xt, Button as St, Table as vt } from "antd";
13
+ import yt from "query-string";
14
+ import { isArray as O, startCase as m, snakeCase as _, get as u, initial as G, debounce as bt, isEqual as jt, isEmpty as Ct, merge as Dt, forEach as At } from "lodash-es";
15
+ import { E as Tt } from "./chunks/ErrorMsg-K8k5PPTp.js";
16
+ import { C as N, N as $t } from "./chunks/DatasetCitation-bkPmDDYB.js";
17
+ import Et from "react-highlight-words";
18
+ import { M as Ot } from "./chunks/MergedDataBadge-DsTsn5Xu.js";
19
+ import { I as K } from "./chunks/AntdIcon-B1nMlqyh.js";
20
+ var Rt = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z" } }] }, name: "down", theme: "outlined" };
21
+ function R() {
22
+ return R = Object.assign ? Object.assign.bind() : function(r) {
23
+ for (var i = 1; i < arguments.length; i++) {
24
+ var a = arguments[i];
25
+ for (var e in a)
26
+ Object.prototype.hasOwnProperty.call(a, e) && (r[e] = a[e]);
27
+ }
28
+ return r;
29
+ }, R.apply(this, arguments);
30
+ }
31
+ const wt = (r, i) => /* @__PURE__ */ A.createElement(K, R({}, r, {
32
+ ref: i,
33
+ icon: Rt
34
+ })), P = /* @__PURE__ */ A.forwardRef(wt);
35
+ process.env.NODE_ENV !== "production" && (P.displayName = "DownOutlined");
36
+ var kt = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z" } }] }, name: "up", theme: "outlined" };
37
+ function w() {
38
+ return w = Object.assign ? Object.assign.bind() : function(r) {
39
+ for (var i = 1; i < arguments.length; i++) {
40
+ var a = arguments[i];
41
+ for (var e in a)
42
+ Object.prototype.hasOwnProperty.call(a, e) && (r[e] = a[e]);
43
+ }
44
+ return r;
45
+ }, w.apply(this, arguments);
46
+ }
47
+ const Bt = (r, i) => /* @__PURE__ */ A.createElement(K, w({}, r, {
48
+ ref: i,
49
+ icon: kt
50
+ })), z = /* @__PURE__ */ A.forwardRef(Bt);
51
+ process.env.NODE_ENV !== "production" && (z.displayName = "UpOutlined");
52
+ const $ = ["family", "superfamily", "order", "subclass", "class", "superclass", "subphylum", "phylum"], H = ({ classification: r, maxParents: i = r.length, truncate: a }) => {
53
+ const e = r.slice(Math.max(r.length - i));
54
+ if (a) {
55
+ const l = r.reduce((h, d) => (h[d.rank] = d, h), {}), o = l.kingdom;
56
+ let n;
57
+ for (let h = 0; h < $.length; h++)
58
+ if (l[$[h]]) {
59
+ n = l[$[h]];
60
+ break;
61
+ }
62
+ return o && n ? /* @__PURE__ */ s.jsxs(f.Fragment, { children: [
63
+ /* @__PURE__ */ s.jsx(S, { to: "taxon", args: o.id, children: o.name }),
64
+ n.rank === "phylum" ? " > " : " > ... > ",
65
+ /* @__PURE__ */ s.jsx(S, { to: "taxon", args: n.id, children: n.name })
66
+ ] }) : o ? /* @__PURE__ */ s.jsx(S, { to: "taxon", args: o.id, children: o.name }) : null;
67
+ } else
68
+ return e.map((l, o) => /* @__PURE__ */ s.jsxs(f.Fragment, { children: [
69
+ /* @__PURE__ */ s.jsx(S, { to: "taxon", args: l.id, children: l.name }),
70
+ !Object.is(e.length - 1, o) && " > "
71
+ ] }, o));
72
+ }, It = F.Search;
73
+ class _t extends f.Component {
74
+ constructor(a) {
75
+ super(a);
76
+ c(this, "componentDidMount", () => {
77
+ this.props.defaultValue && this.setState({ search: this.props.defaultValue });
78
+ });
79
+ c(this, "componentDidUpdate", (a) => {
80
+ a.defaultValue !== this.props.defaultValue && this.setState({ search: this.props.defaultValue });
81
+ });
82
+ c(this, "resetSearch", () => {
83
+ this.setState({ search: "" }, () => {
84
+ this.props.onSearch(this.state.search);
85
+ });
86
+ });
87
+ c(this, "render", () => /* @__PURE__ */ s.jsx(
88
+ It,
89
+ {
90
+ style: this.props.style || null,
91
+ placeholder: "Search query",
92
+ value: this.state.search,
93
+ onSearch: (a) => this.props.onSearch(this.state.search),
94
+ onChange: (a) => this.setState({ search: a.target.value }),
95
+ addonAfter: this.props.addonAfter,
96
+ allowClear: !0,
97
+ autoFocus: !0
98
+ }
99
+ ));
100
+ this.state = {
101
+ search: ""
102
+ };
103
+ }
104
+ }
105
+ const Nt = D.Item, L = k.Option, Lt = {
106
+ labelCol: {
107
+ xs: { span: 24 },
108
+ sm: { span: 24 },
109
+ md: { span: 8 }
110
+ },
111
+ wrapperCol: {
112
+ xs: { span: 24 },
113
+ sm: { span: 24 },
114
+ md: { span: 16 }
115
+ }
116
+ };
117
+ class p extends f.Component {
118
+ constructor(a) {
119
+ super(a);
120
+ c(this, "handleChange", (a) => {
121
+ this.setState({ selected: a }, () => {
122
+ this.props.onChange(a);
123
+ });
124
+ });
125
+ c(this, "render", () => {
126
+ const { defaultValue: a, label: e, vocab: l } = this.props, { randomID: o } = this.state, n = /* @__PURE__ */ new Set([...l.map((d) => d.value)]);
127
+ let h;
128
+ return a && O(a) ? h = a.filter((d) => n.has(d)) : a && (h = [a].filter((d) => n.has(d))), /* @__PURE__ */ s.jsx(
129
+ Nt,
130
+ {
131
+ ...Lt,
132
+ label: e,
133
+ style: { marginBottom: "8px", width: "100%" },
134
+ children: /* @__PURE__ */ s.jsx("div", { id: `${_(e)}_${o}`, children: /* @__PURE__ */ s.jsx(
135
+ k,
136
+ {
137
+ showSearch: !0,
138
+ mode: "multiple",
139
+ placeholder: "Please select",
140
+ value: h,
141
+ onChange: this.handleChange,
142
+ getPopupContainer: () => document.getElementById(`${_(e)}_${o}`),
143
+ children: l.map((d) => typeof d == "string" ? /* @__PURE__ */ s.jsx(L, { value: d, children: m(d) }, d) : /* @__PURE__ */ s.jsx(L, { value: d.value, children: d.label }, d.value))
144
+ }
145
+ ) })
146
+ }
147
+ );
148
+ });
149
+ this.state = {
150
+ selected: this.props.selected,
151
+ randomID: (Math.floor(Math.random() * 100) + 1) * (Math.floor(Math.random() * 100) + 1) * (Math.floor(Math.random() * 100) + 1)
152
+ };
153
+ }
154
+ }
155
+ const Mt = ({ issues: r, usage: i, classification: a, vernacularNames: e, issueMap: l }) => /* @__PURE__ */ s.jsxs(f.Fragment, { children: [
156
+ u(i, "id") && /* @__PURE__ */ s.jsxs(x, { style: { marginBottom: "10px" }, children: [
157
+ /* @__PURE__ */ s.jsx(
158
+ g,
159
+ {
160
+ span: 3,
161
+ style: {
162
+ textAlign: "right",
163
+ paddingRight: "16px",
164
+ fontWeight: "bold"
165
+ },
166
+ children: "ID:"
167
+ }
168
+ ),
169
+ /* @__PURE__ */ s.jsx(g, { span: 18, children: u(i, "id") })
170
+ ] }),
171
+ a && /* @__PURE__ */ s.jsxs(x, { style: { marginBottom: "10px" }, children: [
172
+ /* @__PURE__ */ s.jsx(
173
+ g,
174
+ {
175
+ span: 3,
176
+ style: {
177
+ textAlign: "right",
178
+ paddingRight: "16px",
179
+ fontWeight: "bold"
180
+ },
181
+ children: "Classification:"
182
+ }
183
+ ),
184
+ /* @__PURE__ */ s.jsx(g, { span: 18, children: /* @__PURE__ */ s.jsx(
185
+ H,
186
+ {
187
+ classification: G(a)
188
+ }
189
+ ) })
190
+ ] }),
191
+ e && /* @__PURE__ */ s.jsxs(x, { children: [
192
+ /* @__PURE__ */ s.jsx(
193
+ g,
194
+ {
195
+ span: 3,
196
+ style: {
197
+ textAlign: "right",
198
+ paddingRight: "16px",
199
+ fontWeight: "bold"
200
+ },
201
+ children: "Vernacular:"
202
+ }
203
+ ),
204
+ /* @__PURE__ */ s.jsx(g, { span: 18, style: { paddingBottom: "12px" }, children: e.slice(0, 8).map((o) => o.name).join(", ") })
205
+ ] })
206
+ ] });
207
+ V.Option;
208
+ class Ft extends f.Component {
209
+ constructor(a) {
210
+ super(a);
211
+ c(this, "componentDidMount", () => {
212
+ const { defaultDatasetKey: a } = this.props;
213
+ a && this.setDefaultValue(a);
214
+ });
215
+ c(this, "componentDidUpdate", (a) => {
216
+ const { defaultDatasetKey: e } = this.props;
217
+ e && e !== a.defaultDatasetKey ? this.setDefaultValue(e) : a.defaultDatasetKey && !e && this.setState({ value: "" });
218
+ });
219
+ c(this, "setDefaultValue", (a) => {
220
+ C(`${j.dataApi}dataset/${a}`).then((e) => {
221
+ this.setState({ value: u(e, "data.title") || "" }), this.props.onSelectDataset(e.data);
222
+ });
223
+ });
224
+ c(this, "getDatasets", (a) => {
225
+ const { contributesTo: e } = this.props;
226
+ C(`${j.dataApi}dataset?q=${a}&limit=30${e ? "&contributesTo=" + e : ""}`).then((l) => {
227
+ this.setState({ datasets: l.data.result });
228
+ }).catch((l) => {
229
+ this.setState({ datasets: [], err: l });
230
+ });
231
+ });
232
+ c(this, "onSelectDataset", (a, e) => {
233
+ this.setState({ value: a }), this.props.onSelectDataset({ key: e.key, title: a });
234
+ });
235
+ c(this, "onReset", () => {
236
+ this.setState({ value: "", names: [] }, this.props.onResetSearch);
237
+ });
238
+ c(this, "render", () => {
239
+ const { value: a, randomID: e } = this.state, { style: l } = this.props, o = this.state.datasets ? this.state.datasets.map((n) => {
240
+ const h = `${n.alias || n.title} [${n.key}]`;
241
+ return {
242
+ key: n.key,
243
+ value: h,
244
+ label: /* @__PURE__ */ s.jsx(
245
+ Et,
246
+ {
247
+ highlightStyle: { fontWeight: "bold", padding: 0 },
248
+ searchWords: a.split(" "),
249
+ autoEscape: !0,
250
+ textToHighlight: h
251
+ }
252
+ ),
253
+ data: n
254
+ };
255
+ }) : [];
256
+ return /* @__PURE__ */ s.jsx("div", { id: `dataset_autocomplete_${e}`, children: /* @__PURE__ */ s.jsx(
257
+ V,
258
+ {
259
+ onSelect: this.onSelectDataset,
260
+ onSearch: (n) => n ? this.getDatasets(n) : this.onReset(),
261
+ options: o,
262
+ placeholder: this.props.placeHolder || "Find dataset",
263
+ style: l || { width: "100%" },
264
+ onChange: (n) => this.setState({ value: n }),
265
+ value: a,
266
+ getPopupContainer: () => document.getElementById(`dataset_autocomplete_${e}`),
267
+ children: /* @__PURE__ */ s.jsx(F.Search, { allowClear: !0 })
268
+ }
269
+ ) });
270
+ });
271
+ this.getDatasets = bt(this.getDatasets, 500), this.state = {
272
+ datasets: [],
273
+ value: "",
274
+ randomID: (Math.floor(Math.random() * 100) + 1) * (Math.floor(Math.random() * 100) + 1) * (Math.floor(Math.random() * 100) + 1)
275
+ };
276
+ }
277
+ componentWillUnmount() {
278
+ this.getDatasets.cancel();
279
+ }
280
+ }
281
+ const E = D.Item, M = ft.Group, U = [
282
+ "rank",
283
+ "issue",
284
+ "status",
285
+ "nomStatus",
286
+ "nameType",
287
+ "field",
288
+ "authorship",
289
+ "extinct",
290
+ "environment",
291
+ "group",
292
+ "authorshipYear"
293
+ ], y = 50, W = 50, b = {
294
+ limit: 50,
295
+ offset: 0,
296
+ facet: U,
297
+ //["rank", "issue", "status", "nomStatus", "nameType", "field"],
298
+ facetLimit: W,
299
+ sortBy: "relevance"
300
+ }, Vt = () => [
301
+ {
302
+ title: "",
303
+ dataIndex: ["usage", "merged"],
304
+ key: "merged",
305
+ width: 12,
306
+ render: (r, i) => {
307
+ var a, e, l;
308
+ return (a = i == null ? void 0 : i.usage) != null && a.merged ? /* @__PURE__ */ s.jsx(Ot, { datasetKey: (e = i == null ? void 0 : i.usage) == null ? void 0 : e.datasetKey, verbatimSourceKey: (l = i == null ? void 0 : i.usage) == null ? void 0 : l.verbatimSourceKey }) : "";
309
+ }
310
+ },
311
+ {
312
+ title: "Scientific Name",
313
+ dataIndex: ["usage", "labelHtml"],
314
+ key: "scientificName",
315
+ render: (r, i) => {
316
+ const a = u(i, "usage.accepted.id") || u(i, "usage.id");
317
+ return /* @__PURE__ */ s.jsx(S, { to: "taxon", args: a, children: /* @__PURE__ */ s.jsx("span", { dangerouslySetInnerHTML: { __html: r } }) });
318
+ },
319
+ width: 200,
320
+ sorter: !0
321
+ },
322
+ {
323
+ title: "Status",
324
+ dataIndex: ["usage", "status"],
325
+ key: "status",
326
+ width: 200,
327
+ render: (r, i) => ["synonym", "ambiguous synonym", "misapplied"].includes(r) ? /* @__PURE__ */ s.jsxs(f.Fragment, { children: [
328
+ r,
329
+ " ",
330
+ r === "misapplied" ? "to " : "of ",
331
+ /* @__PURE__ */ s.jsx(
332
+ "span",
333
+ {
334
+ dangerouslySetInnerHTML: {
335
+ __html: u(i, "usage.accepted.labelHtml")
336
+ }
337
+ }
338
+ )
339
+ ] }, u(i, "usage.id")) : r
340
+ },
341
+ {
342
+ title: "Rank",
343
+ dataIndex: ["usage", "name", "rank"],
344
+ key: "rank",
345
+ width: 60,
346
+ sorter: !0
347
+ },
348
+ {
349
+ title: "Classification",
350
+ dataIndex: ["usage", "classification"],
351
+ key: "parents",
352
+ width: 180,
353
+ render: (r, i) => u(i, "classification") ? /* @__PURE__ */ s.jsx(
354
+ H,
355
+ {
356
+ classification: G(i.classification),
357
+ truncate: !0,
358
+ datasetKey: u(i, "usage.name.datasetKey")
359
+ },
360
+ u(i, "usage.id")
361
+ ) : ""
362
+ }
363
+ ];
364
+ class Gt extends f.Component {
365
+ constructor(a) {
366
+ super(a);
367
+ c(this, "componentDidMount", async () => {
368
+ this.parseParamsAndGetData();
369
+ const { datasetKey: a } = this.props;
370
+ try {
371
+ const { data: e } = await mt(a);
372
+ this.setState({
373
+ dataset: e,
374
+ datasetOrigin: ((e == null ? void 0 : e.origin) || "").toLowerCase()
375
+ });
376
+ } catch {
377
+ }
378
+ try {
379
+ const e = await gt();
380
+ this.setState({ taxGroups: e });
381
+ } catch {
382
+ }
383
+ });
384
+ c(this, "componentDidUpdate", (a) => {
385
+ jt(a.filters, this.props.filters) || this.parseParamsAndGetData();
386
+ });
387
+ c(this, "getRank", () => {
388
+ C(`${j.dataApi}vocab/rank`).then(
389
+ (a) => this.setState({ rank: a.data.map((e) => e.name) })
390
+ );
391
+ });
392
+ c(this, "parseParamsAndGetData", () => {
393
+ const { defaultTaxonKey: a, filters: e } = this.props;
394
+ let l = { ...e || {} };
395
+ a && !l.TAXON_ID && (l.TAXON_ID = a), Ct(l) ? (l = b, this.pushParams(b)) : l.facet || (l.facet = U), l.facetLimit || (l.facetLimit = W), delete l.fuzzy, l.limit || (l.limit = y), l.offset || (l.offset = 0), this.setState(
396
+ {
397
+ params: l,
398
+ pagination: {
399
+ pageSize: l.limit || y,
400
+ current: Number(l.offset || 0) / Number(l.limit || y) + 1,
401
+ showQuickJumper: !0,
402
+ pageSizeOptions: [50, 100, 500, 1e3]
403
+ }
404
+ },
405
+ this.getData
406
+ );
407
+ });
408
+ c(this, "pushParams", (a) => {
409
+ const e = { ...a };
410
+ e.q || delete e.q, this.props.onFiltersChange && this.props.onFiltersChange(e);
411
+ });
412
+ c(this, "getData", () => {
413
+ const { params: a } = this.state;
414
+ this.setState({ loading: !0 });
415
+ const { datasetKey: e } = this.props, l = `${j.dataApi}dataset/${e}/nameusage/search`, o = u(a, "status") ? a : { ...a, status: "_NOT_NULL" };
416
+ C(`${l}?${yt.stringify(o)}`).then((n) => {
417
+ const h = { ...this.state.pagination };
418
+ h.total = n.data.total, this.setState({
419
+ loading: !1,
420
+ data: n.data,
421
+ err: null,
422
+ pagination: h
423
+ });
424
+ }).catch((n) => {
425
+ this.setState({ loading: !1, error: n, data: [] });
426
+ });
427
+ });
428
+ c(this, "handleTableChange", (a, e, l) => {
429
+ let o = Dt(this.state.params, {
430
+ limit: a.pageSize,
431
+ offset: (a.current - 1) * a.pageSize,
432
+ ...e
433
+ });
434
+ l && l.field && (l.field[l.field.length - 1] === "labelHtml" ? o.sortBy = "name" : l.field[l.field.length - 1] === "rank" ? o.sortBy = "taxonomic" : o.sortBy = l.field[l.field.length - 1]), l && l.order === "descend" ? o.reverse = !0 : o.reverse = !1, this.setState({ params: o }, () => this.pushParams(o));
435
+ });
436
+ c(this, "updateSearch", (a) => {
437
+ let e = { ...this.state.params, offset: 0, limit: 50 };
438
+ At(a, (o, n) => {
439
+ e[n] = o;
440
+ });
441
+ const l = Object.keys(e).reduce(
442
+ (o, n) => (e[n] !== null && (o[n] = e[n]), o),
443
+ {}
444
+ );
445
+ this.setState(
446
+ { params: l },
447
+ () => this.pushParams(l)
448
+ );
449
+ });
450
+ c(this, "resetSearch", () => {
451
+ this.setState(
452
+ {
453
+ params: b
454
+ },
455
+ () => this.pushParams(b)
456
+ );
457
+ });
458
+ c(this, "toggleAdvancedFilters", () => {
459
+ this.setState({ advancedFilters: !this.state.advancedFilters });
460
+ });
461
+ this.state = {
462
+ data: [],
463
+ advancedFilters: !1,
464
+ columns: Vt(),
465
+ params: {},
466
+ taxGroups: [],
467
+ pagination: {
468
+ pageSize: y,
469
+ current: 1,
470
+ showQuickJumper: !0,
471
+ pageSizeOptions: [50, 100, 500, 1e3]
472
+ },
473
+ loading: !1,
474
+ dataset: null
475
+ };
476
+ }
477
+ render() {
478
+ var I;
479
+ const {
480
+ data: { result: a, facets: e },
481
+ loading: l,
482
+ error: o,
483
+ params: n,
484
+ pagination: h,
485
+ advancedFilters: d,
486
+ dataset: v,
487
+ taxGroups: Pt
488
+ } = this.state, { datasetKey: T, defaultTaxonKey: Y, citation: B } = this.props, q = u(e, "rank") ? e.rank.map((t) => ({
489
+ value: t.value,
490
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
491
+ })) : null;
492
+ u(e, "issue") && e.issue.map((t) => ({
493
+ value: t.value,
494
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
495
+ }));
496
+ const X = u(e, "status") ? e.status.map((t) => ({
497
+ value: t.value,
498
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
499
+ })) : null, Z = u(e, "nomStatus") ? e.nomStatus.map((t) => ({
500
+ value: t.value,
501
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
502
+ })) : null, J = u(e, "nameType") ? e.nameType.map((t) => ({
503
+ value: t.value,
504
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
505
+ })) : null, Q = u(e, "field") ? e.field.map((t) => ({
506
+ value: t.value,
507
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
508
+ })) : null, tt = u(e, "authorship") ? e.authorship.map((t) => ({
509
+ value: t.value,
510
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
511
+ })) : [], et = (t) => t === "1" || t === !0 || t === "true" ? "Extinct" : t === "0" || t === !1 || t === "false" ? "Extant" : "Unknown", at = u(e, "extinct") ? e.extinct.map((t) => ({
512
+ value: t.value,
513
+ label: `${et(t == null ? void 0 : t.value)} (${t.count.toLocaleString("en-GB")})`
514
+ })) : [], st = u(e, "environment") ? e.environment.map((t) => ({
515
+ value: t.value,
516
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
517
+ })) : [], nt = u(e, "group") ? e.group.map((t) => ({
518
+ value: t.value,
519
+ label: `${m(t.value)} (${t.count.toLocaleString("en-GB")})`
520
+ })) : [], lt = u(e, "authorshipYear") ? e.authorshipYear.map((t) => ({
521
+ value: t.value,
522
+ label: `${t.value} (${t.count.toLocaleString("en-GB")})`
523
+ })) : [];
524
+ return /* @__PURE__ */ s.jsxs(
525
+ "div",
526
+ {
527
+ className: "catalogue-of-life",
528
+ style: {
529
+ padding: 24,
530
+ minHeight: 280,
531
+ margin: "16px 0"
532
+ },
533
+ children: [
534
+ B === "top" && v && /* @__PURE__ */ s.jsx(N, { dataset: v }),
535
+ /* @__PURE__ */ s.jsx(x, { children: o && /* @__PURE__ */ s.jsx(
536
+ xt,
537
+ {
538
+ style: { marginBottom: "10px" },
539
+ message: /* @__PURE__ */ s.jsx(Tt, { error: o }),
540
+ type: "error"
541
+ }
542
+ ) }),
543
+ /* @__PURE__ */ s.jsxs(x, { children: [
544
+ /* @__PURE__ */ s.jsxs(g, { xs: 24, sm: 24, md: 12, style: { marginBottom: "8px" }, children: [
545
+ /* @__PURE__ */ s.jsx(
546
+ _t,
547
+ {
548
+ defaultValue: u(this.props.filters || {}, "q"),
549
+ onSearch: (t) => this.updateSearch({ q: t }),
550
+ onResetSearch: (t) => this.updateSearch({ q: null }),
551
+ style: { marginBottom: "8px", width: "100%" }
552
+ }
553
+ ),
554
+ /* @__PURE__ */ s.jsx(
555
+ $t,
556
+ {
557
+ datasetKey: T,
558
+ minRank: "GENUS",
559
+ defaultTaxonKey: u(n, "TAXON_ID") || Y || null,
560
+ onSelectName: (t) => {
561
+ this.updateSearch({ TAXON_ID: t.key });
562
+ },
563
+ onResetSearch: (t) => {
564
+ this.updateSearch({ TAXON_ID: null });
565
+ },
566
+ placeHolder: "Filter by higher taxon",
567
+ sortBy: "relevance",
568
+ autoFocus: !1
569
+ }
570
+ ),
571
+ (this.state.datasetOrigin === "xrelease" || this.state.datasetOrigin === "release") && /* @__PURE__ */ s.jsx("div", { style: { marginTop: "8px", marginBottom: "8px" }, children: /* @__PURE__ */ s.jsx(
572
+ Ft,
573
+ {
574
+ contributesTo: Number(T),
575
+ onSelectDataset: (t) => {
576
+ this.updateSearch({ SECTOR_DATASET_KEY: t.key });
577
+ },
578
+ defaultDatasetKey: u(n, "SECTOR_DATASET_KEY") || null,
579
+ onResetSearch: (t) => {
580
+ this.updateSearch({ SECTOR_DATASET_KEY: null });
581
+ },
582
+ placeHolder: "Filter by source dataset",
583
+ autoFocus: !1
584
+ }
585
+ ) }),
586
+ /* @__PURE__ */ s.jsxs("div", { style: { marginTop: "10px" }, children: [
587
+ /* @__PURE__ */ s.jsx(D, { layout: "inline", children: /* @__PURE__ */ s.jsx(E, { label: "Matching", children: /* @__PURE__ */ s.jsx(
588
+ M,
589
+ {
590
+ size: "small",
591
+ onChange: (t) => {
592
+ this.updateSearch({ type: t.target.value });
593
+ },
594
+ value: n.type || "WHOLE_WORDS",
595
+ optionType: "button",
596
+ options: [
597
+ { value: "EXACT", label: "Exact" },
598
+ { value: "WHOLE_WORDS", label: "Words" },
599
+ { value: "PREFIX", label: "Prefix" },
600
+ { value: "FUZZY", label: "Fuzzy" }
601
+ ]
602
+ }
603
+ ) }) }),
604
+ /* @__PURE__ */ s.jsxs(D, { layout: "inline", children: [
605
+ (this.state.datasetOrigin === "xrelease" || this.state.datasetOrigin === "project") && /* @__PURE__ */ s.jsx(E, { label: "Content", children: /* @__PURE__ */ s.jsx(
606
+ M,
607
+ {
608
+ style: { marginLeft: "8px" },
609
+ size: "small",
610
+ onChange: (t) => {
611
+ this.updateSearch({ sectorMode: t.target.value.split(",").filter((it) => it !== "") });
612
+ },
613
+ value: O(n == null ? void 0 : n.sectorMode) ? (I = n == null ? void 0 : n.sectorMode) == null ? void 0 : I.join(",") : (n == null ? void 0 : n.sectorMode) || "",
614
+ optionType: "button",
615
+ options: [
616
+ { value: "", label: "All" },
617
+ { value: "attach,union", label: "Base" },
618
+ { value: "merge", label: "Extended" }
619
+ ]
620
+ }
621
+ ) }),
622
+ /* @__PURE__ */ s.jsx(E, { children: /* @__PURE__ */ s.jsx(
623
+ k,
624
+ {
625
+ mode: "multiple",
626
+ allowClear: !0,
627
+ size: "small",
628
+ style: { minWidth: 200 },
629
+ placeholder: "Search fields",
630
+ value: O(n == null ? void 0 : n.content) ? n.content : n != null && n.content ? [n.content] : [],
631
+ onChange: (t) => this.updateSearch({ content: t.length ? t : null }),
632
+ options: [
633
+ { value: "SCIENTIFIC_NAME", label: "Scientific name" },
634
+ { value: "AUTHORSHIP", label: "Authorship" },
635
+ { value: "VERNACULAR_NAME", label: "Vernacular name" }
636
+ ]
637
+ }
638
+ ) })
639
+ ] })
640
+ ] })
641
+ ] }),
642
+ /* @__PURE__ */ s.jsxs(g, { xs: 24, sm: 24, md: 12, children: [
643
+ /* @__PURE__ */ s.jsx(
644
+ p,
645
+ {
646
+ defaultValue: u(n, "rank"),
647
+ onChange: (t) => this.updateSearch({ rank: t }),
648
+ vocab: q || [],
649
+ label: "Ranks"
650
+ }
651
+ ),
652
+ /* @__PURE__ */ s.jsx(
653
+ p,
654
+ {
655
+ defaultValue: u(n, "status"),
656
+ onChange: (t) => this.updateSearch({ status: t }),
657
+ vocab: X || [],
658
+ label: "Status"
659
+ }
660
+ ),
661
+ /* @__PURE__ */ s.jsx(
662
+ p,
663
+ {
664
+ defaultValue: u(n, "environment"),
665
+ onChange: (t) => this.updateSearch({ environment: t }),
666
+ vocab: st,
667
+ label: "Environment"
668
+ }
669
+ ),
670
+ /* @__PURE__ */ s.jsx(
671
+ p,
672
+ {
673
+ onChange: (t) => this.updateSearch({ extinct: t }),
674
+ vocab: at,
675
+ label: "Extinct"
676
+ }
677
+ ),
678
+ d && /* @__PURE__ */ s.jsxs(f.Fragment, { children: [
679
+ /* @__PURE__ */ s.jsx(
680
+ p,
681
+ {
682
+ defaultValue: u(n, "nomstatus"),
683
+ onChange: (t) => this.updateSearch({ nomstatus: t }),
684
+ vocab: Z || [],
685
+ label: "Nomenclatural status"
686
+ }
687
+ ),
688
+ /* @__PURE__ */ s.jsx(
689
+ p,
690
+ {
691
+ defaultValue: u(n, "nameType"),
692
+ onChange: (t) => this.updateSearch({ nameType: t }),
693
+ vocab: J || [],
694
+ label: "Name type"
695
+ }
696
+ ),
697
+ /* @__PURE__ */ s.jsx(
698
+ p,
699
+ {
700
+ defaultValue: u(n, "field"),
701
+ onChange: (t) => this.updateSearch({ field: t }),
702
+ vocab: Q || [],
703
+ label: "Name field"
704
+ }
705
+ ),
706
+ /* @__PURE__ */ s.jsx(
707
+ p,
708
+ {
709
+ defaultValue: u(n, "authorship"),
710
+ onChange: (t) => this.updateSearch({ authorship: t }),
711
+ vocab: tt,
712
+ label: "Authorship"
713
+ }
714
+ ),
715
+ /* @__PURE__ */ s.jsx(
716
+ p,
717
+ {
718
+ defaultValue: u(n, "group"),
719
+ onChange: (t) => this.updateSearch({ group: t }),
720
+ vocab: nt,
721
+ label: "Taxonomic group"
722
+ }
723
+ ),
724
+ /* @__PURE__ */ s.jsx(
725
+ p,
726
+ {
727
+ defaultValue: u(n, "authorshipYear"),
728
+ onChange: (t) => this.updateSearch({ authorshipYear: t }),
729
+ vocab: lt,
730
+ label: "Authorship year"
731
+ }
732
+ )
733
+ ] }),
734
+ /* @__PURE__ */ s.jsx("div", { style: { textAlign: "right", marginBottom: "8px" }, children: /* @__PURE__ */ s.jsxs(
735
+ "a",
736
+ {
737
+ style: { marginLeft: 8, fontSize: 12 },
738
+ onClick: this.toggleAdvancedFilters,
739
+ children: [
740
+ "Advanced",
741
+ " ",
742
+ this.state.advancedFilters ? /* @__PURE__ */ s.jsx(z, {}) : /* @__PURE__ */ s.jsx(P, {})
743
+ ]
744
+ }
745
+ ) })
746
+ ] })
747
+ ] }),
748
+ /* @__PURE__ */ s.jsxs(x, { children: [
749
+ /* @__PURE__ */ s.jsx(g, { span: 12, style: { textAlign: "left", marginBottom: "8px" }, children: /* @__PURE__ */ s.jsx(St, { type: "primary", danger: !0, onClick: this.resetSearch, children: "Reset all" }) }),
750
+ /* @__PURE__ */ s.jsx(g, { span: 12, style: { textAlign: "right", marginBottom: "8px" }, children: h && !isNaN(h.total) && `results: ${h.total.toLocaleString("en-GB")}` })
751
+ ] }),
752
+ !o && /* @__PURE__ */ s.jsx(
753
+ vt,
754
+ {
755
+ size: "small",
756
+ columns: this.state.columns,
757
+ scroll: { x: "max-content" },
758
+ dataSource: a,
759
+ loading: l,
760
+ pagination: this.state.pagination,
761
+ onChange: this.handleTableChange,
762
+ rowKey: (t) => t.usage.id,
763
+ showSorterTooltip: !1,
764
+ expandedRowRender: (t) => /* @__PURE__ */ s.jsx(
765
+ Mt,
766
+ {
767
+ ...t,
768
+ datasetKey: T
769
+ }
770
+ )
771
+ }
772
+ ),
773
+ B === "bottom" && v && /* @__PURE__ */ s.jsx(N, { dataset: v })
774
+ ]
775
+ }
776
+ );
777
+ }
778
+ }
779
+ function Kt({
780
+ datasetKey: r,
781
+ filters: i,
782
+ onFiltersChange: a,
783
+ defaultTaxonKey: e,
784
+ citation: l,
785
+ auth: o,
786
+ ...n
787
+ }) {
788
+ return ht(o), /* @__PURE__ */ s.jsx(dt.Provider, { value: pt(n), children: /* @__PURE__ */ s.jsx(
789
+ Gt,
790
+ {
791
+ datasetKey: r,
792
+ filters: i,
793
+ onFiltersChange: a,
794
+ defaultTaxonKey: e,
795
+ citation: l
796
+ }
797
+ ) });
798
+ }
799
+ const ie = ct(ut(Kt));
800
+ export {
801
+ ie as Search
802
+ };
803
+ //# sourceMappingURL=search.js.map