@opengeoweb/warnings 9.29.0 → 9.30.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,6 +1,6 @@
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, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, DrawPolygon, Visibility, Add, 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, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, DrawPolygon, Visibility, Add, breakpoints, Close, Options, ChevronDown, ChevronUp, 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
6
  import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, getPosition, FilterChip, FilterListItem, FilterLabel, StatusTag, LastUpdateTime, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
@@ -13,12 +13,12 @@ import { generateMapId, LayerType, getWMJSMapById, getGeoCoordFromLatLong, WMBBO
13
13
  import { snackbarActions, snackbarTypes } from '@opengeoweb/snackbar';
14
14
  import * as React from 'react';
15
15
  import React__default, { useState, useEffect, useRef } from 'react';
16
- import { styled, Box, Typography, ListItem, Grid2, Paper, ListItemButton, Stack, LinearProgress, Button, MenuItem, FormHelperText, Tabs, Tab, Card, CardContent, CircularProgress, Menu, DialogTitle, DialogContent, Switch } from '@mui/material';
16
+ import { styled, Box, Typography, ListItem, Grid2, Paper, ListItemButton, Stack, LinearProgress, Button, MenuItem, FormHelperText, Tabs, Tab, Card, CardContent, CircularProgress, Menu, DialogTitle, DialogContent, Switch, ListItemIcon, Checkbox, ListItemText } from '@mui/material';
17
17
  import { VariableSizeList } from 'react-window';
18
18
  import AutoSizer from 'react-virtualized-auto-sizer';
19
19
  import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider, ProductStatus, useAirmetList, useSigmetList } from '@opengeoweb/api';
20
20
  import { useFormContext } from 'react-hook-form';
21
- import { isEqual, cloneDeep, clamp } from 'lodash';
21
+ import { isEqual, cloneDeep, clamp, debounce } from 'lodash';
22
22
  import { useAuthenticationContext } from '@opengeoweb/authentication';
23
23
  import { produce } from 'immer';
24
24
  import { isAxiosError } from 'axios';
