@genspectrum/dashboard-components 0.18.1 → 0.18.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.
@@ -7,7 +7,7 @@ import DOMPurify from "dompurify";
7
7
  import { useRef, Grid } from "gridjs";
8
8
  import { Chart, registerables, Scale, BarController } from "chart.js";
9
9
  import { VennDiagramController, ArcSlice, extractSets } from "chartjs-chart-venn";
10
- import { v as views, s as sequenceTypeSchema, n as namedLapisFilterSchema, l as lapisFilterSchema, t as temporalGranularitySchema, b as dateRangeValueSchema, c as dateRangeOptionSchema, e as toYYYYMMDD, D as DateRangeOptionChangedEvent, f as lapisLocationFilterSchema, L as LocationChangedEvent, T as TextFilterChangedEvent, m as mutationsFilterSchema, a as LineageFilterChangedEvent } from "./LineageFilterChangedEvent-DkvWdq_G.js";
10
+ import { v as views, s as sequenceTypeSchema, n as namedLapisFilterSchema, l as lapisFilterSchema, t as temporalGranularitySchema, b as dateRangeValueSchema, c as dateRangeOptionSchema, e as toYYYYMMDD, D as DateRangeOptionChangedEvent, f as lapisLocationFilterSchema, L as LocationChangedEvent, T as TextFilterChangedEvent, m as mutationsFilterSchema, a as LineageFilterChangedEvent } from "./LineageFilterChangedEvent-ixHQkq8y.js";
11
11
  import { autoUpdate, computePosition, offset, shift, flip } from "@floating-ui/dom";
12
12
  import { ReactiveElement } from "@lit/reactive-element";
13
13
  import { BarWithErrorBarsController, BarWithErrorBar } from "chartjs-chart-error-bars";
@@ -6407,6 +6407,80 @@ function getFilteredMutationOverTimeData({
6407
6407
  });
6408
6408
  return filteredData;
6409
6409
  }
