@genspectrum/dashboard-components 0.18.4 → 0.18.5

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/dist/util.d.ts CHANGED
@@ -902,7 +902,7 @@ declare global {
902
902
 
903
903
  declare global {
904
904
  interface HTMLElementTagNameMap {
905
- 'gs-wastewater-mutations-over-time': WastewaterMutationsOverTimeComponent;
905
+ 'gs-mutation-comparison-component': MutationComparisonComponent;
906
906
  }
907
907
  }
908
908
 
@@ -910,7 +910,7 @@ declare global {
910
910
  declare global {
911
911
  namespace JSX {
912
912
  interface IntrinsicElements {
913
- 'gs-wastewater-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
913
+ 'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
914
914
  }
915
915
  }
916
916
  }
@@ -918,11 +918,7 @@ declare global {
918
918
 
919
919
  declare global {
920
920
  interface HTMLElementTagNameMap {
921
- 'gs-date-range-filter': DateRangeFilterComponent;
922
- }
923
- interface HTMLElementEventMap {
924
- 'gs-date-range-filter-changed': CustomEvent<Record<string, string>>;
925
- 'gs-date-range-option-changed': DateRangeOptionChangedEvent;
921
+ 'gs-mutations-component': MutationsComponent;
926
922
  }
927
923
  }
928
924
 
@@ -930,7 +926,7 @@ declare global {
930
926
  declare global {
931
927
  namespace JSX {
932
928
  interface IntrinsicElements {
933
- 'gs-date-range-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
929
+ 'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
934
930
  }
935
931
  }
936
932
  }
@@ -938,10 +934,7 @@ declare global {
938
934
 
939
935
  declare global {
940
936
  interface HTMLElementTagNameMap {
941
- 'gs-location-filter': LocationFilterComponent;
942
- }
943
- interface HTMLElementEventMap {
944
- 'gs-location-changed': LocationChangedEvent;
937
+ 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
945
938
  }
946
939
  }
947
940
 
@@ -949,7 +942,7 @@ declare global {
949
942
  declare global {
950
943
  namespace JSX {
951
944
  interface IntrinsicElements {
952
- 'gs-location-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
945
+ 'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
953
946
  }
954
947
  }
955
948
  }
@@ -957,10 +950,7 @@ declare global {
957
950
 
958
951
  declare global {
959
952
  interface HTMLElementTagNameMap {
960
- 'gs-text-filter': TextFilterComponent;
961
- }
962
- interface HTMLElementEventMap {
963
- 'gs-text-filter-changed': TextFilterChangedEvent;
953
+ 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
964
954
  }
965
955
  }
966
956
 
@@ -968,7 +958,7 @@ declare global {
968
958
  declare global {
969
959
  namespace JSX {
970
960
  interface IntrinsicElements {
971
- 'gs-text-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
961
+ 'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
972
962
  }
973
963
  }
974
964
  }
@@ -976,10 +966,7 @@ declare global {
976
966
 
977
967
  declare global {
978
968
  interface HTMLElementTagNameMap {
979
- 'gs-lineage-filter': LineageFilterComponent;
980
- }
981
- interface HTMLElementEventMap {
982
- 'gs-lineage-filter-changed': LineageFilterChangedEvent;
969
+ 'gs-aggregate': AggregateComponent;
983
970
  }
984
971
  }
985
972
 
@@ -987,7 +974,7 @@ declare global {
987
974
  declare global {
988
975
  namespace JSX {
989
976
  interface IntrinsicElements {
990
- 'gs-lineage-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
977
+ 'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
991
978
  }
992
979
  }
993
980
  }
@@ -995,10 +982,7 @@ declare global {
995
982
 
996
983
  declare global {
997
984
  interface HTMLElementTagNameMap {
998
- 'gs-mutation-filter': MutationFilterComponent;
999
- }
1000
- interface HTMLElementEventMap {
1001
- 'gs-mutation-filter-changed': CustomEvent<MutationsFilter>;
985
+ 'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
1002
986
  }
1003
987
  }
1004
988
 
@@ -1006,7 +990,7 @@ declare global {
1006
990
  declare global {
1007
991
  namespace JSX {
1008
992
  interface IntrinsicElements {
1009
- 'gs-mutation-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
993
+ 'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1010
994
  }
1011
995
  }
1012
996
  }
@@ -1014,7 +998,7 @@ declare global {
1014
998
 
1015
999
  declare global {
1016
1000
  interface HTMLElementTagNameMap {
1017
- 'gs-mutation-comparison-component': MutationComparisonComponent;
1001
+ 'gs-mutations-over-time': MutationsOverTimeComponent;
1018
1002
  }
1019
1003
  }
1020
1004
 
@@ -1022,7 +1006,7 @@ declare global {
1022
1006
  declare global {
1023
1007
  namespace JSX {
1024
1008
  interface IntrinsicElements {
1025
- 'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1009
+ 'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1026
1010
  }
1027
1011
  }
1028
1012
  }
@@ -1030,7 +1014,7 @@ declare global {
1030
1014
 
1031
1015
  declare global {
1032
1016
  interface HTMLElementTagNameMap {
1033
- 'gs-mutations-component': MutationsComponent;
1017
+ 'gs-sequences-by-location': SequencesByLocationComponent;
1034
1018
  }
1035
1019
  }
1036
1020
 
@@ -1038,7 +1022,7 @@ declare global {
1038
1022
  declare global {
1039
1023
  namespace JSX {
1040
1024
  interface IntrinsicElements {
1041
- 'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1025
+ 'gs-sequences-by-location': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1042
1026
  }
1043
1027
  }
1044
1028
  }
@@ -1046,7 +1030,7 @@ declare global {
1046
1030
 
1047
1031
  declare global {
1048
1032
  interface HTMLElementTagNameMap {
1049
- 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
1033
+ 'gs-statistics': StatisticsComponent;
1050
1034
  }
1051
1035
  }
1052
1036
 
@@ -1054,7 +1038,7 @@ declare global {
1054
1038
  declare global {
1055
1039
  namespace JSX {
1056
1040
  interface IntrinsicElements {
1057
- 'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1041
+ 'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1058
1042
  }
1059
1043
  }
1060
1044
  }
@@ -1062,7 +1046,7 @@ declare global {
1062
1046
 
1063
1047
  declare global {
1064
1048
  interface HTMLElementTagNameMap {
1065
- 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
1049
+ 'gs-wastewater-mutations-over-time': WastewaterMutationsOverTimeComponent;
1066
1050
  }
1067
1051
  }
1068
1052
 
@@ -1070,7 +1054,7 @@ declare global {
1070
1054
  declare global {
1071
1055
  namespace JSX {
1072
1056
  interface IntrinsicElements {
1073
- 'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1057
+ 'gs-wastewater-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1074
1058
  }
1075
1059
  }
1076
1060
  }
@@ -1078,7 +1062,11 @@ declare global {
1078
1062
 
1079
1063
  declare global {
1080
1064
  interface HTMLElementTagNameMap {
1081
- 'gs-aggregate': AggregateComponent;
1065
+ 'gs-date-range-filter': DateRangeFilterComponent;
1066
+ }
1067
+ interface HTMLElementEventMap {
1068
+ 'gs-date-range-filter-changed': CustomEvent<Record<string, string>>;
1069
+ 'gs-date-range-option-changed': DateRangeOptionChangedEvent;
1082
1070
  }
1083
1071
  }
1084
1072
 
@@ -1086,7 +1074,7 @@ declare global {
1086
1074
  declare global {
1087
1075
  namespace JSX {
1088
1076
  interface IntrinsicElements {
1089
- 'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1077
+ 'gs-date-range-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1090
1078
  }
1091
1079
  }
1092
1080
  }
@@ -1094,7 +1082,10 @@ declare global {
1094
1082
 
1095
1083
  declare global {
1096
1084
  interface HTMLElementTagNameMap {
1097
- 'gs-mutations-over-time': MutationsOverTimeComponent;
1085
+ 'gs-location-filter': LocationFilterComponent;
1086
+ }
1087
+ interface HTMLElementEventMap {
1088
+ 'gs-location-changed': LocationChangedEvent;
1098
1089
  }
1099
1090
  }
1100
1091
 
@@ -1102,7 +1093,7 @@ declare global {
1102
1093
  declare global {
1103
1094
  namespace JSX {
1104
1095
  interface IntrinsicElements {
1105
- 'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1096
+ 'gs-location-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1106
1097
  }
1107
1098
  }
1108
1099
  }
@@ -1110,7 +1101,10 @@ declare global {
1110
1101
 
1111
1102
  declare global {
1112
1103
  interface HTMLElementTagNameMap {
1113
- 'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
1104
+ 'gs-text-filter': TextFilterComponent;
1105
+ }
1106
+ interface HTMLElementEventMap {
1107
+ 'gs-text-filter-changed': TextFilterChangedEvent;
1114
1108
  }
1115
1109
  }
1116
1110
 
@@ -1118,7 +1112,7 @@ declare global {
1118
1112
  declare global {
1119
1113
  namespace JSX {
1120
1114
  interface IntrinsicElements {
1121
- 'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1115
+ 'gs-text-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1122
1116
  }
1123
1117
  }
1124
1118
  }
@@ -1126,7 +1120,10 @@ declare global {
1126
1120
 
1127
1121
  declare global {
1128
1122
  interface HTMLElementTagNameMap {
1129
- 'gs-sequences-by-location': SequencesByLocationComponent;
1123
+ 'gs-mutation-filter': MutationFilterComponent;
1124
+ }
1125
+ interface HTMLElementEventMap {
1126
+ 'gs-mutation-filter-changed': CustomEvent<MutationsFilter>;
1130
1127
  }
1131
1128
  }
1132
1129
 
@@ -1134,7 +1131,7 @@ declare global {
1134
1131
  declare global {
1135
1132
  namespace JSX {
1136
1133
  interface IntrinsicElements {
1137
- 'gs-sequences-by-location': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1134
+ 'gs-mutation-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1138
1135
  }
1139
1136
  }
1140
1137
  }
@@ -1142,7 +1139,10 @@ declare global {
1142
1139
 
1143
1140
  declare global {
1144
1141
  interface HTMLElementTagNameMap {
1145
- 'gs-statistics': StatisticsComponent;
1142
+ 'gs-lineage-filter': LineageFilterComponent;
1143
+ }
1144
+ interface HTMLElementEventMap {
1145
+ 'gs-lineage-filter-changed': LineageFilterChangedEvent;
1146
1146
  }
1147
1147
  }
1148
1148
 
@@ -1150,7 +1150,7 @@ declare global {
1150
1150
  declare global {
1151
1151
  namespace JSX {
1152
1152
  interface IntrinsicElements {
1153
- 'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1153
+ 'gs-lineage-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1154
1154
  }
1155
1155
  }
1156
1156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genspectrum/dashboard-components",
3
- "version": "0.18.4",
3
+ "version": "0.18.5",
4
4
  "description": "GenSpectrum web components for building dashboards",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
@@ -4,6 +4,7 @@ import { type FunctionComponent } from 'preact';
4
4
  import { useState } from 'preact/hooks';
5
5
 
6
6
  import { type DisplayedSegment, SegmentSelector, type SegmentSelectorProps } from './segment-selector';
7
+ import type { SequenceType } from '../../types';
7
8
 
8
9
  const meta: Meta<SegmentSelectorProps> = {
9
10
  title: 'Component/Segment selector',
@@ -15,7 +16,8 @@ export default meta;
15
16
 
16
17
  const WrapperWithState: FunctionComponent<{
17
18
  displayedSegments: DisplayedSegment[];
18
- }> = ({ displayedSegments: initialDisplayedSegments }) => {
19
+ sequenceType: SequenceType;
20
+ }> = ({ displayedSegments: initialDisplayedSegments, sequenceType }) => {
19
21
  const [displayedSegments, setDisplayedSegments] = useState<DisplayedSegment[]>(initialDisplayedSegments);
20
22
 
21
23
  return (
@@ -24,6 +26,7 @@ const WrapperWithState: FunctionComponent<{
24
26
  setDisplayedSegments={(items: DisplayedSegment[]) => {
25
27
  setDisplayedSegments(items);
26
28
  }}
29
+ sequenceType={sequenceType}
27
30
  />
28
31
  );
29
32
  };
@@ -50,12 +53,13 @@ export const AllSegmentsSelected: StoryObj<SegmentSelectorProps> = {
50
53
  checked: true,
51
54
  },
52
55
  ],
56
+ sequenceType: 'amino acid',
53
57
  },
54
58
  play: async ({ canvasElement, step }) => {
55
59
  const canvas = within(canvasElement);
56
60
 
57
- await step("Show 'All segments' as label", async () => {
58
- await expect(canvas.getByText('All segments')).toBeInTheDocument();
61
+ await step("Show 'All genes' as label", async () => {
62
+ await expect(canvas.getByText('All genes')).toBeInTheDocument();
59
63
  });
60
64
  },
61
65
  };
@@ -80,6 +84,7 @@ export const NoSegmentsSelected: StoryObj<SegmentSelectorProps> = {
80
84
  checked: false,
81
85
  },
82
86
  ],
87
+ sequenceType: 'nucleotide',
83
88
  },
84
89
  play: async ({ canvasElement, step }) => {
85
90
  const canvas = within(canvasElement);
@@ -110,12 +115,13 @@ export const LongSegmentsSelected: StoryObj<SegmentSelectorProps> = {
110
115
  checked: true,
111
116
  },
112
117
  ],
118
+ sequenceType: 'amino acid',
113
119
  },
114
120
  play: async ({ canvasElement, step }) => {
115
121
  const canvas = within(canvasElement);
116
122
 
117
- await step('Show number of active segments as label', async () => {
118
- await expect(canvas.getByText('2 segments')).toBeInTheDocument();
123
+ await step('Show number of active genes as label', async () => {
124
+ await expect(canvas.getByText('2 genes')).toBeInTheDocument();
119
125
  });
120
126
  },
121
127
  };
@@ -140,6 +146,7 @@ export const ShortSegmentsSelected: StoryObj<SegmentSelectorProps> = {
140
146
  checked: false,
141
147
  },
142
148
  ],
149
+ sequenceType: 'amino acid',
143
150
  },
144
151
  play: async ({ canvasElement, step }) => {
145
152
  const canvas = within(canvasElement);
@@ -13,40 +13,44 @@ export type DisplayedSegment = CheckboxItem & {
13
13
  export type SegmentSelectorProps = {
14
14
  displayedSegments: DisplayedSegment[];
15
15
  setDisplayedSegments: (items: DisplayedSegment[]) => void;
16
+ sequenceType: SequenceType;
16
17
  };
17
18
 
18
19
  export const SegmentSelector: FunctionComponent<SegmentSelectorProps> = ({
19
20
  displayedSegments,
20
21
  setDisplayedSegments,
22
+ sequenceType,
21
23
  }) => {
22
24
  if (displayedSegments.length <= 1) {
23
25
  return null;
24
26
  }
25
27
 
26
28
  return (
27
- <div className='w-24'>
29
+ <div className='w-20 inline-flex'>
28
30
  <CheckboxSelector
29
31
  items={displayedSegments}
30
- label={getSegmentSelectorLabel(displayedSegments)}
32
+ label={getSegmentSelectorLabel(displayedSegments, sequenceType)}
31
33
  setItems={(items) => setDisplayedSegments(items)}
32
34
  />
33
35
  </div>
34
36
  );
35
37
  };
36
38
 
37
- const getSegmentSelectorLabel = (displayedSegments: DisplayedSegment[]) => {
39
+ const getSegmentSelectorLabel = (displayedSegments: DisplayedSegment[], sequenceType: SequenceType) => {
38
40
  const allSelectedSelected = displayedSegments
39
41
  .filter((segment) => segment.checked)
40
42
  .map((segment) => segment.segment);
41
43
 
44
+ const label = sequenceType === 'amino acid' ? 'gene' : 'segment';
45
+
42
46
  if (allSelectedSelected.length === 0) {
43
- return `No segments`;
47
+ return `No ${label}s`;
44
48
  }
45
49
  if (displayedSegments.length === allSelectedSelected.length) {
46
- return `All segments`;
50
+ return `All ${label}s`;
47
51
  }
48
52
 
49
- const longestDisplayString = `All segments`;
53
+ const longestDisplayString = `All ${label}s`;
50
54
 
51
55
  const allSelectedSelectedString = allSelectedSelected.join(', ');
52
56
 
@@ -54,7 +58,7 @@ const getSegmentSelectorLabel = (displayedSegments: DisplayedSegment[]) => {
54
58
  return allSelectedSelectedString;
55
59
  }
56
60
 
57
- return `${allSelectedSelected.length} ${allSelectedSelected.length === 1 ? 'segment' : 'segments'}`;
61
+ return `${allSelectedSelected.length} ${allSelectedSelected.length === 1 ? label : `${label}s`}`;
58
62
  };
59
63
 
60
64
  export function useDisplayedSegments(sequenceType: SequenceType) {
@@ -172,7 +172,11 @@ const Toolbar: FunctionComponent<ToolbarProps> = ({
172
172
  setMinProportion={(min) => setProportionInterval((prev) => ({ ...prev, min }))}
173
173
  setMaxProportion={(max) => setProportionInterval((prev) => ({ ...prev, max }))}
174
174
  />
175
- <SegmentSelector displayedSegments={displayedSegments} setDisplayedSegments={setDisplayedSegments} />
175
+ <SegmentSelector
176
+ displayedSegments={displayedSegments}
177
+ setDisplayedSegments={setDisplayedSegments}
178
+ sequenceType={originalComponentProps.sequenceType}
179
+ />
176
180
  <MutationTypeSelector
177
181
  displayedMutationTypes={displayedMutationTypes}
178
182
  setDisplayedMutationTypes={setDisplayedMutationTypes}
@@ -185,7 +185,11 @@ const Toolbar: FunctionComponent<ToolbarProps> = ({
185
185
  }) => {
186
186
  return (
187
187
  <>
188
- <SegmentSelector displayedSegments={displayedSegments} setDisplayedSegments={setDisplayedSegments} />
188
+ <SegmentSelector
189
+ displayedSegments={displayedSegments}
190
+ setDisplayedSegments={setDisplayedSegments}
191
+ sequenceType={originalComponentProps.sequenceType}
192
+ />
189
193
  {activeTab === 'Table' && (
190
194
  <MutationTypeSelector
191
195
  setDisplayedMutationTypes={setDisplayedMutationTypes}
@@ -192,7 +192,7 @@ const ProportionCell: FunctionComponent<{
192
192
  backgroundColor: getColorWithinScale(proportion, colorScale),
193
193
  color: getTextColorForScale(proportion, colorScale),
194
194
  }}
195
- className={`w-full h-full hover:font-bold text-xs group @container`}
195
+ className={`w-full h-full hover:font-bold text-xs group @container text-nowrap`}
196
196
  >
197
197
  {value === null ? (
198
198
  <span className='invisible'>No data</span>
@@ -228,7 +228,11 @@ const Toolbar: FunctionComponent<ToolbarProps> = ({
228
228
  {activeTab === 'Grid' && (
229
229
  <ColorScaleSelectorDropdown colorScale={colorScale} setColorScale={setColorScale} />
230
230
  )}
231
- <SegmentSelector displayedSegments={displayedSegments} setDisplayedSegments={setDisplayedSegments} />
231
+ <SegmentSelector
232
+ displayedSegments={displayedSegments}
233
+ setDisplayedSegments={setDisplayedSegments}
234
+ sequenceType={originalComponentProps.sequenceType}
235
+ />
232
236
  <MutationTypeSelector
233
237
  setDisplayedMutationTypes={setDisplayedMutationTypes}
234
238
  displayedMutationTypes={displayedMutationTypes}