@opengeoweb/warnings 9.25.2 → 9.26.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/index.esm.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useDispatch, useSelector } from 'react-redux';
3
- import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, Wind, Fog, Lightning, Snow, Rain, TemperatureHigh, TemperatureLow, CoastalEvent, breakpoints, Close, Options, Copy, Success, Expire, Remove } from '@opengeoweb/theme';
3
+ import { Polygons, Share, ExitDomain, Edit, Delete, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, DrawPolygon, Visibility, Add, breakpoints, Close, Options, Copy, Success, Expire, Remove } from '@opengeoweb/theme';
4
4
  import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, mapStoreActions, drawtoolActions, layerActions, useSetupDialog } from '@opengeoweb/store';
5
5
  import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, MapView, MapViewLayer, defaultLayers, getFeatureExtent } from '@opengeoweb/webmap-react';
6
- import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, getPosition, FilterChip, FilterListItem, LastUpdateTime, StatusTag, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
6
+ import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, getPosition, FilterChip, FilterListItem, FilterLabel, LastUpdateTime, StatusTag, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
7
7
  import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
8
8
  import i18n from 'i18next';
9
9
  import { useTranslation } from 'react-i18next';
10
10
  import '@opengeoweb/core';
11
- import { FORM_FIELDS_NAMESPACE, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
11
+ import { FORM_FIELDS_NAMESPACE, useDraftFormHelpers, ReactHookFormSelect, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, errorMessages, ReactHookFormDateTime, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
12
12
  import { snackbarActions } from '@opengeoweb/snackbar';
13
13
  import * as React from 'react';
14
14
  import React__default, { useState, useEffect, useRef } from 'react';
15
- import { styled, Box, Typography, ListItem, Grid, Paper, ListItemButton, Stack, LinearProgress, Button, FormHelperText, MenuItem, Tabs, Tab, Card, CardContent, ListItemIcon, CircularProgress, Menu, DialogTitle, DialogContent, Switch, List } from '@mui/material';
15
+ import { styled, Box, Typography, ListItem, Grid, Paper, ListItemButton, Stack, LinearProgress, Button, MenuItem, ListItemIcon, FormHelperText, Tabs, Tab, Card, CardContent, CircularProgress, Menu, DialogTitle, DialogContent, Switch, List } from '@mui/material';
16
16
  import { VariableSizeList } from 'react-window';
17
17
  import AutoSizer from 'react-virtualized-auto-sizer';
18
18
  import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider } from '@opengeoweb/api';
@@ -1652,6 +1652,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1652
1652
  *
1653
1653
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1654
1654
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1655
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1655
1656
  * */
1656
1657
  const objectDialogType = uiTypes.DialogTypes.ObjectManager;
1657
1658
  const drawingDialogType = uiTypes.DialogTypes.DrawingTool;
@@ -1672,6 +1673,7 @@ const areaObjectLoaderType = uiTypes.DialogTypes.AreaObjectLoader;
1672
1673
  *
1673
1674
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1674
1675
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1676
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1675
1677
  * */
1676
1678
  const drawAdapter = createEntityAdapter({
1677
1679
  selectId: draw => draw.drawingInstanceId
@@ -1768,6 +1770,7 @@ const drawActions = slice$2.actions;
1768
1770
  *
1769
1771
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1770
1772
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1773
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1771
1774
  * */
1772
1775
  const {
1773
1776
  selectById: selectDrawByInstanceId
@@ -1802,6 +1805,7 @@ const useWarningsTranslation = () => useTranslation(ns);
1802
1805
  *
1803
1806
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1804
1807
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1808
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1805
1809
  * */
1806
1810
  const confirmationDialogOptions = t => {
1807
1811
  return {
@@ -2741,6 +2745,7 @@ $$g({ target: 'Array', proto: true, arity: 1, forced: FORCED$4 }, {
2741
2745
  *
2742
2746
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2743
2747
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
2748
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2744
2749
  * */
2745
2750
  const DATE_FORMAT_HEADER = 'EEEE, MMMM dd';
2746
2751
 
@@ -3155,6 +3160,7 @@ const ObjectManager = ({
3155
3160
  *
3156
3161
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3157
3162
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
3163
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3158
3164
  * */
3159
3165
  const API_NAME = 'warnings';
3160
3166
  const getIdFromUrl = url => {
@@ -3286,6 +3292,7 @@ const ConfirmDeleteDialog = ({
3286
3292
  *
3287
3293
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3288
3294
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
3295
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3289
3296
  * */
3290
3297
  const publicWarningDialogType = uiTypes.DialogTypes.PublicWarnings;
3291
3298
 
@@ -3676,27 +3683,218 @@ $$c({ target: 'Array', proto: true, forced: FORCED$2 }, {
3676
3683
  }
3677
3684
  });
3678
3685
 
3679
- /* *
3680
- * Licensed under the Apache License, Version 2.0 (the "License");
3681
- * you may not use this file except in compliance with the License.
3682
- * You may obtain a copy of the License at
3683
- *
3684
- * http://www.apache.org/licenses/LICENSE-2.0
3685
- *
3686
- * Unless required by applicable law or agreed to in writing, software
3687
- * distributed under the License is distributed on an "AS IS" BASIS,
3688
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3689
- * See the License for the specific language governing permissions and
3690
- * limitations under the License.
3691
- *
3692
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3693
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
3694
- * */
3686
+ const getWarningPhenomenaIcon = key => {
3687
+ switch (key) {
3688
+ case 'wind':
3689
+ return jsx(Wind, {});
3690
+ case 'fog':
3691
+ return jsx(Fog, {});
3692
+ case 'thunderstorm':
3693
+ return jsx(Lightning, {});
3694
+ case 'snowIce':
3695
+ return jsx(Snow, {});
3696
+ case 'rain':
3697
+ return jsx(Rain, {});
3698
+ case 'highTemp':
3699
+ return jsx(TemperatureHigh, {});
3700
+ case 'lowTemp':
3701
+ return jsx(TemperatureLow, {});
3702
+ case 'coastalEvent':
3703
+ return jsx(CoastalEvent, {});
3704
+ default:
3705
+ return undefined;
3706
+ }
3707
+ };
3708
+ const warningPhenomena = [{
3709
+ translationKey: 'warning-phenomenon-wind',
3710
+ key: 'wind'
3711
+ }, {
3712
+ translationKey: 'warning-phenomenon-fog',
3713
+ key: 'fog'
3714
+ }, {
3715
+ translationKey: 'warning-phenomenon-thunderstorm',
3716
+ key: 'thunderstorm'
3717
+ }, {
3718
+ translationKey: 'warning-phenomenon-snow-ice',
3719
+ key: 'snowIce'
3720
+ }, {
3721
+ translationKey: 'warning-phenomenon-rain',
3722
+ key: 'rain'
3723
+ }, {
3724
+ translationKey: 'warning-phenomenon-high-temp',
3725
+ key: 'highTemp'
3726
+ },
3727
+ // {
3728
+ // title: 'warning-phenomenon-funnel-cloud',
3729
+ // key: 'funnelCloud',
3730
+ // },
3731
+ {
3732
+ translationKey: 'warning-phenomenon-low-temp',
3733
+ key: 'lowTemp'
3734
+ }, {
3735
+ translationKey: 'warning-phenomenon-coastal-event',
3736
+ key: 'coastalEvent'
3737
+ }];
3738
+ const Phenomenon = ({
3739
+ isDisabled,
3740
+ isReadOnly
3741
+ }) => {
3742
+ const {
3743
+ t
3744
+ } = useWarningsTranslation();
3745
+ const {
3746
+ isRequired
3747
+ } = useDraftFormHelpers();
3748
+ return jsx(ReactHookFormSelect, Object.assign({
3749
+ name: "phenomenon",
3750
+ label: t('warning-phenomenon'),
3751
+ rules: {
3752
+ validate: {
3753
+ isRequired
3754
+ }
3755
+ },
3756
+ disabled: isDisabled || isReadOnly,
3757
+ isReadOnly: isReadOnly
3758
+ }, {
3759
+ children: warningPhenomena.map(phenomenon => {
3760
+ return jsx(MenuItem, Object.assign({
3761
+ value: phenomenon.key
3762
+ }, {
3763
+ children: jsxs(Grid, Object.assign({
3764
+ container: true,
3765
+ justifyContent: "space-between"
3766
+ }, {
3767
+ children: [jsx(Grid, Object.assign({
3768
+ item: true
3769
+ }, {
3770
+ children: t(phenomenon.translationKey)
3771
+ })), jsx(Grid, Object.assign({
3772
+ item: true
3773
+ }, {
3774
+ children: jsx(ListItemIcon, {
3775
+ children: getWarningPhenomenaIcon(phenomenon.key)
3776
+ })
3777
+ }))]
3778
+ }))
3779
+ }), phenomenon.key);
3780
+ })
3781
+ }));
3782
+ };
3783
+
3784
+ var WarningLevel;
3785
+ (function (WarningLevel) {
3786
+ WarningLevel["moderate"] = "moderate";
3787
+ WarningLevel["severe"] = "severe";
3788
+ WarningLevel["extreme"] = "extreme";
3789
+ })(WarningLevel || (WarningLevel = {}));
3790
+ const LevelColors = {
3791
+ moderate: {
3792
+ color: '#FAE21E',
3793
+ textColor: '#051039'
3794
+ },
3795
+ severe: {
3796
+ color: '#E27000',
3797
+ textColor: '#051039'
3798
+ },
3799
+ extreme: {
3800
+ color: '#D62A20',
3801
+ textColor: '#ffffff'
3802
+ }
3803
+ };
3804
+ const getLevelStyle = levelColor => ({
3805
+ color: levelColor && levelColor.textColor,
3806
+ backgroundColor: levelColor && levelColor.color,
3807
+ paddingLeft: 0.5,
3808
+ paddingRight: 0.5,
3809
+ paddingBottom: '1px',
3810
+ marginLeft: -0.5
3811
+ });
3812
+ const levelOptions = [Object.assign({
3813
+ translationKey: 'warning-level-moderate',
3814
+ key: WarningLevel.moderate
3815
+ }, LevelColors[WarningLevel.moderate]), Object.assign({
3816
+ translationKey: 'warning-level-severe',
3817
+ key: WarningLevel.severe
3818
+ }, LevelColors[WarningLevel.severe]), Object.assign({
3819
+ translationKey: 'warning-level-extreme',
3820
+ key: WarningLevel.extreme
3821
+ }, LevelColors[WarningLevel.extreme])];
3822
+ const LevelField = ({
3823
+ isDisabled: _isDisabled = false,
3824
+ isReadOnly: _isReadOnly = false
3825
+ }) => {
3826
+ const {
3827
+ t
3828
+ } = useWarningsTranslation();
3829
+ const {
3830
+ isRequired
3831
+ } = useDraftFormHelpers();
3832
+ const {
3833
+ watch,
3834
+ trigger
3835
+ } = useFormContext();
3836
+ const selectedLevel = watch('level');
3837
+ const levelDetails = levelOptions.find(level => level.key === selectedLevel);
3838
+ const onChangeLevel = () => {
3839
+ trigger(['level', 'probability']);
3840
+ };
3841
+ return jsx(ReactHookFormSelect, Object.assign({
3842
+ name: "level",
3843
+ label: t('warning-level'),
3844
+ rules: {
3845
+ validate: {
3846
+ isRequired
3847
+ }
3848
+ },
3849
+ sx: {
3850
+ '& .MuiSelect-select.MuiSelect-filled': {
3851
+ color: (levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.textColor) || 'none',
3852
+ backgroundColor: (levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.color) || 'none',
3853
+ backgroundClip: 'content-box'
3854
+ }
3855
+ },
3856
+ disabled: _isDisabled || _isReadOnly,
3857
+ isReadOnly: _isReadOnly,
3858
+ onChange: onChangeLevel
3859
+ }, {
3860
+ children: levelOptions.map(level => jsxs(MenuItem, Object.assign({
3861
+ value: level.key,
3862
+ sx: {
3863
+ '&.MuiMenuItem-root ': {
3864
+ color: level.textColor,
3865
+ background: level.color,
3866
+ backgroundClip: 'content-box',
3867
+ padding: '12px 8px',
3868
+ '&:hover': {
3869
+ backgroundColor: `${level.color}`,
3870
+ backgroundClip: 'content-box',
3871
+ boxShadow: theme => `inset -8px -12px ${theme.palette.geowebColors.cards.cardContainerMouseOver}, inset 8px 12px ${theme.palette.geowebColors.cards.cardContainerMouseOver}`
3872
+ },
3873
+ '&.Mui-selected': {
3874
+ backgroundColor: `${level.color}`,
3875
+ '&:hover': {
3876
+ boxShadow: theme => `inset 4px 0px 0px 0px ${theme.palette.geowebColors.typographyAndIcons.iconLinkActive}, inset -8px -12px ${theme.palette.geowebColors.cards.cardContainerMouseOver}, inset 8px 12px ${theme.palette.geowebColors.cards.cardContainerMouseOver}`
3877
+ }
3878
+ }
3879
+ }
3880
+ }
3881
+ }, {
3882
+ children: ["\u00A0", t(level.translationKey)]
3883
+ }), level.key))
3884
+ }));
3885
+ };
3886
+
3695
3887
  const emptyFilter = {
3696
3888
  id: 'empty',
3697
3889
  name: '(not specified)',
3698
3890
  checked: true
3699
3891
  };
3892
+ const getFilterlistWithTranslationKeys = filterList => filterList.reduce((fiterList, {
3893
+ key,
3894
+ translationKey
3895
+ }) => Object.assign(Object.assign({}, fiterList), {
3896
+ [key]: translationKey
3897
+ }), {});
3700
3898
  const defaultFilters = [{
3701
3899
  key: 'incident',
3702
3900
  translationKey: 'filter-incident'
@@ -3705,10 +3903,12 @@ const defaultFilters = [{
3705
3903
  translationKey: 'filter-domain'
3706
3904
  }, {
3707
3905
  key: 'phenomenon',
3708
- translationKey: 'filter-phenomenon'
3906
+ translationKey: 'filter-phenomenon',
3907
+ translations: getFilterlistWithTranslationKeys(warningPhenomena)
3709
3908
  }, {
3710
3909
  key: 'level',
3711
- translationKey: 'filter-level'
3910
+ translationKey: 'filter-level',
3911
+ translations: getFilterlistWithTranslationKeys(levelOptions)
3712
3912
  }, {
3713
3913
  key: 'warningProposalSource',
3714
3914
  translationKey: 'filter-source'
@@ -3729,15 +3929,18 @@ const getFiltersFromWarnings = warnings => {
3729
3929
  }
3730
3930
  const filledFilters = defaultFilters.map(({
3731
3931
  key,
3732
- translationKey
3932
+ translationKey,
3933
+ translations
3733
3934
  }) => {
3734
3935
  const filterOptions = [];
3735
3936
  warnings.forEach(warning => {
3736
- const name = warning.warningDetail[key];
3737
- if (name && filterOptions.findIndex(option => option.filter.name === name) === -1) {
3937
+ const id = warning.warningDetail[key];
3938
+ if (id && filterOptions.findIndex(option => option.filter.id === id) === -1) {
3939
+ const translationKey = translations && translations[id];
3940
+ const label = translationKey ? translateKeyOutsideComponents(translationKey) : id;
3738
3941
  const filter = {
3739
- id: name,
3740
- name,
3942
+ id,
3943
+ name: label,
3741
3944
  checked: true
3742
3945
  };
3743
3946
  filterOptions.push({
@@ -3916,6 +4119,7 @@ const publicWarningActions = slice$1.actions;
3916
4119
  *
3917
4120
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3918
4121
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
4122
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3919
4123
  * */
3920
4124
  const TAKEOVER_MESSAGE = 'You are no longer the editor of this warning';
3921
4125
  const initialState = {};
@@ -8217,7 +8421,7 @@ var warningListJSON = [
8217
8421
  phenomenon: "wind",
8218
8422
  areas: [
8219
8423
  {
8220
- objectName: "test name",
8424
+ objectName: "wind test name",
8221
8425
  geoJSON: {
8222
8426
  type: "FeatureCollection",
8223
8427
  features: [
@@ -8321,7 +8525,7 @@ var warningListJSON = [
8321
8525
  phenomenon: "highTemp",
8322
8526
  areas: [
8323
8527
  {
8324
- objectName: "test name",
8528
+ objectName: "high temp test name",
8325
8529
  geoJSON: {
8326
8530
  type: "FeatureCollection",
8327
8531
  features: [
@@ -9471,6 +9675,7 @@ var warningListJSON = [
9471
9675
  *
9472
9676
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
9473
9677
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
9678
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
9474
9679
  * */
9475
9680
  const drawingList = drawingListJSON;
9476
9681
  const drawingsListFullContent = drawingsListFullContentJSON;
@@ -9766,6 +9971,7 @@ $$8({ global: true, forced: parseInt !== $parseInt }, {
9766
9971
  *
9767
9972
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
9768
9973
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
9974
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
9769
9975
  * */
9770
9976
  const useFormDirty = ({
9771
9977
  isDirty,
@@ -10474,6 +10680,28 @@ const DescriptionField = ({
10474
10680
  setActiveTab(1);
10475
10681
  }
10476
10682
  }, [formState.errors, formState.submitCount]);
10683
+ const focusForwards = fieldName => {
10684
+ if (fieldName === 'descriptionOriginal') {
10685
+ setActiveTab(1);
10686
+ }
10687
+ };
10688
+ const focusBackwards = fieldName => {
10689
+ if (fieldName === 'descriptionTranslation') {
10690
+ setActiveTab(0);
10691
+ }
10692
+ };
10693
+ const onKeyDown = event => {
10694
+ const target = event.target;
10695
+ const {
10696
+ name
10697
+ } = target;
10698
+ event.stopPropagation();
10699
+ if (event.code === 'Tab' && event.shiftKey) {
10700
+ focusBackwards(name);
10701
+ } else if (event.code === 'Tab') {
10702
+ focusForwards(name);
10703
+ }
10704
+ };
10477
10705
  return jsxs(Fragment, {
10478
10706
  children: [jsxs(Tabs, Object.assign({
10479
10707
  value: activeTab,
@@ -10490,11 +10718,13 @@ const DescriptionField = ({
10490
10718
  children: [jsx(Tab, Object.assign({
10491
10719
  sx: tabStyle,
10492
10720
  label: t('warning-description-original'),
10493
- disabled: _isDisabled
10721
+ disabled: _isDisabled,
10722
+ tabIndex: -1
10494
10723
  }, a11yProps(0))), jsx(Tab, Object.assign({
10495
10724
  sx: tabStyle,
10496
10725
  label: t('warning-description-translation'),
10497
- disabled: _isDisabled
10726
+ disabled: _isDisabled,
10727
+ tabIndex: -1
10498
10728
  }, a11yProps(1)))]
10499
10729
  })), jsx(CustomTabPanel, Object.assign({
10500
10730
  value: activeTab,
@@ -10511,7 +10741,7 @@ const DescriptionField = ({
10511
10741
  multiline: true,
10512
10742
  disabled: _isDisabled,
10513
10743
  isReadOnly: _isReadOnly,
10514
- onKeyDown: event => event.stopPropagation()
10744
+ onKeyDown: onKeyDown
10515
10745
  })
10516
10746
  })), jsx(CustomTabPanel, Object.assign({
10517
10747
  value: activeTab,
@@ -10528,7 +10758,7 @@ const DescriptionField = ({
10528
10758
  multiline: true,
10529
10759
  disabled: _isDisabled,
10530
10760
  isReadOnly: _isReadOnly,
10531
- onKeyDown: event => event.stopPropagation()
10761
+ onKeyDown: onKeyDown
10532
10762
  })
10533
10763
  }))]
10534
10764
  });
@@ -10661,186 +10891,6 @@ const AreaField = ({
10661
10891
  });
10662
10892
  };
10663
10893
 
10664
- const warningPhenomena = t => [{
10665
- title: t('warning-phenomenon-wind'),
10666
- key: 'wind',
10667
- icon: jsx(Wind, {})
10668
- }, {
10669
- title: t('warning-phenomenon-fog'),
10670
- key: 'fog',
10671
- icon: jsx(Fog, {})
10672
- }, {
10673
- title: t('warning-phenomenon-thunderstorm'),
10674
- key: 'thunderstorm',
10675
- icon: jsx(Lightning, {})
10676
- }, {
10677
- title: t('warning-phenomenon-snow-ice'),
10678
- key: 'snowIce',
10679
- icon: jsx(Snow, {})
10680
- }, {
10681
- title: t('warning-phenomenon-rain'),
10682
- key: 'rain',
10683
- icon: jsx(Rain, {})
10684
- }, {
10685
- title: t('warning-phenomenon-high-temp'),
10686
- key: 'highTemp',
10687
- icon: jsx(TemperatureHigh, {})
10688
- },
10689
- // {
10690
- // title: t('warning-phenomenon-funnel-cloud'),
10691
- // key: 'funnelCloud',
10692
- // icon: <FunnelCloud />,
10693
- // },
10694
- {
10695
- title: t('warning-phenomenon-low-temp'),
10696
- key: 'lowTemp',
10697
- icon: jsx(TemperatureLow, {})
10698
- }, {
10699
- title: t('warning-phenomenon-coastal-event'),
10700
- key: 'coastalEvent',
10701
- icon: jsx(CoastalEvent, {})
10702
- }];
10703
- const Phenomenon = ({
10704
- isDisabled,
10705
- isReadOnly
10706
- }) => {
10707
- const {
10708
- t
10709
- } = useWarningsTranslation();
10710
- const {
10711
- isRequired
10712
- } = useDraftFormHelpers();
10713
- return jsx(ReactHookFormSelect, Object.assign({
10714
- name: "phenomenon",
10715
- label: t('warning-phenomenon'),
10716
- rules: {
10717
- validate: {
10718
- isRequired
10719
- }
10720
- },
10721
- disabled: isDisabled || isReadOnly,
10722
- isReadOnly: isReadOnly
10723
- }, {
10724
- children: warningPhenomena(t).map(phenomenon => {
10725
- return jsx(MenuItem, Object.assign({
10726
- value: phenomenon.key
10727
- }, {
10728
- children: jsxs(Grid, Object.assign({
10729
- container: true,
10730
- justifyContent: "space-between"
10731
- }, {
10732
- children: [jsx(Grid, Object.assign({
10733
- item: true
10734
- }, {
10735
- children: phenomenon.title
10736
- })), jsx(Grid, Object.assign({
10737
- item: true
10738
- }, {
10739
- children: jsx(ListItemIcon, {
10740
- children: phenomenon.icon
10741
- })
10742
- }))]
10743
- }))
10744
- }), phenomenon.key);
10745
- })
10746
- }));
10747
- };
10748
-
10749
- var WarningLevel;
10750
- (function (WarningLevel) {
10751
- WarningLevel["moderate"] = "moderate";
10752
- WarningLevel["severe"] = "severe";
10753
- WarningLevel["extreme"] = "extreme";
10754
- })(WarningLevel || (WarningLevel = {}));
10755
- const LevelColors = {
10756
- moderate: {
10757
- color: '#FAE21E',
10758
- textColor: '#051039'
10759
- },
10760
- severe: {
10761
- color: '#E27000',
10762
- textColor: '#051039'
10763
- },
10764
- extreme: {
10765
- color: '#D62A20',
10766
- textColor: '#ffffff'
10767
- }
10768
- };
10769
- const levelOptions = t => [Object.assign({
10770
- title: t('warning-level-moderate'),
10771
- key: WarningLevel.moderate
10772
- }, LevelColors[WarningLevel.moderate]), Object.assign({
10773
- title: t('warning-level-severe'),
10774
- key: WarningLevel.severe
10775
- }, LevelColors[WarningLevel.severe]), Object.assign({
10776
- title: t('warning-level-extreme'),
10777
- key: WarningLevel.extreme
10778
- }, LevelColors[WarningLevel.extreme])];
10779
- const LevelField = ({
10780
- isDisabled: _isDisabled = false,
10781
- isReadOnly: _isReadOnly = false
10782
- }) => {
10783
- const {
10784
- t
10785
- } = useWarningsTranslation();
10786
- const {
10787
- isRequired
10788
- } = useDraftFormHelpers();
10789
- const {
10790
- watch,
10791
- trigger
10792
- } = useFormContext();
10793
- const selectedLevel = watch('level');
10794
- const levelDetails = levelOptions(t).find(level => level.key === selectedLevel);
10795
- const onChangeLevel = () => {
10796
- trigger(['level', 'probability']);
10797
- };
10798
- return jsx(ReactHookFormSelect, Object.assign({
10799
- name: "level",
10800
- label: t('warning-level'),
10801
- rules: {
10802
- validate: {
10803
- isRequired
10804
- }
10805
- },
10806
- sx: {
10807
- '& .MuiSelect-select.MuiSelect-filled': {
10808
- color: (levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.textColor) || 'none',
10809
- backgroundColor: (levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.color) || 'none',
10810
- backgroundClip: 'content-box'
10811
- }
10812
- },
10813
- disabled: _isDisabled || _isReadOnly,
10814
- isReadOnly: _isReadOnly,
10815
- onChange: onChangeLevel
10816
- }, {
10817
- children: levelOptions(t).map(level => jsxs(MenuItem, Object.assign({
10818
- value: level.key,
10819
- sx: {
10820
- '&.MuiMenuItem-root ': {
10821
- color: level.textColor,
10822
- background: level.color,
10823
- backgroundClip: 'content-box',
10824
- padding: '12px 8px',
10825
- '&:hover': {
10826
- backgroundColor: `${level.color}`,
10827
- backgroundClip: 'content-box',
10828
- boxShadow: theme => `inset -8px -12px ${theme.palette.geowebColors.cards.cardContainerMouseOver}, inset 8px 12px ${theme.palette.geowebColors.cards.cardContainerMouseOver}`
10829
- },
10830
- '&.Mui-selected': {
10831
- backgroundColor: `${level.color}`,
10832
- '&:hover': {
10833
- boxShadow: theme => `inset 4px 0px 0px 0px ${theme.palette.geowebColors.typographyAndIcons.iconLinkActive}, inset -8px -12px ${theme.palette.geowebColors.cards.cardContainerMouseOver}, inset 8px 12px ${theme.palette.geowebColors.cards.cardContainerMouseOver}`
10834
- }
10835
- }
10836
- }
10837
- }
10838
- }, {
10839
- children: ["\u00A0", level.title]
10840
- }), level.key))
10841
- }));
10842
- };
10843
-
10844
10894
  const VALID_FROM_MAX_HOURS_AFTER_CURRENT = 168;
10845
10895
  const isValueBeforeCurrentTime$1 = (value, t) => {
10846
10896
  return isXHoursBefore(value, dateUtils.getCurrentTimeAsString(), 0) || t('warning-valid-from-error-before-current');
@@ -11245,7 +11295,8 @@ const Form = ({
11245
11295
  formState: {
11246
11296
  dirtyFields
11247
11297
  },
11248
- getValues
11298
+ getValues,
11299
+ setValue
11249
11300
  } = useFormContext();
11250
11301
  const {
11251
11302
  toggleIsDraft,
@@ -11284,10 +11335,19 @@ const Form = ({
11284
11335
  reset(getEmptyPublicWarning());
11285
11336
  setWarningGeoJSONFeature(undefined);
11286
11337
  };
11338
+ const publicWarningId = publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.id;
11287
11339
  React.useEffect(() => {
11288
11340
  // sync redux with react-hook-form
11289
11341
  reset(getFormData(publicWarningDetails, object));
11290
- }, [object, reset, publicWarningDetails]);
11342
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11343
+ }, [publicWarningId]);
11344
+ const areas = publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.areas;
11345
+ React.useEffect(() => {
11346
+ // sync redux with react-hook-form
11347
+ if (areas) {
11348
+ setValue('areas', areas);
11349
+ }
11350
+ }, [areas, setValue]);
11291
11351
  React.useEffect(() => {
11292
11352
  // sync drawing on map with selected warning
11293
11353
  setWarningGeoJSONFeature(initialPublicWarningArea);
@@ -11547,6 +11607,7 @@ const PublicWarningsForm = props => {
11547
11607
  *
11548
11608
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
11549
11609
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
11610
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
11550
11611
  * */
11551
11612
  const getPublicWarningStore = store => {
11552
11613
  if (store && store.publicWarningForm) {
@@ -13581,7 +13642,47 @@ const FilterChipWithOptions = ({
13581
13642
  marginLeft: '-12px'
13582
13643
  }
13583
13644
  }, {
13584
- children: _filterList.map(filterItem => jsx(FilterListItem, Object.assign({}, filterItem), filterItem.filter.id))
13645
+ children: _filterList.map(filterItem => {
13646
+ switch (id) {
13647
+ case 'level':
13648
+ {
13649
+ const warningColor = LevelColors[filterItem.filter.id];
13650
+ return jsx(FilterListItem, Object.assign({}, filterItem, {
13651
+ children: warningColor ? jsx(Box, Object.assign({
13652
+ component: "span",
13653
+ sx: Object.assign(Object.assign({}, getLevelStyle(warningColor)), {
13654
+ fontSize: '16px'
13655
+ }),
13656
+ "data-testid": `icon-${filterItem.filter.id}`
13657
+ }, {
13658
+ children: filterItem.filter.name
13659
+ })) : jsx(FilterLabel, {
13660
+ name: filterItem.filter.name
13661
+ })
13662
+ }), filterItem.filter.id);
13663
+ }
13664
+ case 'phenomenon':
13665
+ {
13666
+ const icon = getWarningPhenomenaIcon(filterItem.filter.id);
13667
+ return jsxs(FilterListItem, Object.assign({}, filterItem, {
13668
+ children: [icon && jsx(Box, Object.assign({
13669
+ "data-testid": `icon-${filterItem.filter.id}`,
13670
+ sx: {
13671
+ marginRight: 1
13672
+ }
13673
+ }, {
13674
+ children: icon
13675
+ })), jsx(FilterLabel, {
13676
+ name: filterItem.filter.name
13677
+ })]
13678
+ }), filterItem.filter.id);
13679
+ }
13680
+ default:
13681
+ {
13682
+ return jsx(FilterListItem, Object.assign({}, filterItem), filterItem.filter.id);
13683
+ }
13684
+ }
13685
+ })
13585
13686
  }))]
13586
13687
  }))]
13587
13688
  }))]
@@ -13941,8 +14042,8 @@ const WarningsOnStatus = ({
13941
14042
  }, {
13942
14043
  children: warnings.map(warning => {
13943
14044
  var _a;
13944
- const phenomenonDetails = warningPhenomena(t).find(phenomenon => phenomenon.key === warning.warningDetail.phenomenon);
13945
- const levelDetails = levelOptions(t).find(level => level.key === warning.warningDetail.level);
14045
+ const phenomenonDetails = warningPhenomena.find(phenomenon => phenomenon.key === warning.warningDetail.phenomenon);
14046
+ const levelDetails = levelOptions.find(level => level.key === warning.warningDetail.level);
13946
14047
  return jsx(ListItem, Object.assign({
13947
14048
  sx: {
13948
14049
  marginBottom: 0.25,
@@ -14024,14 +14125,14 @@ const WarningsOnStatus = ({
14024
14125
  position: 'relative'
14025
14126
  }
14026
14127
  }, {
14027
- children: [(phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.title) || '-', jsx(Box, Object.assign({
14128
+ children: [(phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.translationKey) ? t(phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.translationKey) : '-', jsx(Box, Object.assign({
14028
14129
  sx: {
14029
14130
  position: 'absolute',
14030
14131
  right: 0,
14031
14132
  bottom: -6
14032
14133
  }
14033
14134
  }, {
14034
- children: phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.icon
14135
+ children: getWarningPhenomenaIcon(phenomenonDetails === null || phenomenonDetails === void 0 ? void 0 : phenomenonDetails.key)
14035
14136
  }))]
14036
14137
  })), jsx(WarningListColumnContent, Object.assign({
14037
14138
  title: t('warning-list-header-level'),
@@ -14039,16 +14140,9 @@ const WarningsOnStatus = ({
14039
14140
  }, {
14040
14141
  children: jsx(Box, Object.assign({
14041
14142
  component: "span",
14042
- sx: {
14043
- color: levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.textColor,
14044
- backgroundColor: levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.color,
14045
- paddingLeft: 0.5,
14046
- paddingRight: 0.5,
14047
- paddingBottom: '1px',
14048
- marginLeft: -0.5
14049
- }
14143
+ sx: getLevelStyle(levelDetails)
14050
14144
  }, {
14051
- children: ((_a = warning.warningDetail) === null || _a === void 0 ? void 0 : _a.level) && (levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.title) || '-'
14145
+ children: ((_a = warning.warningDetail) === null || _a === void 0 ? void 0 : _a.level) && (levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.translationKey) ? t(levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.translationKey) : '-'
14052
14146
  }))
14053
14147
  })), jsx(WarningListColumnContent, Object.assign({
14054
14148
  title: t('warning-list-header-status'),
@@ -14784,6 +14878,7 @@ publicWarningFormListener.startListening({
14784
14878
  *
14785
14879
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
14786
14880
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
14881
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
14787
14882
  * */
14788
14883
  const getLastUpdatedTimeFormatted = () => dateUtils.dateToString(dateUtils.utc(), dateUtils.DATE_FORMAT_HOURS);
14789
14884
  const publicWarningsListener = createListenerMiddleware();
@@ -14839,6 +14934,7 @@ publicWarningsListener.startListening({
14839
14934
  *
14840
14935
  * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
14841
14936
  * Copyright 2024 - Finnish Meteorological Institute (FMI)
14937
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
14842
14938
  * */
14843
14939
  const getSnackbarMessage = (objectName, id) => id ? `Object "${objectName}" ${translateKeyOutsideComponents('update-succes')}!` : `Object "${objectName}" ${translateKeyOutsideComponents('save-succes')}!`;
14844
14940
  const drawingsListener = createListenerMiddleware();
@@ -14911,6 +15007,7 @@ drawingsListener.startListening({
14911
15007
  *
14912
15008
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
14913
15009
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
15010
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
14914
15011
  * */
14915
15012
  const drawingModuleConfig = {
14916
15013
  id: 'drawing-module',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "9.25.2",
3
+ "version": "9.26.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,11 +1,10 @@
1
1
  import * as React from 'react';
2
- import { TFunction } from 'i18next';
3
2
  export interface LevelColor {
4
3
  color: string;
5
4
  textColor: string;
6
5
  }
7
- interface LevelDetails extends LevelColor {
8
- title: string;
6
+ export interface LevelDetails extends LevelColor {
7
+ translationKey: string;
9
8
  key: string;
10
9
  }
11
10
  export declare enum WarningLevel {
@@ -14,9 +13,9 @@ export declare enum WarningLevel {
14
13
  extreme = "extreme"
15
14
  }
16
15
  export declare const LevelColors: Record<WarningLevel, LevelColor>;
17
- export declare const levelOptions: (t: TFunction) => LevelDetails[];
16
+ export declare const getLevelStyle: (levelColor?: LevelColor) => React.CSSProperties;
17
+ export declare const levelOptions: LevelDetails[];
18
18
  export declare const LevelField: React.FC<{
19
19
  isDisabled?: boolean;
20
20
  isReadOnly?: boolean;
21
21
  }>;
22
- export {};
@@ -1,13 +1,11 @@
1
1
  import * as React from 'react';
2
- import { TFunction } from 'i18next';
3
- interface PhenomenonDetails {
4
- title: string;
2
+ export declare const getWarningPhenomenaIcon: (key: string) => JSX.Element | undefined;
3
+ export interface PhenomenonDetails {
4
+ translationKey: string;
5
5
  key: string;
6
- icon: JSX.Element;
7
6
  }
8
- export declare const warningPhenomena: (t: TFunction) => PhenomenonDetails[];
7
+ export declare const warningPhenomena: PhenomenonDetails[];
9
8
  export declare const Phenomenon: React.FC<{
10
9
  isDisabled?: boolean;
11
10
  isReadOnly?: boolean;
12
11
  }>;
13
- export {};
@@ -7,9 +7,11 @@ export declare const emptyFilter: {
7
7
  name: string;
8
8
  checked: boolean;
9
9
  };
10
+ type TranslateListDict = Record<string, string>;
10
11
  export declare const defaultFilters: {
11
12
  key: string;
12
13
  translationKey: string;
14
+ translations?: TranslateListDict;
13
15
  }[];
14
16
  export declare const getFiltersFromWarnings: (warnings: PublicWarning[]) => WarningListFilter[];
15
17
  export declare const isWarningMatchingFilter: (filters: OptionListItem[], filterId: EntityId, warningDetailValue: string) => boolean;
@@ -18,3 +20,4 @@ export declare const getUpdatedFilters: (filters: EntityState<WarningListFilter>
18
20
  changes: WarningListFilter;
19
21
  }[];
20
22
  export declare const getUpdatedFilterList: (oldList: FilterListItemProps[], newList: FilterListItemProps[]) => FilterListItemProps[];
23
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { layerTypes, mapTypes } from '@opengeoweb/store';
2
2
  export declare const initialBbox: {
3
- srs: string;
3
+ srs: "EPSG:3857";
4
4
  bbox: {
5
5
  left: number;
6
6
  bottom: number;