@@ -149,8 +149,10 @@ var en = {
149
149
  "filter-source": "Sources",
150
150
  "filter-hide": "Hide {{subject}}",
151
151
  "filter-show": "Show {{subject}}",
152
- airmet: "Airmet",
153
- sigmet: "Sigmet",
152
+ "filter-only": "ONLY",
153
+ "warning-domain-aviation": "Aviation",
154
+ "warning-domain-maritime": "Maritime",
155
+ "warning-domain-public": "Public",
154
156
  "error-title-retry": "Try again",
155
157
  "aviation-phenomenon-radioactive-cloud": "Radioactive cloud",
156
158
  "aviation-phenomenon-heavy-sandstorm": "Heavy sandstorm",
@@ -318,7 +320,6 @@ var nl = {
318
320
  "filter-phenomenon": "Fenomenen",
319
321
  "filter-level": "Niveaus",
320
322
  "filter-source": "Bronnen",
321
- "error-title-retry": "Probeer opnieuw",
322
323
  "warning-dialog-expire-succes": "Waarschuwing laten verlopen is succesvol",
323
324
  "warning-dialog-expire-title": "Waarschuwing laten verlopen",
324
325
  "warning-dialog-expire-confirm": "Verlopen",
@@ -326,7 +327,12 @@ var nl = {
326
327
  "warning-dialog-withdraw-succes": "Waarschuwing is succesvol ingetrokken",
327
328
  "warning-dialog-withdraw-title": "Waarschuwing intrekken",
328
329
  "warning-dialog-withdraw-confirm": "Intrekken",
329
- "warning-dialog-withdraw-description": "Weet je zeker dat je deze waarschuwing wilt intrekken?"
330
+ "warning-dialog-withdraw-description": "Weet je zeker dat je deze waarschuwing wilt intrekken?",
331
+ "filter-only": "ALLEEN",
332
+ "warning-domain-aviation": "Luchtvaart",
333
+ "warning-domain-maritime": "Maritiem",
334
+ "warning-domain-public": "Publiek",
335
+ "error-title-retry": "Probeer opnieuw"
330
336
  };
331
337
  var fi = {
332
338
  "drawing-tool-form-tools": "Työkalut",
@@ -452,7 +458,6 @@ var fi = {
452
458
  "filter-phenomenon": "ei käännetty",
453
459
  "filter-level": "ei käännetty",
454
460
  "filter-source": "ei käännetty",
455
- "error-title-retry": "Yritä uudelleen",
456
461
  "warning-dialog-expire-succes": "ei käännetty",
457
462
  "warning-dialog-expire-title": "ei käännetty",
458
463
  "warning-dialog-expire-confirm": "ei käännetty",
@@ -460,7 +465,12 @@ var fi = {
460
465
  "warning-dialog-withdraw-succes": "ei käännetty",
461
466
  "warning-dialog-withdraw-title": "ei käännetty",
462
467
  "warning-dialog-withdraw-confirm": "ei käännetty",
463
- "warning-dialog-withdraw-description": "ei käännetty"
468
+ "warning-dialog-withdraw-description": "ei käännetty",
469
+ "filter-only": "Pelkästään",
470
+ "warning-domain-aviation": "ei käännetty",
471
+ "warning-domain-maritime": "ei käännetty",
472
+ "warning-domain-public": "ei käännetty",
473
+ "error-title-retry": "Yritä uudelleen"
464
474
  };
465
475
  var no = {
466
476
  "drawing-tool-form-tools": "Verktøy",
@@ -586,7 +596,6 @@ var no = {
586
596
  "filter-phenomenon": "Fenomen",
587
597
  "filter-level": "Grad",
588
598
  "filter-source": "Kilder",
589
- "error-title-retry": "Prøv igjen",
590
599
  "warning-dialog-expire-succes": "ikke oversatt",
591
600
  "warning-dialog-expire-title": "ikke oversatt",
592
601
  "warning-dialog-expire-confirm": "ikke oversatt",
@@ -594,7 +603,12 @@ var no = {
594
603
  "warning-dialog-withdraw-succes": "ikke oversatt",
595
604
  "warning-dialog-withdraw-title": "ikke oversatt",
596
605
  "warning-dialog-withdraw-confirm": "ikke oversatt",
597
- "warning-dialog-withdraw-description": "ikke oversatt"
606
+ "warning-dialog-withdraw-description": "ikke oversatt",
607
+ "filter-only": "BARE",
608
+ "warning-domain-aviation": "ikke oversatt",
609
+ "warning-domain-maritime": "ikke oversatt",
610
+ "warning-domain-public": "ikke oversatt",
611
+ "error-title-retry": "Prøv igjen"
598
612
  };
599
613
  var warningsTranslations = {
600
614
  en: en,
@@ -4164,9 +4178,6 @@ const getFilterlistWithTranslationKeys = filterList => filterList.reduce((fiterL
4164
4178
  const defaultFilters = [{
4165
4179
  key: 'incident',
4166
4180
  translationKey: 'filter-incident'
4167
- }, {
4168
- key: 'domain',
4169
- translationKey: 'filter-domain'
4170
4181
  }, {
4171
4182
  key: 'phenomenon',
4172
4183
  translationKey: 'filter-phenomenon',
@@ -13909,7 +13920,6 @@ const FilterChipWithOptions = ({
13909
13920
  children: jsx(FilterChip, {
13910
13921
  id: id,
13911
13922
  label: label,
13912
- onAction: onClickOptions,
13913
13923
  actionIcon: actionButton(selectedFiltersAmount),
13914
13924
  isSelected: isAnyFilterSelected,
13915
13925
  handleClick: onClickOptions,
@@ -14071,14 +14081,218 @@ const FilterChipWithOptionsConnect = ({
14071
14081
  }));
14072
14082
  };
14073
14083
 
14084
+ const FilterOption = ({
14085
+ filterId,
14086
+ optionId,
14087
+ checked,
14088
+ onClick,
14089
+ label
14090
+ }) => {
14091
+ const {
14092
+ t
14093
+ } = useWarningsTranslation();
14094
+ const [showOnly, setShowOnly] = useState(false);
14095
+ const updateShowOnly = debounce(show => setShowOnly(show), 100);
14096
+ return jsx(ListItem, Object.assign({
14097
+ disablePadding: true,
14098
+ dense: true,
14099
+ sx: {
14100
+ width: '100%',
14101
+ minWidth: '300px',
14102
+ paddingRight: '0px',
14103
+ marginLeft: '-12px',
14104
+ fontSize: '12px'
14105
+ },
14106
+ secondaryAction: showOnly && jsx(CustomIconButton, Object.assign({
14107
+ "aria-label": `Only ${optionId}`,
14108
+ style: {
14109
+ backgroundColor: 'transparent',
14110
+ width: 'auto'
14111
+ },
14112
+ edge: "end",
14113
+ onClick: () => onClick(!checked, true),
14114
+ onMouseOver: () => updateShowOnly(true),
14115
+ onMouseOut: () => updateShowOnly(false)
14116
+ }, {
14117
+ children: jsx(Typography, Object.assign({
14118
+ sx: {
14119
+ color: 'geowebColors.buttons.primary.default.fill',
14120
+ fontSize: '14px',
14121
+ fontWeight: 500
14122
+ }
14123
+ }, {
14124
+ children: t('filter-only')
14125
+ }))
14126
+ }))
14127
+ }, {
14128
+ children: jsxs(ListItemButton, Object.assign({
14129
+ role: undefined,
14130
+ onClick: () => onClick(!checked),
14131
+ onMouseOver: () => updateShowOnly(true),
14132
+ onMouseOut: () => updateShowOnly(false),
14133
+ dense: true,
14134
+ disableGutters: true,
14135
+ sx: {
14136
+ padding: 0
14137
+ }
14138
+ }, {
14139
+ children: [jsx(ListItemIcon, {
14140
+ children: jsx(Checkbox, {
14141
+ checked: checked,
14142
+ tabIndex: -1,
14143
+ disableRipple: true,
14144
+ inputProps: {
14145
+ 'aria-labelledby': optionId,
14146
+ 'aria-label': optionId
14147
+ }
14148
+ })
14149
+ }), jsx(ListItemText, {
14150
+ id: optionId,
14151
+ sx: {
14152
+ padding: 0,
14153
+ margin: 0
14154
+ },
14155
+ primary: label || t(`warning-${filterId}-${optionId}`)
14156
+ })]
14157
+ }))
14158
+ }), optionId);
14159
+ };
14160
+
14161
+ const ExpandableFilterChip = ({
14162
+ id,
14163
+ options,
14164
+ updateFilter
14165
+ }) => {
14166
+ const {
14167
+ t
14168
+ } = useWarningsTranslation();
14169
+ const [anchorEl, setAnchorEl] = useState(null);
14170
+ const selectedOptions = Object.keys(options).filter(k => options[k]);
14171
+ const allSelected = selectedOptions.length === Object.keys(options).length;
14172
+ return jsxs(Fragment, {
14173
+ children: [jsx(CustomTooltip, Object.assign({
14174
+ title: t('filter-options'),
14175
+ placement: "bottom"
14176
+ }, {
14177
+ children: jsx("span", Object.assign({
14178
+ style: {
14179
+ margin: 0
14180
+ }
14181
+ }, {
14182
+ children: jsx(FilterChip, {
14183
+ id: id,
14184
+ label: t(`filter-${id}`),
14185
+ isSelected: selectedOptions.length > 0,
14186
+ onClick: ref => setAnchorEl(ref),
14187
+ isDisabled: false,
14188
+ size: "medium",
14189
+ actionIcon: jsxs(Grid2, Object.assign({
14190
+ container: true,
14191
+ alignItems: "center",
14192
+ style: {
14193
+ marginRight: '8px',
14194
+ minWidth: '36px'
14195
+ }
14196
+ }, {
14197
+ children: [jsx(Options, {}), jsx(Typography, Object.assign({
14198
+ variant: "body2",
14199
+ sx: {
14200
+ paddingLeft: 0.5
14201
+ }
14202
+ }, {
14203
+ children: selectedOptions.length > 0 && selectedOptions.length
14204
+ }))]
14205
+ }))
14206
+ })
14207
+ }))
14208
+ })), jsxs(Menu, Object.assign({
14209
+ title: t(`filter-${id}`),
14210
+ open: Boolean(anchorEl),
14211
+ onClose: () => setAnchorEl(null),
14212
+ anchorEl: anchorEl,
14213
+ BackdropProps: {
14214
+ style: {
14215
+ opacity: 0,
14216
+ transition: 'none'
14217
+ }
14218
+ },
14219
+ sx: {
14220
+ padding: 3
14221
+ }
14222
+ }, {
14223
+ children: [jsxs(DialogTitle, Object.assign({
14224
+ id: "dialog-title",
14225
+ sx: {
14226
+ zIndex: 1,
14227
+ padding: '8px 18px 16px 24px',
14228
+ display: 'flex',
14229
+ justifyContent: 'space-between',
14230
+ alignItems: 'center'
14231
+ }
14232
+ }, {
14233
+ children: [jsx(Typography, Object.assign({
14234
+ sx: {
14235
+ fontSize: '20px',
14236
+ fontWeight: 500,
14237
+ paddingRight: 1
14238
+ },
14239
+ "data-testid": "customDialog-title",
14240
+ component: "span"
14241
+ }, {
14242
+ children: t(`filter-${id}`)
14243
+ })), jsx(CustomIconButton, Object.assign({
14244
+ "aria-label": t('close-dialog-confirm'),
14245
+ onClick: () => setAnchorEl(null),
14246
+ sx: {
14247
+ '&.MuiIconButton-root': {
14248
+ color: 'geowebColors.greys.accessible'
14249
+ }
14250
+ }
14251
+ }, {
14252
+ children: jsx(Close, {})
14253
+ }))]
14254
+ })), jsxs(DialogContent, Object.assign({
14255
+ sx: {
14256
+ padding: '0px 24px 16px 24px'
14257
+ }
14258
+ }, {
14259
+ children: [jsxs(Grid2, Object.assign({
14260
+ container: true,
14261
+ justifyContent: "space-between",
14262
+ alignItems: "center"
14263
+ }, {
14264
+ children: [t('filter-select-all'), jsx(Switch, {
14265
+ inputProps: {
14266
+ 'aria-label': t('filter-select-all')
14267
+ },
14268
+ checked: allSelected,
14269
+ onChange: () => updateFilter(id, 'ALL', !allSelected),
14270
+ sx: {
14271
+ marginRight: '-12px',
14272
+ marginTop: '-6px'
14273
+ }
14274
+ })]
14275
+ })), jsx(Box, {
14276
+ children: Object.keys(options).map(optionId => {
14277
+ return jsx(FilterOption, {
14278
+ filterId: id,
14279
+ optionId: optionId,
14280
+ checked: options[optionId],
14281
+ onClick: (checked, only) => updateFilter(id, optionId, checked, only)
14282
+ }, `${id}-${optionId}`);
14283
+ })
14284
+ })]
14285
+ }))]
14286
+ }))]
14287
+ });
14288
+ };
14289
+
14074
14290
  const FilterList = ({
14075
14291
  filters: _filters = [],
14076
14292
  onClickAll: _onClickAll = () => {},
14077
14293
  isAllSelected: _isAllSelected = true,
14078
- showSigmet: _showSigmet = false,
14079
- showAirmet: _showAirmet = false,
14080
- setShowSigmet,
14081
- setShowAirmet
14294
+ filterState,
14295
+ updateFilter
14082
14296
  }) => {
14083
14297
  const {
14084
14298
  t
@@ -14116,58 +14330,23 @@ const FilterList = ({
14116
14330
  return jsx(FilterChipWithOptionsConnect, {
14117
14331
  filter: filter
14118
14332
  }, filter.id);
14119
- }), setShowSigmet && jsx(CustomTooltip, Object.assign({
14120
- title: _showSigmet ? t('filter-hide', {
14121
- subject: t('sigmet')
14122
- }) : t('filter-show', {
14123
- subject: t('sigmet')
14124
- }),
14125
- placement: "bottom"
14126
- }, {
14127
- children: jsx("span", Object.assign({
14128
- style: {
14129
- margin: 0
14130
- }
14131
- }, {
14132
- children: jsx(FilterChip, {
14133
- id: "sigmet",
14134
- label: t('sigmet'),
14135
- isSelected: _showSigmet,
14136
- handleClick: () => setShowSigmet(!_showSigmet),
14137
- size: "medium"
14138
- })
14139
- }))
14140
- })), setShowAirmet && jsx(CustomTooltip, Object.assign({
14141
- title: _showAirmet ? t('filter-hide', {
14142
- subject: t('airmet')
14143
- }) : t('filter-show', {
14144
- subject: t('airmet')
14145
- }),
14146
- placement: "bottom"
14147
- }, {
14148
- children: jsx("span", Object.assign({
14149
- style: {
14150
- margin: 0
14151
- }
14152
- }, {
14153
- children: jsx(FilterChip, {
14154
- id: "airmet",
14155
- label: t('airmet'),
14156
- isSelected: _showAirmet,
14157
- handleClick: () => setShowAirmet(!_showAirmet),
14158
- size: "medium"
14159
- })
14160
- }))
14161
- }))]
14333
+ }), filterState && Object.keys(filterState).map(filterId => jsx(ExpandableFilterChip, {
14334
+ id: filterId,
14335
+ options: filterState[filterId],
14336
+ updateFilter: updateFilter
14337
+ }, filterId))]
14162
14338
  }));
14163
14339
  };
14164
14340
 
14341
+ const HEADER_SIZE = 32;
14165
14342
  const WarningListItemSeperator = _a => {
14166
14343
  var {
14167
14344
  totalWarnings,
14168
- status
14345
+ status,
14346
+ isExpanded,
14347
+ onClick
14169
14348
  } = _a,
14170
- props = __rest(_a, ["totalWarnings", "status"]);
14349
+ props = __rest(_a, ["totalWarnings", "status", "isExpanded", "onClick"]);
14171
14350
  const {
14172
14351
  t
14173
14352
  } = useWarningsTranslation();
@@ -14185,15 +14364,28 @@ const WarningListItemSeperator = _a => {
14185
14364
  };
14186
14365
  const headerText = `${totalWarnings} ${getStatus(status)}`;
14187
14366
  return jsx(ListItem, Object.assign({}, props, {
14367
+ sx: {
14368
+ height: HEADER_SIZE,
14369
+ padding: 0
14370
+ },
14188
14371
  "aria-label": `warninglist ${status}`
14189
14372
  }, {
14190
- children: jsx(Typography, Object.assign({
14191
- variant: "caption",
14373
+ children: jsxs(ListItemButton, Object.assign({
14192
14374
  sx: {
14193
- opacity: 0.67
14194
- }
14375
+ height: HEADER_SIZE,
14376
+ padding: 0
14377
+ },
14378
+ onClick: onClick
14195
14379
  }, {
14196
- children: headerText
14380
+ children: [isExpanded ? jsx(ChevronDown, {}) : jsx(ChevronUp, {}), jsx(Typography, Object.assign({
14381
+ variant: "caption",
14382
+ sx: {
14383
+ opacity: 0.67,
14384
+ marginLeft: 1
14385
+ }
14386
+ }, {
14387
+ children: headerText
14388
+ }))]
14197
14389
  }))
14198
14390
  }));
14199
14391
  };
@@ -14774,6 +14966,57 @@ const WarningListItem = _a => {
14774
14966
  }), warning.id);
14775
14967
  };
14776
14968
 
14969
+ var Domain;
14970
+ (function (Domain) {
14971
+ Domain["aviation"] = "aviation";
14972
+ Domain["maritime"] = "maritime";
14973
+ Domain["public"] = "public";
14974
+ })(Domain || (Domain = {}));
14975
+ const defaultDomainFilter = {
14976
+ aviation: false,
14977
+ maritime: false,
14978
+ public: true
14979
+ };
14980
+ const useWarningFilters = () => {
14981
+ const [domainFilter, setDomainFilter] = useState(defaultDomainFilter);
14982
+ const updateState = (state, optionKey, value, only) => {
14983
+ if (only) {
14984
+ return Object.keys(state).reduce((acc, k) => Object.assign(Object.assign({}, acc), {
14985
+ [k]: k === optionKey
14986
+ }), {});
14987
+ }
14988
+ return optionKey === 'ALL' ? Object.keys(state).reduce((acc, k) => Object.assign(Object.assign({}, acc), {
14989
+ [k]: value
14990
+ }), {}) : Object.assign(Object.assign({}, state), {
14991
+ [optionKey]: value
14992
+ });
14993
+ };
14994
+ const updateFilter = (filterKey, optionKey, value, only) => {
14995
+ if (filterKey === 'ALL') {
14996
+ return;
14997
+ }
14998
+ if (filterKey === 'domain') {
14999
+ setDomainFilter(state => {
15000
+ return updateState(state, optionKey, value, only);
15001
+ });
15002
+ }
15003
+ };
15004
+ const byFilterState = warning => {
15005
+ const levelDomain = ['SIG', 'AIR'].find(d => d === warning.warningDetail.level) ? Domain.aviation : Domain.public;
15006
+ if (!domainFilter[levelDomain]) {
15007
+ return false;
15008
+ }
15009
+ return true;
15010
+ };
15011
+ return {
15012
+ filterState: {
15013
+ domain: domainFilter
15014
+ },
15015
+ updateFilter,
15016
+ byFilterState
15017
+ };
15018
+ };
15019
+
14777
15020
  const sortWarningsOnStatus = warnings => {
14778
15021
  return warnings.reduce((allWarnings, warning) => {
14779
15022
  const status = warning.status || mapProductStatusToWarningStatus(warning.productStatus);
@@ -14838,10 +15081,6 @@ const PublicWarningList = ({
14838
15081
  error,
14839
15082
  selectedPublicWarningId: _selectedPublicWarningId = '',
14840
15083
  lastUpdatedTime,
14841
- showSigmet,
14842
- showAirmet,
14843
- setShowSigmet,
14844
- setShowAirmet,
14845
15084
  onSelectWarning: _onSelectWarning = () => {},
14846
15085
  onEditWarning: _onEditWarning = () => {},
14847
15086
  onCreateWarning: _onCreateWarning = () => {},
@@ -14856,20 +15095,37 @@ const PublicWarningList = ({
14856
15095
  const {
14857
15096
  t
14858
15097
  } = useWarningsTranslation();
14859
- const sortedWarnings = sortWarningsOnStatus(_warnings);
15098
+ const {
15099
+ filterState,
15100
+ updateFilter,
15101
+ byFilterState
15102
+ } = useWarningFilters();
15103
+ const sortedWarnings = sortWarningsOnStatus(_warnings.filter(byFilterState));
15104
+ const [expandedSections, setExpandedSections] = React__default.useState({
15105
+ TODO: true,
15106
+ DRAFT: true,
15107
+ PUBLISHED: true,
15108
+ EXPIRED: true
15109
+ });
15110
+ const toggleExpand = (shouldToggle, status) => {
15111
+ setExpandedSections(Object.assign(Object.assign({}, expandedSections), {
15112
+ [status]: shouldToggle
15113
+ }));
15114
+ resetListIndex();
15115
+ };
14860
15116
  const items = [{
14861
15117
  status: PublicWarningStatus.TODO,
14862
15118
  totalWarnings: sortedWarnings.todo.length
14863
- }, ...sortedWarnings.todo, {
15119
+ }, ...(expandedSections.TODO ? sortedWarnings.todo : []), {
14864
15120
  status: PublicWarningStatus.DRAFT,
14865
15121
  totalWarnings: sortedWarnings.draft.length
14866
- }, ...sortedWarnings.draft, {
15122
+ }, ...(expandedSections.DRAFT ? sortedWarnings.draft : []), {
14867
15123
  status: PublicWarningStatus.PUBLISHED,
14868
15124
  totalWarnings: sortedWarnings.published.length
14869
- }, ...sortedWarnings.published, {
15125
+ }, ...(expandedSections.PUBLISHED ? sortedWarnings.published : []), {
14870
15126
  status: PublicWarningStatus.EXPIRED,
14871
15127
  totalWarnings: sortedWarnings.expired.length
14872
- }, ...sortedWarnings.expired];
15128
+ }, ...(expandedSections.EXPIRED ? sortedWarnings.expired : [])];
14873
15129
  const getItemSize = (index, width) => {
14874
15130
  const item = items[index];
14875
15131
  if (item.totalWarnings !== undefined) {
@@ -14947,10 +15203,8 @@ const PublicWarningList = ({
14947
15203
  filters: filters,
14948
15204
  isAllSelected: _isAllChipSelected,
14949
15205
  onClickAll: _onClickAllChip,
14950
- showSigmet: showSigmet,
14951
- showAirmet: showAirmet,
14952
- setShowSigmet: setShowSigmet,
14953
- setShowAirmet: setShowAirmet
15206
+ filterState: filterState,
15207
+ updateFilter: updateFilter
14954
15208
  })
14955
15209
  })), jsxs(Grid2, Object.assign({
14956
15210
  className: "create-warning",
@@ -15084,7 +15338,11 @@ const PublicWarningList = ({
15084
15338
  return jsx(WarningListItemSeperator, {
15085
15339
  status: header.status,
15086
15340
  totalWarnings: header.totalWarnings,
15087
- style: style
15341
+ style: style,
15342
+ isExpanded: expandedSections[warning.status],
15343
+ onClick: () => {
15344
+ toggleExpand(!expandedSections[header.status], header.status);
15345
+ }
15088
15346
  }, key);
15089
15347
  }
15090
15348
  const publicWarning = warning;
@@ -15297,8 +15555,6 @@ const PublicWarningListConnect = () => {
15297
15555
  refetch: refetchSigmetList,
15298
15556
  isFetching: isFetchingSigmet
15299
15557
  } = useSigmetList();
15300
- const [showAirmet, setShowAirmet] = React__default.useState(false);
15301
- const [showSigmet, setShowSigmet] = React__default.useState(false);
15302
15558
  const [confirmDialogOptions, setConfirmDialogOptions] = React__default.useState(undefined);
15303
15559
  const filters = useSelector(selectAllFilters);
15304
15560
  const isAllChipSelected = useSelector(getIsAllSelected);
@@ -15431,7 +15687,7 @@ const PublicWarningListConnect = () => {
15431
15687
  }, [dispatch, warnings]);
15432
15688
  const transformedSigmets = (sigmetList === null || sigmetList === void 0 ? void 0 : sigmetList.map(transformSigmetToWarningFormat)) || [];
15433
15689
  const transformedAirmets = (airmetList === null || airmetList === void 0 ? void 0 : airmetList.map(transformAirmetToWarningFormat)) || [];
15434
- const combinedWarnings = filteredWarnings.concat(showSigmet ? transformedSigmets : []).concat(showAirmet ? transformedAirmets : []).sort((w1, w2) => {
15690
+ const combinedWarnings = filteredWarnings.concat(transformedSigmets).concat(transformedAirmets).sort((w1, w2) => {
15435
15691
  var _a;
15436
15692
  return ((_a = w2.lastUpdatedTime) === null || _a === void 0 ? void 0 : _a.localeCompare(w1.lastUpdatedTime || '')) || 0;
15437
15693
  });
@@ -15452,11 +15708,7 @@ const PublicWarningListConnect = () => {
15452
15708
  onRefetchWarnings: fetchWarnings,
15453
15709
  filters: filters,
15454
15710
  isAllChipSelected: isAllChipSelected,
15455
- onClickAllChip: onClickAllChip,
15456
- showSigmet: showSigmet,
15457
- showAirmet: showAirmet,
15458
- setShowSigmet: setShowSigmet,
15459
- setShowAirmet: setShowAirmet
15711
+ onClickAllChip: onClickAllChip
15460
15712
  }), confirmDialogOptions && jsx(ConfirmDeleteWarningDialog, {
15461
15713
  onClose: () => setConfirmDialogOptions(undefined),
15462
15714
  title: confirmDialogOptions.title,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "9.29.0",
3
+ "version": "9.30.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { FilterState, UpdateFilter } from '../PublicWarningList/hooks';
3
+ type IdType = keyof FilterState;
4
+ interface Props {
5
+ id: IdType;
6
+ options: FilterState[IdType];
7
+ updateFilter: UpdateFilter;
8
+ }
9
+ declare const ExpandableFilterChip: React.FC<Props>;
10
+ export default ExpandableFilterChip;
@@ -1,13 +1,12 @@
1
1
  import { FC } from 'react';
2
2
  import { WarningListFilter } from '../../store/publicWarnings/types';
3
+ import { FilterState, UpdateFilter } from '../PublicWarningList/hooks';
3
4
  interface FilterListProps {
4
5
  filters?: WarningListFilter[];
5
6
  onClickAll?: (isChecked: boolean) => void;
6
7
  isAllSelected?: boolean;
7
- showSigmet?: boolean;
8
- showAirmet?: boolean;
9
- setShowSigmet?: React.Dispatch<React.SetStateAction<boolean>>;
10
- setShowAirmet?: React.Dispatch<React.SetStateAction<boolean>>;
8
+ filterState?: FilterState;
9
+ updateFilter: UpdateFilter;
11
10
  }
12
11
  declare const FilterList: FC<FilterListProps>;
13
12
  export default FilterList;
@@ -0,0 +1,12 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { FilterState, OptionKey } from '../PublicWarningList/hooks';
3
+ type FilterType = keyof FilterState;
4
+ interface Props {
5
+ filterId: FilterType;
6
+ optionId: OptionKey<FilterType>;
7
+ checked: boolean;
8
+ onClick: (checked: boolean, only?: boolean) => void;
9
+ label?: ReactNode;
10
+ }
11
+ declare const FilterOption: React.FC<Props>;
12
+ export default FilterOption;
@@ -1,16 +1,10 @@
1
1
  import React from 'react';
2
2
  import { PublicWarning } from '../../store/publicWarningForm/types';
3
3
  import { WarningListFilter } from '../../store/publicWarnings/types';
4
- interface WarningStatusProps {
4
+ import { WarningListItemActions } from './WarningListItemMenu';
5
+ interface PublicWarningListProps extends WarningListItemActions {
5
6
  warnings: PublicWarning[];
6
7
  onSelectWarning?: (warning: PublicWarning) => void;
7
- onEditWarning?: (warning: PublicWarning) => void;
8
- onDeleteWarning?: (warningId: string, warningEditor?: string) => void;
9
- onDeleteReviewWarning?: (warning: PublicWarning) => void;
10
- onExpireWarning?: (warning: PublicWarning) => void;
11
- onWithdrawWarning?: (warning: PublicWarning) => void;
12
- }
13
- export declare const PublicWarningList: React.FC<{
14
8
  isLoading?: boolean;
15
9
  error?: Error;
16
10
  selectedPublicWarningId?: string;
@@ -20,9 +14,6 @@ export declare const PublicWarningList: React.FC<{
20
14
  filters?: WarningListFilter[];
21
15
  onClickAllChip?: (isChecked: boolean) => void;
22
16
  isAllChipSelected?: boolean;
23
- showSigmet?: boolean;
24
- showAirmet?: boolean;
25
- setShowSigmet?: React.Dispatch<React.SetStateAction<boolean>>;
26
- setShowAirmet?: React.Dispatch<React.SetStateAction<boolean>>;
27
- } & WarningStatusProps>;
17
+ }
18
+ export declare const PublicWarningList: React.FC<PublicWarningListProps>;
28
19
  export default PublicWarningList;
@@ -7,3 +7,4 @@ export declare const PublicWarningListLight: () => React.ReactElement;
7
7
  export declare const PublicWarningListError: () => React.ReactElement;
8
8
  export declare const PublicWarningListErrorDeleteWarning: () => React.ReactElement;
9
9
  export declare const PublicWarningListDifferentEditors: () => React.ReactElement;
10
+ export declare const PublicWarningListExtraLongList: () => React.ReactElement;
@@ -1,17 +1,11 @@
1
1
  import React from 'react';
2
2
  import { ListItemProps } from '@mui/material';
3
3
  import { PublicWarning } from '../../store/publicWarningForm/types';
4
- interface WarningStatusProps extends ListItemProps {
4
+ import { WarningListItemActions } from './WarningListItemMenu';
5
+ export interface WarningListItemProps extends ListItemProps, WarningListItemActions {
5
6
  warning: PublicWarning;
7
+ activeWarningId: string;
6
8
  onSelectWarning?: (warning: PublicWarning) => void;
7
- onEditWarning?: (warning: PublicWarning) => void;
8
- onDeleteWarning?: (warningId: string, warningEditor?: string) => void;
9
- onDeleteReviewWarning?: (warning: PublicWarning) => void;
10
- onExpireWarning?: (warning: PublicWarning) => void;
11
- onWithdrawWarning?: (warning: PublicWarning) => void;
12
9
  }
13
- declare const WarningListItem: React.FC<{
14
- warning: PublicWarning;
15
- activeWarningId: string;
16
- } & WarningStatusProps>;
10
+ declare const WarningListItem: React.FC<WarningListItemProps>;
17
11
  export default WarningListItem;
@@ -1,13 +1,15 @@
1
1
  import { MenuItemType } from '@opengeoweb/shared';
2
2
  import { TFunction } from 'i18next';
3
3
  import { PublicWarning } from '../../store/publicWarningForm/types';
4
- interface WarningListItemMenuProps {
5
- warning: PublicWarning;
4
+ export interface WarningListItemActions {
6
5
  onEditWarning?: (warning: PublicWarning) => void;
7
6
  onDeleteWarning?: (warningId: string, warningEditor?: string) => void;
8
7
  onDeleteReviewWarning?: (warning: PublicWarning) => void;
9
8
  onExpireWarning?: (warning: PublicWarning) => void;
10
9
  onWithdrawWarning?: (warning: PublicWarning) => void;
10
+ }
11
+ interface WarningListItemMenuProps extends WarningListItemActions {
12
+ warning: PublicWarning;
11
13
  t: TFunction;
12
14
  }
13
15
  declare const WarningListItemMenu: ({ warning, onEditWarning, onDeleteWarning, onDeleteReviewWarning, onExpireWarning, onWithdrawWarning, t, }: WarningListItemMenuProps) => MenuItemType[];
@@ -4,5 +4,6 @@ import { PublicWarningStatus } from '../../store/publicWarningForm/types';
4
4
  declare const WarningListItemSeperator: React.FC<{
5
5
  totalWarnings: number;
6
6
  status: PublicWarningStatus;
7
+ isExpanded: boolean;
7
8
  } & ListItemProps>;
8
9
  export default WarningListItemSeperator;
@@ -0,0 +1,19 @@
1
+ import { PublicWarning } from '../../store/publicWarningForm/types';
2
+ declare enum Domain {
3
+ aviation = "aviation",
4
+ maritime = "maritime",
5
+ public = "public"
6
+ }
7
+ declare const defaultDomainFilter: Record<Domain, boolean>;
8
+ export interface FilterState {
9
+ domain: typeof defaultDomainFilter;
10
+ }
11
+ export type FilterKeyType = keyof FilterState;
12
+ export type OptionKey<T extends FilterKeyType> = keyof FilterState[T];
13
+ export type UpdateFilter = <T extends FilterKeyType>(filterKey: T | 'ALL', optionKey: OptionKey<T> | 'ALL', value: boolean, only?: boolean) => void;
14
+ export declare const useWarningFilters: () => {
15
+ filterState: FilterState;
16
+ updateFilter: UpdateFilter;
17
+ byFilterState: (warning: PublicWarning) => boolean;
18
+ };
19
+ export {};