@genspectrum/dashboard-components 0.12.1 → 0.13.0

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.
Files changed (36) hide show
  1. package/custom-elements.json +114 -25
  2. package/dist/{LocationChangedEvent-CORvQvXv.js → LineageFilterChangedEvent-GedKNGFI.js} +25 -3
  3. package/dist/LineageFilterChangedEvent-GedKNGFI.js.map +1 -0
  4. package/dist/components.d.ts +55 -21
  5. package/dist/components.js +229 -286
  6. package/dist/components.js.map +1 -1
  7. package/dist/util.d.ts +28 -14
  8. package/dist/util.js +3 -1
  9. package/package.json +1 -1
  10. package/src/preact/components/downshift-combobox.tsx +145 -0
  11. package/src/preact/lineageFilter/LineageFilterChangedEvent.ts +11 -0
  12. package/src/preact/lineageFilter/fetchLineageAutocompleteList.spec.ts +16 -2
  13. package/src/preact/lineageFilter/fetchLineageAutocompleteList.ts +13 -2
  14. package/src/preact/lineageFilter/lineage-filter.stories.tsx +110 -9
  15. package/src/preact/lineageFilter/lineage-filter.tsx +40 -50
  16. package/src/preact/locationFilter/LocationChangedEvent.ts +1 -1
  17. package/src/preact/locationFilter/fetchAutocompletionList.spec.ts +6 -2
  18. package/src/preact/locationFilter/fetchAutocompletionList.ts +16 -6
  19. package/src/preact/locationFilter/location-filter.stories.tsx +33 -30
  20. package/src/preact/locationFilter/location-filter.tsx +47 -144
  21. package/src/preact/textInput/TextInputChangedEvent.ts +1 -1
  22. package/src/preact/textInput/fetchStringAutocompleteList.ts +20 -0
  23. package/src/preact/textInput/text-input.stories.tsx +14 -11
  24. package/src/preact/textInput/text-input.tsx +39 -140
  25. package/src/types.ts +3 -0
  26. package/src/utilEntrypoint.ts +2 -0
  27. package/src/web-components/input/gs-lineage-filter.stories.ts +120 -31
  28. package/src/web-components/input/gs-lineage-filter.tsx +24 -8
  29. package/src/web-components/input/gs-location-filter.stories.ts +9 -0
  30. package/src/web-components/input/gs-location-filter.tsx +21 -3
  31. package/src/web-components/input/gs-text-input.stories.ts +14 -5
  32. package/src/web-components/input/gs-text-input.tsx +23 -7
  33. package/standalone-bundle/dashboard-components.js +5574 -5605
  34. package/standalone-bundle/dashboard-components.js.map +1 -1
  35. package/dist/LocationChangedEvent-CORvQvXv.js.map +0 -1
  36. package/src/preact/textInput/fetchAutocompleteList.ts +0 -9
@@ -14,8 +14,9 @@ import { withinShadowRoot } from '../withinShadowRoot.story';
14
14
  const codeExample = String.raw`
15
15
  <gs-text-input
16
16
  lapisField="host"
17
+ lapisFilter='{"country": "Germany"}'
17
18
  placeholderText="Enter host name"
18
- initialValue="Homo sapiens"
19
+ value="Homo sapiens"
19
20
  width="50%">
20
21
  </gs-text-input>`;
21
22
 
@@ -34,6 +35,7 @@ const meta: Meta<Required<TextInputProps>> = {
34
35
  url: AGGREGATED_ENDPOINT,
35
36
  body: {
36
37
  fields: ['host'],
38
+ country: 'Germany',
37
39
  },
38
40
  },
39
41
  response: {
@@ -60,7 +62,7 @@ const meta: Meta<Required<TextInputProps>> = {
60
62
  type: 'text',
61
63
  },
62
64
  },
63
- initialValue: {
65
+ value: {
64
66
  control: {
65
67
  type: 'text',
66
68
  },
@@ -70,6 +72,11 @@ const meta: Meta<Required<TextInputProps>> = {
70
72
  type: 'text',
71
73
  },
72
74
  },
75
+ lapisFilter: {
76
+ control: {
77
+ type: 'object',
78
+ },
79
+ },
73
80
  },
74
81
  tags: ['autodocs'],
75
82
  };
