@genspectrum/dashboard-components 1.7.0 → 1.8.1

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 (31) hide show
  1. package/README.md +22 -2
  2. package/custom-elements.json +81 -0
  3. package/dist/assets/{mutationOverTimeWorker-DPS3tmOd.js.map → mutationOverTimeWorker-BRPqAM5Z.js.map} +1 -1
  4. package/dist/components.d.ts +49 -22
  5. package/dist/components.js +130 -37
  6. package/dist/components.js.map +1 -1
  7. package/dist/util.d.ts +22 -22
  8. package/package.json +1 -1
  9. package/src/preact/MutationLinkTemplateContext.tsx +56 -0
  10. package/src/preact/components/annotated-mutation.stories.tsx +69 -17
  11. package/src/preact/components/annotated-mutation.tsx +45 -19
  12. package/src/preact/mutationComparison/mutation-comparison-table.tsx +3 -0
  13. package/src/preact/mutations/mutations-table.tsx +3 -0
  14. package/src/preact/shared/stories/expectMutationAnnotation.ts +3 -1
  15. package/src/preact/wastewater/mutationsOverTime/__mockData__/detailsAminAcidNonSegmented.json +88 -0
  16. package/src/preact/wastewater/mutationsOverTime/wastewater-mutations-over-time.stories.tsx +34 -0
  17. package/src/query/queryWastewaterMutationsOverTime.ts +1 -1
  18. package/src/utils/mutations.ts +18 -10
  19. package/src/web-components/gs-app.spec-d.ts +7 -0
  20. package/src/web-components/gs-app.stories.ts +32 -2
  21. package/src/web-components/gs-app.ts +17 -0
  22. package/src/web-components/mutation-link-template-context.ts +13 -0
  23. package/src/web-components/mutationLinks.mdx +27 -0
  24. package/src/web-components/visualization/gs-mutation-comparison.tsx +18 -8
  25. package/src/web-components/visualization/gs-mutations-over-time.stories.ts +12 -1
  26. package/src/web-components/visualization/gs-mutations-over-time.tsx +24 -14
  27. package/src/web-components/visualization/gs-mutations.tsx +19 -9
  28. package/src/web-components/wastewaterVisualization/gs-wastewater-mutations-over-time.tsx +17 -7
  29. package/standalone-bundle/assets/{mutationOverTimeWorker-Dp-A14AP.js.map → mutationOverTimeWorker-DtFX4Ihx.js.map} +1 -1
  30. package/standalone-bundle/dashboard-components.js +6360 -6298
  31. package/standalone-bundle/dashboard-components.js.map +1 -1
package/README.md CHANGED
@@ -179,6 +179,26 @@ Node.js [subpath imports](https://nodejs.org/api/packages.html#subpath-imports),
179
179
  from [storybook](https://storybook.js.org/docs/writing-stories/mocking-data-and-modules/mocking-modules). This ensures
180
180
  that when importing the worker in the component, the mock worker is used inside Storybook instead of the real worker.
181
181
 
182
- ### Exporting types into the final build
182
+ ### How The Release Build Works
183
183
 
184
- This project uses `vite build`. The release config is `vite.release.config.ts`. In there, the lib export entrypoints are defined. If you want to export a utility type for your component, re-export it inside of `utilEntrypoint.ts`.
184
+ The `"exports"` field in `package.json` defines which files a user of the package can import using the normal module systems.
185
+ `"files"` defines which files are included in the package when it is published to npm.
186
+ Obviously, `"files"` must include everything that is referenced in `"exports"`,
187
+ but we also include `src/` for best practice so that users can see non-built files if they want to.
188
+
189
+ We use Vite to build the entry point files that are referenced in `"exports"`: [vite.release.config.ts](./vite.release.config.ts).
190
+ Important points to note:
191
+
192
+ - We need to build the code since we need to convert TypeScript to JavaScript.
193
+ - We also include type declarations.
194
+ - We do not minify the code. That's up to the user of the package.
195
+ - We exclude dependencies. Users should download them via their own package manager. Our libraries should not be in the build output.
196
+ - We also build a ["standalone" version](vite.release-standalone.config.ts) of the components that includes all dependencies.
197
+ This can be used without a package manager (and it's not supposed to be used if you are using a package manager).
198
+
199
+ If you add code that's supposed to be used by the users of the package,
200
+ you need to make sure that it is exported from one of the entry points defined in `"exports"`.
201
+ Currently, we have two entry points:
202
+
203
+ - [components](src/componentsEntrypoint.ts): Supposed to be used in the browser. This file registers all web components when it's imported.
204
+ - [util](src/utilEntrypoint.ts): Can also be used in a non-browser environment. Exports some code and types so that users can reuse some of our logic.
@@ -110,6 +110,14 @@
110
110
  },
111
111
  "default": "{ ...Template, args: { lapis: 'https://url.to.lapis-definitely-not-a-valid-url', }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); await waitFor(async () => { await expect( canvas.getByText('Error in gs-app: Cannot fetch reference genome.', { exact: false }), ).toBeVisible(); }); }, }"
112
112
  },
113
+ {
114
+ "kind": "variable",
115
+ "name": "ProvidesMutationLinkTemplateToChildren",
116
+ "type": {
117
+ "text": "StoryObj<StoryProps>"
118
+ },
119
+ "default": "{ ...Template, play: async ({ canvasElement }) => { const canvas = within(canvasElement); await waitFor(async () => { await expect(canvas.getByText('http://foo.com/query?nucMut={{mutation}}', { exact: false })).toBeVisible(); await expect(canvas.getByText('http://foo.com/query?aaMut={{mutation}}', { exact: false })).toBeVisible(); }); }, }"
120
+ },
113
121
  {
114
122
  "kind": "class",
115
123
  "description": "",
@@ -138,6 +146,14 @@
138
146
  "text": "MutationAnnotations"
139
147
  },
140
148
  "default": "[]"
149
+ },
150
+ {
151
+ "kind": "field",
152
+ "name": "mutationLinkTemplate",
153
+ "type": {
154
+ "text": "MutationLinkTemplate"
155
+ },
156
+ "default": "{}"
141
157
  }
