col-browser 2.6.5 → 2.7.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.
- package/README.md +5 -4
- package/es/chunks/Distributions-CHjEIZ3F.js +1232 -0
- package/es/chunks/Distributions-CHjEIZ3F.js.map +1 -0
- package/es/chunks/TaxonBreakdown-CyHl1YES.js +174 -0
- package/es/chunks/TaxonBreakdown-CyHl1YES.js.map +1 -0
- package/es/taxon.js +704 -692
- package/es/taxon.js.map +1 -1
- package/es/taxonBreakdown.js +26 -29
- package/es/taxonBreakdown.js.map +1 -1
- package/es/taxonDistribution.js +1 -1
- package/es/tree.js +360 -356
- package/es/tree.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +5 -2
- package/umd/col-browser.js +146 -143
- 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/chunks/Distributions-CvS4r1hC.js +0 -1204
- package/es/chunks/Distributions-CvS4r1hC.js.map +0 -1
- package/es/chunks/TaxonBreakdown-DqdQ18QM.js +0 -210
- package/es/chunks/TaxonBreakdown-DqdQ18QM.js.map +0 -1
package/umd/col-browser.js
CHANGED
|
@@ -13397,7 +13397,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13397
13397
|
*/
|
|
13398
13398
|
WIN_KEY: 224
|
|
13399
13399
|
};
|
|
13400
|
-
let cached;
|
|
13400
|
+
let cached$1;
|
|
13401
13401
|
function measureScrollbarSize(ele) {
|
|
13402
13402
|
const randomId = `rc-scrollbar-measure-${Math.random().toString(36).substring(7)}`;
|
|
13403
13403
|
const measureEle = document.createElement("div");
|
|
@@ -13446,10 +13446,10 @@ ${heightStyle}
|
|
|
13446
13446
|
if (typeof document === "undefined") {
|
|
13447
13447
|
return 0;
|
|
13448
13448
|
}
|
|
13449
|
-
if (cached === void 0) {
|
|
13450
|
-
cached = measureScrollbarSize();
|
|
13449
|
+
if (cached$1 === void 0) {
|
|
13450
|
+
cached$1 = measureScrollbarSize();
|
|
13451
13451
|
}
|
|
13452
|
-
return cached.width;
|
|
13452
|
+
return cached$1.width;
|
|
13453
13453
|
}
|
|
13454
13454
|
function getTargetScrollBarSize(target) {
|
|
13455
13455
|
if (typeof document === "undefined" || !target || !(target instanceof Element)) {
|
|
@@ -68668,7 +68668,7 @@ html body {
|
|
|
68668
68668
|
if (defaultExpandKey) {
|
|
68669
68669
|
return this.expandToTaxon(defaultExpandKey);
|
|
68670
68670
|
} else if (defaultTaxonKey) {
|
|
68671
|
-
return this.expandToTaxon(defaultTaxonKey);
|
|
68671
|
+
return this.expandToTaxon(defaultTaxonKey, false);
|
|
68672
68672
|
}
|
|
68673
68673
|
}
|
|
68674
68674
|
);
|
|
@@ -68685,7 +68685,7 @@ html body {
|
|
|
68685
68685
|
});
|
|
68686
68686
|
});
|
|
68687
68687
|
});
|
|
68688
|
-
__publicField(this, "expandToTaxon", async (defaultExpandKey) => {
|
|
68688
|
+
__publicField(this, "expandToTaxon", async (defaultExpandKey, scrollToTaxon = true) => {
|
|
68689
68689
|
const {
|
|
68690
68690
|
showSourceTaxon,
|
|
68691
68691
|
datasetKey,
|
|
@@ -68764,7 +68764,7 @@ html body {
|
|
|
68764
68764
|
const loadedKeys = [...data.map((t2) => t2.id).reverse()];
|
|
68765
68765
|
this.setState(
|
|
68766
68766
|
{ treeData },
|
|
68767
|
-
() => this.reloadLoadedKeys(loadedKeys, defaultExpandKey)
|
|
68767
|
+
() => this.reloadLoadedKeys(loadedKeys, defaultExpandKey, true, scrollToTaxon)
|
|
68768
68768
|
);
|
|
68769
68769
|
});
|
|
68770
68770
|
__publicField(this, "fetchChildPage", async (dataRef, reloadAll, dontUpdateState) => {
|
|
@@ -68893,7 +68893,7 @@ html body {
|
|
|
68893
68893
|
}
|
|
68894
68894
|
return node2;
|
|
68895
68895
|
});
|
|
68896
|
-
__publicField(this, "reloadLoadedKeys", async (keys2, expandKey, expandAll = true) => {
|
|
68896
|
+
__publicField(this, "reloadLoadedKeys", async (keys2, expandKey, expandAll = true, scrollToTaxon = true) => {
|
|
68897
68897
|
this.setState({ rootLoading: true });
|
|
68898
68898
|
const { loadedKeys: storedKeys } = this.state;
|
|
68899
68899
|
let { treeData } = this.state;
|
|
@@ -68946,6 +68946,7 @@ html body {
|
|
|
68946
68946
|
);
|
|
68947
68947
|
if (targetNode) {
|
|
68948
68948
|
this.setState({ treeData: [...this.state.treeData] }, () => {
|
|
68949
|
+
if (!scrollToTaxon) return;
|
|
68949
68950
|
setTimeout(() => {
|
|
68950
68951
|
const elmnt = document.getElementById(expandKey);
|
|
68951
68952
|
elmnt.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
@@ -68977,7 +68978,7 @@ html body {
|
|
|
68977
68978
|
newState.expandedKeys = loadedKeys;
|
|
68978
68979
|
}
|
|
68979
68980
|
this.setState(newState, () => {
|
|
68980
|
-
if (expandKey) {
|
|
68981
|
+
if (expandKey && scrollToTaxon) {
|
|
68981
68982
|
setTimeout(() => {
|
|
68982
68983
|
const elmnt = document.getElementById(expandKey);
|
|
68983
68984
|
elmnt.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
@@ -69638,7 +69639,8 @@ html body {
|
|
|
69638
69639
|
linkToSpeciesPage,
|
|
69639
69640
|
citation,
|
|
69640
69641
|
type: type2,
|
|
69641
|
-
insertPlaceholder = true
|
|
69642
|
+
insertPlaceholder = true,
|
|
69643
|
+
autoFocus
|
|
69642
69644
|
} = this.props;
|
|
69643
69645
|
const { hideExtinct, dataset } = this.state;
|
|
69644
69646
|
const handleSelectName = (name) => {
|
|
@@ -69673,7 +69675,8 @@ html body {
|
|
|
69673
69675
|
},
|
|
69674
69676
|
defaultTaxonKey: expandedTaxonKey || null,
|
|
69675
69677
|
onSelectName: handleSelectName,
|
|
69676
|
-
onResetSearch: handleResetSearch
|
|
69678
|
+
onResetSearch: handleResetSearch,
|
|
69679
|
+
autoFocus
|
|
69677
69680
|
}
|
|
69678
69681
|
) }),
|
|
69679
69682
|
showTreeOptions && /* @__PURE__ */ jsxRuntimeExports.jsxs(Col, { style: { paddingLeft: "8px" }, children: [
|
|
@@ -69743,6 +69746,7 @@ html body {
|
|
|
69743
69746
|
citation,
|
|
69744
69747
|
type: type2,
|
|
69745
69748
|
insertPlaceholder,
|
|
69749
|
+
autoFocus,
|
|
69746
69750
|
auth,
|
|
69747
69751
|
...routerProps
|
|
69748
69752
|
}) {
|
|
@@ -69758,6 +69762,7 @@ html body {
|
|
|
69758
69762
|
citation,
|
|
69759
69763
|
type: type2,
|
|
69760
69764
|
insertPlaceholder,
|
|
69765
|
+
autoFocus,
|
|
69761
69766
|
auth
|
|
69762
69767
|
}
|
|
69763
69768
|
) });
|
|
@@ -77494,7 +77499,7 @@ html body {
|
|
|
77494
77499
|
] }) });
|
|
77495
77500
|
};
|
|
77496
77501
|
const TypeMaterial = ({ dataset, data, nameID, style: style2 }) => {
|
|
77497
|
-
return data[nameID] ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: style2, children: data[nameID].map((s) => /* @__PURE__ */ jsxRuntimeExports.jsx(BorderedListItem$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
77502
|
+
return data[nameID] ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: style2, children: data[nameID].map(({ status, nameId, typeMaterial: s }) => /* @__PURE__ */ jsxRuntimeExports.jsx(BorderedListItem$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
77498
77503
|
XrGutter,
|
|
77499
77504
|
{
|
|
77500
77505
|
merged: s.merged,
|
|
@@ -77503,7 +77508,7 @@ html body {
|
|
|
77503
77508
|
verbatimSourceKey: s == null ? void 0 : s.verbatimSourceKey,
|
|
77504
77509
|
sourceDatasetKey: s == null ? void 0 : s.sourceDatasetKey,
|
|
77505
77510
|
children: [
|
|
77506
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { color: getTypeColor(
|
|
77511
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { color: getTypeColor(status), children: status }),
|
|
77507
77512
|
" ",
|
|
77508
77513
|
getLinks(dataset, s),
|
|
77509
77514
|
" ",
|
|
@@ -77515,7 +77520,7 @@ html body {
|
|
|
77515
77520
|
)
|
|
77516
77521
|
]
|
|
77517
77522
|
}
|
|
77518
|
-
) }, s.id)) }) : null;
|
|
77523
|
+
) }, `${s.id}-${nameId}`)) }) : null;
|
|
77519
77524
|
};
|
|
77520
77525
|
class TypeMaterialPopover extends React.Component {
|
|
77521
77526
|
constructor(props) {
|
|
@@ -77539,8 +77544,8 @@ html body {
|
|
|
77539
77544
|
const { typeMaterial, nameId } = this.props;
|
|
77540
77545
|
const data = (typeMaterial == null ? void 0 : typeMaterial[nameId]) || [];
|
|
77541
77546
|
if (data.length > 0) {
|
|
77542
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: data.map((s) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginBottom: "8px", paddingLeft: "18px" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(XrGutter, { merged: s.merged, children: [
|
|
77543
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { color: getTypeColor(
|
|
77547
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: data.map(({ status, nameId: nameId2, typeMaterial: s }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginBottom: "8px", paddingLeft: "18px" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(XrGutter, { merged: s.merged, children: [
|
|
77548
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Tag, { color: getTypeColor(status), children: status }),
|
|
77544
77549
|
" ",
|
|
77545
77550
|
(s == null ? void 0 : s.citation) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
77546
77551
|
"span",
|
|
@@ -77550,7 +77555,7 @@ html body {
|
|
|
77550
77555
|
}
|
|
77551
77556
|
}
|
|
77552
77557
|
)
|
|
77553
|
-
] }) }, s.id)) });
|
|
77558
|
+
] }) }, `${s.id}-${nameId2}`)) });
|
|
77554
77559
|
}
|
|
77555
77560
|
});
|
|
77556
77561
|
__publicField(this, "render", () => {
|
|
@@ -78210,6 +78215,26 @@ html body {
|
|
|
78210
78215
|
] })
|
|
78211
78216
|
] });
|
|
78212
78217
|
};
|
|
78218
|
+
let cached = null;
|
|
78219
|
+
const probe = () => {
|
|
78220
|
+
var _a2, _b2;
|
|
78221
|
+
if (typeof window === "undefined" || !window.WebGLRenderingContext) {
|
|
78222
|
+
return false;
|
|
78223
|
+
}
|
|
78224
|
+
try {
|
|
78225
|
+
const canvas = document.createElement("canvas");
|
|
78226
|
+
const ctx = canvas.getContext("webgl2") || canvas.getContext("webgl");
|
|
78227
|
+
if (!ctx || typeof ctx.getParameter !== "function") return false;
|
|
78228
|
+
(_b2 = (_a2 = ctx.getExtension) == null ? void 0 : _a2.call(ctx, "WEBGL_lose_context")) == null ? void 0 : _b2.loseContext();
|
|
78229
|
+
return true;
|
|
78230
|
+
} catch (e2) {
|
|
78231
|
+
return false;
|
|
78232
|
+
}
|
|
78233
|
+
};
|
|
78234
|
+
const isWebglSupported = () => {
|
|
78235
|
+
if (cached === null) cached = probe();
|
|
78236
|
+
return cached;
|
|
78237
|
+
};
|
|
78213
78238
|
const POPUP_FIELDS = [
|
|
78214
78239
|
"establishmentMeans",
|
|
78215
78240
|
"degreeOfEstablishment",
|
|
@@ -78344,10 +78369,6 @@ html body {
|
|
|
78344
78369
|
if (geojson.type === "FeatureCollection") return geojson.features || [];
|
|
78345
78370
|
return [geojson];
|
|
78346
78371
|
};
|
|
78347
|
-
const supported = () => {
|
|
78348
|
-
if (typeof (maplibregl == null ? void 0 : maplibregl.supported) === "function") return maplibregl.supported();
|
|
78349
|
-
return typeof WebGLRenderingContext !== "undefined";
|
|
78350
|
-
};
|
|
78351
78372
|
const DistributionsMap = ({
|
|
78352
78373
|
records,
|
|
78353
78374
|
onUnmappable,
|
|
@@ -78361,7 +78382,9 @@ html body {
|
|
|
78361
78382
|
gbifAvailable = true,
|
|
78362
78383
|
// MapLibre style URL or inline style object; falls back to the global
|
|
78363
78384
|
// `configure({ basemapStyle })` value. Changing it rebuilds the map.
|
|
78364
|
-
basemapStyle
|
|
78385
|
+
basemapStyle,
|
|
78386
|
+
// Called from the no-WebGL notice to switch the host to its list view.
|
|
78387
|
+
onShowList
|
|
78365
78388
|
}) => {
|
|
78366
78389
|
var _a2;
|
|
78367
78390
|
const containerRef = reactExports.useRef(null);
|
|
@@ -78374,6 +78397,7 @@ html body {
|
|
|
78374
78397
|
const focalAttachedRef = reactExports.useRef(false);
|
|
78375
78398
|
const gbifAttachedRef = reactExports.useRef(false);
|
|
78376
78399
|
const descendantLayersRef = reactExports.useRef(/* @__PURE__ */ new Set());
|
|
78400
|
+
const [webglFailed, setWebglFailed] = reactExports.useState(false);
|
|
78377
78401
|
const [readyMap, setReadyMap] = reactExports.useState(null);
|
|
78378
78402
|
const [focalReady, setFocalReady] = reactExports.useState(false);
|
|
78379
78403
|
const [descendantState, setDescendantState] = reactExports.useState({
|
|
@@ -78452,17 +78476,24 @@ html body {
|
|
|
78452
78476
|
const styleKey = `${typeof styleSpec === "string" ? styleSpec : JSON.stringify(styleSpec)}|${cartoKey || ""}`;
|
|
78453
78477
|
reactExports.useEffect(() => {
|
|
78454
78478
|
if (!containerRef.current || mapRef.current) return;
|
|
78455
|
-
if (!
|
|
78456
|
-
|
|
78457
|
-
|
|
78458
|
-
|
|
78459
|
-
|
|
78460
|
-
|
|
78461
|
-
|
|
78462
|
-
|
|
78463
|
-
|
|
78464
|
-
|
|
78465
|
-
|
|
78479
|
+
if (!isWebglSupported()) return;
|
|
78480
|
+
let map;
|
|
78481
|
+
try {
|
|
78482
|
+
map = new maplibregl.Map({
|
|
78483
|
+
container: containerRef.current,
|
|
78484
|
+
style: styleSpec,
|
|
78485
|
+
transformRequest: cartoTransformRequest(cartoKey),
|
|
78486
|
+
center: [0, 20],
|
|
78487
|
+
zoom: 1,
|
|
78488
|
+
minZoom: 0,
|
|
78489
|
+
attributionControl: false,
|
|
78490
|
+
renderWorldCopies: true
|
|
78491
|
+
});
|
|
78492
|
+
} catch (e2) {
|
|
78493
|
+
console.warn("Distribution map disabled:", e2);
|
|
78494
|
+
setWebglFailed(true);
|
|
78495
|
+
return;
|
|
78496
|
+
}
|
|
78466
78497
|
map.addControl(
|
|
78467
78498
|
new maplibregl.AttributionControl({ compact: true }),
|
|
78468
78499
|
"bottom-right"
|
|
@@ -78807,8 +78838,8 @@ html body {
|
|
|
78807
78838
|
return next2;
|
|
78808
78839
|
});
|
|
78809
78840
|
};
|
|
78810
|
-
if (!
|
|
78811
|
-
return /* @__PURE__ */ jsxRuntimeExports.
|
|
78841
|
+
if (webglFailed || !isWebglSupported()) {
|
|
78842
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
78812
78843
|
"div",
|
|
78813
78844
|
{
|
|
78814
78845
|
style: {
|
|
@@ -78819,7 +78850,15 @@ html body {
|
|
|
78819
78850
|
color: "#666",
|
|
78820
78851
|
fontSize: 12
|
|
78821
78852
|
},
|
|
78822
|
-
children:
|
|
78853
|
+
children: [
|
|
78854
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: "The distribution map can't be shown because WebGL is not available in your browser." }),
|
|
78855
|
+
" ",
|
|
78856
|
+
"This usually means hardware acceleration is turned off or the graphics drivers aren't set up for WebGL.",
|
|
78857
|
+
typeof onShowList === "function" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
78858
|
+
" ",
|
|
78859
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: onShowList, style: { cursor: "pointer" }, children: "Show distributions as a list" })
|
|
78860
|
+
] })
|
|
78861
|
+
]
|
|
78823
78862
|
}
|
|
78824
78863
|
);
|
|
78825
78864
|
}
|
|
@@ -79201,7 +79240,9 @@ html body {
|
|
|
79201
79240
|
const baseUnmappable = data.length - mappable.length;
|
|
79202
79241
|
const hasGbifConfigured = !!gbifChecklistKey;
|
|
79203
79242
|
const hasAnyRecords = data.length > 0;
|
|
79204
|
-
const [view, setView] = reactExports.useState(
|
|
79243
|
+
const [view, setView] = reactExports.useState(
|
|
79244
|
+
() => isWebglSupported() ? "map" : "list"
|
|
79245
|
+
);
|
|
79205
79246
|
const [fetchFailures, setFetchFailures] = reactExports.useState(0);
|
|
79206
79247
|
const [gbifCount, setGbifCount] = reactExports.useState(null);
|
|
79207
79248
|
reactExports.useEffect(() => {
|
|
@@ -79273,7 +79314,8 @@ html body {
|
|
|
79273
79314
|
rankOrder,
|
|
79274
79315
|
gbifChecklistKey,
|
|
79275
79316
|
gbifAvailable,
|
|
79276
|
-
basemapStyle
|
|
79317
|
+
basemapStyle,
|
|
79318
|
+
onShowList: showToggle ? () => setView("list") : void 0
|
|
79277
79319
|
}
|
|
79278
79320
|
),
|
|
79279
79321
|
showToggle && unmappable > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginTop: 6 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("a", { onClick: () => setView("list"), style: { cursor: "pointer" }, children: [
|
|
@@ -86800,38 +86842,19 @@ html body {
|
|
|
86800
86842
|
const HighchartsReact = /* @__PURE__ */ getDefaultExportFromCjs(highchartsReact_minExports);
|
|
86801
86843
|
const BREAKDOWN_LEVEL_KEY = "breakdown-level";
|
|
86802
86844
|
const MAX_SLICES_PER_RING = 100;
|
|
86803
|
-
const canonicalRanks = [
|
|
86804
|
-
"kingdom",
|
|
86805
|
-
"phylum",
|
|
86806
|
-
"class",
|
|
86807
|
-
"order",
|
|
86808
|
-
"family",
|
|
86809
|
-
"genus",
|
|
86810
|
-
"species"
|
|
86811
|
-
];
|
|
86812
86845
|
const notAssignedLabel = (rk) => rk ? `Not assigned ${rk}` : "Not assigned";
|
|
86813
|
-
const
|
|
86814
|
-
|
|
86815
|
-
const
|
|
86816
|
-
|
|
86817
|
-
|
|
86818
|
-
|
|
86819
|
-
|
|
86820
|
-
|
|
86821
|
-
if (sum >= parentSpecies) return sorted;
|
|
86822
|
-
return [
|
|
86823
|
-
...sorted,
|
|
86824
|
-
{
|
|
86825
|
-
name: notAssignedLabel(get(sorted, "[0].rank", "")),
|
|
86826
|
-
species: parentSpecies - sum,
|
|
86827
|
-
children: []
|
|
86828
|
-
}
|
|
86829
|
-
];
|
|
86846
|
+
const ringNodes = (nodes, parentCount) => {
|
|
86847
|
+
const named = (nodes || []).filter((n2) => n2.id).sort((a, b2) => (b2.count || 0) - (a.count || 0)).slice(0, MAX_SLICES_PER_RING);
|
|
86848
|
+
const sum = named.reduce((a, n2) => a + (n2.count || 0), 0);
|
|
86849
|
+
const rank = get(nodes, "[0].rank", "");
|
|
86850
|
+
return sum < parentCount ? [
|
|
86851
|
+
...named,
|
|
86852
|
+
{ name: notAssignedLabel(rank), count: parentCount - sum, children: [] }
|
|
86853
|
+
] : named;
|
|
86830
86854
|
};
|
|
86831
86855
|
const TaxonBreakdown$1 = ({
|
|
86832
86856
|
taxon,
|
|
86833
86857
|
datasetKey,
|
|
86834
|
-
rank = [],
|
|
86835
86858
|
dataset,
|
|
86836
86859
|
level = 1,
|
|
86837
86860
|
showLevelSwitch = false,
|
|
@@ -86855,57 +86878,29 @@ html body {
|
|
|
86855
86878
|
getData();
|
|
86856
86879
|
}
|
|
86857
86880
|
}, [taxon, datasetKey, activeLevel]);
|
|
86858
|
-
const getOverView = async () => {
|
|
86859
|
-
const res = await client(
|
|
86860
|
-
`${config.dataApi}dataset/${datasetKey}/nameusage/search?TAXON_ID=${encodeURIComponent(
|
|
86861
|
-
taxon.id
|
|
86862
|
-
)}&facet=rank&status=accepted&status=provisionally%20accepted&limit=0`
|
|
86863
|
-
);
|
|
86864
|
-
return keyBy(get(res, "data.facets.rank", []), "value");
|
|
86865
|
-
};
|
|
86866
86881
|
const getData = async () => {
|
|
86867
86882
|
setLoading(true);
|
|
86868
86883
|
try {
|
|
86869
|
-
const counts = await getOverView();
|
|
86870
|
-
const ranks2 = canonicalRanks;
|
|
86871
|
-
let taxonRankIdx = ranks2.indexOf(get(taxon, "name.rank"));
|
|
86872
|
-
if (taxonRankIdx === -1) {
|
|
86873
|
-
let rankIndex2 = rank.indexOf(get(taxon, "name.rank")) + 1;
|
|
86874
|
-
while (taxonRankIdx === -1 && rankIndex2 < rank.length - 1) {
|
|
86875
|
-
const canonicalRankIndex = ranks2.indexOf(rank[rankIndex2]);
|
|
86876
|
-
if (canonicalRankIndex > -1) {
|
|
86877
|
-
taxonRankIdx = canonicalRankIndex - 1;
|
|
86878
|
-
}
|
|
86879
|
-
rankIndex2++;
|
|
86880
|
-
}
|
|
86881
|
-
}
|
|
86882
|
-
let childRank;
|
|
86883
|
-
let childRankIndex = taxonRankIdx + 1;
|
|
86884
|
-
while (!childRank && childRankIndex < ranks2.length) {
|
|
86885
|
-
const nextRank = get(ranks2, `[${childRankIndex}]`);
|
|
86886
|
-
if (nextRank && get(counts, `${nextRank}.count`, 0) > 0) {
|
|
86887
|
-
childRank = nextRank;
|
|
86888
|
-
} else {
|
|
86889
|
-
childRankIndex++;
|
|
86890
|
-
}
|
|
86891
|
-
}
|
|
86892
|
-
if (!childRank) {
|
|
86893
|
-
setInvalid(true);
|
|
86894
|
-
setLoading(false);
|
|
86895
|
-
return;
|
|
86896
|
-
}
|
|
86897
86884
|
const res = await client(
|
|
86898
|
-
`${config.dataApi}dataset/${datasetKey}/taxon/${
|
|
86885
|
+
`${config.dataApi}dataset/${datasetKey}/taxon/${encodeURIComponent(
|
|
86886
|
+
taxon.id
|
|
86887
|
+
)}/breakdown?level=${activeLevel}`
|
|
86899
86888
|
);
|
|
86900
|
-
const
|
|
86901
|
-
const totalSpecies = get(counts, "species.count", 0);
|
|
86889
|
+
const bd = res.data || {};
|
|
86902
86890
|
setLoading(false);
|
|
86903
|
-
|
|
86891
|
+
if (!bd.countRank || !bd.children || bd.children.length === 0) {
|
|
86892
|
+
setInvalid(true);
|
|
86893
|
+
return;
|
|
86894
|
+
}
|
|
86895
|
+
setInvalid(false);
|
|
86896
|
+
buildChart(bd);
|
|
86904
86897
|
} catch (err) {
|
|
86905
86898
|
setLoading(false);
|
|
86899
|
+
setInvalid(true);
|
|
86906
86900
|
}
|
|
86907
86901
|
};
|
|
86908
|
-
const buildChart = (children,
|
|
86902
|
+
const buildChart = ({ children, total, countRank }) => {
|
|
86903
|
+
const seriesName = startCase(countRank === "genus" ? "genera" : countRank);
|
|
86909
86904
|
const DOI = dataset.doi ? "https://doi.org/" + dataset.doi : null;
|
|
86910
86905
|
const baseColors = Highcharts.getOptions().colors;
|
|
86911
86906
|
const prefersDark = typeof darkMode === "boolean" ? darkMode : typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
@@ -86917,33 +86912,33 @@ html body {
|
|
|
86917
86912
|
}
|
|
86918
86913
|
}
|
|
86919
86914
|
};
|
|
86920
|
-
const innerNodes =
|
|
86915
|
+
const innerNodes = ringNodes(children, total);
|
|
86921
86916
|
const innerData = innerNodes.map((n2, i) => ({
|
|
86922
86917
|
name: n2.name,
|
|
86923
|
-
y: n2.
|
|
86918
|
+
y: n2.count,
|
|
86924
86919
|
_id: n2.id,
|
|
86925
86920
|
color: baseColors[i % baseColors.length],
|
|
86926
86921
|
_kids: n2.children
|
|
86927
86922
|
}));
|
|
86928
86923
|
const outerData = [];
|
|
86929
|
-
const hasOuterData =
|
|
86924
|
+
const hasOuterData = innerData.some((s) => s._kids && s._kids.length > 0);
|
|
86930
86925
|
if (hasOuterData) {
|
|
86931
86926
|
innerData.forEach((slice2) => {
|
|
86932
|
-
const sorted =
|
|
86933
|
-
const sum = sorted.reduce((a, n2) => a + (n2.
|
|
86927
|
+
const sorted = (slice2._kids || []).filter((n2) => n2.id).sort((a, b2) => (b2.count || 0) - (a.count || 0)).slice(0, MAX_SLICES_PER_RING);
|
|
86928
|
+
const sum = sorted.reduce((a, n2) => a + (n2.count || 0), 0);
|
|
86934
86929
|
sorted.forEach((g2, j2) => {
|
|
86935
86930
|
const t2 = sorted.length > 1 ? j2 / (sorted.length - 1) : 0;
|
|
86936
86931
|
const shift = -0.1 + t2 * 0.4;
|
|
86937
86932
|
outerData.push({
|
|
86938
86933
|
name: g2.name,
|
|
86939
|
-
y: g2.
|
|
86934
|
+
y: g2.count,
|
|
86940
86935
|
_id: g2.id,
|
|
86941
86936
|
color: Highcharts.color(slice2.color).brighten(shift).get()
|
|
86942
86937
|
});
|
|
86943
86938
|
});
|
|
86944
86939
|
if (sum < slice2.y) {
|
|
86945
86940
|
outerData.push({
|
|
86946
|
-
name: notAssignedLabel(get(
|
|
86941
|
+
name: notAssignedLabel(get(slice2._kids, "[0].rank", "")),
|
|
86947
86942
|
y: slice2.y - sum,
|
|
86948
86943
|
color: gapColor,
|
|
86949
86944
|
borderColor: gapColor,
|
|
@@ -86954,7 +86949,7 @@ html body {
|
|
|
86954
86949
|
});
|
|
86955
86950
|
}
|
|
86956
86951
|
const clean = (rows) => rows.map(({ _kids, ...rest }) => rest);
|
|
86957
|
-
const grandTotal =
|
|
86952
|
+
const grandTotal = total || innerData.reduce((a, s) => a + s.y, 0);
|
|
86958
86953
|
const innerLabelStyle = {
|
|
86959
86954
|
color: "contrast",
|
|
86960
86955
|
textOutline: "1px contrast",
|
|
@@ -86968,12 +86963,12 @@ html body {
|
|
|
86968
86963
|
style: innerLabelStyle
|
|
86969
86964
|
} : {
|
|
86970
86965
|
formatter: function() {
|
|
86971
|
-
return this.y >
|
|
86966
|
+
return this.y > 0 ? "<b>" + this.point.name + ":</b> " + this.y.toLocaleString("en-GB") : null;
|
|
86972
86967
|
}
|
|
86973
86968
|
};
|
|
86974
86969
|
const series = [
|
|
86975
86970
|
{
|
|
86976
|
-
name:
|
|
86971
|
+
name: seriesName,
|
|
86977
86972
|
data: clean(innerData),
|
|
86978
86973
|
size: hasOuterData ? "60%" : "85%",
|
|
86979
86974
|
dataLabels: innerDataLabels,
|
|
@@ -86982,13 +86977,13 @@ html body {
|
|
|
86982
86977
|
];
|
|
86983
86978
|
if (hasOuterData) {
|
|
86984
86979
|
series.push({
|
|
86985
|
-
name:
|
|
86980
|
+
name: seriesName,
|
|
86986
86981
|
data: outerData,
|
|
86987
86982
|
size: "85%",
|
|
86988
86983
|
innerSize: "60%",
|
|
86989
86984
|
dataLabels: {
|
|
86990
86985
|
formatter: function() {
|
|
86991
|
-
return this.y >
|
|
86986
|
+
return this.y > 0 ? "<b>" + this.point.name + ":</b> " + this.y.toLocaleString("en-GB") : null;
|
|
86992
86987
|
}
|
|
86993
86988
|
},
|
|
86994
86989
|
point: { events: taxonClickHandler }
|
|
@@ -87049,6 +87044,14 @@ html body {
|
|
|
87049
87044
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(HighchartsReact, { highcharts: Highcharts, options })
|
|
87050
87045
|
] });
|
|
87051
87046
|
};
|
|
87047
|
+
const groupBySource = (secondarySources) => Object.values(
|
|
87048
|
+
Object.entries(secondarySources || {}).reduce((groups, [key2, src]) => {
|
|
87049
|
+
const id = `${src.datasetKey}:${src.id}`;
|
|
87050
|
+
groups[id] = groups[id] || { id, src, keys: [] };
|
|
87051
|
+
groups[id].keys.push(key2);
|
|
87052
|
+
return groups;
|
|
87053
|
+
}, {})
|
|
87054
|
+
);
|
|
87052
87055
|
const SecondarySources = ({ info, datasetKey }) => {
|
|
87053
87056
|
var _a2, _b2;
|
|
87054
87057
|
const [datasets, setDatasets] = reactExports.useState({});
|
|
@@ -87076,20 +87079,20 @@ html body {
|
|
|
87076
87079
|
}
|
|
87077
87080
|
setDatasets(data);
|
|
87078
87081
|
};
|
|
87079
|
-
return ((_a2 = info == null ? void 0 : info.source) == null ? void 0 : _a2.secondarySources) ?
|
|
87080
|
-
var _a3
|
|
87082
|
+
return ((_a2 = info == null ? void 0 : info.source) == null ? void 0 : _a2.secondarySources) ? groupBySource((_b2 = info == null ? void 0 : info.source) == null ? void 0 : _b2.secondarySources).map(({ id, src, keys: keys2 }) => {
|
|
87083
|
+
var _a3;
|
|
87081
87084
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(React.Fragment, { children: [
|
|
87082
|
-
startCase(key2),
|
|
87085
|
+
keys2.map((key2) => startCase(key2)).join(", "),
|
|
87083
87086
|
":",
|
|
87084
87087
|
" ",
|
|
87085
87088
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
87086
87089
|
"a",
|
|
87087
87090
|
{
|
|
87088
|
-
href: `https://www.checklistbank.org/dataset/${
|
|
87089
|
-
children: ((
|
|
87091
|
+
href: `https://www.checklistbank.org/dataset/${src.datasetKey}/taxon/${encodeURIComponent(src.id)}`,
|
|
87092
|
+
children: ((_a3 = datasets[src.datasetKey]) == null ? void 0 : _a3.title) || src.datasetKey
|
|
87090
87093
|
}
|
|
87091
87094
|
)
|
|
87092
|
-
] },
|
|
87095
|
+
] }, id);
|
|
87093
87096
|
}) : null;
|
|
87094
87097
|
};
|
|
87095
87098
|
staticMethods.config({
|
|
@@ -88582,15 +88585,24 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
|
|
|
88582
88585
|
(res) => this.setState({ rank: res.data.map((r2) => r2.name) })
|
|
88583
88586
|
);
|
|
88584
88587
|
});
|
|
88588
|
+
// Accepted descendants by rank. Read from the taxon metrics, a single row
|
|
88589
|
+
// lookup; only datasets without metrics (projects) fall back to a rank
|
|
88590
|
+
// facet search, which costs elasticsearch a lot more.
|
|
88585
88591
|
__publicField(this, "getIncludes", (taxonKey) => {
|
|
88586
88592
|
const { datasetKey } = this.props;
|
|
88587
|
-
|
|
88588
|
-
|
|
88589
|
-
|
|
88590
|
-
|
|
88591
|
-
|
|
88592
|
-
|
|
88593
|
-
|
|
88593
|
+
const base = `${config.dataApi}dataset/${datasetKey}`;
|
|
88594
|
+
client(`${base}/taxon/${encodeURIComponent(taxonKey)}/metrics`).then(
|
|
88595
|
+
(res) => Object.entries(get(res, "data.taxaByRankCount") || {}).map(
|
|
88596
|
+
([value, count]) => ({ value, count })
|
|
88597
|
+
)
|
|
88598
|
+
).catch(
|
|
88599
|
+
() => client(
|
|
88600
|
+
`${base}/nameusage/search?TAXON_ID=${encodeURIComponent(
|
|
88601
|
+
taxonKey
|
|
88602
|
+
)}&facet=rank&facetLimit=500&status=accepted&status=provisionally%20accepted&limit=0`
|
|
88603
|
+
).then((res) => get(res, "data.facets.rank") || [])
|
|
88604
|
+
).then((includes2) => {
|
|
88605
|
+
this.setState({ includesLoading: false, includes: includes2 });
|
|
88594
88606
|
}).catch((err) => {
|
|
88595
88607
|
this.setState({
|
|
88596
88608
|
includesLoading: false,
|
|
@@ -88919,12 +88931,11 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
|
|
|
88919
88931
|
{
|
|
88920
88932
|
taxon,
|
|
88921
88933
|
datasetKey,
|
|
88922
|
-
rank,
|
|
88923
88934
|
dataset: catalogue,
|
|
88924
88935
|
showLevelSwitch: true
|
|
88925
88936
|
}
|
|
88926
88937
|
) }),
|
|
88927
|
-
!isSynonym &&
|
|
88938
|
+
!isSynonym && rank && taxon && includes2.some((t2) => t2.value !== get(taxon, "name.rank")) && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Statistics", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
88928
88939
|
IncludesTable,
|
|
88929
88940
|
{
|
|
88930
88941
|
style: { marginTop: "-3px", marginLeft: "-3px" },
|
|
@@ -90007,29 +90018,21 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
|
|
|
90007
90018
|
setAuth(auth);
|
|
90008
90019
|
const [taxon, setTaxon] = reactExports.useState(null);
|
|
90009
90020
|
const [dataset, setDataset] = reactExports.useState(null);
|
|
90010
|
-
const [rank, setRank] = reactExports.useState([]);
|
|
90011
90021
|
reactExports.useEffect(() => {
|
|
90012
90022
|
if (taxonId && datasetKey) getTaxon();
|
|
90013
|
-
if (datasetKey)
|
|
90014
|
-
getDataset2();
|
|
90015
|
-
getRank();
|
|
90016
|
-
}
|
|
90023
|
+
if (datasetKey) getDataset2();
|
|
90017
90024
|
}, [taxonId, datasetKey]);
|
|
90018
|
-
const getRank = () => client(`${config.dataApi}vocab/rank`).then(
|
|
90019
|
-
(res) => setRank(res.data.map((r2) => r2.name))
|
|
90020
|
-
);
|
|
90021
90025
|
const getTaxon = () => client(`${config.dataApi}dataset/${datasetKey}/taxon/${taxonId}`).then(
|
|
90022
90026
|
(res) => setTaxon(res.data)
|
|
90023
90027
|
);
|
|
90024
90028
|
const getDataset2 = () => client(`${config.dataApi}dataset/${datasetKey}`).then(
|
|
90025
90029
|
(res) => setDataset(res.data)
|
|
90026
90030
|
);
|
|
90027
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(RouterContext.Provider, { value: buildRouter(routerProps), children: !!taxon && !!dataset
|
|
90031
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(RouterContext.Provider, { value: buildRouter(routerProps), children: !!taxon && !!dataset ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
90028
90032
|
TaxonBreakdown$1,
|
|
90029
90033
|
{
|
|
90030
90034
|
taxon,
|
|
90031
90035
|
datasetKey,
|
|
90032
|
-
rank,
|
|
90033
90036
|
dataset,
|
|
90034
90037
|
level,
|
|
90035
90038
|
showLevelSwitch,
|