@opengeoweb/soundings 13.1.0 → 13.2.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.
package/index.esm.js
CHANGED
|
@@ -1604,7 +1604,7 @@ const Soundings = ({
|
|
|
1604
1604
|
svg.on('mousemove', null);
|
|
1605
1605
|
};
|
|
1606
1606
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1607
|
-
}, [showTooltip, data, diagramType]);
|
|
1607
|
+
}, [showTooltip, data, diagramType, width, height]);
|
|
1608
1608
|
useEffect(() => {
|
|
1609
1609
|
const handleMouseLeave = () => {
|
|
1610
1610
|
if (pressureRef.current) {
|
|
@@ -1648,8 +1648,7 @@ const Soundings = ({
|
|
|
1648
1648
|
return jsxs(Box, {
|
|
1649
1649
|
ref: canvasRef,
|
|
1650
1650
|
sx: {
|
|
1651
|
-
position: 'relative'
|
|
1652
|
-
paddingBottom: '20px'
|
|
1651
|
+
position: 'relative'
|
|
1653
1652
|
},
|
|
1654
1653
|
children: [jsx("svg", {
|
|
1655
1654
|
ref: svgRef
|
|
@@ -2288,10 +2287,33 @@ const translateKeyOutsideComponents = (key, params = undefined) => i18n.t(key, {
|
|
|
2288
2287
|
});
|
|
2289
2288
|
const useSoundingsTranslation = () => useTranslation(ns);
|
|
2290
2289
|
|
|
2291
|
-
const
|
|
2292
|
-
const
|
|
2293
|
-
|
|
2294
|
-
|
|
2290
|
+
const TIMESLIDER_HEIGHT = 108;
|
|
2291
|
+
const LABEL_MIN_WIDTH = 48;
|
|
2292
|
+
const useMaxLabelCount = ref => {
|
|
2293
|
+
const [width, setWidth] = React.useState(0);
|
|
2294
|
+
React.useLayoutEffect(() => {
|
|
2295
|
+
let resizeObserver;
|
|
2296
|
+
if (ref.current) {
|
|
2297
|
+
resizeObserver = new ResizeObserver(entry => {
|
|
2298
|
+
const {
|
|
2299
|
+
width
|
|
2300
|
+
} = entry[0].target.getBoundingClientRect();
|
|
2301
|
+
setWidth(width);
|
|
2302
|
+
});
|
|
2303
|
+
resizeObserver.observe(ref.current);
|
|
2304
|
+
}
|
|
2305
|
+
return () => {
|
|
2306
|
+
if (resizeObserver) {
|
|
2307
|
+
resizeObserver.disconnect();
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
}, [ref]);
|
|
2311
|
+
const maxLabelCount = Math.max(1, Math.floor(width / LABEL_MIN_WIDTH));
|
|
2312
|
+
return maxLabelCount;
|
|
2313
|
+
};
|
|
2314
|
+
const shouldHideLabel = (nItems, index, maxLabelCount) => {
|
|
2315
|
+
const nthLabelsToShow = Math.ceil(nItems / maxLabelCount);
|
|
2316
|
+
return nItems > maxLabelCount &&
|
|
2295
2317
|
// hide labels if too many items
|
|
2296
2318
|
index !== nItems - 1 && (
|
|
2297
2319
|
// not last item (always shown)
|
|
@@ -2303,12 +2325,14 @@ const SoundingsTimeSlider = ({
|
|
|
2303
2325
|
selectedTime,
|
|
2304
2326
|
updateSelectedTime
|
|
2305
2327
|
}) => {
|
|
2328
|
+
const sliderRef = React.useRef(null);
|
|
2329
|
+
const maxLabelCount = useMaxLabelCount(sliderRef);
|
|
2306
2330
|
const {
|
|
2307
2331
|
i18n
|
|
2308
2332
|
} = useSoundingsTranslation();
|
|
2309
2333
|
const marks = timesteps.filter(date => dateUtils.isValidIsoDateString(date)).map((date, index, arr) => ({
|
|
2310
2334
|
value: dateUtils.unix(dateUtils.getUtcFromString(date)),
|
|
2311
|
-
label: shouldHideLabel(arr.length, index) ? '' : dateUtils.dateToString(dateUtils.getUtcFromString(date), 'iii d. HH:mm', true, i18n.language)
|
|
2335
|
+
label: shouldHideLabel(arr.length, index, maxLabelCount) ? '' : dateUtils.dateToString(dateUtils.getUtcFromString(date), 'iii d. HH:mm', true, i18n.language)
|
|
2312
2336
|
}));
|
|
2313
2337
|
const onStepBackward = React.useCallback(() => {
|
|
2314
2338
|
const currentIndex = timesteps.indexOf(selectedTime);
|
|
@@ -2321,10 +2345,13 @@ const SoundingsTimeSlider = ({
|
|
|
2321
2345
|
updateSelectedTime(timesteps[followingIndex]);
|
|
2322
2346
|
}, [selectedTime, updateSelectedTime, timesteps]);
|
|
2323
2347
|
return jsxs("div", {
|
|
2348
|
+
ref: sliderRef,
|
|
2324
2349
|
style: {
|
|
2325
2350
|
display: 'flex',
|
|
2326
|
-
|
|
2327
|
-
marginRight: '
|
|
2351
|
+
paddingTop: '16px',
|
|
2352
|
+
marginRight: '80px',
|
|
2353
|
+
marginLeft: '24px',
|
|
2354
|
+
height: `${TIMESLIDER_HEIGHT}px`
|
|
2328
2355
|
},
|
|
2329
2356
|
children: [jsxs("div", {
|
|
2330
2357
|
style: {
|
|
@@ -2378,8 +2405,8 @@ const SoundingsTimeSlider = ({
|
|
|
2378
2405
|
extraStyles: {
|
|
2379
2406
|
margin: '0px 20px 0px 20px',
|
|
2380
2407
|
'.MuiSlider-markLabel': {
|
|
2381
|
-
|
|
2382
|
-
|
|
2408
|
+
transform: 'translate(-90%, 20px) rotate(-45deg)',
|
|
2409
|
+
transformOrigin: 'top center'
|
|
2383
2410
|
}
|
|
2384
2411
|
}
|
|
2385
2412
|
})]
|
|
@@ -2753,11 +2780,41 @@ const SoundingsLegend = ({
|
|
|
2753
2780
|
});
|
|
2754
2781
|
};
|
|
2755
2782
|
|
|
2756
|
-
const
|
|
2783
|
+
const DIAGRAM_TYPE_BUTTON_HEIGHT = 28;
|
|
2784
|
+
const useGetSize = (viewRef, legendRef) => {
|
|
2785
|
+
const [size, setSize] = React.useState(0);
|
|
2786
|
+
React.useLayoutEffect(() => {
|
|
2787
|
+
let resizeObserver;
|
|
2788
|
+
if (viewRef.current) {
|
|
2789
|
+
resizeObserver = new ResizeObserver(entry => {
|
|
2790
|
+
const {
|
|
2791
|
+
width,
|
|
2792
|
+
height
|
|
2793
|
+
} = entry[0].target.getBoundingClientRect();
|
|
2794
|
+
const availableWidth = width; // currently ignoring the windbarbs as they will be moved to a separate panel
|
|
2795
|
+
const legendHeight = legendRef.current?.getBoundingClientRect().height || 0;
|
|
2796
|
+
const availableHeight = height - legendHeight - DIAGRAM_TYPE_BUTTON_HEIGHT - TIMESLIDER_HEIGHT;
|
|
2797
|
+
// set size to the smallest of available width and height to keep the diagram square
|
|
2798
|
+
const newSize = Math.min(availableWidth, availableHeight);
|
|
2799
|
+
setSize(newSize);
|
|
2800
|
+
});
|
|
2801
|
+
resizeObserver.observe(viewRef.current);
|
|
2802
|
+
}
|
|
2803
|
+
return () => {
|
|
2804
|
+
if (resizeObserver) {
|
|
2805
|
+
resizeObserver.disconnect();
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
}, [legendRef, viewRef]);
|
|
2809
|
+
return size;
|
|
2810
|
+
};
|
|
2757
2811
|
const SoundingsConnect = ({
|
|
2758
2812
|
viewId,
|
|
2759
2813
|
diagramType = 'SKEWT'
|
|
2760
2814
|
}) => {
|
|
2815
|
+
const viewRef = React.useRef(null);
|
|
2816
|
+
const legendRef = React.useRef(null);
|
|
2817
|
+
const size = useGetSize(viewRef, legendRef);
|
|
2761
2818
|
const [chosenDiagramType, setChosenDiagramType] = React.useState(diagramType);
|
|
2762
2819
|
const geojsonLayerId = React.useRef(webmapUtils.generateLayerId()).current;
|
|
2763
2820
|
const dispatch = useDispatch();
|
|
@@ -2818,11 +2875,12 @@ const SoundingsConnect = ({
|
|
|
2818
2875
|
position: 'absolute',
|
|
2819
2876
|
width: '100%'
|
|
2820
2877
|
}
|
|
2821
|
-
}), jsxs(
|
|
2878
|
+
}), jsxs(Stack, {
|
|
2822
2879
|
sx: {
|
|
2823
|
-
padding:
|
|
2824
|
-
|
|
2825
|
-
height: '100%'
|
|
2880
|
+
padding: '12px',
|
|
2881
|
+
width: '100%',
|
|
2882
|
+
height: '100%',
|
|
2883
|
+
backgroundColor: 'geowebColors.background.surfaceApp'
|
|
2826
2884
|
},
|
|
2827
2885
|
children: [jsx(Box, {
|
|
2828
2886
|
paddingLeft: 5,
|
|
@@ -2830,14 +2888,21 @@ const SoundingsConnect = ({
|
|
|
2830
2888
|
viewId: viewId
|
|
2831
2889
|
})
|
|
2832
2890
|
}), jsxs(Card, {
|
|
2891
|
+
ref: viewRef,
|
|
2892
|
+
sx: {
|
|
2893
|
+
width: '100%',
|
|
2894
|
+
height: '100%'
|
|
2895
|
+
},
|
|
2833
2896
|
children: [jsx(Box, {
|
|
2834
2897
|
sx: {
|
|
2835
2898
|
display: 'flex',
|
|
2836
2899
|
justifyContent: 'center',
|
|
2837
2900
|
paddingTop: '2px',
|
|
2838
2901
|
paddingRight: '2px',
|
|
2839
|
-
|
|
2902
|
+
minHeight: '24px',
|
|
2903
|
+
width: '100%'
|
|
2840
2904
|
},
|
|
2905
|
+
ref: legendRef,
|
|
2841
2906
|
children: jsx(SoundingsLegend, {
|
|
2842
2907
|
sourceSelections: sourceSelections
|
|
2843
2908
|
})
|
|
@@ -2866,8 +2931,15 @@ const SoundingsConnect = ({
|
|
|
2866
2931
|
}
|
|
2867
2932
|
},
|
|
2868
2933
|
diagramType: chosenDiagramType
|
|
2934
|
+
}), jsx(Box, {
|
|
2935
|
+
sx: {
|
|
2936
|
+
position: 'absolute',
|
|
2937
|
+
bottom: '8px',
|
|
2938
|
+
width: '100%'
|
|
2939
|
+
},
|
|
2940
|
+
children: jsx(SoundingsTimeSliderConnect, {})
|
|
2869
2941
|
})]
|
|
2870
|
-
})
|
|
2942
|
+
})]
|
|
2871
2943
|
})]
|
|
2872
2944
|
});
|
|
2873
2945
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/soundings",
|
|
3
|
-
"version": "13.1
|
|
3
|
+
"version": "13.2.1",
|
|
4
4
|
"description": "GeoWeb soundings library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -8,24 +8,24 @@
|
|
|
8
8
|
"url": "git@gitlab.com:opengeoweb/opengeoweb.git"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@opengeoweb/api": "13.1
|
|
11
|
+
"@opengeoweb/api": "13.2.1",
|
|
12
12
|
"@tanstack/react-query": "^5.85.5",
|
|
13
13
|
"react": "^18.3.1",
|
|
14
14
|
"d3": "^7.9.0",
|
|
15
15
|
"react-i18next": "^15.1.1",
|
|
16
16
|
"i18next": "^25.0.1",
|
|
17
|
-
"@opengeoweb/shared": "13.1
|
|
17
|
+
"@opengeoweb/shared": "13.2.1",
|
|
18
18
|
"@mui/material": "^7.0.1",
|
|
19
|
-
"@opengeoweb/store": "13.1
|
|
19
|
+
"@opengeoweb/store": "13.2.1",
|
|
20
20
|
"react-redux": "^9.2.0",
|
|
21
|
-
"@opengeoweb/theme": "13.1
|
|
21
|
+
"@opengeoweb/theme": "13.2.1",
|
|
22
22
|
"@reduxjs/toolkit": "^2.6.1",
|
|
23
|
-
"@opengeoweb/time-slider": "13.1
|
|
23
|
+
"@opengeoweb/time-slider": "13.2.1",
|
|
24
24
|
"react-window": "^1.8.10",
|
|
25
|
-
"@opengeoweb/webmap": "13.1
|
|
25
|
+
"@opengeoweb/webmap": "13.2.1",
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
27
|
"@types/geojson": "^7946.0.14",
|
|
28
|
-
"@opengeoweb/webmap-react": "13.1
|
|
28
|
+
"@opengeoweb/webmap-react": "13.2.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"eslint-plugin-storybook": "9.0.17"
|