@vitessce/vit-s 2.0.3-beta.0 → 3.0.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.
- package/dist/index.js +41348 -18
- package/dist-tsc/CallbackPublisher.d.ts +18 -0
- package/dist-tsc/CallbackPublisher.d.ts.map +1 -0
- package/{dist → dist-tsc}/CallbackPublisher.js +6 -12
- package/dist-tsc/LoadingIndicator.d.ts +2 -0
- package/dist-tsc/LoadingIndicator.d.ts.map +1 -0
- package/{dist → dist-tsc}/LoadingIndicator.js +1 -2
- package/dist-tsc/TitleInfo.d.ts +2 -0
- package/dist-tsc/TitleInfo.d.ts.map +1 -0
- package/{dist → dist-tsc}/TitleInfo.js +6 -83
- package/dist-tsc/VitS.d.ts +45 -0
- package/dist-tsc/VitS.d.ts.map +1 -0
- package/dist-tsc/VitS.js +119 -0
- package/dist-tsc/VitessceGrid.d.ts +23 -0
- package/dist-tsc/VitessceGrid.d.ts.map +1 -0
- package/{dist → dist-tsc}/VitessceGrid.js +14 -13
- package/dist-tsc/VitessceGrid.test.d.ts +2 -0
- package/dist-tsc/VitessceGrid.test.d.ts.map +1 -0
- package/{dist → dist-tsc}/VitessceGrid.test.js +8 -4
- package/dist-tsc/Warning.d.ts +2 -0
- package/dist-tsc/Warning.d.ts.map +1 -0
- package/{dist → dist-tsc}/Warning.js +2 -2
- package/dist-tsc/classNames.d.ts +8 -0
- package/dist-tsc/classNames.d.ts.map +1 -0
- package/dist-tsc/data/AbstractLoader.d.ts +22 -0
- package/dist-tsc/data/AbstractLoader.d.ts.map +1 -0
- package/dist-tsc/data/AbstractLoader.js +18 -0
- package/dist-tsc/data/AbstractTwoStepLoader.d.ts +6 -0
- package/dist-tsc/data/AbstractTwoStepLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/data/AbstractTwoStepLoader.js +1 -1
- package/dist-tsc/data/LoaderResult.d.ts +7 -0
- package/dist-tsc/data/LoaderResult.d.ts.map +1 -0
- package/dist-tsc/data/index.d.ts +4 -0
- package/dist-tsc/data/index.d.ts.map +1 -0
- package/dist-tsc/data/index.js +3 -0
- package/dist-tsc/data/loader-registry.d.ts +9 -0
- package/dist-tsc/data/loader-registry.d.ts.map +1 -0
- package/dist-tsc/data/loader-registry.js +27 -0
- package/dist-tsc/data-hook-utils.d.ts +69 -0
- package/dist-tsc/data-hook-utils.d.ts.map +1 -0
- package/{dist → dist-tsc}/data-hook-utils.js +4 -6
- package/dist-tsc/data-hooks.d.ts +77 -0
- package/dist-tsc/data-hooks.d.ts.map +1 -0
- package/{dist → dist-tsc}/data-hooks.js +4 -4
- package/dist-tsc/errors/AbstractLoaderError.d.ts +10 -0
- package/dist-tsc/errors/AbstractLoaderError.d.ts.map +1 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts +8 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/DataSourceFetchError.js +1 -1
- package/dist-tsc/errors/DatasetNotFoundError.d.ts +6 -0
- package/dist-tsc/errors/DatasetNotFoundError.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/DatasetNotFoundError.js +1 -1
- package/dist-tsc/errors/LoaderNotFoundError.d.ts +10 -0
- package/dist-tsc/errors/LoaderNotFoundError.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/LoaderNotFoundError.js +1 -1
- package/dist-tsc/errors/LoaderValidationError.d.ts +10 -0
- package/dist-tsc/errors/LoaderValidationError.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/LoaderValidationError.js +1 -1
- package/dist-tsc/errors/index.d.ts +6 -0
- package/dist-tsc/errors/index.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/index.js +5 -6
- package/dist-tsc/hooks.d.ts +80 -0
- package/dist-tsc/hooks.d.ts.map +1 -0
- package/{dist → dist-tsc}/hooks.js +60 -4
- package/dist-tsc/index.d.ts +11 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +11 -0
- package/dist-tsc/plugins.test.fixtures.d.ts +61 -0
- package/dist-tsc/plugins.test.fixtures.d.ts.map +1 -0
- package/{dist → dist-tsc}/schemas/config-1.0.16.schema.json +21 -41
- package/dist-tsc/schemas/obsSets.schema.d.ts +179 -0
- package/dist-tsc/schemas/obsSets.schema.d.ts.map +1 -0
- package/dist-tsc/schemas/obsSetsTabular.schema.d.ts +57 -0
- package/dist-tsc/schemas/obsSetsTabular.schema.d.ts.map +1 -0
- package/dist-tsc/schemas/raster.schema.d.ts +239 -0
- package/dist-tsc/schemas/raster.schema.d.ts.map +1 -0
- package/dist-tsc/shared-mui/components.d.ts +2 -0
- package/dist-tsc/shared-mui/components.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-mui/components.js +2 -8
- package/dist-tsc/shared-mui/container.d.ts +2 -0
- package/dist-tsc/shared-mui/container.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-mui/container.js +1 -1
- package/dist-tsc/shared-mui/styles.d.ts +5 -0
- package/dist-tsc/shared-mui/styles.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-mui/styles.js +4 -2
- package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts +2 -0
- package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-plot-options/CellColorEncodingOption.js +3 -4
- package/dist-tsc/shared-plot-options/OptionSelect.d.ts +2 -0
- package/dist-tsc/shared-plot-options/OptionSelect.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-plot-options/OptionSelect.js +2 -2
- package/dist-tsc/shared-plot-options/OptionsContainer.d.ts +2 -0
- package/dist-tsc/shared-plot-options/OptionsContainer.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-plot-options/OptionsContainer.js +2 -5
- package/dist-tsc/shared-plot-options/index.d.ts +5 -0
- package/dist-tsc/shared-plot-options/index.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/index.js +4 -0
- package/dist-tsc/shared-plot-options/styles.d.ts +2 -0
- package/dist-tsc/shared-plot-options/styles.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-plot-options/styles.js +1 -1
- package/dist-tsc/state/hooks.d.ts +216 -0
- package/dist-tsc/state/hooks.d.ts.map +1 -0
- package/{dist → dist-tsc}/state/hooks.js +47 -21
- package/dist-tsc/title-styles.d.ts +2 -0
- package/dist-tsc/title-styles.d.ts.map +1 -0
- package/dist-tsc/title-styles.js +72 -0
- package/dist-tsc/view-config-utils.d.ts +30 -0
- package/dist-tsc/view-config-utils.d.ts.map +1 -0
- package/{dist → dist-tsc}/view-config-utils.js +32 -84
- package/dist-tsc/view-config-utils.test.d.ts +2 -0
- package/dist-tsc/view-config-utils.test.d.ts.map +1 -0
- package/dist-tsc/view-config-utils.test.fixtures.d.ts +1049 -0
- package/dist-tsc/view-config-utils.test.fixtures.d.ts.map +1 -0
- package/{dist → dist-tsc}/view-config-utils.test.fixtures.js +118 -0
- package/dist-tsc/view-config-utils.test.js +209 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts +8 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts.map +1 -0
- package/{dist → dist-tsc}/vitessce-grid-layout/VitessceGridLayout.js +47 -28
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts.map +1 -0
- package/{dist → dist-tsc}/vitessce-grid-layout/VitessceGridLayout.test.js +13 -5
- package/dist-tsc/vitessce-grid-layout/index.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/index.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/index.js +1 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts +15 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts.map +1 -0
- package/{dist → dist-tsc}/vitessce-grid-layout/layout-utils.js +2 -1
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts.map +1 -0
- package/{dist → dist-tsc}/vitessce-grid-layout/layout-utils.test.js +3 -1
- package/dist-tsc/vitessce-grid-utils.d.ts +13 -0
- package/dist-tsc/vitessce-grid-utils.d.ts.map +1 -0
- package/{dist → dist-tsc}/vitessce-grid-utils.js +15 -14
- package/package.json +24 -11
- package/src/CallbackPublisher.js +77 -0
- package/src/LoadingIndicator.js +33 -0
- package/src/TitleInfo.js +167 -0
- package/src/VitS.js +202 -0
- package/src/VitessceGrid.js +118 -0
- package/src/VitessceGrid.test.jsx +57 -0
- package/src/Warning.js +62 -0
- package/src/classNames.js +8 -0
- package/src/data/AbstractLoader.js +23 -0
- package/src/data/AbstractTwoStepLoader.js +8 -0
- package/src/data/LoaderResult.js +8 -0
- package/src/data/index.js +3 -0
- package/src/data/loader-registry.js +28 -0
- package/src/data-hook-utils.js +195 -0
- package/src/data-hooks.js +354 -0
- package/src/errors/AbstractLoaderError.js +14 -0
- package/src/errors/DataSourceFetchError.js +15 -0
- package/src/errors/DatasetNotFoundError.js +23 -0
- package/src/errors/LoaderNotFoundError.js +24 -0
- package/src/errors/LoaderValidationError.js +23 -0
- package/src/errors/index.js +5 -0
- package/src/hooks.js +317 -0
- package/src/index.js +76 -0
- package/src/plugins.test.fixtures.js +78 -0
- package/src/schemas/config-0.1.0.schema.json +85 -0
- package/src/schemas/config-1.0.0.schema.json +733 -0
- package/src/schemas/config-1.0.1.schema.json +909 -0
- package/src/schemas/config-1.0.10.schema.json +969 -0
- package/src/schemas/config-1.0.11.schema.json +990 -0
- package/src/schemas/config-1.0.12.schema.json +997 -0
- package/src/schemas/config-1.0.13.schema.json +1013 -0
- package/src/schemas/config-1.0.14.schema.json +1048 -0
- package/src/schemas/config-1.0.15.schema.json +1048 -0
- package/src/schemas/config-1.0.16.schema.json +1089 -0
- package/src/schemas/config-1.0.2.schema.json +911 -0
- package/src/schemas/config-1.0.3.schema.json +911 -0
- package/src/schemas/config-1.0.4.schema.json +949 -0
- package/src/schemas/config-1.0.5.schema.json +949 -0
- package/src/schemas/config-1.0.6.schema.json +950 -0
- package/src/schemas/config-1.0.7.schema.json +950 -0
- package/src/schemas/config-1.0.8.schema.json +966 -0
- package/src/schemas/config-1.0.9.schema.json +965 -0
- package/src/schemas/fixtures/cellSets.good.json +16 -0
- package/src/schemas/fixtures/config-1.0.1.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.1.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.1.good.json +37 -0
- package/src/schemas/fixtures/config-1.0.2.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.2.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.2.good.json +38 -0
- package/src/schemas/fixtures/config-1.0.3.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.3.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.3.good.json +38 -0
- package/src/schemas/fixtures/obsSets.bad.json +1 -0
- package/src/schemas/fixtures/obsSets.bad.message.json +11 -0
- package/src/schemas/fixtures/obsSets.good.json +16 -0
- package/src/schemas/fixtures/obsSetsTabular.bad.json +1 -0
- package/src/schemas/fixtures/obsSetsTabular.bad.message.json +11 -0
- package/src/schemas/fixtures/obsSetsTabular.good.json +26 -0
- package/src/schemas/fixtures/raster.bad.json +1 -0
- package/src/schemas/fixtures/raster.bad.message.json +11 -0
- package/src/schemas/fixtures/raster.good.json +39 -0
- package/src/schemas/obsSets.schema.js +195 -0
- package/src/schemas/obsSetsTabular.schema.js +39 -0
- package/src/schemas/raster.schema.js +121 -0
- package/src/schemas/schema-schema.sh +34 -0
- package/src/shared-mui/components.js +81 -0
- package/src/shared-mui/container.js +212 -0
- package/src/shared-mui/styles.js +113 -0
- package/src/shared-plot-options/CellColorEncodingOption.js +42 -0
- package/src/shared-plot-options/OptionSelect.js +19 -0
- package/src/shared-plot-options/OptionsContainer.js +23 -0
- package/src/shared-plot-options/index.js +4 -0
- package/src/shared-plot-options/styles.js +49 -0
- package/src/state/hooks.js +640 -0
- package/src/title-styles.js +73 -0
- package/src/view-config-utils.js +263 -0
- package/src/view-config-utils.test.fixtures.js +893 -0
- package/src/view-config-utils.test.jsx +222 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.js +179 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +64 -0
- package/src/vitessce-grid-layout/index.js +1 -0
- package/src/vitessce-grid-layout/layout-utils.js +76 -0
- package/src/vitessce-grid-layout/layout-utils.test.js +167 -0
- package/src/vitessce-grid-utils.js +172 -0
- package/dist/VitS.js +0 -117
- package/dist/Vitessce.integration.test.js +0 -36
- package/dist/Vitessce.js +0 -101
- package/dist/component-registry.js +0 -16
- package/dist/data/AbstractLoader.js +0 -35
- package/dist/data/index.js +0 -3
- package/dist/data/loader-registry.js +0 -15
- package/dist/errors/OptionsValidationError.js +0 -15
- package/dist/export-utils.js +0 -70
- package/dist/export-utils.test.js +0 -66
- package/dist/file-options-schemas-legacy.js +0 -136
- package/dist/file-options-schemas-legacy.test.js +0 -126
- package/dist/file-options-schemas.js +0 -322
- package/dist/file-options-schemas.test.js +0 -23
- package/dist/joint-file-types-legacy.js +0 -278
- package/dist/joint-file-types-legacy.test.js +0 -400
- package/dist/joint-file-types.js +0 -148
- package/dist/joint-file-types.test.js +0 -139
- package/dist/loader-registry.js +0 -98
- package/dist/plugins.js +0 -154
- package/dist/plugins.test.js +0 -30
- package/dist/schemas/PrettyJsonSchema.js +0 -34
- package/dist/schemas/config-1.0.15.schema.test.js +0 -22
- package/dist/schemas/config-1.0.16.schema.test.js +0 -22
- package/dist/schemas/obs-sets-tabular.schema.js +0 -37
- package/dist/schemas/obs-sets.schema.js +0 -194
- package/dist/schemas/schema.test-old.js +0 -50
- package/dist/schemas/schema.test.js +0 -46
- package/dist/schemas-extra.js +0 -3
- package/dist/schemas.js +0 -4
- package/dist/shared-plot-options/index.js +0 -4
- package/dist/view-config-upgraders.js +0 -525
- package/dist/view-config-utils.test.js +0 -66
- package/dist/view-config-versions.js +0 -47
- package/dist/vitessce-grid-layout/index.js +0 -1
- /package/{dist → dist-tsc}/classNames.js +0 -0
- /package/{dist → dist-tsc}/data/LoaderResult.js +0 -0
- /package/{dist → dist-tsc}/errors/AbstractLoaderError.js +0 -0
- /package/{dist → dist-tsc}/plugins.test.fixtures.js +0 -0
- /package/{dist → dist-tsc}/schemas/config-0.1.0.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.0.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.1.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.10.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.11.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.12.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.13.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.14.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.15.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.2.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.3.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.4.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.5.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.6.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.7.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.8.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.9.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/obsSets.schema.js +0 -0
- /package/{dist → dist-tsc}/schemas/obsSetsTabular.schema.js +0 -0
- /package/{dist → dist-tsc}/schemas/raster.schema.js +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect,
|
|
3
|
+
useCallback,
|
|
4
|
+
} from 'react';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { VITESSCE_CONTAINER } from './classNames.js';
|
|
7
|
+
import { VitessceGridLayout } from './vitessce-grid-layout/index.js';
|
|
8
|
+
import { useRowHeight, createLoaders } from './vitessce-grid-utils.js';
|
|
9
|
+
import {
|
|
10
|
+
useViewConfigStoreApi,
|
|
11
|
+
useSetViewConfig,
|
|
12
|
+
useSetLoaders,
|
|
13
|
+
useEmitGridResize,
|
|
14
|
+
useRemoveComponent,
|
|
15
|
+
useChangeLayout,
|
|
16
|
+
useLayout,
|
|
17
|
+
} from './state/hooks.js';
|
|
18
|
+
import {
|
|
19
|
+
useClosestVitessceContainerSize,
|
|
20
|
+
} from './hooks.js';
|
|
21
|
+
import { useVitessceContainerStyles } from './shared-mui/container.js';
|
|
22
|
+
import { useTitleStyles } from './title-styles.js';
|
|
23
|
+
|
|
24
|
+
const padding = 10;
|
|
25
|
+
const margin = 5;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The wrapper for the VitessceGrid and LoadingIndicator components.
|
|
29
|
+
* @param {object} props
|
|
30
|
+
* @param {number} props.rowHeight The height of each grid row. Optional.
|
|
31
|
+
* @param {object} props.config The view config.
|
|
32
|
+
* @param {string} props.theme The theme name.
|
|
33
|
+
* @param {number} props.height Total height for grid. Optional.
|
|
34
|
+
* @param {function} props.onWarn A callback for warning messages. Optional.
|
|
35
|
+
* @param {PluginViewType[]} props.viewTypes
|
|
36
|
+
* @param {PluginFileType[]} props.fileTypes
|
|
37
|
+
* @param {PluginCoordinationType[]} props.coordinationTypes
|
|
38
|
+
*/
|
|
39
|
+
export default function VitessceGrid(props) {
|
|
40
|
+
const {
|
|
41
|
+
rowHeight: initialRowHeight,
|
|
42
|
+
config,
|
|
43
|
+
theme,
|
|
44
|
+
height,
|
|
45
|
+
isBounded,
|
|
46
|
+
viewTypes,
|
|
47
|
+
fileTypes,
|
|
48
|
+
coordinationTypes,
|
|
49
|
+
} = props;
|
|
50
|
+
|
|
51
|
+
const [rowHeight, containerRef] = useRowHeight(config, initialRowHeight, height, margin, padding);
|
|
52
|
+
const onResize = useEmitGridResize();
|
|
53
|
+
|
|
54
|
+
const [componentWidth] = useClosestVitessceContainerSize(containerRef);
|
|
55
|
+
|
|
56
|
+
const classes = useVitessceContainerStyles();
|
|
57
|
+
const titleClasses = useTitleStyles();
|
|
58
|
+
|
|
59
|
+
// When the row height has changed, publish a GRID_RESIZE event.
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
onResize();
|
|
62
|
+
}, [rowHeight, onResize]);
|
|
63
|
+
|
|
64
|
+
const viewConfigStoreApi = useViewConfigStoreApi();
|
|
65
|
+
const setViewConfig = useSetViewConfig(viewConfigStoreApi);
|
|
66
|
+
const setLoaders = useSetLoaders();
|
|
67
|
+
const removeComponent = useRemoveComponent();
|
|
68
|
+
const changeLayout = useChangeLayout();
|
|
69
|
+
const layout = useLayout();
|
|
70
|
+
|
|
71
|
+
const changeLayoutPostMount = useCallback((newComponentProps) => {
|
|
72
|
+
if (componentWidth > 0) {
|
|
73
|
+
changeLayout(newComponentProps);
|
|
74
|
+
}
|
|
75
|
+
}, [changeLayout, componentWidth]);
|
|
76
|
+
|
|
77
|
+
// Update the view config and loaders in the global state.
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (config) {
|
|
80
|
+
setViewConfig(config);
|
|
81
|
+
const loaders = createLoaders(
|
|
82
|
+
config.datasets,
|
|
83
|
+
config.description,
|
|
84
|
+
fileTypes,
|
|
85
|
+
coordinationTypes,
|
|
86
|
+
);
|
|
87
|
+
setLoaders(loaders);
|
|
88
|
+
} else {
|
|
89
|
+
// No config found, so clear the loaders.
|
|
90
|
+
setLoaders({});
|
|
91
|
+
}
|
|
92
|
+
}, [config, setViewConfig, setLoaders, fileTypes, coordinationTypes]);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
ref={containerRef}
|
|
97
|
+
className={clsx(VITESSCE_CONTAINER, classes.vitessceContainer)}
|
|
98
|
+
>
|
|
99
|
+
{layout && (
|
|
100
|
+
<VitessceGridLayout
|
|
101
|
+
layout={layout}
|
|
102
|
+
height={height}
|
|
103
|
+
rowHeight={rowHeight}
|
|
104
|
+
theme={theme}
|
|
105
|
+
viewTypes={viewTypes}
|
|
106
|
+
draggableHandle={titleClasses.title}
|
|
107
|
+
margin={margin}
|
|
108
|
+
padding={padding}
|
|
109
|
+
onRemoveComponent={removeComponent}
|
|
110
|
+
onLayoutChange={changeLayoutPostMount}
|
|
111
|
+
isBounded={isBounded}
|
|
112
|
+
onResize={onResize}
|
|
113
|
+
onResizeStop={onResize}
|
|
114
|
+
/>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
import { cleanup, render, screen } from '@testing-library/react';
|
|
3
|
+
import { afterEach } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { PluginViewType } from '@vitessce/plugins';
|
|
7
|
+
import VitessceGrid from './VitessceGrid.js';
|
|
8
|
+
import {
|
|
9
|
+
ViewConfigProvider, createViewConfigStore,
|
|
10
|
+
AuxiliaryProvider, createAuxiliaryStore,
|
|
11
|
+
} from './state/hooks.js';
|
|
12
|
+
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
cleanup();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('VitessceGrid.js', () => {
|
|
18
|
+
describe('<VitessceGrid />', () => {
|
|
19
|
+
it('renders', async () => {
|
|
20
|
+
const config = {
|
|
21
|
+
version: '1.0.0',
|
|
22
|
+
description: 'fake description',
|
|
23
|
+
datasets: [],
|
|
24
|
+
name: 'fake name',
|
|
25
|
+
layout: [
|
|
26
|
+
{
|
|
27
|
+
component: 'FakeComponent',
|
|
28
|
+
props: { description: 'fake prop description' },
|
|
29
|
+
uid: 'A',
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function FakeComponent() {
|
|
37
|
+
return <p>FakeComponent!</p>;
|
|
38
|
+
}
|
|
39
|
+
const viewTypes = [new PluginViewType('FakeComponent', FakeComponent, [])];
|
|
40
|
+
const fileTypes = [];
|
|
41
|
+
const coordinationTypes = [];
|
|
42
|
+
render(
|
|
43
|
+
<ViewConfigProvider createStore={createViewConfigStore}>
|
|
44
|
+
<AuxiliaryProvider createStore={createAuxiliaryStore}>
|
|
45
|
+
<VitessceGrid
|
|
46
|
+
config={config}
|
|
47
|
+
viewTypes={viewTypes}
|
|
48
|
+
fileTypes={fileTypes}
|
|
49
|
+
coordinationTypes={coordinationTypes}
|
|
50
|
+
/>
|
|
51
|
+
</AuxiliaryProvider>
|
|
52
|
+
</ViewConfigProvider>,
|
|
53
|
+
);
|
|
54
|
+
expect(await screen.findByText('FakeComponent!'));
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
package/src/Warning.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { makeStyles } from '@material-ui/core';
|
|
3
|
+
import { VITESSCE_CONTAINER } from './classNames.js';
|
|
4
|
+
|
|
5
|
+
const useStyles = makeStyles(theme => ({
|
|
6
|
+
warningLayout: {
|
|
7
|
+
backgroundColor: theme.palette.gridLayoutBackground,
|
|
8
|
+
position: 'absolute',
|
|
9
|
+
width: '100%',
|
|
10
|
+
height: '100vh',
|
|
11
|
+
},
|
|
12
|
+
containerFluid: {
|
|
13
|
+
width: '100%',
|
|
14
|
+
padding: '15px',
|
|
15
|
+
marginRight: 'auto',
|
|
16
|
+
marginLeft: 'auto',
|
|
17
|
+
boxSizing: 'border-box',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
},
|
|
20
|
+
row: {
|
|
21
|
+
flexGrow: '1',
|
|
22
|
+
},
|
|
23
|
+
card: {
|
|
24
|
+
border: `1px solid ${theme.palette.cardBorder}`,
|
|
25
|
+
flex: '1 1 auto',
|
|
26
|
+
minHeight: '1px',
|
|
27
|
+
padding: '12px',
|
|
28
|
+
marginTop: '8px',
|
|
29
|
+
marginBottom: '8px',
|
|
30
|
+
position: 'relative',
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
minWidth: '0',
|
|
34
|
+
wordWrap: 'break-word',
|
|
35
|
+
backgroundClip: 'border-box',
|
|
36
|
+
borderRadius: '4px',
|
|
37
|
+
backgroundColor: theme.palette.primaryBackground,
|
|
38
|
+
color: theme.palette.primaryForeground,
|
|
39
|
+
},
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
export function Warning(props) {
|
|
43
|
+
const {
|
|
44
|
+
title,
|
|
45
|
+
preformatted,
|
|
46
|
+
unformatted,
|
|
47
|
+
} = props;
|
|
48
|
+
const classes = useStyles();
|
|
49
|
+
return (
|
|
50
|
+
<div className={VITESSCE_CONTAINER}>
|
|
51
|
+
<div className={clsx(classes.warningLayout, classes.containerFluid)}>
|
|
52
|
+
<div className={classes.row}>
|
|
53
|
+
<div className={classes.card}>
|
|
54
|
+
<h1>{title}</h1>
|
|
55
|
+
{preformatted ? (<pre>{preformatted}</pre>) : null}
|
|
56
|
+
<p>{unformatted}</p>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const TOOLTIP_ANCESTOR = 'tooltip-ancestor';
|
|
2
|
+
const CARD = `card card-body my-2 ${TOOLTIP_ANCESTOR}`;
|
|
3
|
+
export const PRIMARY_CARD = `${CARD} bg-primary`;
|
|
4
|
+
export const SECONDARY_CARD = `${CARD} bg-secondary`;
|
|
5
|
+
export const BLACK_CARD = `${CARD} bg-black`;
|
|
6
|
+
export const TITLE_CARD = 'title';
|
|
7
|
+
export const SCROLL_CARD = `${PRIMARY_CARD} scroll`;
|
|
8
|
+
export const VITESSCE_CONTAINER = 'vitessce-container';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A loader ancestor class containing a default constructor
|
|
3
|
+
* and a stub for the required load() method.
|
|
4
|
+
*/
|
|
5
|
+
export default class AbstractLoader {
|
|
6
|
+
constructor({
|
|
7
|
+
type, fileType,
|
|
8
|
+
url, requestInit,
|
|
9
|
+
options, coordinationValues,
|
|
10
|
+
}) {
|
|
11
|
+
this.fileType = fileType;
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.url = url;
|
|
14
|
+
this.requestInit = requestInit;
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.coordinationValues = coordinationValues;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line class-methods-use-this
|
|
20
|
+
load() {
|
|
21
|
+
return Promise.resolve(true);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the data source and data loader class.
|
|
3
|
+
* @param {string} type The fileType name.
|
|
4
|
+
* @param {PluginFileType[]} fileTypes The array of file types.
|
|
5
|
+
* @returns {array} [dataSourceClass, dataLoaderClass].
|
|
6
|
+
*/
|
|
7
|
+
export function getSourceAndLoaderFromFileType(type, fileTypes) {
|
|
8
|
+
if (Array.isArray(fileTypes)) {
|
|
9
|
+
const matchingFileType = fileTypes.find(ft => ft.name === type);
|
|
10
|
+
if (matchingFileType) {
|
|
11
|
+
return matchingFileType.getSourceAndLoader();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// Fallback to JSON.
|
|
15
|
+
// TODO(monorepo)
|
|
16
|
+
// return [JsonSource, JsonLoader];
|
|
17
|
+
return [null, null];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getDataTypeFromFileType(type, fileTypes) {
|
|
21
|
+
if (Array.isArray(fileTypes)) {
|
|
22
|
+
const matchingFileType = fileTypes.find(ft => ft.name === type);
|
|
23
|
+
if (matchingFileType) {
|
|
24
|
+
return matchingFileType.dataType;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { capitalize } from '@vitessce/utils';
|
|
3
|
+
import { STATUS } from '@vitessce/constants-internal';
|
|
4
|
+
import { useMatchingLoader, useMatchingLoaders, useSetWarning } from './state/hooks.js';
|
|
5
|
+
import {
|
|
6
|
+
AbstractLoaderError,
|
|
7
|
+
LoaderNotFoundError,
|
|
8
|
+
} from './errors/index.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Warn via publishing to the console
|
|
12
|
+
* and to the global warning store.
|
|
13
|
+
* @param {AbstractLoaderError} error An error instance.
|
|
14
|
+
*/
|
|
15
|
+
export function warn(error, setWarning) {
|
|
16
|
+
setWarning(error.message);
|
|
17
|
+
console.warn(error.message);
|
|
18
|
+
console.error(error.stack);
|
|
19
|
+
if (error instanceof AbstractLoaderError) {
|
|
20
|
+
error.warnInConsole();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Initialize values in the coordination space.
|
|
26
|
+
* @param {object} values Object where
|
|
27
|
+
* keys are coordination type names,
|
|
28
|
+
* values are initial coordination values.
|
|
29
|
+
* @param {object} setters Object where
|
|
30
|
+
* keys are coordination type names with the prefix 'set',
|
|
31
|
+
* values are coordination setter functions.
|
|
32
|
+
* @param {object} initialValues Object where
|
|
33
|
+
* keys are coordination type names and keys are values.
|
|
34
|
+
*/
|
|
35
|
+
export function initCoordinationSpace(values, setters, initialValues) {
|
|
36
|
+
if (!values || !setters) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
Object.entries(values).forEach(([coordinationType, value]) => {
|
|
40
|
+
const setterName = `set${capitalize(coordinationType)}`;
|
|
41
|
+
const setterFunc = setters[setterName];
|
|
42
|
+
const initialValue = initialValues && initialValues[coordinationType];
|
|
43
|
+
// Interpret null as "uninitialized" and therefore needing initialization.
|
|
44
|
+
const shouldInit = initialValue === null;
|
|
45
|
+
if (shouldInit && setterFunc) {
|
|
46
|
+
setterFunc(value);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get data from a cells data type loader,
|
|
54
|
+
* updating "ready" and URL state appropriately.
|
|
55
|
+
* Throw warnings if the data is marked as required.
|
|
56
|
+
* Subscribe to loader updates.
|
|
57
|
+
* @param {object} loaders The object mapping
|
|
58
|
+
* datasets and data types to loader instances.
|
|
59
|
+
* @param {string} dataset The key for a dataset,
|
|
60
|
+
* used to identify which loader to use.
|
|
61
|
+
* @param {function} addUrl A function to call to update
|
|
62
|
+
* the URL list.
|
|
63
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
64
|
+
* loading is unsuccessful?
|
|
65
|
+
* @param {object} coordinationSetters Object where
|
|
66
|
+
* keys are coordination type names with the prefix 'set',
|
|
67
|
+
* values are coordination setter functions.
|
|
68
|
+
* @param {object} initialCoordinationValues Object where
|
|
69
|
+
* keys are coordination type names with the prefix 'initialize',
|
|
70
|
+
* values are initialization preferences as boolean values.
|
|
71
|
+
* @returns {array} [cells, cellsCount] where
|
|
72
|
+
* cells is an object and cellsCount is the
|
|
73
|
+
* number of items in the cells object.
|
|
74
|
+
*/
|
|
75
|
+
export function useDataType(
|
|
76
|
+
dataType, loaders, dataset, addUrl, isRequired,
|
|
77
|
+
coordinationSetters, initialCoordinationValues, matchOn,
|
|
78
|
+
) {
|
|
79
|
+
const [data, setData] = useState({});
|
|
80
|
+
const [status, setStatus] = useState(STATUS.LOADING);
|
|
81
|
+
|
|
82
|
+
const setWarning = useSetWarning();
|
|
83
|
+
const loader = useMatchingLoader(loaders, dataset, dataType, matchOn);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (loader) {
|
|
87
|
+
setStatus(STATUS.LOADING);
|
|
88
|
+
loader.load().catch(e => warn(e, setWarning)).then((payload) => {
|
|
89
|
+
if (!payload) return;
|
|
90
|
+
const { data: payloadData, url, coordinationValues } = payload;
|
|
91
|
+
setData(payloadData);
|
|
92
|
+
if (Array.isArray(url)) {
|
|
93
|
+
url.forEach(([val, name]) => {
|
|
94
|
+
addUrl(val, name);
|
|
95
|
+
});
|
|
96
|
+
} else if (url) {
|
|
97
|
+
addUrl(url, dataType);
|
|
98
|
+
}
|
|
99
|
+
initCoordinationSpace(
|
|
100
|
+
coordinationValues,
|
|
101
|
+
coordinationSetters,
|
|
102
|
+
initialCoordinationValues,
|
|
103
|
+
);
|
|
104
|
+
setStatus(STATUS.SUCCESS);
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
setData({});
|
|
108
|
+
if (isRequired) {
|
|
109
|
+
warn(new LoaderNotFoundError(loaders, dataset, dataType, matchOn), setWarning);
|
|
110
|
+
setStatus(STATUS.ERROR);
|
|
111
|
+
} else {
|
|
112
|
+
setStatus(STATUS.SUCCESS);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
116
|
+
}, [loader]);
|
|
117
|
+
|
|
118
|
+
return [data, status];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get data from a cells data type loader,
|
|
123
|
+
* updating "ready" and URL state appropriately.
|
|
124
|
+
* Throw warnings if the data is marked as required.
|
|
125
|
+
* Subscribe to loader updates.
|
|
126
|
+
* @param {object} loaders The object mapping
|
|
127
|
+
* datasets and data types to loader instances.
|
|
128
|
+
* @param {string} dataset The key for a dataset,
|
|
129
|
+
* used to identify which loader to use.
|
|
130
|
+
* @param {function} addUrl A function to call to update
|
|
131
|
+
* the URL list.
|
|
132
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
133
|
+
* loading is unsuccessful?
|
|
134
|
+
* @param {object} coordinationSetters Object where
|
|
135
|
+
* keys are coordination type names with the prefix 'set',
|
|
136
|
+
* values are coordination setter functions.
|
|
137
|
+
* @param {object} initialCoordinationValues Object where
|
|
138
|
+
* keys are coordination type names with the prefix 'initialize',
|
|
139
|
+
* values are initialization preferences as boolean values.
|
|
140
|
+
* @returns {array} [cells, cellsCount] where
|
|
141
|
+
* cells is an object and cellsCount is the
|
|
142
|
+
* number of items in the cells object.
|
|
143
|
+
*/
|
|
144
|
+
export function useDataTypeMulti(
|
|
145
|
+
dataType, loaders, dataset, addUrl, isRequired,
|
|
146
|
+
coordinationSetters, initialCoordinationValues, matchOnObj,
|
|
147
|
+
) {
|
|
148
|
+
const [data, setData] = useState({});
|
|
149
|
+
const [status, setStatus] = useState(STATUS.LOADING);
|
|
150
|
+
|
|
151
|
+
const setWarning = useSetWarning();
|
|
152
|
+
const matchingLoaders = useMatchingLoaders(loaders, dataset, dataType, matchOnObj);
|
|
153
|
+
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (matchingLoaders) {
|
|
156
|
+
setStatus(STATUS.LOADING);
|
|
157
|
+
Object.entries(matchingLoaders).forEach(([scopeKey, loader]) => {
|
|
158
|
+
if (loader) {
|
|
159
|
+
loader.load().catch(e => warn(e, setWarning)).then((payload) => {
|
|
160
|
+
if (!payload) return;
|
|
161
|
+
const { data: payloadData, url, coordinationValues } = payload;
|
|
162
|
+
setData((prev) => {
|
|
163
|
+
// eslint-disable-next-line no-param-reassign
|
|
164
|
+
prev[scopeKey] = payloadData;
|
|
165
|
+
return prev;
|
|
166
|
+
});
|
|
167
|
+
addUrl(url, dataType);
|
|
168
|
+
initCoordinationSpace(
|
|
169
|
+
coordinationValues,
|
|
170
|
+
coordinationSetters,
|
|
171
|
+
initialCoordinationValues,
|
|
172
|
+
);
|
|
173
|
+
setStatus(STATUS.SUCCESS);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
setData({});
|
|
179
|
+
if (isRequired) {
|
|
180
|
+
warn(new LoaderNotFoundError(loaders, dataset, dataType, matchOnObj), setWarning);
|
|
181
|
+
setStatus(STATUS.ERROR);
|
|
182
|
+
} else {
|
|
183
|
+
setStatus(STATUS.SUCCESS);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
187
|
+
}, [matchingLoaders]);
|
|
188
|
+
|
|
189
|
+
return [data, status];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function useHasLoader(loaders, dataset, dataType, matchOn) {
|
|
193
|
+
const loader = useMatchingLoader(loaders, dataset, dataType, matchOn);
|
|
194
|
+
return loader !== null;
|
|
195
|
+
}
|