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