synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
104 lines (103 loc) • 2.53 kB
JavaScript
import l from "dayjs";
const N = 10, u = 60, c = u * 60, a = c * 24, E = a * 7, A = a * 30, y = a * 365, d = [
{ id: "ANY_TIME", label: "Any Time", range: null },
{ id: "PAST_HOUR", label: "Past Hour", range: c },
{ id: "PAST_DAY", label: "Past 24 Hours", range: a },
{ id: "PAST_WEEK", label: "Past Week", range: E },
{ id: "PAST_MONTH", label: "Past Month", range: A },
{ id: "PAST_YEAR", label: "Past Year", range: y }
], f = {
node_type: "Entity Type",
modified_by: "Last Modified By"
}, g = [
"node_type",
"consortium",
"disease",
"modified_on",
"modified_by",
"created_on",
"tissue",
"num_samples",
"created_by"
], T = [
"modified_by",
"created_by",
"ModifiedBy",
"CreatedBy"
], m = {
node_type: "Entity Types",
consortium: "Consortiums",
disease: "Diseases",
tissue: "Tissues",
num_samples: "Num Samples",
modified_by: "Last Modified By",
created_by: "Created By"
};
function I(e) {
return `All ${m[e] || _(e)}`;
}
function M(e, t) {
if (!t || t.trim() === "")
return !1;
const n = (e === "node_type" || e === "EntityType") && t === "link", s = t.includes(":");
return !n && !s;
}
const b = (e) => {
const t = e.toLowerCase().replace(/_/g, "");
return T.some(
(n) => n.toLowerCase().replace(/_/g, "") === t
);
};
function _(e) {
return e.replace(/_/g, " ").replace(/\b\w/g, (t) => t.toUpperCase());
}
function C(e) {
return f[e] || _(e);
}
function P(e) {
return !(!e.constraints || e.constraints.length === 0);
}
function p(e) {
const t = parseInt(e);
if (!t)
return "ANY_TIME";
const n = l().unix() - t;
return n <= 0 ? "ANY_TIME" : d.filter(
(o) => o.id !== "ANY_TIME"
).reduce(
(o, i) => Math.abs(n - i.range) < Math.abs(n - o.range) ? i : o
).id;
}
function R(e) {
const t = parseInt(e);
if (isNaN(t))
return e;
if (t === 0)
return "any time";
const n = p(e), s = d.find((r) => r.id === n);
if (s && s.id !== "ANY_TIME")
return s.label;
try {
const r = t * 1e3;
return new Date(r).toLocaleDateString();
} catch {
return e;
}
}
export {
f as FACET_DISPLAY_NAMES,
g as FACET_DISPLAY_ORDER,
m as FACET_PLURAL_DISPLAY_NAMES,
N as MAX_FACET_VALUES_SHOWN,
T as USER_FACET_NAMES,
_ as formatFacetName,
R as formatTimeRangeDisplayValue,
I as getAllFacetLabel,
C as getFacetDisplayName,
p as getSelectedTimeRangeId,
b as isUserFacet,
P as shouldRenderFacet,
M as shouldShowFacetValue,
d as timeRanges
};
//# sourceMappingURL=SearchFacetPanelUtils.js.map