@vitessce/vit-s 2.0.3 → 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 -0
- package/dist-tsc/CallbackPublisher.d.ts +18 -0
- package/dist-tsc/CallbackPublisher.d.ts.map +1 -0
- package/dist-tsc/CallbackPublisher.js +62 -0
- package/dist-tsc/LoadingIndicator.d.ts +2 -0
- package/dist-tsc/LoadingIndicator.d.ts.map +1 -0
- package/dist-tsc/LoadingIndicator.js +26 -0
- package/dist-tsc/TitleInfo.d.ts +2 -0
- package/dist-tsc/TitleInfo.d.ts.map +1 -0
- package/dist-tsc/TitleInfo.js +74 -0
- 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-tsc/VitessceGrid.js +60 -0
- package/dist-tsc/VitessceGrid.test.d.ts +2 -0
- package/dist-tsc/VitessceGrid.test.d.ts.map +1 -0
- package/dist-tsc/VitessceGrid.test.js +40 -0
- package/dist-tsc/Warning.d.ts +2 -0
- package/dist-tsc/Warning.d.ts.map +1 -0
- package/dist-tsc/Warning.js +45 -0
- package/dist-tsc/classNames.d.ts +8 -0
- package/dist-tsc/classNames.d.ts.map +1 -0
- package/dist-tsc/classNames.js +8 -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-tsc/data/AbstractTwoStepLoader.js +7 -0
- package/dist-tsc/data/LoaderResult.d.ts +7 -0
- package/dist-tsc/data/LoaderResult.d.ts.map +1 -0
- package/dist-tsc/data/LoaderResult.js +7 -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-tsc/data-hook-utils.js +173 -0
- package/dist-tsc/data-hooks.d.ts +77 -0
- package/dist-tsc/data-hooks.d.ts.map +1 -0
- package/dist-tsc/data-hooks.js +241 -0
- package/dist-tsc/errors/AbstractLoaderError.d.ts +10 -0
- package/dist-tsc/errors/AbstractLoaderError.d.ts.map +1 -0
- package/dist-tsc/errors/AbstractLoaderError.js +13 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts +8 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts.map +1 -0
- package/dist-tsc/errors/DataSourceFetchError.js +13 -0
- package/dist-tsc/errors/DatasetNotFoundError.d.ts +6 -0
- package/dist-tsc/errors/DatasetNotFoundError.d.ts.map +1 -0
- package/dist-tsc/errors/DatasetNotFoundError.js +17 -0
- package/dist-tsc/errors/LoaderNotFoundError.d.ts +10 -0
- package/dist-tsc/errors/LoaderNotFoundError.d.ts.map +1 -0
- package/dist-tsc/errors/LoaderNotFoundError.js +17 -0
- package/dist-tsc/errors/LoaderValidationError.d.ts +10 -0
- package/dist-tsc/errors/LoaderValidationError.d.ts.map +1 -0
- package/dist-tsc/errors/LoaderValidationError.js +15 -0
- package/dist-tsc/errors/index.d.ts +6 -0
- package/dist-tsc/errors/index.d.ts.map +1 -0
- package/dist-tsc/errors/index.js +5 -0
- package/dist-tsc/hooks.d.ts +80 -0
- package/dist-tsc/hooks.d.ts.map +1 -0
- package/dist-tsc/hooks.js +271 -0
- package/dist-tsc/index.d.ts +11 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +10 -17
- package/dist-tsc/plugins.test.fixtures.d.ts +61 -0
- package/dist-tsc/plugins.test.fixtures.d.ts.map +1 -0
- package/dist-tsc/plugins.test.fixtures.js +76 -0
- package/dist-tsc/schemas/config-0.1.0.schema.json +84 -0
- package/dist-tsc/schemas/config-1.0.0.schema.json +733 -0
- package/dist-tsc/schemas/config-1.0.1.schema.json +909 -0
- package/dist-tsc/schemas/config-1.0.10.schema.json +969 -0
- package/dist-tsc/schemas/config-1.0.11.schema.json +990 -0
- package/dist-tsc/schemas/config-1.0.12.schema.json +997 -0
- package/dist-tsc/schemas/config-1.0.13.schema.json +1013 -0
- package/dist-tsc/schemas/config-1.0.14.schema.json +1048 -0
- package/dist-tsc/schemas/config-1.0.15.schema.json +1048 -0
- package/dist-tsc/schemas/config-1.0.16.schema.json +1089 -0
- package/dist-tsc/schemas/config-1.0.2.schema.json +910 -0
- package/dist-tsc/schemas/config-1.0.3.schema.json +910 -0
- package/dist-tsc/schemas/config-1.0.4.schema.json +949 -0
- package/dist-tsc/schemas/config-1.0.5.schema.json +949 -0
- package/dist-tsc/schemas/config-1.0.6.schema.json +949 -0
- package/dist-tsc/schemas/config-1.0.7.schema.json +949 -0
- package/dist-tsc/schemas/config-1.0.8.schema.json +965 -0
- package/dist-tsc/schemas/config-1.0.9.schema.json +965 -0
- 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/obsSets.schema.js +195 -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/obsSetsTabular.schema.js +38 -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/schemas/raster.schema.js +120 -0
- package/dist-tsc/shared-mui/components.d.ts +2 -0
- package/dist-tsc/shared-mui/components.d.ts.map +1 -0
- package/dist-tsc/shared-mui/components.js +29 -0
- package/dist-tsc/shared-mui/container.d.ts +2 -0
- package/dist-tsc/shared-mui/container.d.ts.map +1 -0
- package/dist-tsc/shared-mui/container.js +211 -0
- package/dist-tsc/shared-mui/styles.d.ts +5 -0
- package/dist-tsc/shared-mui/styles.d.ts.map +1 -0
- package/dist-tsc/shared-mui/styles.js +109 -0
- 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-tsc/shared-plot-options/CellColorEncodingOption.js +17 -0
- 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-tsc/shared-plot-options/OptionSelect.js +12 -0
- 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-tsc/shared-plot-options/OptionsContainer.js +9 -0
- 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-tsc/shared-plot-options/styles.js +48 -0
- package/dist-tsc/state/hooks.d.ts +216 -0
- package/dist-tsc/state/hooks.d.ts.map +1 -0
- package/dist-tsc/state/hooks.js +575 -0
- 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-tsc/view-config-utils.js +234 -0
- 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-tsc/view-config-utils.test.fixtures.js +883 -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-tsc/vitessce-grid-layout/VitessceGridLayout.js +114 -0
- 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-tsc/vitessce-grid-layout/VitessceGridLayout.test.js +48 -0
- 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-tsc/vitessce-grid-layout/layout-utils.js +61 -0
- 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-tsc/vitessce-grid-layout/layout-utils.test.js +148 -0
- package/dist-tsc/vitessce-grid-utils.d.ts +13 -0
- package/dist-tsc/vitessce-grid-utils.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-utils.js +141 -0
- package/package.json +23 -10
- package/src/CallbackPublisher.js +7 -11
- package/src/LoadingIndicator.js +1 -2
- package/src/TitleInfo.js +12 -85
- package/src/VitS.js +72 -50
- package/src/VitessceGrid.js +21 -13
- package/src/VitessceGrid.test.jsx +16 -7
- package/src/Warning.js +2 -2
- package/src/data/AbstractLoader.js +2 -25
- package/src/data/AbstractTwoStepLoader.js +1 -1
- package/src/data/index.js +3 -3
- package/src/data/loader-registry.js +22 -13
- package/src/data-hook-utils.js +4 -6
- package/src/data-hooks.js +4 -4
- package/src/errors/DataSourceFetchError.js +1 -1
- package/src/errors/DatasetNotFoundError.js +1 -1
- package/src/errors/LoaderNotFoundError.js +1 -1
- package/src/errors/LoaderValidationError.js +1 -1
- package/src/errors/index.js +5 -6
- package/src/hooks.js +70 -5
- package/src/index.js +21 -46
- package/src/schemas/config-1.0.16.schema.json +21 -1
- package/src/shared-mui/components.js +10 -8
- package/src/shared-mui/container.js +1 -1
- package/src/shared-mui/styles.js +5 -2
- package/src/shared-plot-options/CellColorEncodingOption.js +3 -4
- package/src/shared-plot-options/OptionSelect.js +2 -2
- package/src/shared-plot-options/OptionsContainer.js +2 -5
- package/src/shared-plot-options/index.js +4 -4
- package/src/shared-plot-options/styles.js +1 -1
- package/src/state/hooks.js +10 -3
- package/src/title-styles.js +73 -0
- package/src/view-config-utils.js +46 -98
- package/src/view-config-utils.test.jsx +222 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.js +51 -30
- package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +17 -9
- package/src/vitessce-grid-layout/index.js +1 -1
- package/src/vitessce-grid-layout/layout-utils.js +1 -1
- package/src/vitessce-grid-layout/layout-utils.test.js +1 -1
- package/src/vitessce-grid-utils.js +27 -15
- package/dist/index.mjs +0 -84801
- package/src/component-registry.js +0 -21
- package/src/errors/OptionsValidationError.js +0 -25
- package/src/file-options-schemas-legacy.js +0 -139
- package/src/file-options-schemas-legacy.test.js +0 -138
- package/src/file-options-schemas.js +0 -327
- package/src/file-options-schemas.test.js +0 -26
- package/src/joint-file-types-legacy.js +0 -298
- package/src/joint-file-types-legacy.test.js +0 -412
- package/src/joint-file-types.js +0 -171
- package/src/joint-file-types.test.js +0 -144
- package/src/json-schemas.js +0 -9
- package/src/plugins.js +0 -186
- package/src/plugins.test.js +0 -42
- package/src/schemas/config-1.0.16.schema.test.js +0 -32
- package/src/schemas/schema.test-old.js +0 -49
- package/src/view-config-upgraders.js +0 -628
- package/src/view-config-utils.test.js +0 -95
- package/src/view-config-versions.js +0 -68
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { useState, useEffect, useRef, } from 'react';
|
|
2
|
+
import { InternMap } from 'internmap';
|
|
3
|
+
import { isEqual, pick } from 'lodash-es';
|
|
4
|
+
import { fromEntries } from '@vitessce/utils';
|
|
5
|
+
import { DATA_TYPE_COORDINATION_VALUE_USAGE } from '@vitessce/constants-internal';
|
|
6
|
+
import { getSourceAndLoaderFromFileType, getDataTypeFromFileType } from './data/loader-registry.js';
|
|
7
|
+
/**
|
|
8
|
+
* Return the bottom coordinate of the layout.
|
|
9
|
+
* https://github.com/STRML/react-grid-layout/blob/20dac73f91274526034c00968b5bedb9c2ed36b9/lib/utils.js#L82
|
|
10
|
+
* @param {array} layout react-grid-layout layout array.
|
|
11
|
+
* @returns {number} Bottom coordinate.
|
|
12
|
+
*/
|
|
13
|
+
function getNumRows(layout) {
|
|
14
|
+
let max = 0;
|
|
15
|
+
let bottomY;
|
|
16
|
+
// eslint-disable-next-line no-plusplus
|
|
17
|
+
for (let i = 0, len = layout.length; i < len; i++) {
|
|
18
|
+
bottomY = layout[i].y + layout[i].h;
|
|
19
|
+
if (bottomY > max)
|
|
20
|
+
max = bottomY;
|
|
21
|
+
}
|
|
22
|
+
return max;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compute the row height based on the container height, number of rows,
|
|
26
|
+
* and margin/padding. Basically the reverse of the react-grid-layout's
|
|
27
|
+
* `.containerHeight()` function.
|
|
28
|
+
* https://github.com/STRML/react-grid-layout/blob/83251e5e682abfa3252ff89d4bacf47fdc1f4270/lib/ReactGridLayout.jsx#L223
|
|
29
|
+
* @param {number} containerHeight The height of the .vitessce-container element.
|
|
30
|
+
* @param {number} numRows The number of rows in the layout.
|
|
31
|
+
* @param {number} margin The margin value that will be passed to VitessceGrid.
|
|
32
|
+
* @param {number} padding The padding value that will be passed to VitessceGrid.
|
|
33
|
+
* @returns {number} The new row height value.
|
|
34
|
+
*/
|
|
35
|
+
function getRowHeight(containerHeight, numRows, margin, padding) {
|
|
36
|
+
const effectiveContainerHeight = containerHeight - 2 * padding - (numRows - 1) * margin;
|
|
37
|
+
return effectiveContainerHeight / numRows;
|
|
38
|
+
}
|
|
39
|
+
export function useRowHeight(config, initialRowHeight, height, margin, padding) {
|
|
40
|
+
const [containerHeight, setContainerHeight] = useState(height);
|
|
41
|
+
const [rowHeight, setRowHeight] = useState(initialRowHeight);
|
|
42
|
+
const containerRef = useRef();
|
|
43
|
+
// Detect when the `config` or `containerHeight` variables
|
|
44
|
+
// have changed, and update `rowHeight` in response.
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const numRows = getNumRows(config.layout);
|
|
47
|
+
const newRowHeight = getRowHeight(containerHeight, numRows, margin, padding);
|
|
48
|
+
setRowHeight(newRowHeight);
|
|
49
|
+
}, [containerHeight, config, margin, padding]);
|
|
50
|
+
// Update the `containerHeight` state when the `height` prop has changed.
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (height !== null && height !== undefined) {
|
|
53
|
+
setContainerHeight(height);
|
|
54
|
+
}
|
|
55
|
+
}, [height]);
|
|
56
|
+
// If no height prop has been provided, set the `containerHeight`
|
|
57
|
+
// using height of the `.vitessce-container` element.
|
|
58
|
+
// Check the container element height whenever the window has been
|
|
59
|
+
// resized, as it may change if `.vitessce-container` should be
|
|
60
|
+
// sized relative to its parent (and by extension, potentially the window).
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (height !== null && height !== undefined) {
|
|
63
|
+
// eslint will complain if the return value is inconsistent,
|
|
64
|
+
// so return a no-op function.
|
|
65
|
+
return () => { };
|
|
66
|
+
}
|
|
67
|
+
function onWindowResize() {
|
|
68
|
+
if (!containerRef.current)
|
|
69
|
+
return;
|
|
70
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
71
|
+
setContainerHeight(containerRect.height);
|
|
72
|
+
}
|
|
73
|
+
window.addEventListener('resize', onWindowResize);
|
|
74
|
+
onWindowResize();
|
|
75
|
+
return () => {
|
|
76
|
+
window.removeEventListener('resize', onWindowResize);
|
|
77
|
+
};
|
|
78
|
+
}, [containerRef, height]);
|
|
79
|
+
return [rowHeight, containerRef];
|
|
80
|
+
}
|
|
81
|
+
function withDefaults(coordinationValues, dataType, fileType, datasetUid, defaultCoordinationValues) {
|
|
82
|
+
const defaultKeys = DATA_TYPE_COORDINATION_VALUE_USAGE[dataType]
|
|
83
|
+
.filter(k => (Object.keys(defaultCoordinationValues).includes(k)
|
|
84
|
+
&& defaultCoordinationValues[k]
|
|
85
|
+
&& !Object.keys(coordinationValues).includes(k)));
|
|
86
|
+
const defaultValues = pick(defaultCoordinationValues, defaultKeys);
|
|
87
|
+
const coordinationValuesWithDefaults = {
|
|
88
|
+
...defaultValues,
|
|
89
|
+
// The user-provided values should take precedence.
|
|
90
|
+
...coordinationValues,
|
|
91
|
+
};
|
|
92
|
+
if (!isEqual(coordinationValues, coordinationValuesWithDefaults)) {
|
|
93
|
+
// eslint-disable-next-line max-len
|
|
94
|
+
console.warn(`Using coordination value defaults for file type ${fileType} in dataset ${datasetUid}\nBefore: ${JSON.stringify(coordinationValues)}\nAfter: ${JSON.stringify(coordinationValuesWithDefaults)}`);
|
|
95
|
+
}
|
|
96
|
+
return coordinationValuesWithDefaults;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create a mapping from dataset ID to loader objects by data type.
|
|
100
|
+
* @param {object[]} datasets The datasets array from the view config.
|
|
101
|
+
* @param {string} configDescription The top-level description in the
|
|
102
|
+
* @param {PluginFileType[]} fileTypes
|
|
103
|
+
* @param {PluginCoordinationType[]} coordinationTypes
|
|
104
|
+
* view config.
|
|
105
|
+
* @returns {object} Mapping from dataset ID to data type to loader
|
|
106
|
+
* instance.
|
|
107
|
+
*/
|
|
108
|
+
export function createLoaders(datasets, configDescription, fileTypes, coordinationTypes) {
|
|
109
|
+
const result = {};
|
|
110
|
+
const dataSources = {};
|
|
111
|
+
const defaultCoordinationValues = fromEntries(coordinationTypes.map(ct => ([ct.name, ct.defaultValue])));
|
|
112
|
+
datasets.forEach((dataset) => {
|
|
113
|
+
const datasetLoaders = {
|
|
114
|
+
name: dataset.name,
|
|
115
|
+
description: dataset.description || configDescription,
|
|
116
|
+
loaders: {},
|
|
117
|
+
};
|
|
118
|
+
dataset.files.forEach((file) => {
|
|
119
|
+
const { url, options, requestInit, fileType, coordinationValues = {}, } = file;
|
|
120
|
+
const dataType = getDataTypeFromFileType(fileType, fileTypes);
|
|
121
|
+
const coordinationValuesWithDefaults = withDefaults(coordinationValues, dataType, fileType, dataset.uid, defaultCoordinationValues);
|
|
122
|
+
const [DataSourceClass, LoaderClass] = getSourceAndLoaderFromFileType(fileType, fileTypes);
|
|
123
|
+
// Create _one_ DataSourceClass instance per URL. Derived loaders share this object.
|
|
124
|
+
const fileId = url || JSON.stringify(options);
|
|
125
|
+
if (!(fileId in dataSources)) {
|
|
126
|
+
dataSources[fileId] = new DataSourceClass({ url, requestInit });
|
|
127
|
+
}
|
|
128
|
+
const loader = new LoaderClass(dataSources[fileId], file);
|
|
129
|
+
if (datasetLoaders.loaders[dataType]) {
|
|
130
|
+
datasetLoaders.loaders[dataType].set(coordinationValuesWithDefaults, loader);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
datasetLoaders.loaders[dataType] = new InternMap([
|
|
134
|
+
[coordinationValuesWithDefaults, loader],
|
|
135
|
+
], JSON.stringify);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
result[dataset.uid] = datasetLoaders;
|
|
139
|
+
});
|
|
140
|
+
return result;
|
|
141
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/vit-s",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -8,30 +8,36 @@
|
|
|
8
8
|
"url": "git+https://github.com/vitessce/vitessce.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
12
13
|
"files": [
|
|
14
|
+
"src",
|
|
13
15
|
"dist",
|
|
14
|
-
"
|
|
16
|
+
"dist-tsc"
|
|
15
17
|
],
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"@material-ui/core": "~4.12.3",
|
|
18
20
|
"@material-ui/icons": "~4.11.2",
|
|
19
|
-
"ajv": "^6.10.0",
|
|
20
21
|
"clsx": "^1.1.1",
|
|
22
|
+
"d3-array": "^2.4.0",
|
|
21
23
|
"fast-deep-equal": "^3.1.3",
|
|
22
24
|
"internmap": "^2.0.3",
|
|
23
25
|
"jss-plugin-global": "^10.9.2",
|
|
24
|
-
"lodash": "^4.17.21",
|
|
26
|
+
"lodash-es": "^4.17.21",
|
|
25
27
|
"react-grid-layout-with-lodash": "^1.3.5",
|
|
26
|
-
"uuid": "^
|
|
28
|
+
"uuid": "^9.0.0",
|
|
27
29
|
"zustand": "^3.5.10",
|
|
28
|
-
"@vitessce/constants-internal": "
|
|
29
|
-
"@vitessce/
|
|
30
|
+
"@vitessce/constants-internal": "3.0.0",
|
|
31
|
+
"@vitessce/plugins": "3.0.0",
|
|
32
|
+
"@vitessce/schemas": "3.0.0",
|
|
33
|
+
"@vitessce/utils": "3.0.0"
|
|
30
34
|
},
|
|
31
35
|
"devDependencies": {
|
|
32
36
|
"react": "^18.0.0",
|
|
33
|
-
"vite": "^3.0
|
|
34
|
-
"vitest": "^0.23.4"
|
|
37
|
+
"vite": "^4.3.0",
|
|
38
|
+
"vitest": "^0.23.4",
|
|
39
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
40
|
+
"@testing-library/react": "^13.3.0"
|
|
35
41
|
},
|
|
36
42
|
"peerDependencies": {
|
|
37
43
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
@@ -39,5 +45,12 @@
|
|
|
39
45
|
"scripts": {
|
|
40
46
|
"bundle": "pnpm exec vite build -c ../../scripts/vite.config.js",
|
|
41
47
|
"test": "pnpm exec vitest --run -r ../../ --dir ."
|
|
48
|
+
},
|
|
49
|
+
"module": "dist/index.js",
|
|
50
|
+
"exports": {
|
|
51
|
+
".": {
|
|
52
|
+
"types": "./dist-tsc/index.d.ts",
|
|
53
|
+
"import": "./dist/index.js"
|
|
54
|
+
}
|
|
42
55
|
}
|
|
43
56
|
}
|
package/src/CallbackPublisher.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { useViewConfigStoreApi, useLoaders, useWarning } from './state/hooks';
|
|
2
|
+
import { useViewConfigStoreApi, useLoaders, useWarning } from './state/hooks.js';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
function validateViewConfig(viewConfig, pluginSpecificConfigSchema) {
|
|
6
6
|
// Need the try-catch here since Zustand will actually
|
|
7
7
|
// just catch and ignore errors in its subscription callbacks.
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
const valid = validate(viewConfig);
|
|
11
|
-
if (!valid) {
|
|
12
|
-
const failureReason = JSON.stringify(validate.errors, null, 2);
|
|
13
|
-
throw new Error(`Config validation failed: ${failureReason}`);
|
|
14
|
-
}
|
|
9
|
+
pluginSpecificConfigSchema.parse(viewConfig);
|
|
15
10
|
} catch (e) {
|
|
16
11
|
console.error(e);
|
|
17
12
|
}
|
|
@@ -36,6 +31,7 @@ export default function CallbackPublisher(props) {
|
|
|
36
31
|
onConfigChange,
|
|
37
32
|
onLoaderChange,
|
|
38
33
|
validateOnConfigChange,
|
|
34
|
+
pluginSpecificConfigSchema,
|
|
39
35
|
} = props;
|
|
40
36
|
|
|
41
37
|
const warning = useWarning();
|
|
@@ -51,7 +47,7 @@ export default function CallbackPublisher(props) {
|
|
|
51
47
|
// The function to run on each publish.
|
|
52
48
|
(viewConfig) => {
|
|
53
49
|
if (validateOnConfigChange && viewConfig) {
|
|
54
|
-
validateViewConfig(viewConfig);
|
|
50
|
+
validateViewConfig(viewConfig, pluginSpecificConfigSchema);
|
|
55
51
|
}
|
|
56
52
|
if (onConfigChange && viewConfig) {
|
|
57
53
|
onConfigChange(viewConfig);
|
|
@@ -60,7 +56,7 @@ export default function CallbackPublisher(props) {
|
|
|
60
56
|
// The function to specify which part of the store
|
|
61
57
|
// we want to subscribe to.
|
|
62
58
|
state => state.viewConfig,
|
|
63
|
-
), [onConfigChange, validateOnConfigChange, viewConfigStoreApi]);
|
|
59
|
+
), [onConfigChange, validateOnConfigChange, viewConfigStoreApi, pluginSpecificConfigSchema]);
|
|
64
60
|
|
|
65
61
|
// Emit updates to the warning message.
|
|
66
62
|
useEffect(() => {
|
package/src/LoadingIndicator.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { makeStyles } from '@material-ui/core
|
|
3
|
-
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
2
|
+
import { makeStyles, CircularProgress } from '@material-ui/core';
|
|
4
3
|
|
|
5
4
|
const useStyles = makeStyles(() => ({
|
|
6
5
|
loadingIndicatorBackdrop: {
|
package/src/TitleInfo.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { makeStyles } from '@material-ui/core
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import CloseIcon from '@material-ui/icons/Close';
|
|
3
|
+
import { makeStyles, MenuItem, IconButton, Link } from '@material-ui/core';
|
|
4
|
+
import {
|
|
5
|
+
CloudDownload as CloudDownloadIcon,
|
|
6
|
+
ArrowDropDown as ArrowDropDownIcon,
|
|
7
|
+
ArrowDropUp as ArrowDropUpIcon,
|
|
8
|
+
Settings as SettingsIcon,
|
|
9
|
+
Close as CloseIcon,
|
|
10
|
+
} from '@material-ui/icons';
|
|
12
11
|
|
|
13
|
-
import { TOOLTIP_ANCESTOR } from './classNames';
|
|
14
|
-
import LoadingIndicator from './LoadingIndicator';
|
|
15
|
-
import { PopperMenu } from './shared-mui/components';
|
|
12
|
+
import { TOOLTIP_ANCESTOR } from './classNames.js';
|
|
13
|
+
import LoadingIndicator from './LoadingIndicator.js';
|
|
14
|
+
import { PopperMenu } from './shared-mui/components.js';
|
|
15
|
+
import { useTitleStyles } from './title-styles.js';
|
|
16
16
|
|
|
17
17
|
const useStyles = makeStyles(theme => ({
|
|
18
18
|
iconButton: {
|
|
@@ -117,79 +117,6 @@ function ClosePaneButton(props) {
|
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
export const useTitleStyles = makeStyles(theme => ({
|
|
121
|
-
title: {
|
|
122
|
-
color: theme.palette.primaryForeground,
|
|
123
|
-
overflowX: 'hidden',
|
|
124
|
-
display: 'flex',
|
|
125
|
-
flexDirection: 'row',
|
|
126
|
-
flexShrink: '0',
|
|
127
|
-
},
|
|
128
|
-
titleLeft: {
|
|
129
|
-
flexShrink: '1',
|
|
130
|
-
textOverflow: 'ellipsis',
|
|
131
|
-
whiteSpace: 'nowrap',
|
|
132
|
-
},
|
|
133
|
-
titleInfo: {
|
|
134
|
-
width: '100%',
|
|
135
|
-
textOverflow: 'ellipsis',
|
|
136
|
-
whiteSpace: 'nowrap',
|
|
137
|
-
overflow: 'hidden',
|
|
138
|
-
fontSize: '80% !important',
|
|
139
|
-
opacity: '.8',
|
|
140
|
-
padding: '0 4px',
|
|
141
|
-
justifyContent: 'center',
|
|
142
|
-
lineHeight: '25px !important',
|
|
143
|
-
flexShrink: '1',
|
|
144
|
-
textAlign: 'right !important',
|
|
145
|
-
},
|
|
146
|
-
titleButtons: {
|
|
147
|
-
display: 'flex',
|
|
148
|
-
flexDirection: 'row',
|
|
149
|
-
flexGrow: '1',
|
|
150
|
-
flexShrink: '0',
|
|
151
|
-
justifyContent: 'right',
|
|
152
|
-
'& div': {
|
|
153
|
-
display: 'inline-block',
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
card: {
|
|
157
|
-
border: `1px solid ${theme.palette.cardBorder}`,
|
|
158
|
-
flex: '1 1 auto',
|
|
159
|
-
minHeight: '1px',
|
|
160
|
-
padding: '12px',
|
|
161
|
-
marginTop: '8px',
|
|
162
|
-
marginBottom: '8px',
|
|
163
|
-
position: 'relative',
|
|
164
|
-
display: 'flex',
|
|
165
|
-
flexDirection: 'column',
|
|
166
|
-
minWidth: '0',
|
|
167
|
-
wordWrap: 'break-word',
|
|
168
|
-
backgroundClip: 'border-box',
|
|
169
|
-
borderRadius: '4px',
|
|
170
|
-
},
|
|
171
|
-
noScrollCard: {
|
|
172
|
-
backgroundColor: theme.palette.secondaryBackground,
|
|
173
|
-
color: theme.palette.secondaryForeground,
|
|
174
|
-
},
|
|
175
|
-
scrollCard: {
|
|
176
|
-
backgroundColor: theme.palette.primaryBackground,
|
|
177
|
-
color: theme.palette.primaryForeground,
|
|
178
|
-
'& a': {
|
|
179
|
-
color: theme.palette.primaryForegroundActive,
|
|
180
|
-
},
|
|
181
|
-
overflowY: 'auto',
|
|
182
|
-
},
|
|
183
|
-
spatialCard: {
|
|
184
|
-
backgroundColor: theme.palette.black,
|
|
185
|
-
color: theme.palette.white,
|
|
186
|
-
'& a': {
|
|
187
|
-
color: theme.palette.white,
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
}));
|
|
191
|
-
|
|
192
|
-
|
|
193
120
|
export function TitleInfo(props) {
|
|
194
121
|
const {
|
|
195
122
|
title, info, children, isScroll, isSpatial, removeGridComponent, urls,
|
package/src/VitS.js
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
1
|
import React, { useEffect, useMemo } from 'react';
|
|
3
2
|
import {
|
|
4
3
|
ThemeProvider,
|
|
5
4
|
StylesProvider,
|
|
6
5
|
createGenerateClassName,
|
|
7
|
-
} from '@material-ui/core/styles';
|
|
8
|
-
import isEqual from 'lodash
|
|
6
|
+
} from '@material-ui/core/es/styles/index.js';
|
|
7
|
+
import { isEqual } from 'lodash-es';
|
|
9
8
|
import { META_VERSION } from '@vitessce/constants-internal';
|
|
10
|
-
import {
|
|
9
|
+
import { buildConfigSchema, latestConfigSchema } from '@vitessce/schemas';
|
|
10
|
+
import { muiTheme } from './shared-mui/styles.js';
|
|
11
11
|
import {
|
|
12
12
|
ViewConfigProvider,
|
|
13
13
|
createViewConfigStore,
|
|
14
14
|
AuxiliaryProvider,
|
|
15
15
|
createAuxiliaryStore,
|
|
16
|
-
} from './state/hooks';
|
|
16
|
+
} from './state/hooks.js';
|
|
17
17
|
|
|
18
|
-
import VitessceGrid from './VitessceGrid';
|
|
19
|
-
import { Warning } from './Warning';
|
|
20
|
-
import CallbackPublisher from './CallbackPublisher';
|
|
21
|
-
import { getComponent } from './component-registry';
|
|
18
|
+
import VitessceGrid from './VitessceGrid.js';
|
|
19
|
+
import { Warning } from './Warning.js';
|
|
20
|
+
import CallbackPublisher from './CallbackPublisher.js';
|
|
22
21
|
import {
|
|
23
|
-
checkTypes,
|
|
24
22
|
initialize,
|
|
25
|
-
|
|
26
|
-
} from './view-config-utils';
|
|
23
|
+
} from './view-config-utils.js';
|
|
27
24
|
|
|
28
25
|
function logConfig(config, name) {
|
|
29
26
|
console.groupCollapsed(`🚄 Vitessce (${META_VERSION.version}) ${name}`);
|
|
@@ -38,7 +35,7 @@ function logConfig(config, name) {
|
|
|
38
35
|
* @param {object} props.config A Vitessce view config.
|
|
39
36
|
* If the config is valid, the VitessceGrid will be rendered as a child.
|
|
40
37
|
* If the config is invalid, a Warning will be rendered instead.
|
|
41
|
-
* @param {number} props.rowHeight Row height for grid layout. Optional.
|
|
38
|
+
* @param {undefined|number} props.rowHeight Row height for grid layout. Optional.
|
|
42
39
|
* @param {number} props.height Total height for grid layout. Optional.
|
|
43
40
|
* @param {string} props.theme The theme, used for styling as
|
|
44
41
|
* light or dark. Optional. By default, "dark"
|
|
@@ -53,6 +50,12 @@ function logConfig(config, name) {
|
|
|
53
50
|
* @param {undefined|string} props.uid A unique identifier for this Vitessce instance,
|
|
54
51
|
* for the purpose of avoiding CSS autogenerated class name conflicts. Must be valid as part
|
|
55
52
|
* of a CSS class name string.
|
|
53
|
+
* @param {array} props.viewTypes Plugin view types.
|
|
54
|
+
* @param {array} props.fileTypes Plugin file types.
|
|
55
|
+
* @param {array} props.jointFileTypes Plugin joint file types.
|
|
56
|
+
* @param {array} props.coordinationTypes Plugin coordination types.
|
|
57
|
+
* @param {null|object} props.warning A warning to render within the Vitessce grid,
|
|
58
|
+
* provided by the parent.
|
|
56
59
|
*/
|
|
57
60
|
export function VitS(props) {
|
|
58
61
|
const {
|
|
@@ -64,11 +67,26 @@ export function VitS(props) {
|
|
|
64
67
|
onConfigChange,
|
|
65
68
|
onLoaderChange,
|
|
66
69
|
validateOnConfigChange = false,
|
|
67
|
-
onConfigUpgrade,
|
|
68
70
|
isBounded = false,
|
|
69
71
|
uid,
|
|
72
|
+
viewTypes: viewTypesProp,
|
|
73
|
+
fileTypes: fileTypesProp,
|
|
74
|
+
jointFileTypes: jointFileTypesProp,
|
|
75
|
+
coordinationTypes: coordinationTypesProp,
|
|
76
|
+
warning,
|
|
70
77
|
} = props;
|
|
71
78
|
|
|
79
|
+
const viewTypes = useMemo(() => (viewTypesProp || []), [viewTypesProp]);
|
|
80
|
+
const fileTypes = useMemo(() => (fileTypesProp || []), [fileTypesProp]);
|
|
81
|
+
const jointFileTypes = useMemo(
|
|
82
|
+
() => (jointFileTypesProp || []),
|
|
83
|
+
[jointFileTypesProp],
|
|
84
|
+
);
|
|
85
|
+
const coordinationTypes = useMemo(
|
|
86
|
+
() => (coordinationTypesProp || []),
|
|
87
|
+
[coordinationTypesProp],
|
|
88
|
+
);
|
|
89
|
+
|
|
72
90
|
const generateClassName = useMemo(() => createGenerateClassName({
|
|
73
91
|
disableGlobal: false, // Class names need to be deterministic
|
|
74
92
|
// Avoid conflicts with portal-ui MUI class names,
|
|
@@ -76,52 +94,48 @@ export function VitS(props) {
|
|
|
76
94
|
productionPrefix: (uid ? `vit${uid}` : 'vit'),
|
|
77
95
|
}), [uid]);
|
|
78
96
|
|
|
97
|
+
const configUid = config?.uid;
|
|
98
|
+
const configVersion = config?.version;
|
|
99
|
+
|
|
100
|
+
const pluginSpecificConfigSchema = useMemo(() => buildConfigSchema(
|
|
101
|
+
fileTypes,
|
|
102
|
+
jointFileTypes,
|
|
103
|
+
coordinationTypes,
|
|
104
|
+
viewTypes,
|
|
105
|
+
), [viewTypes, fileTypes, jointFileTypes, coordinationTypes]);
|
|
106
|
+
|
|
79
107
|
// Process the view config and memoize the result:
|
|
80
108
|
// - Validate.
|
|
81
109
|
// - Upgrade, if legacy schema.
|
|
82
110
|
// - Validate after upgrade, if legacy schema.
|
|
83
111
|
// - Initialize (based on initStrategy).
|
|
84
112
|
const [configOrWarning, success] = useMemo(() => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return [
|
|
88
|
-
{
|
|
89
|
-
title: 'No such dataset',
|
|
90
|
-
unformatted: 'The dataset configuration could not be found.',
|
|
91
|
-
},
|
|
92
|
-
false,
|
|
93
|
-
];
|
|
94
|
-
}
|
|
95
|
-
// If the view config is missing a version, show a warning message.
|
|
96
|
-
if (!config.version) {
|
|
97
|
-
return [
|
|
98
|
-
{
|
|
99
|
-
title: 'Missing version',
|
|
100
|
-
unformatted:
|
|
101
|
-
'The dataset configuration is missing a version, preventing validation.',
|
|
102
|
-
},
|
|
103
|
-
false,
|
|
104
|
-
];
|
|
113
|
+
if (warning) {
|
|
114
|
+
return [warning, false];
|
|
105
115
|
}
|
|
106
116
|
logConfig(config, 'input view config');
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
onConfigUpgrade,
|
|
111
|
-
);
|
|
112
|
-
if (upgradeSuccess) {
|
|
117
|
+
const result = latestConfigSchema.safeParse(config);
|
|
118
|
+
if (result.success) {
|
|
119
|
+
const upgradedConfig = result.data;
|
|
113
120
|
logConfig(upgradedConfig, 'upgraded view config');
|
|
121
|
+
// Perform second round of parsing against plugin-specific config schema.
|
|
122
|
+
const pluginSpecificResult = pluginSpecificConfigSchema.safeParse(upgradedConfig);
|
|
114
123
|
// Initialize the view config according to the initStrategy.
|
|
115
|
-
|
|
116
|
-
if (typeCheckSuccess) {
|
|
124
|
+
if (pluginSpecificResult.success) {
|
|
117
125
|
try {
|
|
118
|
-
const
|
|
126
|
+
const upgradedConfigWithValidPlugins = pluginSpecificResult.data;
|
|
127
|
+
const initializedConfig = initialize(
|
|
128
|
+
upgradedConfigWithValidPlugins,
|
|
129
|
+
jointFileTypes,
|
|
130
|
+
coordinationTypes,
|
|
131
|
+
viewTypes,
|
|
132
|
+
);
|
|
119
133
|
logConfig(initializedConfig, 'initialized view config');
|
|
120
134
|
return [initializedConfig, true];
|
|
121
135
|
} catch (e) {
|
|
122
136
|
return [
|
|
123
137
|
{
|
|
124
|
-
title: '
|
|
138
|
+
title: 'Config initialization failed.',
|
|
125
139
|
unformatted: e.message,
|
|
126
140
|
},
|
|
127
141
|
false,
|
|
@@ -130,14 +144,18 @@ export function VitS(props) {
|
|
|
130
144
|
}
|
|
131
145
|
return [
|
|
132
146
|
{
|
|
133
|
-
title: '
|
|
134
|
-
unformatted:
|
|
147
|
+
title: 'Config validation failed on second pass.',
|
|
148
|
+
unformatted: pluginSpecificResult.error.message,
|
|
135
149
|
},
|
|
136
150
|
false,
|
|
137
151
|
];
|
|
138
152
|
}
|
|
139
|
-
return [
|
|
140
|
-
|
|
153
|
+
return [{
|
|
154
|
+
title: 'Config validation failed on first pass.',
|
|
155
|
+
unformatted: result.error.message,
|
|
156
|
+
}, result.success];
|
|
157
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
158
|
+
}, [configUid, configVersion, pluginSpecificConfigSchema, warning]);
|
|
141
159
|
|
|
142
160
|
// Emit the upgraded/initialized view config
|
|
143
161
|
// to onConfigChange if necessary.
|
|
@@ -145,7 +163,8 @@ export function VitS(props) {
|
|
|
145
163
|
if (success && !isEqual(configOrWarning, config) && onConfigChange) {
|
|
146
164
|
onConfigChange(configOrWarning);
|
|
147
165
|
}
|
|
148
|
-
|
|
166
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
167
|
+
}, [success, configUid, configOrWarning, onConfigChange]);
|
|
149
168
|
|
|
150
169
|
return success ? (
|
|
151
170
|
<StylesProvider generateClassName={generateClassName}>
|
|
@@ -153,8 +172,10 @@ export function VitS(props) {
|
|
|
153
172
|
<ViewConfigProvider createStore={createViewConfigStore}>
|
|
154
173
|
<AuxiliaryProvider createStore={createAuxiliaryStore}>
|
|
155
174
|
<VitessceGrid
|
|
175
|
+
viewTypes={viewTypes}
|
|
176
|
+
fileTypes={fileTypes}
|
|
177
|
+
coordinationTypes={coordinationTypes}
|
|
156
178
|
config={configOrWarning}
|
|
157
|
-
getComponent={getComponent}
|
|
158
179
|
rowHeight={rowHeight}
|
|
159
180
|
height={height}
|
|
160
181
|
theme={theme}
|
|
@@ -165,6 +186,7 @@ export function VitS(props) {
|
|
|
165
186
|
onConfigChange={onConfigChange}
|
|
166
187
|
onLoaderChange={onLoaderChange}
|
|
167
188
|
validateOnConfigChange={validateOnConfigChange}
|
|
189
|
+
pluginSpecificConfigSchema={pluginSpecificConfigSchema}
|
|
168
190
|
/>
|
|
169
191
|
</AuxiliaryProvider>
|
|
170
192
|
</ViewConfigProvider>
|
package/src/VitessceGrid.js
CHANGED
|
@@ -3,9 +3,9 @@ import React, {
|
|
|
3
3
|
useCallback,
|
|
4
4
|
} from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { VITESSCE_CONTAINER } from './classNames';
|
|
7
|
-
import { VitessceGridLayout } from './vitessce-grid-layout';
|
|
8
|
-
import { useRowHeight, createLoaders } from './vitessce-grid-utils';
|
|
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
9
|
import {
|
|
10
10
|
useViewConfigStoreApi,
|
|
11
11
|
useSetViewConfig,
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
useRemoveComponent,
|
|
15
15
|
useChangeLayout,
|
|
16
16
|
useLayout,
|
|
17
|
-
} from './state/hooks';
|
|
17
|
+
} from './state/hooks.js';
|
|
18
18
|
import {
|
|
19
19
|
useClosestVitessceContainerSize,
|
|
20
|
-
} from './hooks';
|
|
21
|
-
import { useVitessceContainerStyles } from './shared-mui/container';
|
|
22
|
-
import { useTitleStyles } from './
|
|
20
|
+
} from './hooks.js';
|
|
21
|
+
import { useVitessceContainerStyles } from './shared-mui/container.js';
|
|
22
|
+
import { useTitleStyles } from './title-styles.js';
|
|
23
23
|
|
|
24
24
|
const padding = 10;
|
|
25
25
|
const margin = 5;
|
|
@@ -29,20 +29,23 @@ const margin = 5;
|
|
|
29
29
|
* @param {object} props
|
|
30
30
|
* @param {number} props.rowHeight The height of each grid row. Optional.
|
|
31
31
|
* @param {object} props.config The view config.
|
|
32
|
-
* @param {function} props.getComponent A function that maps component names to their
|
|
33
|
-
* React counterparts.
|
|
34
32
|
* @param {string} props.theme The theme name.
|
|
35
33
|
* @param {number} props.height Total height for grid. Optional.
|
|
36
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
|
|
37
38
|
*/
|
|
38
39
|
export default function VitessceGrid(props) {
|
|
39
40
|
const {
|
|
40
41
|
rowHeight: initialRowHeight,
|
|
41
42
|
config,
|
|
42
|
-
getComponent,
|
|
43
43
|
theme,
|
|
44
44
|
height,
|
|
45
45
|
isBounded,
|
|
46
|
+
viewTypes,
|
|
47
|
+
fileTypes,
|
|
48
|
+
coordinationTypes,
|
|
46
49
|
} = props;
|
|
47
50
|
|
|
48
51
|
const [rowHeight, containerRef] = useRowHeight(config, initialRowHeight, height, margin, padding);
|
|
@@ -75,13 +78,18 @@ export default function VitessceGrid(props) {
|
|
|
75
78
|
useEffect(() => {
|
|
76
79
|
if (config) {
|
|
77
80
|
setViewConfig(config);
|
|
78
|
-
const loaders = createLoaders(
|
|
81
|
+
const loaders = createLoaders(
|
|
82
|
+
config.datasets,
|
|
83
|
+
config.description,
|
|
84
|
+
fileTypes,
|
|
85
|
+
coordinationTypes,
|
|
86
|
+
);
|
|
79
87
|
setLoaders(loaders);
|
|
80
88
|
} else {
|
|
81
89
|
// No config found, so clear the loaders.
|
|
82
90
|
setLoaders({});
|
|
83
91
|
}
|
|
84
|
-
}, [config, setViewConfig, setLoaders]);
|
|
92
|
+
}, [config, setViewConfig, setLoaders, fileTypes, coordinationTypes]);
|
|
85
93
|
|
|
86
94
|
return (
|
|
87
95
|
<div
|
|
@@ -94,7 +102,7 @@ export default function VitessceGrid(props) {
|
|
|
94
102
|
height={height}
|
|
95
103
|
rowHeight={rowHeight}
|
|
96
104
|
theme={theme}
|
|
97
|
-
|
|
105
|
+
viewTypes={viewTypes}
|
|
98
106
|
draggableHandle={titleClasses.title}
|
|
99
107
|
margin={margin}
|
|
100
108
|
padding={padding}
|