6410
+ const MutationsOverTimeGridTooltip = ({
6411
+ mutation,
6412
+ date,
6413
+ value
6414
+ }) => {
6415
+ const dateClass = toTemporalClass(date);
6416
+ return /* @__PURE__ */ u$1("div", { children: [
6417
+ /* @__PURE__ */ u$1("p", { children: /* @__PURE__ */ u$1("span", { className: "font-bold", children: dateClass.englishName() }) }),
6418
+ /* @__PURE__ */ u$1("p", { children: [
6419
+ "(",
6420
+ timeIntervalDisplay(dateClass),
6421
+ ")"
6422
+ ] }),
6423
+ /* @__PURE__ */ u$1("p", { children: mutation.code }),
6424
+ /* @__PURE__ */ u$1(TooltipValueDescription, { value })
6425
+ ] });
6426
+ };
6427
+ const TooltipValueDescription = ({ value }) => {
6428
+ if (value === null) {
6429
+ return /* @__PURE__ */ u$1("p", { children: "No data" });
6430
+ }
6431
+ const proportion = value.type === "belowThreshold" ? `<${formatProportion(MUTATIONS_OVER_TIME_MIN_PROPORTION)}` : formatProportion(value.proportion);
6432
+ return /* @__PURE__ */ u$1(Fragment, { children: [
6433
+ /* @__PURE__ */ u$1("p", { children: [
6434
+ "Proportion: ",
6435
+ proportion
6436
+ ] }),
6437
+ /* @__PURE__ */ u$1(TooltipValueCountsDescription, { value })
6438
+ ] });
6439
+ };
6440
+ const TooltipValueCountsDescription = ({ value }) => {
6441
+ switch (value.type) {
6442
+ case "wastewaterValue":
6443
+ return;
6444
+ case "belowThreshold":
6445
+ return /* @__PURE__ */ u$1(Fragment, { children: [
6446
+ /* @__PURE__ */ u$1("p", { children: [
6447
+ value.totalCount,
6448
+ " samples are in the timeframe"
6449
+ ] }),
6450
+ /* @__PURE__ */ u$1("p", { children: [
6451
+ "none or less than ",
6452
+ formatProportion(MUTATIONS_OVER_TIME_MIN_PROPORTION),
6453
+ " have the mutation"
6454
+ ] })
6455
+ ] });
6456
+ case "value":
6457
+ return /* @__PURE__ */ u$1(Fragment, { children: [
6458
+ /* @__PURE__ */ u$1("p", { children: [
6459
+ value.totalCount,
6460
+ " samples are in the timeframe"
6461
+ ] }),
6462
+ /* @__PURE__ */ u$1("p", { children: [
6463
+ totalCountWithCoverage(value.count, value.proportion),
6464
+ " have coverage, of those ",
6465
+ value.count,
6466
+ " ",
6467
+ "have the mutation"
6468
+ ] })
6469
+ ] });
6470
+ }
6471
+ };
6472
+ function totalCountWithCoverage(count, proportion) {
6473
+ if (count === 0) {
6474
+ return 0;
6475
+ }
6476
+ return Math.round(count / proportion);
6477
+ }
6478
+ const timeIntervalDisplay = (date) => {
6479
+ if (date instanceof YearMonthDayClass) {
6480
+ return date.toString();
6481
+ }
6482
+ return `${date.firstDay.toString()} - ${date.lastDay.toString()}`;
6483
+ };
6410
6484
  const ColorScaleSelector = ({ colorScale, setColorScale }) => {
6411
6485
  const colorDisplayCss = `w-10 h-8 border border-gray-200 mx-2 text-xs flex items-center justify-center`;
6412
6486
  return /* @__PURE__ */ u$1("div", { className: "flex items-center", children: [
@@ -6740,86 +6814,25 @@ function getTooltipPosition(rowIndex, rows, columnIndex, columns) {
6740
6814
  return `${tooltipX}-${tooltipY}`;
6741
6815
  }
6742
6816
  const ProportionCell = ({ value, mutation, date, tooltipPosition, colorScale }) => {
6743
- const dateClass = toTemporalClass(date);
6744
- const tooltipContent = /* @__PURE__ */ u$1("div", { children: [
6745
- /* @__PURE__ */ u$1("p", { children: /* @__PURE__ */ u$1("span", { className: "font-bold", children: dateClass.englishName() }) }),
6746
- /* @__PURE__ */ u$1("p", { children: [
6747
- "(",
6748
- timeIntervalDisplay(dateClass),
6749
- ")"
6750
- ] }),
6751
- /* @__PURE__ */ u$1("p", { children: mutation.code }),
6752
- /* @__PURE__ */ u$1(TooltipValueDescription, { value })
6753
- ] });
6754
6817
  const proportion = (value == null ? void 0 : value.type) === "belowThreshold" ? 0 : value == null ? void 0 : value.proportion;
6755
- return /* @__PURE__ */ u$1("div", { className: "py-1 w-full h-full", children: /* @__PURE__ */ u$1(Tooltip, { content: tooltipContent, position: tooltipPosition, children: /* @__PURE__ */ u$1(
6756
- "div",
6818
+ return /* @__PURE__ */ u$1("div", { className: "py-1 w-full h-full", children: /* @__PURE__ */ u$1(
6819
+ Tooltip,
6757
6820
  {
6758
- style: {
6759
- backgroundColor: getColorWithinScale(proportion, colorScale),
6760
- color: getTextColorForScale(proportion, colorScale)
6761
- },
6762
- className: `w-full h-full hover:font-bold text-xs group @container`,
6763
- children: value === null ? /* @__PURE__ */ u$1("span", { className: "invisible", children: "No data" }) : /* @__PURE__ */ u$1("span", { className: "invisible @[2rem]:visible", children: formatProportion(proportion ?? 0, 0) })
6821
+ content: /* @__PURE__ */ u$1(MutationsOverTimeGridTooltip, { mutation, date, value }),
6822
+ position: tooltipPosition,
6823
+ children: /* @__PURE__ */ u$1(
6824
+ "div",
6825
+ {
6826
+ style: {
6827
+ backgroundColor: getColorWithinScale(proportion, colorScale),
6828
+ color: getTextColorForScale(proportion, colorScale)
6829
+ },
6830
+ className: `w-full h-full hover:font-bold text-xs group @container`,
6831
+ children: value === null ? /* @__PURE__ */ u$1("span", { className: "invisible", children: "No data" }) : /* @__PURE__ */ u$1("span", { className: "invisible @[2rem]:visible", children: formatProportion(proportion ?? 0, 0) })
6832
+ }
6833
+ )
6764
6834
  }
6765
- ) }) });
6766
- };
6767
- const TooltipValueDescription = ({ value }) => {
6768
- if (value === null) {
6769
- return /* @__PURE__ */ u$1("p", { children: "No data" });
6770
- }
6771
- const proportion = value.type === "belowThreshold" ? `<${formatProportion(MUTATIONS_OVER_TIME_MIN_PROPORTION)}` : formatProportion(value.proportion);
6772
- return /* @__PURE__ */ u$1(Fragment, { children: [
6773
- /* @__PURE__ */ u$1("p", { children: [
6774
- "Proportion: ",
6775
- proportion
6776
- ] }),
6777
- /* @__PURE__ */ u$1(TooltipValueCountsDescription, { value })
6778
- ] });
6779
- };
6780
- const TooltipValueCountsDescription = ({ value }) => {
6781
- switch (value.type) {
6782
- case "wastewaterValue":
6783
- return;
6784
- case "belowThreshold":
6785
- return /* @__PURE__ */ u$1(Fragment, { children: [
6786
- /* @__PURE__ */ u$1("p", { children: [
6787
- value.totalCount,
6788
- " samples are in the timeframe"
6789
- ] }),
6790
- /* @__PURE__ */ u$1("p", { children: [
6791
- "none or less than ",
6792
- formatProportion(MUTATIONS_OVER_TIME_MIN_PROPORTION),
6793
- " have the mutation"
6794
- ] })
6795
- ] });
6796
- case "value":
6797
- return /* @__PURE__ */ u$1(Fragment, { children: [
6798
- /* @__PURE__ */ u$1("p", { children: [
6799
- value.totalCount,
6800
- " samples are in the timeframe"
6801
- ] }),
6802
- /* @__PURE__ */ u$1("p", { children: [
6803
- totalCountWithCoverage(value.count, value.proportion),
6804
- " have coverage, of those ",
6805
- value.count,
6806
- " ",
6807
- "have the mutation"
6808
- ] })
6809
- ] });
6810
- }
6811
- };
6812
- function totalCountWithCoverage(count, proportion) {
6813
- if (count === 0) {
6814
- return 0;
6815
- }
6816
- return Math.round(count / proportion);
6817
- }
6818
- const timeIntervalDisplay = (date) => {
6819
- if (date instanceof YearMonthDayClass) {
6820
- return date.toString();
6821
- }
6822
- return `${date.firstDay.toString()} - ${date.lastDay.toString()}`;
6835
+ ) });
6823
6836
  };
6824
6837
  const ColorScaleSelectorDropdown = ({
6825
6838
  colorScale,
@@ -8642,7 +8655,7 @@ const getDatesForSelectorValue = (initialSelectedDateRange, dateRangeOptions, ea
8642
8655
  };
8643
8656
  function computeInitialValues(value, earliestDate, dateRangeOptions) {
8644
8657
  var _a;
8645
- if (value === void 0) {
8658
+ if (value === null) {
8646
8659
  return void 0;
8647
8660
  }
8648
8661
  if (typeof value === "string") {
@@ -8920,10 +8933,18 @@ const DateRangeFilterInner = ({
8920
8933
  };
8921
8934
  const fireOptionChangedEvent = (state2) => {
8922
8935
  var _a2;
8923
- const eventDetail = (state2 == null ? void 0 : state2.label) === customOption ? {
8924
- dateFrom: state2.dateFrom !== void 0 ? toYYYYMMDD(state2.dateFrom) : void 0,
8925
- dateTo: state2.dateTo !== void 0 ? toYYYYMMDD(state2.dateTo) : void 0
8926
- } : state2 == null ? void 0 : state2.label;
8936
+ const eventDetail = (() => {
8937
+ if (state2 === null) {
8938
+ return null;
8939
+ }
8940
+ if (state2.label === customOption) {
8941
+ return {
8942
+ dateFrom: state2.dateFrom !== void 0 ? toYYYYMMDD(state2.dateFrom) : void 0,
8943
+ dateTo: state2.dateTo !== void 0 ? toYYYYMMDD(state2.dateTo) : void 0
8944
+ };
8945
+ }
8946
+ return state2.label;
8947
+ })();
8927
8948
  (_a2 = divRef.current) == null ? void 0 : _a2.dispatchEvent(new DateRangeOptionChangedEvent(eventDetail));
8928
8949
  };
8929
8950
  return /* @__PURE__ */ u$1("div", { className: "@container", ref: divRef, children: /* @__PURE__ */ u$1("div", { className: "flex min-w-[7.5rem] flex-col @md:flex-row", children: [
@@ -8979,7 +9000,7 @@ let DateRangeFilterComponent = class extends PreactLitAdapter {
8979
9000
  super(...arguments);
8980
9001
  this.dateRangeOptions = [];
8981
9002
  this.earliestDate = "1900-01-01";
8982
- this.value = void 0;
9003
+ this.value = null;
8983
9004
  this.width = "100%";
8984
9005
  this.placeholder = void 0;
8985
9006
  this.lapisDateField = "";
@@ -9008,7 +9029,7 @@ __decorateClass$4([
9008
9029
  n$1({
9009
9030
  converter: (value) => {
9010
9031
  if (value === null) {
9011
- return void 0;
9032
+ return null;
9012
9033
  }
9013
9034
  try {
9014
9035
  const result = JSON.parse(value);