Skip to content

Commit 9825e41

Browse files
committed
Normalise mapped components' props with ArrayValue
1 parent e4dd359 commit 9825e41

File tree

17 files changed

+73
-58
lines changed

17 files changed

+73
-58
lines changed

packages/app/src/providers/mock/mock-api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import {
55
} from '@h5web/shared/guards';
66
import {
77
type ArrayShape,
8+
type ArrayValue,
89
type AttributeValues,
910
type Dataset,
1011
type Entity,
1112
type GroupWithChildren,
12-
type NumArrayDataset,
13+
type NumericType,
1314
type ProvidedEntity,
1415
type Value,
1516
} from '@h5web/shared/hdf5-models';
@@ -123,7 +124,7 @@ export class MockApi extends DataProviderApi {
123124
) {
124125
return async () => {
125126
let csv = '';
126-
(value as Value<NumArrayDataset>).forEach((val) => {
127+
(value as ArrayValue<NumericType>).forEach((val) => {
127128
csv += `${val.toString()}\n`;
128129
});
129130

packages/app/src/providers/mock/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
type Dataset,
1010
type DType,
1111
type GroupWithChildren,
12-
type Primitive,
1312
type ProvidedEntity,
1413
type ScalarShape,
14+
type ScalarValue,
1515
} from '@h5web/shared/hdf5-models';
1616
import { getChildEntity } from '@h5web/shared/hdf5-utils';
1717
import ndarray from 'ndarray';
@@ -50,9 +50,9 @@ export function sliceValue<T extends DType>(
5050
value: unknown,
5151
dataset: Dataset<ArrayShape | ScalarShape, T>,
5252
selection: string,
53-
): Primitive<T>[] {
53+
): ScalarValue<T>[] {
5454
const { shape } = dataset;
55-
const dataArray = ndarray(value as Primitive<typeof dataset.type>[], shape);
55+
const dataArray = ndarray(value as ScalarValue<typeof dataset.type>[], shape);
5656
const mappedArray = applyMapping(
5757
dataArray,
5858
selection.split(',').map((s) => (s === ':' ? s : Number.parseInt(s))),

packages/app/src/vis-packs/core/complex/MappedComplexLineVis.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import {
66
useSafeDomain,
77
useVisDomain,
88
} from '@h5web/lib';
9-
import { type ArrayValue, type ComplexType } from '@h5web/shared/hdf5-models';
9+
import {
10+
type ArrayValue,
11+
type ComplexType,
12+
type NumericType,
13+
} from '@h5web/shared/hdf5-models';
1014
import { type AxisMapping } from '@h5web/shared/nexus-models';
11-
import { type NumArray } from '@h5web/shared/vis-models';
1215
import { createPortal } from 'react-dom';
1316

1417
import { type DimensionMapping } from '../../../dimension-mapper/models';
@@ -28,7 +31,7 @@ interface Props {
2831
dims: number[];
2932
dimMapping: DimensionMapping;
3033
axisLabels?: AxisMapping<string>;
31-
axisValues?: AxisMapping<NumArray>;
34+
axisValues?: AxisMapping<ArrayValue<NumericType>>;
3235
title: string;
3336
toolbarContainer: HTMLDivElement | undefined;
3437
config: ComplexLineConfig;

packages/app/src/vis-packs/core/complex/MappedComplexVis.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import {
44
useValidDomainForScale,
55
useVisDomain,
66
} from '@h5web/lib';
7-
import { type H5WebComplex } from '@h5web/shared/hdf5-models';
7+
import {
8+
type ArrayValue,
9+
type ComplexType,
10+
type NumericType,
11+
} from '@h5web/shared/hdf5-models';
812
import { type AxisMapping } from '@h5web/shared/nexus-models';
9-
import { ComplexVisType, type NumArray } from '@h5web/shared/vis-models';
13+
import { ComplexVisType } from '@h5web/shared/vis-models';
1014
import { useMemo } from 'react';
1115
import { createPortal } from 'react-dom';
1216

@@ -24,11 +28,11 @@ import { type ComplexConfig } from './config';
2428
import { COMPLEX_VIS_TYPE_LABELS, getPhaseAmplitudeValues } from './utils';
2529

2630
interface Props {
27-
value: H5WebComplex[];
31+
value: ArrayValue<ComplexType>;
2832
dims: number[];
2933
dimMapping: DimensionMapping;
3034
axisLabels?: AxisMapping<string>;
31-
axisValues?: AxisMapping<NumArray>;
35+
axisValues?: AxisMapping<ArrayValue<NumericType>>;
3236
title: string;
3337
toolbarContainer: HTMLDivElement | undefined;
3438
config: ComplexConfig;

packages/app/src/vis-packs/core/compound/MappedCompoundVis.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { MatrixVis } from '@h5web/lib';
22
import {
33
type ArrayShape,
4+
type ArrayValue,
45
type CompoundType,
56
type Dataset,
67
type PrintableType,
78
type ScalarShape,
8-
type Value,
9+
type ScalarValue,
910
} from '@h5web/shared/hdf5-models';
1011
import { createPortal } from 'react-dom';
1112

@@ -20,7 +21,9 @@ import { getSliceSelection } from '../utils';
2021

2122
interface Props {
2223
dataset: Dataset<ScalarShape | ArrayShape, CompoundType<PrintableType>>;
23-
value: Value<Props['dataset']>;
24+
value:
25+
| ScalarValue<CompoundType<PrintableType>>
26+
| ArrayValue<CompoundType<PrintableType>>;
2427
dimMapping: DimensionMapping;
2528
toolbarContainer: HTMLDivElement | undefined;
2629
config: MatrixVisConfig;

packages/app/src/vis-packs/core/heatmap/MappedHeatmapVis.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {
44
type ArrayValue,
55
type Dataset,
66
type NumericLikeType,
7+
type NumericType,
78
} from '@h5web/shared/hdf5-models';
89
import { type AxisMapping } from '@h5web/shared/nexus-models';
9-
import { type NumArray } from '@h5web/shared/vis-models';
1010
import { createPortal } from 'react-dom';
1111

1212
import { type DimensionMapping } from '../../../dimension-mapper/models';
@@ -25,7 +25,7 @@ interface Props {
2525
dataset: Dataset<ArrayShape, NumericLikeType>;
2626
value: ArrayValue<NumericLikeType>;
2727
axisLabels?: AxisMapping<string>;
28-
axisValues?: AxisMapping<NumArray>;
28+
axisValues?: AxisMapping<ArrayValue<NumericType>>;
2929
dimMapping: DimensionMapping;
3030
title: string;
3131
toolbarContainer: HTMLDivElement | undefined;

packages/app/src/vis-packs/core/line/MappedLineVis.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {
88
} from '@h5web/lib';
99
import {
1010
type ArrayShape,
11+
type ArrayValue,
1112
type Dataset,
1213
type NumericLikeType,
13-
type Value,
14+
type NumericType,
1415
} from '@h5web/shared/hdf5-models';
1516
import { type AxisMapping } from '@h5web/shared/nexus-models';
16-
import { type NumArray } from '@h5web/shared/vis-models';
1717
import { createPortal } from 'react-dom';
1818

1919
import { type DimensionMapping } from '../../../dimension-mapper/models';
@@ -32,16 +32,16 @@ import LineToolbar from './LineToolbar';
3232

3333
interface Props {
3434
dataset: Dataset<ArrayShape, NumericLikeType>;
35-
value: Value<Props['dataset']>;
35+
value: ArrayValue<NumericLikeType>;
3636
valueLabel?: string;
37-
errors?: NumArray;
37+
errors?: ArrayValue<NumericType>;
3838
auxLabels?: string[];
39-
auxValues?: Value<Props['dataset']>[];
40-
auxErrors?: (NumArray | undefined)[];
39+
auxValues?: ArrayValue<NumericLikeType>[];
40+
auxErrors?: (ArrayValue<NumericType> | undefined)[];
4141
dims: number[];
4242
dimMapping: DimensionMapping;
4343
axisLabels?: AxisMapping<string>;
44-
axisValues?: AxisMapping<NumArray>;
44+
axisValues?: AxisMapping<ArrayValue<NumericType>>;
4545
title: string;
4646
toolbarContainer?: HTMLDivElement | undefined;
4747
config: LineConfig;

packages/app/src/vis-packs/core/matrix/MappedMatrixVis.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { MatrixVis } from '@h5web/lib';
22
import {
33
type ArrayShape,
4+
type ArrayValue,
45
type Dataset,
56
type PrintableType,
6-
type Value,
77
} from '@h5web/shared/hdf5-models';
88
import { createPortal } from 'react-dom';
99

@@ -18,7 +18,7 @@ import { getCellWidth, getFormatter } from './utils';
1818

1919
interface Props {
2020
dataset: Dataset<ArrayShape, PrintableType>;
21-
value: Value<Props['dataset']>;
21+
value: ArrayValue<PrintableType>;
2222
dimMapping: DimensionMapping;
2323
toolbarContainer: HTMLDivElement | undefined;
2424
config: MatrixVisConfig;

packages/app/src/vis-packs/core/rgb/MappedRgbVis.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { RgbVis } from '@h5web/lib';
2-
import { type NumArrayDataset } from '@h5web/shared/hdf5-models';
2+
import {
3+
type ArrayShape,
4+
type ArrayValue,
5+
type Dataset,
6+
type NumericType,
7+
} from '@h5web/shared/hdf5-models';
38
import { type AxisMapping } from '@h5web/shared/nexus-models';
4-
import { type NumArray } from '@h5web/shared/vis-models';
5-
import { type TypedArray } from 'ndarray';
69
import { createPortal } from 'react-dom';
710

811
import { type DimensionMapping } from '../../../dimension-mapper/models';
@@ -12,10 +15,10 @@ import { type RgbVisConfig } from './config';
1215
import RgbToolbar from './RgbToolbar';
1316

1417
interface Props {
15-
dataset: NumArrayDataset;
16-
value: number[] | TypedArray;
18+
dataset: Dataset<ArrayShape, NumericType>;
19+
value: ArrayValue<NumericType>;
1720
axisLabels?: AxisMapping<string>;
18-
axisValues?: AxisMapping<NumArray>;
21+
axisValues?: AxisMapping<ArrayValue<NumericType>>;
1922
dimMapping: DimensionMapping;
2023
title: string;
2124
toolbarContainer: HTMLDivElement | undefined;

packages/app/src/vis-packs/core/scatter/MappedScatterVis.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ScatterVis, useDomain, useSafeDomain, useVisDomain } from '@h5web/lib';
22
import { assertDefined } from '@h5web/shared/guards';
3+
import { type ArrayValue, type NumericType } from '@h5web/shared/hdf5-models';
34
import { type AxisMapping } from '@h5web/shared/nexus-models';
4-
import { type NumArray } from '@h5web/shared/vis-models';
55
import { createPortal } from 'react-dom';
66

77
import visualizerStyles from '../../../visualizer/Visualizer.module.css';
@@ -11,9 +11,9 @@ import { type ScatterConfig } from './config';
1111
import ScatterToolbar from './ScatterToolbar';
1212

1313
interface Props {
14-
value: NumArray;
14+
value: ArrayValue<NumericType>;
1515
axisLabels: AxisMapping<string>;
16-
axisValues: AxisMapping<NumArray>;
16+
axisValues: AxisMapping<ArrayValue<NumericType>>;
1717
title: string;
1818
toolbarContainer: HTMLDivElement | undefined;
1919
config: ScatterConfig;

0 commit comments

Comments
 (0)