142
158
  ],
143
159
  "superclass": {
@@ -189,6 +205,14 @@
189
205
  "module": "src/web-components/gs-app.stories.ts"
190
206
  }
191
207
  },
208
+ {
209
+ "kind": "js",
210
+ "name": "ProvidesMutationLinkTemplateToChildren",
211
+ "declaration": {
212
+ "name": "ProvidesMutationLinkTemplateToChildren",
213
+ "module": "src/web-components/gs-app.stories.ts"
214
+ }
215
+ },
192
216
  {
193
217
  "kind": "custom-element-definition",
194
218
  "name": "gs-app-display",
@@ -227,6 +251,16 @@
227
251
  "default": "[]",
228
252
  "description": "Supply lists of mutations that are especially relevant for the current organism.\n\nVisit https://genspectrum.github.io/dashboard-components/?path=/docs/concepts-mutation-annotations--docs for more information.",
229
253
  "attribute": "mutationAnnotations"
254
+ },
255
+ {
256
+ "kind": "field",
257
+ "name": "mutationLinkTemplate",
258
+ "type": {
259
+ "text": "{\n nucleotideMutation?: string;\n aminoAcidMutation?: string;\n }"
260
+ },
261
+ "default": "{ nucleotideMutation: undefined, aminoAcidMutation: undefined, }",
262
+ "description": "Supply a link template for nucleotide and amino acid mutations.\nThe template should include '{{mutation}}' where the mutation code will be inserted, for example:\n\n https://my-site.org/query?nucleotideMutation={{mutation}}",
263
+ "attribute": "mutationLinkTemplate"
230
264
  }
231
265
  ],
232
266
  "attributes": [
@@ -247,6 +281,15 @@
247
281
  "default": "[]",
248
282
  "description": "Supply lists of mutations that are especially relevant for the current organism.\n\nVisit https://genspectrum.github.io/dashboard-components/?path=/docs/concepts-mutation-annotations--docs for more information.",
249
283
  "fieldName": "mutationAnnotations"
284
+ },
285
+ {
286
+ "name": "mutationLinkTemplate",
287
+ "type": {
288
+ "text": "{\n nucleotideMutation?: string;\n aminoAcidMutation?: string;\n }"
289
+ },
290
+ "default": "{ nucleotideMutation: undefined, aminoAcidMutation: undefined, }",
291
+ "description": "Supply a link template for nucleotide and amino acid mutations.\nThe template should include '{{mutation}}' where the mutation code will be inserted, for example:\n\n https://my-site.org/query?nucleotideMutation={{mutation}}",
292
+ "fieldName": "mutationLinkTemplate"
250
293
  }
251
294
  ],
252
295
  "superclass": {
@@ -1798,12 +1841,50 @@
1798
1841
  }
1799
1842
  ]
1800
1843
  },
1844
+ {
1845
+ "kind": "javascript-module",
1846
+ "path": "src/web-components/mutation-link-template-context.ts",
1847
+ "declarations": [
1848
+ {
1849
+ "kind": "variable",
1850
+ "name": "mutationLinkTemplateSchema"
1851
+ },
1852
+ {
1853
+ "kind": "variable",
1854
+ "name": "mutationLinkTemplateContext"
1855
+ }
1856
+ ],
1857
+ "exports": [
1858
+ {
1859
+ "kind": "js",
1860
+ "name": "mutationLinkTemplateSchema",
1861
+ "declaration": {
1862
+ "name": "mutationLinkTemplateSchema",
1863
+ "module": "src/web-components/mutation-link-template-context.ts"
1864
+ }
1865
+ },
1866
+ {
1867
+ "kind": "js",
1868
+ "name": "mutationLinkTemplateContext",
1869
+ "declaration": {
1870
+ "name": "mutationLinkTemplateContext",
1871
+ "module": "src/web-components/mutation-link-template-context.ts"
1872
+ }
1873
+ }
1874
+ ]
1875
+ },
1801
1876
  {
1802
1877
  "kind": "javascript-module",
1803
1878
  "path": "src/web-components/mutationAnnotations.mdx",
1804
1879
  "declarations": [],
1805
1880
  "exports": []
1806
1881
  },
1882
+ {
1883
+ "kind": "javascript-module",
1884
+ "path": "src/web-components/mutationLinks.mdx",
1885
+ "declarations": [],
1886
+ "exports": []
1887
+ },
1807
1888
  {
1808
1889
  "kind": "javascript-module",
1809
1890
  "path": "src/web-components/reference-genome-context.ts",