@opengeoweb/cap 9.20.1 → 9.20.2
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 +14 -10
- package/package.json +1 -1
- package/src/lib/components/Providers/Providers.d.ts +3 -0
- package/src/lib/components/types.d.ts +0 -1
- package/src/lib/utils/findEventIndexInLanguage.d.ts +2 -2
- package/src/lib/utils/i18n.d.ts +1 -1
- package/src/lib/utils/feedLanguageUtils.d.ts +0 -1
- package/src/lib/utils/feedLanguageUtils.spec.d.ts +0 -1
package/index.esm.js
CHANGED
|
@@ -6,7 +6,7 @@ import { dateUtils, AlertBanner } from '@opengeoweb/shared';
|
|
|
6
6
|
import { useSelector, useDispatch } from 'react-redux';
|
|
7
7
|
import { createEntityAdapter, createSlice, createSelector } from '@reduxjs/toolkit';
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import 'i18next';
|
|
9
|
+
import i18n from 'i18next';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import { ConfigurableMapConnect } from '@opengeoweb/core';
|
|
12
12
|
import { mapSelectors } from '@opengeoweb/store';
|
|
@@ -1881,14 +1881,14 @@ $$c({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_RE
|
|
|
1881
1881
|
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
1882
1882
|
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
1883
1883
|
* */
|
|
1884
|
-
const findEventIndexInLanguage = (languages, capWarningPresets, feedAddressFromProps) => {
|
|
1884
|
+
const findEventIndexInLanguage = (language, languages, capWarningPresets, feedAddressFromProps) => {
|
|
1885
1885
|
const correctFeedIndex = capWarningPresets.feeds.findIndex(({
|
|
1886
1886
|
feedAddress
|
|
1887
1887
|
}) => feedAddress === feedAddressFromProps);
|
|
1888
1888
|
if (correctFeedIndex === -1) {
|
|
1889
1889
|
return 0;
|
|
1890
1890
|
}
|
|
1891
|
-
const languageIndex = languages.findIndex(
|
|
1891
|
+
const languageIndex = languages.findIndex(lang => lang.language.startsWith(language));
|
|
1892
1892
|
if (languageIndex === -1) {
|
|
1893
1893
|
const fallbackLanguage = languages.findIndex(object => object.language.startsWith('en'));
|
|
1894
1894
|
if (fallbackLanguage === -1) {
|
|
@@ -2014,16 +2014,21 @@ const WarningListRowCapConnect = ({
|
|
|
2014
2014
|
alertId,
|
|
2015
2015
|
capWarningPresets
|
|
2016
2016
|
}) => {
|
|
2017
|
+
var _a;
|
|
2017
2018
|
const [languageIndex, setLanguageIndex] = React.useState(0);
|
|
2018
2019
|
const alert = useSelector(store => getAlertById(store, alertId));
|
|
2020
|
+
const alertHasLanguages = Boolean((_a = alert === null || alert === void 0 ? void 0 : alert.languages) === null || _a === void 0 ? void 0 : _a.length);
|
|
2021
|
+
const {
|
|
2022
|
+
language
|
|
2023
|
+
} = i18n;
|
|
2019
2024
|
React.useEffect(() => {
|
|
2020
|
-
if (alert) {
|
|
2021
|
-
const foundLanguageIndex = findEventIndexInLanguage(alert.languages, capWarningPresets, alert.feedAddress);
|
|
2025
|
+
if (alert && alertHasLanguages) {
|
|
2026
|
+
const foundLanguageIndex = findEventIndexInLanguage(language, alert.languages, capWarningPresets, alert.feedAddress);
|
|
2022
2027
|
setLanguageIndex(foundLanguageIndex);
|
|
2023
2028
|
}
|
|
2024
|
-
}, [alert, capWarningPresets]);
|
|
2029
|
+
}, [alert, language, alertHasLanguages, capWarningPresets]);
|
|
2025
2030
|
return jsx("div", {
|
|
2026
|
-
children: alert && jsx(WarningListRowCap, {
|
|
2031
|
+
children: alert && alertHasLanguages && jsx(WarningListRowCap, {
|
|
2027
2032
|
event: alert.languages[languageIndex].event,
|
|
2028
2033
|
severity: alert.severity,
|
|
2029
2034
|
expires: alert.expires
|
|
@@ -4378,7 +4383,7 @@ const MapViewCapConnect = ({
|
|
|
4378
4383
|
}), selectedFeatureEvent && jsx(MapWarningProperties, {
|
|
4379
4384
|
"data-testid": "mapWarnings",
|
|
4380
4385
|
selectedFeatureProperties: selectedFeatureEvent.feature.properties.details,
|
|
4381
|
-
languageIndex: findEventIndexInLanguage(selectedFeatureEvent.feature.properties.details.languages, capWarningPresets, selectedFeatureEvent.feature.properties.details.feedAddress),
|
|
4386
|
+
languageIndex: findEventIndexInLanguage(i18n.language, selectedFeatureEvent.feature.properties.details.languages, capWarningPresets, selectedFeatureEvent.feature.properties.details.feedAddress),
|
|
4382
4387
|
parentSize: parentSize
|
|
4383
4388
|
})]
|
|
4384
4389
|
}))
|
|
@@ -4446,9 +4451,8 @@ const ComponentsLookUp = ({
|
|
|
4446
4451
|
id
|
|
4447
4452
|
}) => {
|
|
4448
4453
|
// TODO: implement polling when backend is ready
|
|
4449
|
-
// TODO: fetch new data using feedLanguage if previous response indicates there are new warnings
|
|
4450
|
-
var _a, _b;
|
|
4451
4454
|
// NOTE: Fetching data inside this component might not work, as using React Hooks causes Invalid Hook Call -errors in tests.
|
|
4455
|
+
var _a, _b;
|
|
4452
4456
|
switch (componentType) {
|
|
4453
4457
|
case 'CapWarningMap':
|
|
4454
4458
|
{
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Store } from '@reduxjs/toolkit';
|
|
3
3
|
import { ThemeProviderProps } from '@opengeoweb/theme';
|
|
4
4
|
import { Theme } from '@mui/material';
|
|
5
|
+
import i18n from 'i18next';
|
|
5
6
|
export declare const CapThemeWrapper: React.FC<ThemeProviderProps>;
|
|
6
7
|
interface CapApiProviderProps {
|
|
7
8
|
children: React.ReactNode;
|
|
@@ -11,9 +12,11 @@ interface CapThemeStoreProviderProps {
|
|
|
11
12
|
children?: React.ReactNode;
|
|
12
13
|
theme?: Theme;
|
|
13
14
|
store: Store;
|
|
15
|
+
i18nInstance?: typeof i18n;
|
|
14
16
|
}
|
|
15
17
|
interface CapTranslationsWrapperProps {
|
|
16
18
|
children?: React.ReactNode;
|
|
19
|
+
i18nInstance?: typeof i18n;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
22
|
* A Provider component which returns the Api Provider for the Cap library
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CapPresets } from '../components/types';
|
|
2
|
-
interface
|
|
2
|
+
interface Language {
|
|
3
3
|
language: string;
|
|
4
4
|
event: string;
|
|
5
5
|
senderName: string;
|
|
6
6
|
headline: string;
|
|
7
7
|
description: string;
|
|
8
8
|
}
|
|
9
|
-
export declare const findEventIndexInLanguage: (languages:
|
|
9
|
+
export declare const findEventIndexInLanguage: (language: string, languages: Language[], capWarningPresets: CapPresets, feedAddressFromProps: string) => number;
|
|
10
10
|
export {};
|
package/src/lib/utils/i18n.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import i18n from 'i18next';
|
|
2
2
|
import { UseTranslationResponse } from 'react-i18next';
|
|
3
3
|
export declare const CAP_NAMESPACE = "cap";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const initCapI18n: () => typeof i18n;
|
|
5
5
|
export declare const useCapTranslation: () => UseTranslationResponse<typeof CAP_NAMESPACE, typeof i18n>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const feedLanguage: (languagePriority?: string) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|