@genspectrum/dashboard-components 0.11.4 → 0.11.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/style.css CHANGED
@@ -3155,9 +3155,6 @@ input.tab:checked + .tab-content,
3155
3155
  .cursor-pointer {
3156
3156
  cursor: pointer;
3157
3157
  }
3158
- .resize {
3159
- resize: both;
3160
- }
3161
3158
  .list-inside {
3162
3159
  list-style-position: inside;
3163
3160
  }
@@ -3194,8 +3191,8 @@ input.tab:checked + .tab-content,
3194
3191
  .gap-y-1 {
3195
3192
  row-gap: 0.25rem;
3196
3193
  }
3197
- .overflow-auto {
3198
- overflow: auto;
3194
+ .overflow-scroll {
3195
+ overflow: scroll;
3199
3196
  }
3200
3197
  .overflow-x-auto {
3201
3198
  overflow-x: auto;
package/dist/util.d.ts CHANGED
@@ -787,7 +787,7 @@ declare global {
787
787
 
788
788
  declare global {
789
789
  interface HTMLElementTagNameMap {
790
- 'gs-mutations-component': MutationsComponent;
790
+ 'gs-mutation-comparison-component': MutationComparisonComponent;
791
791
  }
792
792
  }
793
793
 
@@ -795,7 +795,7 @@ declare global {
795
795
  declare global {
796
796
  namespace JSX {
797
797
  interface IntrinsicElements {
798
- 'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
798
+ 'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
799
799
  }
800
800
  }
801
801
  }
@@ -803,7 +803,7 @@ declare global {
803
803
 
804
804
  declare global {
805
805
  interface HTMLElementTagNameMap {
806
- 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
806
+ 'gs-mutations-component': MutationsComponent;
807
807
  }
808
808
  }
809
809
 
@@ -811,7 +811,7 @@ declare global {
811
811
  declare global {
812
812
  namespace JSX {
813
813
  interface IntrinsicElements {
814
- 'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
814
+ 'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
815
815
  }
816
816
  }
817
817
  }
@@ -819,7 +819,7 @@ declare global {
819
819
 
820
820
  declare global {
821
821
  interface HTMLElementTagNameMap {
822
- 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
822
+ 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
823
823
  }
824
824
  }
825
825
 
@@ -827,7 +827,7 @@ declare global {
827
827
  declare global {
828
828
  namespace JSX {
829
829
  interface IntrinsicElements {
830
- 'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
830
+ 'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
831
831
  }
832
832
  }
833
833
  }
@@ -835,7 +835,7 @@ declare global {
835
835
 
836
836
  declare global {
837
837
  interface HTMLElementTagNameMap {
838
- 'gs-aggregate': AggregateComponent;
838
+ 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
839
839
  }
840
840
  }
841
841
 
@@ -843,7 +843,7 @@ declare global {
843
843
  declare global {
844
844
  namespace JSX {
845
845
  interface IntrinsicElements {
846
- 'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
846
+ 'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
847
847
  }
848
848
  }
849
849
  }
@@ -851,7 +851,7 @@ declare global {
851
851
 
852
852
  declare global {
853
853
  interface HTMLElementTagNameMap {
854
- 'gs-mutation-comparison-component': MutationComparisonComponent;
854
+ 'gs-aggregate': AggregateComponent;
855
855
  }
856
856
  }
857
857
 
@@ -859,7 +859,7 @@ declare global {
859
859
  declare global {
860
860
  namespace JSX {
861
861
  interface IntrinsicElements {
862
- 'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
862
+ 'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
863
863
  }
864
864
  }
865
865
  }
@@ -867,7 +867,7 @@ declare global {
867
867
 
868
868
  declare global {
869
869
  interface HTMLElementTagNameMap {
870
- 'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
870
+ 'gs-mutations-over-time': MutationsOverTimeComponent;
871
871
  }
872
872
  }
873
873
 
@@ -875,7 +875,7 @@ declare global {
875
875
  declare global {
876
876
  namespace JSX {
877
877
  interface IntrinsicElements {
878
- 'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
878
+ 'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
879
879
  }
880
880
  }
881
881
  }
@@ -883,7 +883,7 @@ declare global {
883
883
 
884
884
  declare global {
885
885
  interface HTMLElementTagNameMap {
886
- 'gs-sequences-by-location': SequencesByLocationComponent;
886
+ 'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
887
887
  }
888
888
  }
889
889
 
@@ -891,7 +891,7 @@ declare global {
891
891
  declare global {
892
892
  namespace JSX {
893
893
  interface IntrinsicElements {
894
- 'gs-sequences-by-location': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
894
+ 'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
895
895
  }
896
896
  }
897
897
  }
@@ -899,7 +899,7 @@ declare global {
899
899
 
900
900
  declare global {
901
901
  interface HTMLElementTagNameMap {
902
- 'gs-mutations-over-time': MutationsOverTimeComponent;
902
+ 'gs-sequences-by-location': SequencesByLocationComponent;
903
903
  }
904
904
  }
905
905
 
@@ -907,7 +907,7 @@ declare global {
907
907
  declare global {
908
908
  namespace JSX {
909
909
  interface IntrinsicElements {
910
- 'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
910
+ 'gs-sequences-by-location': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
911
911
  }
912
912
  }
913
913
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genspectrum/dashboard-components",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "description": "GenSpectrum web components for building dashboards",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
@@ -1,5 +1,5 @@
1
- import { Fragment, type FunctionComponent } from 'preact';
2
- import { useEffect, useRef, useState } from 'preact/hooks';
1
+ import { type FunctionComponent } from 'preact';
2
+ import { useState } from 'preact/hooks';
3
3
  import { type JSXInternal } from 'preact/src/jsx';
4
4
 
5
5
  type Tab = {
@@ -14,43 +14,24 @@ interface ComponentTabsProps {
14
14
 
15
15
  const Tabs: FunctionComponent<ComponentTabsProps> = ({ tabs, toolbar }) => {
16
16
  const [activeTab, setActiveTab] = useState(tabs[0]?.title);
17
- const [heightOfTabs, setHeightOfTabs] = useState('3rem');
18
- const tabRef = useRef<HTMLDivElement>(null);
19
-
20
- const updateHeightOfTabs = () => {
21
- if (tabRef.current) {
22
- const heightOfTabs = tabRef.current.getBoundingClientRect().height;
23
- setHeightOfTabs(`${heightOfTabs}px`);
24
- }
25
- };
26
-
27
- useEffect(() => {
28
- updateHeightOfTabs();
29
-
30
- window.addEventListener('resize', updateHeightOfTabs);
31
- return () => {
32
- window.removeEventListener('resize', updateHeightOfTabs);
33
- };
34
- }, []);
35
17
 
36
18
  const tabElements = (
37
19
  <div className='flex flex-row'>
38
20
  {tabs.map((tab) => {
39
21
  return (
40
- <Fragment key={tab.title}>
41
- <button
42
- className={`px-4 py-2 text-sm font-medium leading-5 transition-colors duration-150 ${
43
- activeTab === tab.title
44
- ? 'border-b-2 border-gray-400'
45
- : 'text-gray-600 hover:bg-gray-100 hover:text-gray-700'
46
- }`}
47
- onClick={() => {
48
- setActiveTab(tab.title);
49
- }}
50
- >
51
- {tab.title}
52
- </button>
53
- </Fragment>
22
+ <button
23
+ key={tab.title}
24
+ className={`px-4 py-2 text-sm font-medium leading-5 transition-colors duration-150 ${
25
+ activeTab === tab.title
26
+ ? 'border-b-2 border-gray-400'
27
+ : 'text-gray-600 hover:bg-gray-100 hover:text-gray-700'
28
+ }`}
29
+ onClick={() => {
30
+ setActiveTab(tab.title);
31
+ }}
32
+ >
33
+ {tab.title}
34
+ </button>
54
35
  );
55
36
  })}
56
37
  </div>
@@ -59,17 +40,16 @@ const Tabs: FunctionComponent<ComponentTabsProps> = ({ tabs, toolbar }) => {
59
40
  const toolbarElement = typeof toolbar === 'function' ? toolbar(activeTab) : toolbar;
60
41
 
61
42
  return (
62
- <div className='h-full w-full'>
63
- <div ref={tabRef} className='flex flex-row justify-between flex-wrap'>
43
+ <div className='h-full w-full flex flex-col'>
44
+ <div className='flex flex-row justify-between flex-wrap'>
64
45
  {tabElements}
65
46
  {toolbar && <div className='py-2 flex flex-wrap gap-y-1'>{toolbarElement}</div>}
66
47
  </div>
67
48
  <div
68
- className={`p-2 border-2 border-gray-100 rounded-b-md rounded-tr-md ${activeTab === tabs[0]?.title ? '' : 'rounded-tl-md'}`}
69
- style={{ height: `calc(100% - ${heightOfTabs})` }}
49
+ className={`p-2 flex-grow overflow-scroll border-2 border-gray-100 rounded-b-md rounded-tr-md ${activeTab === tabs[0]?.title ? '' : 'rounded-tl-md'}`}
70
50
  >
71
51
  {tabs.map((tab) => (
72
- <div className='h-full overflow-auto' key={tab.title} hidden={activeTab !== tab.title}>
52
+ <div className='h-full' key={tab.title} hidden={activeTab !== tab.title}>
73
53
  {tab.content}
74
54
  </div>
75
55
  ))}
@@ -68,15 +68,69 @@ describe('YearMonthDay', () => {
68
68
  });
69
69
 
70
70
  describe('YearWeek', () => {
71
- it('should parse from string', () => {
72
- const underTest = YearWeekClass.parse('2020-W02', cache);
71
+ const examples = [
72
+ {
73
+ string: '2020-W01',
74
+ expectedYear: 2020,
75
+ expectedWeek: 1,
76
+ expectedFirstDay: '2019-12-30',
77
+ expectedLastDay: '2020-01-05',
78
+ expectedText: '2020-W01',
79
+ },
80
+ {
81
+ string: '2020-W53',
82
+ expectedYear: 2020,
83
+ expectedWeek: 53,
84
+ expectedFirstDay: '2020-12-28',
85
+ expectedLastDay: '2021-01-03',
86
+ expectedText: '2020-W53',
87
+ },
88
+ {
89
+ string: '2021-W01',
90
+ expectedYear: 2021,
91
+ expectedWeek: 1,
92
+ expectedFirstDay: '2021-01-04',
93
+ expectedLastDay: '2021-01-10',
94
+ expectedText: '2021-W01',
95
+ },
96
+ {
97
+ string: '2021-W53',
98
+ expectedYear: 2021,
99
+ expectedWeek: 53,
100
+ expectedFirstDay: '2022-01-03',
101
+ expectedLastDay: '2022-01-09',
102
+ expectedText: '2022-W01',
103
+ },
104
+ {
105
+ string: '2022-W01',
106
+ expectedYear: 2022,
107
+ expectedWeek: 1,
108
+ expectedFirstDay: '2022-01-03',
109
+ expectedLastDay: '2022-01-09',
110
+ expectedText: '2022-W01',
111
+ },
112
+ {
113
+ string: '2024-W01',
114
+ expectedYear: 2024,
115
+ expectedWeek: 1,
116
+ expectedFirstDay: '2024-01-01',
117
+ expectedLastDay: '2024-01-07',
118
+ expectedText: '2024-W01',
119
+ },
120
+ ];
73
121
 
74
- expect(underTest.isoYearNumber).equal(2020);
75
- expect(underTest.isoWeekNumber).equal(2);
76
- expect(underTest.firstDay.text).equal('2020-01-06');
77
- expect(underTest.text).equal('2020-W02');
78
- expect(underTest.lastDay.text).equal('2020-01-12');
79
- });
122
+ for (const example of examples) {
123
+ const { string, expectedYear, expectedWeek, expectedFirstDay, expectedLastDay, expectedText } = example;
124
+ it(`should parse ${string} from string`, () => {
125
+ const underTest = YearWeekClass.parse(string, cache);
126
+
127
+ expect(underTest.isoYearNumber).equal(expectedYear);
128
+ expect(underTest.isoWeekNumber).equal(expectedWeek);
129
+ expect(underTest.firstDay.text).equal(expectedFirstDay);
130
+ expect(underTest.text).equal(expectedText);
131
+ expect(underTest.lastDay.text).equal(expectedLastDay);
132
+ });
133
+ }
80
134
  });
81
135
 
82
136
  describe('YearMonth', () => {
@@ -171,14 +171,7 @@ export class YearWeekClass implements YearWeek {
171
171
  }
172
172
 
173
173
  get lastDay(): YearMonthDayClass {
174
- const firstDay = dayjs()
175
- .year(this.isoYearNumber)
176
- .startOf('year')
177
- .add((this.isoWeekNumber - 1) * 7, 'day')
178
- .startOf('week')
179
- .add(1, 'day');
180
- const lastDay = firstDay.add(6, 'day');
181
-
174
+ const lastDay = this.firstDay.dayjs.add(6, 'days');
182
175
  return this.cache.getYearMonthDay(lastDay.format('YYYY-MM-DD'));
183
176
  }
184
177