@genspectrum/dashboard-components 0.8.2 → 0.8.4
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/custom-elements.json +3 -3
- package/dist/dashboard-components.js +207 -214
- package/dist/dashboard-components.js.map +1 -1
- package/dist/genspectrum-components.d.ts +13 -12
- package/dist/style.css +47 -49
- package/package.json +7 -1
- package/src/preact/components/chart.tsx +7 -13
- package/src/preact/mutationFilter/mutation-filter.stories.tsx +95 -11
- package/src/preact/mutationFilter/mutation-filter.tsx +178 -175
- package/src/preact/mutationFilter/parseAndValidateMutation.ts +1 -1
- package/src/preact/mutationsOverTime/mutations-over-time-grid.tsx +5 -35
- package/src/web-components/input/gs-mutation-filter.stories.ts +12 -2
- package/src/web-components/input/gs-mutation-filter.tsx +3 -2
- package/standalone-bundle/dashboard-components.js +9843 -9856
- package/standalone-bundle/dashboard-components.js.map +1 -1
|
@@ -1001,21 +1001,20 @@ const GsChart = ({ configuration }) => {
|
|
|
1001
1001
|
return;
|
|
1002
1002
|
}
|
|
1003
1003
|
chartRef.current = new Chart(ctx, configuration);
|
|
1004
|
-
resizeChartAfterFullscreenChange(
|
|
1004
|
+
const resizeChartAfterFullscreenChange = () => {
|
|
1005
|
+
var _a;
|
|
1006
|
+
(_a = chartRef.current) == null ? void 0 : _a.destroy();
|
|
1007
|
+
chartRef.current = new Chart(ctx, configuration);
|
|
1008
|
+
};
|
|
1009
|
+
document.addEventListener("fullscreenchange", resizeChartAfterFullscreenChange);
|
|
1005
1010
|
return () => {
|
|
1006
1011
|
var _a;
|
|
1012
|
+
document.removeEventListener("fullscreenchange", resizeChartAfterFullscreenChange);
|
|
1007
1013
|
(_a = chartRef.current) == null ? void 0 : _a.destroy();
|
|
1008
1014
|
};
|
|
1009
1015
|
}, [canvasRef, configuration]);
|
|
1010
1016
|
return /* @__PURE__ */ u$1("canvas", { ref: canvasRef });
|
|
1011
1017
|
};
|
|
1012
|
-
const resizeChartAfterFullscreenChange = (chartRef, ctx, configuration) => {
|
|
1013
|
-
document.addEventListener("fullscreenchange", () => {
|
|
1014
|
-
var _a;
|
|
1015
|
-
(_a = chartRef.current) == null ? void 0 : _a.destroy();
|
|
1016
|
-
chartRef.current = new Chart(ctx, configuration);
|
|
1017
|
-
});
|
|
1018
|
-
};
|
|
1019
1018
|
Chart.register(...registerables, VennDiagramController, ArcSlice);
|
|
1020
1019
|
const MutationComparisonVenn = ({
|
|
1021
1020
|
data,
|
|
@@ -2195,7 +2194,7 @@ const tailwindStyle = `*, ::before, ::after {
|
|
|
2195
2194
|
--tw-contain-paint: ;
|
|
2196
2195
|
--tw-contain-style: ;
|
|
2197
2196
|
}/*
|
|
2198
|
-
! tailwindcss v3.4.
|
|
2197
|
+
! tailwindcss v3.4.15 | MIT License | https://tailwindcss.com
|
|
2199
2198
|
*//*
|
|
2200
2199
|
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
|
2201
2200
|
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
|
@@ -4742,15 +4741,15 @@ input.tab:checked + .tab-content,
|
|
|
4742
4741
|
.mt-4 {
|
|
4743
4742
|
margin-top: 1rem;
|
|
4744
4743
|
}
|
|
4745
|
-
.inline-block {
|
|
4746
|
-
display: inline-block;
|
|
4747
|
-
}
|
|
4748
4744
|
.inline {
|
|
4749
4745
|
display: inline;
|
|
4750
4746
|
}
|
|
4751
4747
|
.flex {
|
|
4752
4748
|
display: flex;
|
|
4753
4749
|
}
|
|
4750
|
+
.inline-flex {
|
|
4751
|
+
display: inline-flex;
|
|
4752
|
+
}
|
|
4754
4753
|
.table {
|
|
4755
4754
|
display: table;
|
|
4756
4755
|
}
|
|
@@ -4820,6 +4819,9 @@ input.tab:checked + .tab-content,
|
|
|
4820
4819
|
--tw-translate-y: -50%;
|
|
4821
4820
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
4822
4821
|
}
|
|
4822
|
+
.cursor-pointer {
|
|
4823
|
+
cursor: pointer;
|
|
4824
|
+
}
|
|
4823
4825
|
.resize {
|
|
4824
4826
|
resize: both;
|
|
4825
4827
|
}
|
|
@@ -4868,9 +4870,6 @@ input.tab:checked + .tab-content,
|
|
|
4868
4870
|
.break-words {
|
|
4869
4871
|
overflow-wrap: break-word;
|
|
4870
4872
|
}
|
|
4871
|
-
.rounded-full {
|
|
4872
|
-
border-radius: 9999px;
|
|
4873
|
-
}
|
|
4874
4873
|
.rounded-lg {
|
|
4875
4874
|
border-radius: 0.5rem;
|
|
4876
4875
|
}
|
|
@@ -4899,43 +4898,41 @@ input.tab:checked + .tab-content,
|
|
|
4899
4898
|
.border-b-2 {
|
|
4900
4899
|
border-bottom-width: 2px;
|
|
4901
4900
|
}
|
|
4902
|
-
.border-solid {
|
|
4903
|
-
border-style: solid;
|
|
4904
|
-
}
|
|
4905
|
-
.border-none {
|
|
4906
|
-
border-style: none;
|
|
4907
|
-
}
|
|
4908
4901
|
.border-error {
|
|
4909
4902
|
--tw-border-opacity: 1;
|
|
4910
|
-
border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity)));
|
|
4903
|
+
border-color: var(--fallback-er,oklch(var(--er)/var(--tw-border-opacity, 1)));
|
|
4911
4904
|
}
|
|
4912
4905
|
.border-gray-100 {
|
|
4913
4906
|
--tw-border-opacity: 1;
|
|
4914
|
-
border-color: rgb(243 244 246 / var(--tw-border-opacity));
|
|
4907
|
+
border-color: rgb(243 244 246 / var(--tw-border-opacity, 1));
|
|
4915
4908
|
}
|
|
4916
4909
|
.border-gray-200 {
|
|
4917
4910
|
--tw-border-opacity: 1;
|
|
4918
|
-
border-color: rgb(229 231 235 / var(--tw-border-opacity));
|
|
4911
|
+
border-color: rgb(229 231 235 / var(--tw-border-opacity, 1));
|
|
4919
4912
|
}
|
|
4920
4913
|
.border-gray-300 {
|
|
4921
4914
|
--tw-border-opacity: 1;
|
|
4922
|
-
border-color: rgb(209 213 219 / var(--tw-border-opacity));
|
|
4915
|
+
border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
|
|
4923
4916
|
}
|
|
4924
4917
|
.border-gray-400 {
|
|
4925
4918
|
--tw-border-opacity: 1;
|
|
4926
|
-
border-color: rgb(156 163 175 / var(--tw-border-opacity));
|
|
4919
|
+
border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));
|
|
4927
4920
|
}
|
|
4928
|
-
.border-
|
|
4921
|
+
.border-slate-500 {
|
|
4929
4922
|
--tw-border-opacity: 1;
|
|
4930
|
-
border-color: rgb(
|
|
4923
|
+
border-color: rgb(100 116 139 / var(--tw-border-opacity, 1));
|
|
4931
4924
|
}
|
|
4932
4925
|
.bg-red-200 {
|
|
4933
4926
|
--tw-bg-opacity: 1;
|
|
4934
|
-
background-color: rgb(254 202 202 / var(--tw-bg-opacity));
|
|
4927
|
+
background-color: rgb(254 202 202 / var(--tw-bg-opacity, 1));
|
|
4928
|
+
}
|
|
4929
|
+
.bg-slate-200 {
|
|
4930
|
+
--tw-bg-opacity: 1;
|
|
4931
|
+
background-color: rgb(226 232 240 / var(--tw-bg-opacity, 1));
|
|
4935
4932
|
}
|
|
4936
4933
|
.bg-white {
|
|
4937
4934
|
--tw-bg-opacity: 1;
|
|
4938
|
-
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
|
4935
|
+
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
|
|
4939
4936
|
}
|
|
4940
4937
|
.p-1 {
|
|
4941
4938
|
padding: 0.25rem;
|
|
@@ -4946,10 +4943,6 @@ input.tab:checked + .tab-content,
|
|
|
4946
4943
|
.p-4 {
|
|
4947
4944
|
padding: 1rem;
|
|
4948
4945
|
}
|
|
4949
|
-
.px-2 {
|
|
4950
|
-
padding-left: 0.5rem;
|
|
4951
|
-
padding-right: 0.5rem;
|
|
4952
|
-
}
|
|
4953
4946
|
.px-4 {
|
|
4954
4947
|
padding-left: 1rem;
|
|
4955
4948
|
padding-right: 1rem;
|
|
@@ -5014,23 +5007,27 @@ input.tab:checked + .tab-content,
|
|
|
5014
5007
|
}
|
|
5015
5008
|
.text-\\[\\#606060\\] {
|
|
5016
5009
|
--tw-text-opacity: 1;
|
|
5017
|
-
color: rgb(96 96 96 / var(--tw-text-opacity));
|
|
5010
|
+
color: rgb(96 96 96 / var(--tw-text-opacity, 1));
|
|
5011
|
+
}
|
|
5012
|
+
.text-black {
|
|
5013
|
+
--tw-text-opacity: 1;
|
|
5014
|
+
color: rgb(0 0 0 / var(--tw-text-opacity, 1));
|
|
5018
5015
|
}
|
|
5019
5016
|
.text-blue-600 {
|
|
5020
5017
|
--tw-text-opacity: 1;
|
|
5021
|
-
color: rgb(37 99 235 / var(--tw-text-opacity));
|
|
5018
|
+
color: rgb(37 99 235 / var(--tw-text-opacity, 1));
|
|
5022
5019
|
}
|
|
5023
5020
|
.text-gray-600 {
|
|
5024
5021
|
--tw-text-opacity: 1;
|
|
5025
|
-
color: rgb(75 85 99 / var(--tw-text-opacity));
|
|
5022
|
+
color: rgb(75 85 99 / var(--tw-text-opacity, 1));
|
|
5026
5023
|
}
|
|
5027
5024
|
.text-neutral-500 {
|
|
5028
5025
|
--tw-text-opacity: 1;
|
|
5029
|
-
color: rgb(115 115 115 / var(--tw-text-opacity));
|
|
5026
|
+
color: rgb(115 115 115 / var(--tw-text-opacity, 1));
|
|
5030
5027
|
}
|
|
5031
5028
|
.text-red-700 {
|
|
5032
5029
|
--tw-text-opacity: 1;
|
|
5033
|
-
color: rgb(185 28 28 / var(--tw-text-opacity));
|
|
5030
|
+
color: rgb(185 28 28 / var(--tw-text-opacity, 1));
|
|
5034
5031
|
}
|
|
5035
5032
|
.underline {
|
|
5036
5033
|
text-decoration-line: underline;
|
|
@@ -5060,6 +5057,9 @@ input.tab:checked + .tab-content,
|
|
|
5060
5057
|
.duration-150 {
|
|
5061
5058
|
transition-duration: 150ms;
|
|
5062
5059
|
}
|
|
5060
|
+
.\\@container {
|
|
5061
|
+
container-type: inline-size;
|
|
5062
|
+
}
|
|
5063
5063
|
.mdi--fullscreen {
|
|
5064
5064
|
--svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='black' d='M5 5h5v2H7v3H5zm9 0h5v5h-2V7h-3zm3 9h2v5h-5v-2h3zm-7 3v2H5v-5h2v3z'/%3E%3C/svg%3E");
|
|
5065
5065
|
}
|
|
@@ -5088,10 +5088,6 @@ input.tab:checked + .tab-content,
|
|
|
5088
5088
|
border-bottom-left-radius: var(--rounded-box, 1rem);
|
|
5089
5089
|
}
|
|
5090
5090
|
}
|
|
5091
|
-
.focus-within\\:border-gray-400:focus-within {
|
|
5092
|
-
--tw-border-opacity: 1;
|
|
5093
|
-
border-color: rgb(156 163 175 / var(--tw-border-opacity));
|
|
5094
|
-
}
|
|
5095
5091
|
.hover\\:scale-110:hover {
|
|
5096
5092
|
--tw-scale-x: 1.1;
|
|
5097
5093
|
--tw-scale-y: 1.1;
|
|
@@ -5104,39 +5100,40 @@ input.tab:checked + .tab-content,
|
|
|
5104
5100
|
}
|
|
5105
5101
|
.hover\\:bg-gray-100:hover {
|
|
5106
5102
|
--tw-bg-opacity: 1;
|
|
5107
|
-
background-color: rgb(243 244 246 / var(--tw-bg-opacity));
|
|
5103
|
+
background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
|
|
5104
|
+
}
|
|
5105
|
+
.hover\\:bg-gray-300:hover {
|
|
5106
|
+
--tw-bg-opacity: 1;
|
|
5107
|
+
background-color: rgb(209 213 219 / var(--tw-bg-opacity, 1));
|
|
5108
5108
|
}
|
|
5109
5109
|
.hover\\:font-bold:hover {
|
|
5110
5110
|
font-weight: 700;
|
|
5111
5111
|
}
|
|
5112
5112
|
.hover\\:text-blue-700:hover {
|
|
5113
5113
|
--tw-text-opacity: 1;
|
|
5114
|
-
color: rgb(29 78 216 / var(--tw-text-opacity));
|
|
5114
|
+
color: rgb(29 78 216 / var(--tw-text-opacity, 1));
|
|
5115
5115
|
}
|
|
5116
5116
|
.hover\\:text-blue-800:hover {
|
|
5117
5117
|
--tw-text-opacity: 1;
|
|
5118
|
-
color: rgb(30 64 175 / var(--tw-text-opacity));
|
|
5118
|
+
color: rgb(30 64 175 / var(--tw-text-opacity, 1));
|
|
5119
5119
|
}
|
|
5120
5120
|
.hover\\:text-gray-400:hover {
|
|
5121
5121
|
--tw-text-opacity: 1;
|
|
5122
|
-
color: rgb(156 163 175 / var(--tw-text-opacity));
|
|
5122
|
+
color: rgb(156 163 175 / var(--tw-text-opacity, 1));
|
|
5123
5123
|
}
|
|
5124
5124
|
.hover\\:text-gray-700:hover {
|
|
5125
5125
|
--tw-text-opacity: 1;
|
|
5126
|
-
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
5127
|
-
}
|
|
5128
|
-
.focus\\:outline-none:focus {
|
|
5129
|
-
outline: 2px solid transparent;
|
|
5130
|
-
outline-offset: 2px;
|
|
5131
|
-
}
|
|
5132
|
-
.focus\\:ring-0:focus {
|
|
5133
|
-
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
5134
|
-
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
5135
|
-
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
5126
|
+
color: rgb(55 65 81 / var(--tw-text-opacity, 1));
|
|
5136
5127
|
}
|
|
5137
5128
|
.peer:hover ~ .peer-hover\\:visible {
|
|
5138
5129
|
visibility: visible;
|
|
5139
5130
|
}
|
|
5131
|
+
@container (min-width: 30rem) {
|
|
5132
|
+
|
|
5133
|
+
.\\@\\[30rem\\]\\:visible {
|
|
5134
|
+
visibility: visible;
|
|
5135
|
+
}
|
|
5136
|
+
}
|
|
5140
5137
|
@media (min-width: 640px) {
|
|
5141
5138
|
|
|
5142
5139
|
.sm\\:max-w-5xl {
|
|
@@ -8801,9 +8798,7 @@ const MutationsOverTimeGrid = ({ data, colorScale }) => {
|
|
|
8801
8798
|
const allMutations = data.getFirstAxisKeys();
|
|
8802
8799
|
const shownMutations = allMutations.slice(0, MAX_NUMBER_OF_GRID_ROWS);
|
|
8803
8800
|
const dates = data.getSecondAxisKeys();
|
|
8804
|
-
const [showProportionText, setShowProportionText] = h(false);
|
|
8805
8801
|
const gridRef = A(null);
|
|
8806
|
-
useShowProportion(gridRef, dates.length, setShowProportionText);
|
|
8807
8802
|
return /* @__PURE__ */ u$1(Fragment, { children: [
|
|
8808
8803
|
allMutations.length > MAX_NUMBER_OF_GRID_ROWS && /* @__PURE__ */ u$1("div", { className: "pl-2", children: [
|
|
8809
8804
|
"Showing ",
|
|
@@ -8822,6 +8817,7 @@ const MutationsOverTimeGrid = ({ data, colorScale }) => {
|
|
|
8822
8817
|
gridTemplateRows: `repeat(${shownMutations.length}, 24px)`,
|
|
8823
8818
|
gridTemplateColumns: `${MUTATION_CELL_WIDTH_REM}rem repeat(${dates.length}, minmax(0.05rem, 1fr))`
|
|
8824
8819
|
},
|
|
8820
|
+
className: "@container",
|
|
8825
8821
|
children: shownMutations.map((mutation, rowIndex) => {
|
|
8826
8822
|
return /* @__PURE__ */ u$1(Fragment, { children: [
|
|
8827
8823
|
/* @__PURE__ */ u$1(
|
|
@@ -8851,7 +8847,6 @@ const MutationsOverTimeGrid = ({ data, colorScale }) => {
|
|
|
8851
8847
|
date,
|
|
8852
8848
|
mutation,
|
|
8853
8849
|
tooltipPosition,
|
|
8854
|
-
showProportionText,
|
|
8855
8850
|
colorScale
|
|
8856
8851
|
}
|
|
8857
8852
|
)
|
|
@@ -8865,30 +8860,12 @@ const MutationsOverTimeGrid = ({ data, colorScale }) => {
|
|
|
8865
8860
|
)
|
|
8866
8861
|
] });
|
|
8867
8862
|
};
|
|
8868
|
-
function useShowProportion(gridRef, girdColumns, setShowProportionText) {
|
|
8869
|
-
y(() => {
|
|
8870
|
-
const checkWidth = () => {
|
|
8871
|
-
if (gridRef.current) {
|
|
8872
|
-
const width = gridRef.current.getBoundingClientRect().width;
|
|
8873
|
-
const widthPerDate = (width - remToPx(MUTATION_CELL_WIDTH_REM)) / girdColumns;
|
|
8874
|
-
const maxWidthProportionText = 28;
|
|
8875
|
-
setShowProportionText(widthPerDate > maxWidthProportionText);
|
|
8876
|
-
}
|
|
8877
|
-
};
|
|
8878
|
-
checkWidth();
|
|
8879
|
-
window.addEventListener("resize", checkWidth);
|
|
8880
|
-
return () => {
|
|
8881
|
-
window.removeEventListener("resize", checkWidth);
|
|
8882
|
-
};
|
|
8883
|
-
}, [girdColumns, gridRef, setShowProportionText]);
|
|
8884
|
-
}
|
|
8885
|
-
const remToPx = (rem) => rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
8886
8863
|
function getTooltipPosition(rowIndex, rows, columnIndex, columns) {
|
|
8887
8864
|
const tooltipX = rowIndex < rows / 2 ? "bottom" : "top";
|
|
8888
8865
|
const tooltipY = columnIndex < columns / 2 ? "start" : "end";
|
|
8889
8866
|
return `${tooltipX}-${tooltipY}`;
|
|
8890
8867
|
}
|
|
8891
|
-
const ProportionCell = ({ value, mutation, date, tooltipPosition,
|
|
8868
|
+
const ProportionCell = ({ value, mutation, date, tooltipPosition, colorScale }) => {
|
|
8892
8869
|
const dateClass = toTemporalClass(date);
|
|
8893
8870
|
const tooltipContent = /* @__PURE__ */ u$1("div", { children: [
|
|
8894
8871
|
/* @__PURE__ */ u$1("p", { children: /* @__PURE__ */ u$1("span", { className: "font-bold", children: dateClass.englishName() }) }),
|
|
@@ -8918,7 +8895,7 @@ const ProportionCell = ({ value, mutation, date, tooltipPosition, showProportion
|
|
|
8918
8895
|
color: getTextColorForScale(value.proportion, colorScale)
|
|
8919
8896
|
},
|
|
8920
8897
|
className: `w-full h-full text-center hover:font-bold text-xs group`,
|
|
8921
|
-
children:
|
|
8898
|
+
children: /* @__PURE__ */ u$1("span", { className: "invisible @[30rem]:visible", children: formatProportion(value.proportion, 0) })
|
|
8922
8899
|
}
|
|
8923
8900
|
) }) });
|
|
8924
8901
|
};
|
|
@@ -10013,31 +9990,19 @@ const MutationFilterInner = ({ initialValue }) => {
|
|
|
10013
9990
|
const [selectedFilters, setSelectedFilters] = h(
|
|
10014
9991
|
getInitialState(initialValue, referenceGenome)
|
|
10015
9992
|
);
|
|
10016
|
-
const
|
|
10017
|
-
const
|
|
10018
|
-
|
|
10019
|
-
const handleSubmit = (event) => {
|
|
10020
|
-
event.preventDefault();
|
|
10021
|
-
if (inputValue === "") {
|
|
10022
|
-
return;
|
|
10023
|
-
}
|
|
10024
|
-
const parsedMutation = parseAndValidateMutation(inputValue, referenceGenome);
|
|
10025
|
-
if (parsedMutation === null) {
|
|
10026
|
-
setIsError(true);
|
|
10027
|
-
return;
|
|
10028
|
-
}
|
|
10029
|
-
const newSelectedValues = {
|
|
9993
|
+
const filterRef = A(null);
|
|
9994
|
+
const handleRemoveValue = (option) => {
|
|
9995
|
+
const newSelectedFilters = {
|
|
10030
9996
|
...selectedFilters,
|
|
10031
|
-
[
|
|
9997
|
+
[option.type]: selectedFilters[option.type].filter((i2) => option.value.toString() != i2.toString())
|
|
10032
9998
|
};
|
|
10033
|
-
setSelectedFilters(
|
|
10034
|
-
fireChangeEvent(
|
|
10035
|
-
setInputValue("");
|
|
9999
|
+
setSelectedFilters(newSelectedFilters);
|
|
10000
|
+
fireChangeEvent(newSelectedFilters);
|
|
10036
10001
|
};
|
|
10037
10002
|
const fireChangeEvent = (selectedFilters2) => {
|
|
10038
10003
|
var _a;
|
|
10039
10004
|
const detail = mapToMutationFilterStrings(selectedFilters2);
|
|
10040
|
-
(_a =
|
|
10005
|
+
(_a = filterRef.current) == null ? void 0 : _a.dispatchEvent(
|
|
10041
10006
|
new CustomEvent("gs-mutation-filter-changed", {
|
|
10042
10007
|
detail,
|
|
10043
10008
|
bubbles: true,
|
|
@@ -10045,38 +10010,25 @@ const MutationFilterInner = ({ initialValue }) => {
|
|
|
10045
10010
|
})
|
|
10046
10011
|
);
|
|
10047
10012
|
};
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
};
|
|
10052
|
-
return /* @__PURE__ */ u$1("form", { className: "w-full border boder-gray-300 rounded-md relative", onSubmit: handleSubmit, ref: formRef, children: [
|
|
10053
|
-
/* @__PURE__ */ u$1("div", { className: "absolute -top-3 -right-3", children: /* @__PURE__ */ u$1(MutationFilterInfo, {}) }),
|
|
10054
|
-
/* @__PURE__ */ u$1("div", { className: "w-full flex p-2 flex-wrap items-center", children: [
|
|
10013
|
+
return /* @__PURE__ */ u$1("div", { className: "w-full border border-gray-300 rounded-md relative", ref: filterRef, children: [
|
|
10014
|
+
/* @__PURE__ */ u$1("div", { className: "absolute -top-3 -right-3 z-10", children: /* @__PURE__ */ u$1(MutationFilterInfo, {}) }),
|
|
10015
|
+
/* @__PURE__ */ u$1("div", { className: "relative w-full p-1", children: [
|
|
10055
10016
|
/* @__PURE__ */ u$1(
|
|
10056
|
-
|
|
10017
|
+
MutationFilterSelector,
|
|
10057
10018
|
{
|
|
10058
|
-
|
|
10059
|
-
setSelectedFilters
|
|
10060
|
-
|
|
10019
|
+
referenceGenome,
|
|
10020
|
+
setSelectedFilters: (newSelectedFilters) => {
|
|
10021
|
+
setSelectedFilters(newSelectedFilters);
|
|
10022
|
+
fireChangeEvent(newSelectedFilters);
|
|
10023
|
+
},
|
|
10024
|
+
selectedFilters
|
|
10061
10025
|
}
|
|
10062
10026
|
),
|
|
10063
10027
|
/* @__PURE__ */ u$1(
|
|
10064
|
-
|
|
10028
|
+
SelectedMutationFilterDisplay,
|
|
10065
10029
|
{
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
/* @__PURE__ */ u$1(
|
|
10069
|
-
"input",
|
|
10070
|
-
{
|
|
10071
|
-
className: "grow flex-1 p-1 border-none focus:outline-none focus:ring-0",
|
|
10072
|
-
type: "text",
|
|
10073
|
-
value: inputValue,
|
|
10074
|
-
onInput: handleInputChange,
|
|
10075
|
-
placeholder: getPlaceholder(referenceGenome)
|
|
10076
|
-
}
|
|
10077
|
-
),
|
|
10078
|
-
/* @__PURE__ */ u$1("button", { type: "submit", className: "btn btn-xs m-1", children: "+" })
|
|
10079
|
-
]
|
|
10030
|
+
selectedFilters,
|
|
10031
|
+
handleRemoveValue
|
|
10080
10032
|
}
|
|
10081
10033
|
)
|
|
10082
10034
|
] })
|
|
@@ -10111,123 +10063,164 @@ function getInitialState(initialValue, referenceGenome) {
|
|
|
10111
10063
|
}
|
|
10112
10064
|
);
|
|
10113
10065
|
}
|
|
10066
|
+
const MutationFilterSelector = ({ referenceGenome, setSelectedFilters, selectedFilters }) => {
|
|
10067
|
+
const [option, setOption] = h(null);
|
|
10068
|
+
const [inputValue, setInputValue] = h("");
|
|
10069
|
+
const selectorRef = A(null);
|
|
10070
|
+
const handleInputChange = (newValue) => {
|
|
10071
|
+
if (newValue.includes(",") || newValue.includes(";")) {
|
|
10072
|
+
handleCommaSeparatedInput(newValue);
|
|
10073
|
+
} else {
|
|
10074
|
+
setInputValue(newValue);
|
|
10075
|
+
const result = parseAndValidateMutation(newValue, referenceGenome);
|
|
10076
|
+
setOption(result);
|
|
10077
|
+
}
|
|
10078
|
+
};
|
|
10079
|
+
const handleCommaSeparatedInput = (inputValue2) => {
|
|
10080
|
+
const inputValues = inputValue2.split(/[,;]/);
|
|
10081
|
+
let newSelectedOptions = selectedFilters;
|
|
10082
|
+
let updated = false;
|
|
10083
|
+
const invalidQueries = [];
|
|
10084
|
+
for (const value of inputValues) {
|
|
10085
|
+
const trimmedValue = value.trim();
|
|
10086
|
+
const parsedMutation = parseAndValidateMutation(trimmedValue, referenceGenome);
|
|
10087
|
+
if (parsedMutation) {
|
|
10088
|
+
const type = parsedMutation.type;
|
|
10089
|
+
if (!selectedFilters[type].some((i2) => parsedMutation.value.toString() === i2.toString())) {
|
|
10090
|
+
newSelectedOptions = {
|
|
10091
|
+
...newSelectedOptions,
|
|
10092
|
+
[parsedMutation.type]: [...newSelectedOptions[parsedMutation.type], parsedMutation.value]
|
|
10093
|
+
};
|
|
10094
|
+
updated = true;
|
|
10095
|
+
}
|
|
10096
|
+
} else {
|
|
10097
|
+
invalidQueries.push(trimmedValue);
|
|
10098
|
+
}
|
|
10099
|
+
}
|
|
10100
|
+
setInputValue(invalidQueries.join(","));
|
|
10101
|
+
if (updated) {
|
|
10102
|
+
setSelectedFilters(newSelectedOptions);
|
|
10103
|
+
setOption(null);
|
|
10104
|
+
}
|
|
10105
|
+
};
|
|
10106
|
+
const handleOptionClick = () => {
|
|
10107
|
+
if (option === null) {
|
|
10108
|
+
return;
|
|
10109
|
+
}
|
|
10110
|
+
const type = option.type;
|
|
10111
|
+
if (!selectedFilters[type].some((i2) => option.value.toString() === i2.toString())) {
|
|
10112
|
+
const newSelectedValues = {
|
|
10113
|
+
...selectedFilters,
|
|
10114
|
+
[option == null ? void 0 : option.type]: [...selectedFilters[option == null ? void 0 : option.type], option == null ? void 0 : option.value]
|
|
10115
|
+
};
|
|
10116
|
+
setSelectedFilters(newSelectedValues);
|
|
10117
|
+
}
|
|
10118
|
+
setInputValue("");
|
|
10119
|
+
setOption(null);
|
|
10120
|
+
};
|
|
10121
|
+
const handleEnterPress = (event) => {
|
|
10122
|
+
if (event.key === "Enter" && option !== null) {
|
|
10123
|
+
handleOptionClick();
|
|
10124
|
+
}
|
|
10125
|
+
};
|
|
10126
|
+
const handleBlur = (event) => {
|
|
10127
|
+
var _a;
|
|
10128
|
+
if (!((_a = selectorRef.current) == null ? void 0 : _a.contains(event.relatedTarget))) {
|
|
10129
|
+
setOption(null);
|
|
10130
|
+
}
|
|
10131
|
+
};
|
|
10132
|
+
return /* @__PURE__ */ u$1("div", { ref: selectorRef, tabIndex: -1, children: [
|
|
10133
|
+
/* @__PURE__ */ u$1(
|
|
10134
|
+
"input",
|
|
10135
|
+
{
|
|
10136
|
+
type: "text",
|
|
10137
|
+
className: "w-full p-2 border-gray-300 border rounded-md",
|
|
10138
|
+
placeholder: getPlaceholder(referenceGenome),
|
|
10139
|
+
value: inputValue,
|
|
10140
|
+
onInput: (e2) => {
|
|
10141
|
+
handleInputChange(e2.target.value);
|
|
10142
|
+
},
|
|
10143
|
+
onKeyDown: (e2) => handleEnterPress(e2),
|
|
10144
|
+
onFocus: () => handleInputChange(inputValue),
|
|
10145
|
+
onBlur: handleBlur
|
|
10146
|
+
}
|
|
10147
|
+
),
|
|
10148
|
+
option != null && /* @__PURE__ */ u$1(
|
|
10149
|
+
"div",
|
|
10150
|
+
{
|
|
10151
|
+
role: "option",
|
|
10152
|
+
className: "hover:bg-gray-300 absolute cursor-pointer p-2 border-1 border-slate-500 bg-slate-200",
|
|
10153
|
+
onClick: () => handleOptionClick(),
|
|
10154
|
+
children: option.value.toString()
|
|
10155
|
+
}
|
|
10156
|
+
)
|
|
10157
|
+
] });
|
|
10158
|
+
};
|
|
10114
10159
|
function getPlaceholder(referenceGenome) {
|
|
10115
10160
|
const segmentPrefix = referenceGenome.nucleotideSequences.length > 1 ? `${referenceGenome.nucleotideSequences[0].name}:` : "";
|
|
10116
10161
|
const firstGene = referenceGenome.genes[0].name;
|
|
10117
10162
|
return `Enter a mutation (e.g. ${segmentPrefix}A123T, ins_${segmentPrefix}123:AT, ${firstGene}:M123E, ins_${firstGene}:123:ME)`;
|
|
10118
10163
|
}
|
|
10119
|
-
const
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10164
|
+
const backgroundColor = {
|
|
10165
|
+
aminoAcidMutations: singleGraphColorRGBByName("teal", 0.4),
|
|
10166
|
+
nucleotideMutations: singleGraphColorRGBByName("green", 0.4),
|
|
10167
|
+
aminoAcidInsertions: singleGraphColorRGBByName("purple", 0.4),
|
|
10168
|
+
nucleotideInsertions: singleGraphColorRGBByName("indigo", 0.4)
|
|
10169
|
+
};
|
|
10170
|
+
const backgroundColorMap = (data) => {
|
|
10171
|
+
return backgroundColor[data.type] || "lightgray";
|
|
10172
|
+
};
|
|
10173
|
+
const SelectedMutationFilterDisplay = ({ selectedFilters, handleRemoveValue }) => {
|
|
10174
|
+
return /* @__PURE__ */ u$1("div", { className: "flex flex-wrap", children: [
|
|
10129
10175
|
selectedFilters.nucleotideMutations.map((mutation) => /* @__PURE__ */ u$1(
|
|
10130
|
-
|
|
10176
|
+
SelectedFilter,
|
|
10131
10177
|
{
|
|
10132
|
-
|
|
10133
|
-
|
|
10178
|
+
handleRemoveValue,
|
|
10179
|
+
mutationFilter: { type: "nucleotideMutations", value: mutation }
|
|
10134
10180
|
},
|
|
10135
10181
|
mutation.toString()
|
|
10136
10182
|
)),
|
|
10137
10183
|
selectedFilters.aminoAcidMutations.map((mutation) => /* @__PURE__ */ u$1(
|
|
10138
|
-
|
|
10184
|
+
SelectedFilter,
|
|
10139
10185
|
{
|
|
10140
|
-
|
|
10141
|
-
|
|
10186
|
+
handleRemoveValue,
|
|
10187
|
+
mutationFilter: { type: "aminoAcidMutations", value: mutation }
|
|
10142
10188
|
},
|
|
10143
10189
|
mutation.toString()
|
|
10144
10190
|
)),
|
|
10145
|
-
selectedFilters.nucleotideInsertions.map((
|
|
10146
|
-
|
|
10191
|
+
selectedFilters.nucleotideInsertions.map((mutation) => /* @__PURE__ */ u$1(
|
|
10192
|
+
SelectedFilter,
|
|
10147
10193
|
{
|
|
10148
|
-
|
|
10149
|
-
|
|
10194
|
+
handleRemoveValue,
|
|
10195
|
+
mutationFilter: { type: "nucleotideInsertions", value: mutation }
|
|
10150
10196
|
},
|
|
10151
|
-
|
|
10197
|
+
mutation.toString()
|
|
10152
10198
|
)),
|
|
10153
|
-
selectedFilters.aminoAcidInsertions.map((
|
|
10154
|
-
|
|
10199
|
+
selectedFilters.aminoAcidInsertions.map((mutation) => /* @__PURE__ */ u$1(
|
|
10200
|
+
SelectedFilter,
|
|
10155
10201
|
{
|
|
10156
|
-
|
|
10157
|
-
|
|
10202
|
+
handleRemoveValue,
|
|
10203
|
+
mutationFilter: { type: "aminoAcidInsertions", value: mutation }
|
|
10158
10204
|
},
|
|
10159
|
-
|
|
10205
|
+
mutation.toString()
|
|
10160
10206
|
))
|
|
10161
10207
|
] });
|
|
10162
10208
|
};
|
|
10163
|
-
const
|
|
10164
|
-
const backgroundColor = singleGraphColorRGBByName("teal", 0.3);
|
|
10165
|
-
const textColor = singleGraphColorRGBByName("teal", 1);
|
|
10166
|
-
return /* @__PURE__ */ u$1(
|
|
10167
|
-
SelectedFilter,
|
|
10168
|
-
{
|
|
10169
|
-
mutation: insertion,
|
|
10170
|
-
onDelete,
|
|
10171
|
-
backgroundColor,
|
|
10172
|
-
textColor
|
|
10173
|
-
}
|
|
10174
|
-
);
|
|
10175
|
-
};
|
|
10176
|
-
const SelectedAminoAcidMutation = ({ mutation, onDelete }) => {
|
|
10177
|
-
const backgroundColor = singleGraphColorRGBByName("rose", 0.3);
|
|
10178
|
-
const textColor = singleGraphColorRGBByName("rose", 1);
|
|
10179
|
-
return /* @__PURE__ */ u$1(
|
|
10180
|
-
SelectedFilter,
|
|
10181
|
-
{
|
|
10182
|
-
mutation,
|
|
10183
|
-
onDelete,
|
|
10184
|
-
backgroundColor,
|
|
10185
|
-
textColor
|
|
10186
|
-
}
|
|
10187
|
-
);
|
|
10188
|
-
};
|
|
10189
|
-
const SelectedNucleotideMutation = ({ mutation, onDelete }) => {
|
|
10190
|
-
const backgroundColor = singleGraphColorRGBByName("indigo", 0.3);
|
|
10191
|
-
const textColor = singleGraphColorRGBByName("indigo", 1);
|
|
10192
|
-
return /* @__PURE__ */ u$1(
|
|
10193
|
-
SelectedFilter,
|
|
10194
|
-
{
|
|
10195
|
-
mutation,
|
|
10196
|
-
onDelete,
|
|
10197
|
-
backgroundColor,
|
|
10198
|
-
textColor
|
|
10199
|
-
}
|
|
10200
|
-
);
|
|
10201
|
-
};
|
|
10202
|
-
const SelectedNucleotideInsertion = ({ insertion, onDelete }) => {
|
|
10203
|
-
const backgroundColor = singleGraphColorRGBByName("green", 0.3);
|
|
10204
|
-
const textColor = singleGraphColorRGBByName("green", 1);
|
|
10205
|
-
return /* @__PURE__ */ u$1(
|
|
10206
|
-
SelectedFilter,
|
|
10207
|
-
{
|
|
10208
|
-
mutation: insertion,
|
|
10209
|
-
onDelete,
|
|
10210
|
-
backgroundColor,
|
|
10211
|
-
textColor
|
|
10212
|
-
}
|
|
10213
|
-
);
|
|
10214
|
-
};
|
|
10215
|
-
const SelectedFilter = ({
|
|
10216
|
-
mutation,
|
|
10217
|
-
onDelete,
|
|
10218
|
-
backgroundColor,
|
|
10219
|
-
textColor
|
|
10220
|
-
}) => {
|
|
10209
|
+
const SelectedFilter = ({ handleRemoveValue, mutationFilter }) => {
|
|
10221
10210
|
return /* @__PURE__ */ u$1(
|
|
10222
10211
|
"span",
|
|
10223
10212
|
{
|
|
10224
|
-
|
|
10225
|
-
|
|
10213
|
+
name: mutationFilter.value.toString(),
|
|
10214
|
+
className: "center p-2 m-1 inline-flex text-black rounded-md",
|
|
10215
|
+
style: {
|
|
10216
|
+
backgroundColor: backgroundColorMap(mutationFilter)
|
|
10217
|
+
},
|
|
10226
10218
|
children: [
|
|
10227
|
-
|
|
10228
|
-
/* @__PURE__ */ u$1("button", { className: "ml-1",
|
|
10219
|
+
mutationFilter.value.toString(),
|
|
10220
|
+
/* @__PURE__ */ u$1("button", { className: "ml-1", onClick: () => handleRemoveValue(mutationFilter), children: "×" })
|
|
10229
10221
|
]
|
|
10230
|
-
}
|
|
10222
|
+
},
|
|
10223
|
+
mutationFilter.value.toString()
|
|
10231
10224
|
);
|
|
10232
10225
|
};
|
|
10233
10226
|
function mapToMutationFilterStrings(selectedFilters) {
|