col-browser 2.2.0 → 2.2.2
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 +1 -1
- package/es/chunks/DatasetlogoWithFallback-B9WXvNCA.js +24 -0
- package/es/chunks/DatasetlogoWithFallback-B9WXvNCA.js.map +1 -0
- package/es/chunks/{Distributions-CXIEJ6e6.js → Distributions-Cwl_75VG.js} +349 -348
- package/es/chunks/{Distributions-CXIEJ6e6.js.map → Distributions-Cwl_75VG.js.map} +1 -1
- package/es/chunks/{MetricsPresentation-U_CO8JoH.js → MetricsPresentation-DKCJQOtf.js} +2 -2
- package/es/chunks/{MetricsPresentation-U_CO8JoH.js.map → MetricsPresentation-DKCJQOtf.js.map} +1 -1
- package/es/chunks/{DatasetlogoWithFallback-CbP7vRs_.js → PresentationItem-C4yZ555-.js} +243 -262
- package/es/chunks/PresentationItem-C4yZ555-.js.map +1 -0
- package/es/chunks/index-BmhRLlZh.js +100 -0
- package/es/chunks/index-BmhRLlZh.js.map +1 -0
- package/es/index.js +1 -1
- package/es/routing.js +1 -1
- package/es/sourceDataset.js +57 -56
- package/es/sourceDataset.js.map +1 -1
- package/es/sourceDatasetList.js +5 -4
- package/es/sourceDatasetList.js.map +1 -1
- package/es/taxon.js +18 -12
- package/es/taxon.js.map +1 -1
- package/es/taxonDistribution.js +1 -1
- package/es/tree.js +60 -57
- package/es/tree.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +13 -0
- package/umd/col-browser.js +150 -134
- package/umd/col-browser.js.map +1 -1
- package/umd/col-browser.min.js +5 -5
- package/umd/col-browser.min.js.map +1 -1
- package/es/chunks/DatasetlogoWithFallback-CbP7vRs_.js.map +0 -1
- package/es/chunks/index-CNK3JADR.js +0 -95
- package/es/chunks/index-CNK3JADR.js.map +0 -1
package/umd/col-browser.js
CHANGED
|
@@ -68681,7 +68681,10 @@ html body {
|
|
|
68681
68681
|
rootTotal,
|
|
68682
68682
|
rootLoading: false,
|
|
68683
68683
|
treeData: [...this.state.treeData, ...treeData],
|
|
68684
|
-
|
|
68684
|
+
// Nothing is auto-expanded by default. Consumers open a specific root
|
|
68685
|
+
// (or deep taxon) by passing `defaultTaxonKey`/`expandedTaxonKey` —
|
|
68686
|
+
// e.g. defaultTaxonKey="CS5HF" opens Eukaryota in current COL releases.
|
|
68687
|
+
expandedKeys: [],
|
|
68685
68688
|
error: null
|
|
68686
68689
|
},
|
|
68687
68690
|
() => {
|
|
@@ -77770,6 +77773,84 @@ html body {
|
|
|
77770
77773
|
] });
|
|
77771
77774
|
}
|
|
77772
77775
|
}
|
|
77776
|
+
const styles$1 = {
|
|
77777
|
+
tip: {
|
|
77778
|
+
color: "rgba(0,0,0,.45)",
|
|
77779
|
+
marginLeft: "4px"
|
|
77780
|
+
},
|
|
77781
|
+
icon: {
|
|
77782
|
+
marginTop: "4px"
|
|
77783
|
+
}
|
|
77784
|
+
};
|
|
77785
|
+
const Help = ({ title, classes }) => {
|
|
77786
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(React.Fragment, { children: title && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: classes.tip, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { title, getPopupContainer: () => document.getElementsByClassName(`catalogue-of-life`)[0], children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$k, { className: classes.icon }) }) }) });
|
|
77787
|
+
};
|
|
77788
|
+
const Help$1 = createWithStyles(styles$1)(Help);
|
|
77789
|
+
const styles = {
|
|
77790
|
+
formItem: {
|
|
77791
|
+
paddingBottom: 0,
|
|
77792
|
+
width: "100%",
|
|
77793
|
+
clear: "both",
|
|
77794
|
+
borderBottom: "1px solid #eee",
|
|
77795
|
+
"&:last-of-type": {
|
|
77796
|
+
border: "none"
|
|
77797
|
+
},
|
|
77798
|
+
"&>div": {
|
|
77799
|
+
paddingLeft: 10,
|
|
77800
|
+
paddingRight: 10
|
|
77801
|
+
}
|
|
77802
|
+
},
|
|
77803
|
+
label: {
|
|
77804
|
+
display: "block",
|
|
77805
|
+
color: "rgba(0, 0, 0, 0.85)"
|
|
77806
|
+
},
|
|
77807
|
+
content: {
|
|
77808
|
+
wordBreak: "break-word",
|
|
77809
|
+
marginBottom: 0
|
|
77810
|
+
},
|
|
77811
|
+
noContent: {
|
|
77812
|
+
wordBreak: "break-word",
|
|
77813
|
+
color: "#bbb",
|
|
77814
|
+
marginBottom: 0
|
|
77815
|
+
},
|
|
77816
|
+
contentCol: {
|
|
77817
|
+
wordBreak: "break-word"
|
|
77818
|
+
},
|
|
77819
|
+
smallMargin: {
|
|
77820
|
+
marginBottom: 3,
|
|
77821
|
+
marginTop: 3
|
|
77822
|
+
},
|
|
77823
|
+
mediumMargin: {
|
|
77824
|
+
marginBottom: 10,
|
|
77825
|
+
marginTop: 10
|
|
77826
|
+
}
|
|
77827
|
+
};
|
|
77828
|
+
const PresentationItem = ({ label, helpText, classes, children, width, md: md2, size }) => {
|
|
77829
|
+
const getValue2 = () => {
|
|
77830
|
+
let value;
|
|
77831
|
+
if (Array.isArray(children) && children.length > 0) {
|
|
77832
|
+
value = children.map((item, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: classes.content, children: item }, i));
|
|
77833
|
+
} else if (!Array.isArray(children) && typeof children !== "undefined") {
|
|
77834
|
+
value = /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: classes.content, children });
|
|
77835
|
+
}
|
|
77836
|
+
return value;
|
|
77837
|
+
};
|
|
77838
|
+
const medium = md2 || 8;
|
|
77839
|
+
const mediumCol2 = medium < 24 ? 24 - medium : 24;
|
|
77840
|
+
const marginSize = size === "medium" ? classes.mediumMargin : classes.smallMargin;
|
|
77841
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Row, { className: classes.formItem, children: [
|
|
77842
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Col, { sm: 24, md: medium, style: width < MEDIUM ? { marginBottom: 0 } : {}, className: marginSize, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("dt", { className: classes.label, children: [
|
|
77843
|
+
label,
|
|
77844
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Help$1, { title: helpText })
|
|
77845
|
+
] }) }) }),
|
|
77846
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Col, { sm: 24, md: mediumCol2, style: width < MEDIUM ? { marginTop: 0 } : {}, className: marginSize, children: getValue2() })
|
|
77847
|
+
] });
|
|
77848
|
+
};
|
|
77849
|
+
PresentationItem.propTypes = {
|
|
77850
|
+
label: PropTypes.string.isRequired,
|
|
77851
|
+
helpText: PropTypes.object
|
|
77852
|
+
};
|
|
77853
|
+
const PresentationItem$1 = withWidth()(createWithStyles(styles)(PresentationItem));
|
|
77773
77854
|
const INFRASPECIFIC_RANKS = [
|
|
77774
77855
|
"subspecies",
|
|
77775
77856
|
"variety",
|
|
@@ -78973,7 +79054,9 @@ html body {
|
|
|
78973
79054
|
showDistributionMap,
|
|
78974
79055
|
focalTaxon,
|
|
78975
79056
|
rankOrder,
|
|
78976
|
-
gbifChecklistKey
|
|
79057
|
+
gbifChecklistKey,
|
|
79058
|
+
label,
|
|
79059
|
+
md: md2
|
|
78977
79060
|
}) => {
|
|
78978
79061
|
const mappable = data.filter(isMappable);
|
|
78979
79062
|
const baseUnmappable = data.length - mappable.length;
|
|
@@ -79014,22 +79097,16 @@ html body {
|
|
|
79014
79097
|
const gbifAvailable = !hasGbifConfigured ? false : gbifCount === null || gbifCount > 0;
|
|
79015
79098
|
const allMappableFailed = mappable.length > 0 && fetchFailures >= mappable.length;
|
|
79016
79099
|
const showMap = showDistributionMap && (mappable.length > 0 || gbifAvailable) && !(mappable.length > 0 && allMappableFailed && !gbifAvailable);
|
|
79017
|
-
if (!showMap &&
|
|
79018
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: style2, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "#888" }, children: "No occurrence data on GBIF for this taxon." }) });
|
|
79019
|
-
}
|
|
79020
|
-
if (!showMap) {
|
|
79021
|
-
if (!hasAnyRecords) return null;
|
|
79022
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: style2, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListView, { datasetKey, data }) });
|
|
79023
|
-
}
|
|
79100
|
+
if (!showMap && !hasAnyRecords) return null;
|
|
79024
79101
|
const unmappable = baseUnmappable + fetchFailures;
|
|
79025
79102
|
const showToggle = hasAnyRecords;
|
|
79026
|
-
const activeView = showToggle ? view : "map";
|
|
79027
|
-
|
|
79103
|
+
const activeView = showMap && showToggle ? view : showMap ? "map" : "list";
|
|
79104
|
+
const body = activeView === "map" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
79028
79105
|
showToggle ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
79029
79106
|
Radio.Group,
|
|
79030
79107
|
{
|
|
79031
79108
|
size: "small",
|
|
79032
|
-
value:
|
|
79109
|
+
value: view,
|
|
79033
79110
|
onChange: (e2) => setView(e2.target.value),
|
|
79034
79111
|
style: { marginBottom: 8 },
|
|
79035
79112
|
children: [
|
|
@@ -79042,28 +79119,31 @@ html body {
|
|
|
79042
79119
|
// map's top edge lines up with the "Distributions" label.
|
|
79043
79120
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: 24, marginBottom: 8 } })
|
|
79044
79121
|
),
|
|
79045
|
-
|
|
79046
|
-
|
|
79047
|
-
|
|
79048
|
-
|
|
79049
|
-
|
|
79050
|
-
|
|
79051
|
-
|
|
79052
|
-
|
|
79053
|
-
|
|
79054
|
-
|
|
79055
|
-
|
|
79056
|
-
|
|
79057
|
-
|
|
79058
|
-
|
|
79059
|
-
|
|
79060
|
-
|
|
79061
|
-
|
|
79062
|
-
|
|
79063
|
-
|
|
79064
|
-
|
|
79065
|
-
|
|
79066
|
-
|
|
79122
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
79123
|
+
DistributionsMap,
|
|
79124
|
+
{
|
|
79125
|
+
records: mappable,
|
|
79126
|
+
onUnmappable: setFetchFailures,
|
|
79127
|
+
datasetKey,
|
|
79128
|
+
focalTaxon,
|
|
79129
|
+
rankOrder,
|
|
79130
|
+
gbifChecklistKey,
|
|
79131
|
+
gbifAvailable
|
|
79132
|
+
}
|
|
79133
|
+
),
|
|
79134
|
+
showToggle && unmappable > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginTop: 6 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("a", { onClick: () => setView("list"), style: { cursor: "pointer" }, children: [
|
|
79135
|
+
"+",
|
|
79136
|
+
unmappable,
|
|
79137
|
+
" distribution",
|
|
79138
|
+
unmappable === 1 ? "" : "s",
|
|
79139
|
+
" not on map"
|
|
79140
|
+
] }) })
|
|
79141
|
+
] }) : (
|
|
79142
|
+
// List view: either the user toggled to it, or there is no map to show.
|
|
79143
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ListView, { datasetKey, data })
|
|
79144
|
+
);
|
|
79145
|
+
const content = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: style2, children: body });
|
|
79146
|
+
return label ? /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md: md2, label, children: content }) : content;
|
|
79067
79147
|
};
|
|
79068
79148
|
const rankStyle = {
|
|
79069
79149
|
color: "rgba(0, 0, 0, 0.45)",
|
|
@@ -79080,84 +79160,6 @@ html body {
|
|
|
79080
79160
|
i < data.length - 1 && " >"
|
|
79081
79161
|
] }, t2.rank))
|
|
79082
79162
|
] });
|
|
79083
|
-
const styles$1 = {
|
|
79084
|
-
tip: {
|
|
79085
|
-
color: "rgba(0,0,0,.45)",
|
|
79086
|
-
marginLeft: "4px"
|
|
79087
|
-
},
|
|
79088
|
-
icon: {
|
|
79089
|
-
marginTop: "4px"
|
|
79090
|
-
}
|
|
79091
|
-
};
|
|
79092
|
-
const Help = ({ title, classes }) => {
|
|
79093
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(React.Fragment, { children: title && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: classes.tip, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { title, getPopupContainer: () => document.getElementsByClassName(`catalogue-of-life`)[0], children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$k, { className: classes.icon }) }) }) });
|
|
79094
|
-
};
|
|
79095
|
-
const Help$1 = createWithStyles(styles$1)(Help);
|
|
79096
|
-
const styles = {
|
|
79097
|
-
formItem: {
|
|
79098
|
-
paddingBottom: 0,
|
|
79099
|
-
width: "100%",
|
|
79100
|
-
clear: "both",
|
|
79101
|
-
borderBottom: "1px solid #eee",
|
|
79102
|
-
"&:last-of-type": {
|
|
79103
|
-
border: "none"
|
|
79104
|
-
},
|
|
79105
|
-
"&>div": {
|
|
79106
|
-
paddingLeft: 10,
|
|
79107
|
-
paddingRight: 10
|
|
79108
|
-
}
|
|
79109
|
-
},
|
|
79110
|
-
label: {
|
|
79111
|
-
display: "block",
|
|
79112
|
-
color: "rgba(0, 0, 0, 0.85)"
|
|
79113
|
-
},
|
|
79114
|
-
content: {
|
|
79115
|
-
wordBreak: "break-word",
|
|
79116
|
-
marginBottom: 0
|
|
79117
|
-
},
|
|
79118
|
-
noContent: {
|
|
79119
|
-
wordBreak: "break-word",
|
|
79120
|
-
color: "#bbb",
|
|
79121
|
-
marginBottom: 0
|
|
79122
|
-
},
|
|
79123
|
-
contentCol: {
|
|
79124
|
-
wordBreak: "break-word"
|
|
79125
|
-
},
|
|
79126
|
-
smallMargin: {
|
|
79127
|
-
marginBottom: 3,
|
|
79128
|
-
marginTop: 3
|
|
79129
|
-
},
|
|
79130
|
-
mediumMargin: {
|
|
79131
|
-
marginBottom: 10,
|
|
79132
|
-
marginTop: 10
|
|
79133
|
-
}
|
|
79134
|
-
};
|
|
79135
|
-
const PresentationItem = ({ label, helpText, classes, children, width, md: md2, size }) => {
|
|
79136
|
-
const getValue2 = () => {
|
|
79137
|
-
let value;
|
|
79138
|
-
if (Array.isArray(children) && children.length > 0) {
|
|
79139
|
-
value = children.map((item, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: classes.content, children: item }, i));
|
|
79140
|
-
} else if (!Array.isArray(children) && typeof children !== "undefined") {
|
|
79141
|
-
value = /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: classes.content, children });
|
|
79142
|
-
}
|
|
79143
|
-
return value;
|
|
79144
|
-
};
|
|
79145
|
-
const medium = md2 || 8;
|
|
79146
|
-
const mediumCol2 = medium < 24 ? 24 - medium : 24;
|
|
79147
|
-
const marginSize = size === "medium" ? classes.mediumMargin : classes.smallMargin;
|
|
79148
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Row, { className: classes.formItem, children: [
|
|
79149
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Col, { sm: 24, md: medium, style: width < MEDIUM ? { marginBottom: 0 } : {}, className: marginSize, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("dt", { className: classes.label, children: [
|
|
79150
|
-
label,
|
|
79151
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Help$1, { title: helpText })
|
|
79152
|
-
] }) }) }),
|
|
79153
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Col, { sm: 24, md: mediumCol2, style: width < MEDIUM ? { marginTop: 0 } : {}, className: marginSize, children: getValue2() })
|
|
79154
|
-
] });
|
|
79155
|
-
};
|
|
79156
|
-
PresentationItem.propTypes = {
|
|
79157
|
-
label: PropTypes.string.isRequired,
|
|
79158
|
-
helpText: PropTypes.object
|
|
79159
|
-
};
|
|
79160
|
-
const PresentationItem$1 = withWidth()(createWithStyles(styles)(PresentationItem));
|
|
79161
79163
|
const getLabel = (r2, reverse) => {
|
|
79162
79164
|
if (!reverse) {
|
|
79163
79165
|
switch (r2.type) {
|
|
@@ -87571,10 +87573,15 @@ html body {
|
|
|
87571
87573
|
datasetKey: taxon.datasetKey
|
|
87572
87574
|
}
|
|
87573
87575
|
) }),
|
|
87574
|
-
(get(info, "distributions") || showDistributionMap && gbifChecklistKey && taxon) &&
|
|
87576
|
+
(get(info, "distributions") || showDistributionMap && gbifChecklistKey && taxon) && // Distributions owns its labelled block so it can hide entirely
|
|
87577
|
+
// (label included) when there is nothing to show — including after
|
|
87578
|
+
// the async GBIF occurrence lookup comes back empty.
|
|
87579
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
87575
87580
|
DistributionsTable,
|
|
87576
87581
|
{
|
|
87577
87582
|
style: { marginTop: "-3px" },
|
|
87583
|
+
label: "Distributions",
|
|
87584
|
+
md,
|
|
87578
87585
|
data: (info == null ? void 0 : info.distributions) || [],
|
|
87579
87586
|
datasetKey,
|
|
87580
87587
|
showDistributionMap,
|
|
@@ -87582,7 +87589,7 @@ html body {
|
|
|
87582
87589
|
rankOrder: rank,
|
|
87583
87590
|
gbifChecklistKey
|
|
87584
87591
|
}
|
|
87585
|
-
)
|
|
87592
|
+
),
|
|
87586
87593
|
get(taxon, "environments") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Environment(s)", children: get(taxon, "environments").join(", ") }),
|
|
87587
87594
|
get(taxon, "remarks") && /* @__PURE__ */ jsxRuntimeExports.jsx(PresentationItem$1, { md, label: "Additional Data", children: taxon.remarks }),
|
|
87588
87595
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Row, { children: get(taxon, "accordingTo") && /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: 12, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(PresentationItem$1, { md: md * 2, label: "According to", children: [
|
|
@@ -89887,40 +89894,41 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
|
|
|
89887
89894
|
window.addEventListener(evt, cb);
|
|
89888
89895
|
return () => window.removeEventListener(evt, cb);
|
|
89889
89896
|
};
|
|
89890
|
-
const hrefFor = (mode, prefix2, args) => {
|
|
89897
|
+
const hrefFor = (mode, prefix2, args, reserved = {}) => {
|
|
89891
89898
|
if (!prefix2) return null;
|
|
89892
89899
|
const arg = args == null ? "" : typeof args === "object" ? "" : String(args);
|
|
89893
|
-
const
|
|
89900
|
+
const queryObj = typeof args === "object" && args ? { ...args, ...reserved } : { ...reserved };
|
|
89901
|
+
const tail = Object.keys(queryObj).length > 0 ? `?${queryString.stringify(queryObj, { arrayFormat: "none" })}` : "";
|
|
89894
89902
|
const url = `${prefix2}${arg}${tail}`;
|
|
89895
89903
|
return isHash(mode) ? `#${url}` : url;
|
|
89896
89904
|
};
|
|
89897
|
-
const navigate = (mode, navigation2, prefix2, args) => {
|
|
89905
|
+
const navigate = (mode, navigation2, prefix2, args, reserved = {}) => {
|
|
89898
89906
|
if (!prefix2) return;
|
|
89899
89907
|
if (navigation2 === "reload") {
|
|
89900
|
-
const url = hrefFor(mode, prefix2, args);
|
|
89908
|
+
const url = hrefFor(mode, prefix2, args, reserved);
|
|
89901
89909
|
if (url != null && typeof window !== "undefined") {
|
|
89902
89910
|
window.location.assign(url);
|
|
89903
89911
|
}
|
|
89904
89912
|
return;
|
|
89905
89913
|
}
|
|
89906
89914
|
let path = prefix2;
|
|
89907
|
-
let search = null;
|
|
89915
|
+
let search = Object.keys(reserved).length > 0 ? { ...reserved } : null;
|
|
89908
89916
|
if (typeof args === "string" || typeof args === "number") {
|
|
89909
89917
|
path = `${prefix2}${args}`;
|
|
89910
89918
|
} else if (args && typeof args === "object") {
|
|
89911
|
-
search = args;
|
|
89919
|
+
search = { ...search || {}, ...args };
|
|
89912
89920
|
}
|
|
89913
89921
|
writeLocation(mode, path, search);
|
|
89914
89922
|
};
|
|
89915
|
-
const buildNavProps = (mode, navigation2, paths) => ({
|
|
89916
|
-
hrefForTaxon: (id) => hrefFor(mode, paths.taxon, id),
|
|
89917
|
-
hrefForTree: (a) => hrefFor(mode, paths.tree, a),
|
|
89918
|
-
hrefForSearch: (a) => hrefFor(mode, paths.search, a),
|
|
89919
|
-
hrefForSource: (id) => hrefFor(mode, paths.source, id),
|
|
89920
|
-
onNavigateToTaxon: (id) => navigate(mode, navigation2, paths.taxon, id),
|
|
89921
|
-
onNavigateToTree: (a) => navigate(mode, navigation2, paths.tree, a),
|
|
89922
|
-
onNavigateToSearch: (a) => navigate(mode, navigation2, paths.search, a),
|
|
89923
|
-
onNavigateToSource: (id) => navigate(mode, navigation2, paths.source, id)
|
|
89923
|
+
const buildNavProps = (mode, navigation2, paths, reserved = {}) => ({
|
|
89924
|
+
hrefForTaxon: (id) => hrefFor(mode, paths.taxon, id, reserved),
|
|
89925
|
+
hrefForTree: (a) => hrefFor(mode, paths.tree, a, reserved),
|
|
89926
|
+
hrefForSearch: (a) => hrefFor(mode, paths.search, a, reserved),
|
|
89927
|
+
hrefForSource: (id) => hrefFor(mode, paths.source, id, reserved),
|
|
89928
|
+
onNavigateToTaxon: (id) => navigate(mode, navigation2, paths.taxon, id, reserved),
|
|
89929
|
+
onNavigateToTree: (a) => navigate(mode, navigation2, paths.tree, a, reserved),
|
|
89930
|
+
onNavigateToSearch: (a) => navigate(mode, navigation2, paths.search, a, reserved),
|
|
89931
|
+
onNavigateToSource: (id) => navigate(mode, navigation2, paths.source, id, reserved)
|
|
89924
89932
|
});
|
|
89925
89933
|
const lastSegmentAfter = (path, prefix2) => {
|
|
89926
89934
|
if (!prefix2) return void 0;
|
|
@@ -89932,12 +89940,20 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
|
|
|
89932
89940
|
return path.slice(prefix2.length).split("/").filter(Boolean).pop();
|
|
89933
89941
|
};
|
|
89934
89942
|
function withRouting(Component, options) {
|
|
89935
|
-
const { kind, mode = "path", navigation: navigation2 = "spa", paths = {} } = options;
|
|
89943
|
+
const { kind, mode = "path", navigation: navigation2 = "spa", paths = {}, query = "" } = options;
|
|
89944
|
+
const reserved = query ? queryString.parse(query) : {};
|
|
89945
|
+
const reservedKeys = Object.keys(reserved);
|
|
89946
|
+
const stripReserved = (obj) => {
|
|
89947
|
+
if (reservedKeys.length === 0) return obj;
|
|
89948
|
+
const out = { ...obj };
|
|
89949
|
+
for (const k of reservedKeys) delete out[k];
|
|
89950
|
+
return out;
|
|
89951
|
+
};
|
|
89936
89952
|
const Wrapped = (props) => {
|
|
89937
89953
|
const [tick, setTick] = reactExports.useState(0);
|
|
89938
89954
|
reactExports.useEffect(() => subscribe(mode, () => setTick((t2) => t2 + 1)), []);
|
|
89939
89955
|
const { path, search } = readLocationKind(mode);
|
|
89940
|
-
const navProps = reactExports.useMemo(() => buildNavProps(mode, navigation2, paths), []);
|
|
89956
|
+
const navProps = reactExports.useMemo(() => buildNavProps(mode, navigation2, paths, reserved), []);
|
|
89941
89957
|
let extra = {};
|
|
89942
89958
|
if (kind === "taxon") {
|
|
89943
89959
|
extra.taxonKey = lastSegmentAfter(path, paths.taxon);
|
|
@@ -89950,7 +89966,7 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
|
|
|
89950
89966
|
} else if (kind === "bibtex") {
|
|
89951
89967
|
extra.sourceDatasetKey = lastSegmentAfter(path, paths.bibtex);
|
|
89952
89968
|
} else if (kind === "tree") {
|
|
89953
|
-
const parsed = queryString.parse(search);
|
|
89969
|
+
const parsed = stripReserved(queryString.parse(search));
|
|
89954
89970
|
extra.expandedTaxonKey = parsed.taxonKey || void 0;
|
|
89955
89971
|
extra.onExpandedTaxonKeyChange = reactExports.useCallback((id) => {
|
|
89956
89972
|
const cur = readLocationKind(mode);
|
|
@@ -89960,11 +89976,11 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
|
|
|
89960
89976
|
writeLocation(mode, cur.path || paths.tree || "/", next2);
|
|
89961
89977
|
}, []);
|
|
89962
89978
|
} else if (kind === "search") {
|
|
89963
|
-
const parsed = queryString.parse(search, { arrayFormat: "none" });
|
|
89979
|
+
const parsed = stripReserved(queryString.parse(search, { arrayFormat: "none" }));
|
|
89964
89980
|
extra.filters = parsed;
|
|
89965
89981
|
extra.onFiltersChange = reactExports.useCallback((filters) => {
|
|
89966
89982
|
const cur = readLocationKind(mode);
|
|
89967
|
-
writeLocation(mode, cur.path || paths.search || "/", filters);
|
|
89983
|
+
writeLocation(mode, cur.path || paths.search || "/", { ...reserved, ...filters });
|
|
89968
89984
|
}, []);
|
|
89969
89985
|
}
|
|
89970
89986
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ...navProps, ...extra, ...props });
|