@@ -82,8 +89,9 @@ export const Default: StoryObj<Required<TextInputProps>> = {
82
89
  <div class="max-w-screen-lg">
83
90
  <gs-text-input
84
91
  .lapisField=${args.lapisField}
92
+ .lapisFilter=${args.lapisFilter}
85
93
  .placeholderText=${args.placeholderText}
86
- .initialValue=${args.initialValue}
94
+ .value=${args.value}
87
95
  .width=${args.width}
88
96
  ></gs-text-input>
89
97
  </div>
@@ -91,8 +99,9 @@ export const Default: StoryObj<Required<TextInputProps>> = {
91
99
  },
92
100
  args: {
93
101
  lapisField: 'host',
102
+ lapisFilter: { country: 'Germany' },
94
103
  placeholderText: 'Enter host name',
95
- initialValue: 'Homo sapiens',
104
+ value: 'Homo sapiens',
96
105
  width: '100%',
97
106
  },
98
107
  };
@@ -163,6 +172,6 @@ export const FiresEvents: StoryObj<Required<TextInputProps>> = {
163
172
  },
164
173
  args: {
165
174
  ...Default.args,
166
- initialValue: '',
175
+ value: '',
167
176
  },
168
177
  };
@@ -1,6 +1,7 @@
1
1
  import { customElement, property } from 'lit/decorators.js';
2
2
  import type { DetailedHTMLProps, HTMLAttributes } from 'react';
3
3
 
4
+ import { type TextInputChangedEvent } from '../../preact/textInput/TextInputChangedEvent';
4
5
  import { TextInput, type TextInputProps } from '../../preact/textInput/text-input';
5
6
  import type { Equals, Expect } from '../../utils/typeAssertions';
6
7
  import { PreactLitAdapter } from '../PreactLitAdapter';
@@ -11,7 +12,7 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
11
12
  *
12
13
  * This component provides a text input field to specify filters for arbitrary fields of this LAPIS instance.
13
14
  *
14
- * @fires {CustomEvent<Record<string, string>>} gs-text-input-changed
15
+ * @fires {CustomEvent<Record<string, string | undefined>>} gs-text-input-changed
15
16
  * Fired when the input field is changed.
16
17
  * The `details` of this event contain an object with the `lapisField` as key and the input value as value.
17
18
  * Example:
@@ -27,7 +28,7 @@ export class TextInputComponent extends PreactLitAdapter {
27
28
  * The initial value to use for this text input.
28
29
  */
29
30
  @property()
30
- initialValue: string | undefined = undefined;
31
+ value: string | undefined = undefined;
31
32
 
32
33
  /**
33
34
  * Required.
@@ -38,6 +39,19 @@ export class TextInputComponent extends PreactLitAdapter {
38
39
  @property()
39
40
  lapisField = '';
40
41
 
42
+ /**
43
+ * The filter that is used to fetch the available the autocomplete options.
44
+ * If not set it fetches all available options.
45
+ * It must be a valid LAPIS filter object.
46
+ */
47
+ @property({ type: Object })
48
+ lapisFilter: Record<string, string | string[] | number | null | boolean | undefined> & {
49
+ nucleotideMutations?: string[];
50
+ aminoAcidMutations?: string[];
51
+ nucleotideInsertions?: string[];
52
+ aminoAcidInsertions?: string[];
53
+ } = {};
54
+
41
55
  /**
42
56
  * The placeholder text to display in the input field.
43
57
  */
@@ -56,8 +70,9 @@ export class TextInputComponent extends PreactLitAdapter {
56
70
  return (
57
71
  <TextInput
58
72
  lapisField={this.lapisField}
73
+ lapisFilter={this.lapisFilter}
59
74
  placeholderText={this.placeholderText}
60
- initialValue={this.initialValue}
75
+ value={this.value}
61
76
  width={this.width}
62
77
  />
63
78
  );
@@ -70,7 +85,7 @@ declare global {
70
85
  }
71
86
 
72
87
  interface HTMLElementEventMap {
73
- 'gs-text-input-changed': CustomEvent<Record<string, string>>;
88
+ 'gs-text-input-changed': TextInputChangedEvent;
74
89
  }
75
90
  }
76
91
 
@@ -84,10 +99,11 @@ declare global {
84
99
  }
85
100
 
86
101
  /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
87
- type InitialValueMatches = Expect<
88
- Equals<typeof TextInputComponent.prototype.initialValue, TextInputProps['initialValue']>
89
- >;
102
+ type InitialValueMatches = Expect<Equals<typeof TextInputComponent.prototype.value, TextInputProps['value']>>;
90
103
  type LapisFieldMatches = Expect<Equals<typeof TextInputComponent.prototype.lapisField, TextInputProps['lapisField']>>;
104
+ type LapisFilterMatches = Expect<
105
+ Equals<typeof TextInputComponent.prototype.lapisFilter, TextInputProps['lapisFilter']>
106
+ >;
91
107
  type PlaceholderTextMatches = Expect<
92
108
  Equals<typeof TextInputComponent.prototype.placeholderText, TextInputProps['placeholderText']>
93
109
  >;