synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
76 lines (75 loc) • 2.02 kB
JavaScript
import { jsx as r, Fragment as i } from "react/jsx-runtime";
import { PRODUCTION_ENDPOINT_CONFIG as h } from "../../utils/functions/getEndpoint.js";
import { Link as g } from "@mui/material";
import { TargetEnum as u } from "../../utils/html/TargetEnum.js";
import { bioregistryRules as d } from "./BioregistryRules.js";
const p = {
regex: new RegExp("((?:(?<=\\s)|^)syn\\d+)"),
onMatch: (e) => `${h.PORTAL}Synapse:${e}`
}, R = {
regex: /(http:\/\/[^ ",]+)/,
onMatch: (e) => e
}, m = {
regex: /(https:\/\/[^ ",]+)/,
onMatch: (e) => e
}, M = {
regex: /(ftp:\/\/[^ ",]+)/,
onMatch: (e) => e
}, x = {
regex: /(PMID:\d+)/,
onMatch: (e) => `https://pubmed.ncbi.nlm.nih.gov/${e.slice(5)}`
}, f = {
regex: /(MGI:\d+)/,
onMatch: (e) => `https://www.informatics.jax.org/allele/${e}`
}, C = {
regex: /(AB_\d+)|(Addgene_\d+)|(CVCL_[a-zA-Z0-9]+)|(MMRRC_\d+-.{3})|(IMSR_JAX:\d+)/,
onMatch: (e) => `https://scicrunch.org/resolver/${e}`
}, V = {
regex: /(ClinVar:VCV\d+)/,
onMatch: (e) => `https://www.ncbi.nlm.nih.gov/clinvar/variation/${e.slice(8)}`
}, v = {
regex: /(ClinVar:RCV\d+)/,
onMatch: (e) => `https://www.ncbi.nlm.nih.gov/clinvar/${e.slice(8)}`
}, w = {
regex: /(arXiv:[a-zA-Z0-9.]+)/,
onMatch: (e) => `https://arxiv.org/abs/${e.slice(6)}`
}, I = {
regex: /(rrid:[a-zA-Z]+.+)/,
onMatch: (e) => `https://bioregistry.io/${e}`
}, s = [
R,
m,
M,
p,
I,
x,
C,
f,
V,
v,
w,
...d
], $ = s.map((e) => e.regex.source).join("|"), b = new RegExp($, "g");
function D({ text: e, className: t }) {
if (e == null)
return /* @__PURE__ */ r(i, {});
const c = e.split(b);
return /* @__PURE__ */ r(i, { children: c.map((n, l) => {
const o = s.find((a) => a.regex.test(n));
return o ? /* @__PURE__ */ r(
g,
{
href: o.onMatch(n),
target: u.NEW_WINDOW,
rel: "noopener noreferrer",
className: t,
children: n
},
l
) : n;
}) });
}
export {
D as default
};
//# sourceMappingURL=Linkify.js.map