import { Component, createMemo, For, Match, Switch } from "solid-js";
import { ErrorNotification } from "./ErrorNotification";
type AlleleType = "breakend" | "missing" | "symbolic" | "nucs";
export const Allele: Component<{ value: string | null; isAbbreviate: boolean }> = (props) => {
const type = createMemo((): AlleleType => {
const value = props.value;
let type: AlleleType;
if (value === null) type = "missing";
else if (value.startsWith("<") && value.endsWith(">")) type = "symbolic";
else if (value.indexOf("[") !== -1 || value.indexOf("]") !== -1 || value.indexOf(".") !== -1) type = "breakend";
else type = "nucs";
return type;
});
return (
}>
);
};
const AlleleBreakend: Component<{ value: string }> = (props) => {
return {props.value};
};
const AlleleMissing: Component = () => {
return ?;
};
const AlleleSymbolic: Component<{ value: string }> = (props) => {
return {props.value};
};
const Nucs: Component<{ bases: string[] }> = (props) => {
return (
{(base) => (
{base}
)}
);
};
const AlleleNucs: Component<{ values: string[]; isAbbreviate: boolean }> = (props) => {
const abbreviate = (): boolean => props.values.length > 4 && props.isAbbreviate;
const nucs = (): string[] => {
let nucs = props.values;
if (abbreviate()) {
const lastNuc = nucs[nucs.length - 1] as string;
nucs = nucs.slice(0, 2);
nucs.push("\u2026"); // ellipsis
nucs.push(lastNuc);
}
return nucs;
};
return (
<>
{abbreviate() ? (
) : (
)}
>
);
};