@opengeoweb/warnings 9.20.2 → 9.21.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.
Files changed (2) hide show
  1. package/index.esm.js +20 -16
  2. package/package.json +3 -3
package/index.esm.js CHANGED
@@ -7877,7 +7877,7 @@ const levelOptions = t => [Object.assign({
7877
7877
  }, LevelColors[WarningLevel.severe]), Object.assign({
7878
7878
  title: t('warning-level-extreme'),
7879
7879
  key: WarningLevel.extreme
7880
- }, LevelColors['extreme'])];
7880
+ }, LevelColors[WarningLevel.extreme])];
7881
7881
  const LevelField = ({
7882
7882
  isDisabled: _isDisabled = false,
7883
7883
  isReadOnly: _isReadOnly = false
@@ -8286,6 +8286,16 @@ const getErrors = errors => errors ? errors === null || errors === void 0 ? void
8286
8286
  title: '',
8287
8287
  errors: []
8288
8288
  }) : null;
8289
+ const getWarningGeoJSONWithColor = (level, geoJSON) => produce(geoJSON, draft => {
8290
+ const draftFeature = draft === null || draft === void 0 ? void 0 : draft.features[0];
8291
+ if (draftFeature) {
8292
+ const defaultProps = getDefaultFeatureProperties(level);
8293
+ if (!draftFeature.properties) {
8294
+ draftFeature.properties = Object.assign({}, defaultProps);
8295
+ }
8296
+ Object.assign(draftFeature.properties, Object.assign(Object.assign({}, defaultProps), draftFeature.properties));
8297
+ }
8298
+ });
8289
8299
  const Form = ({
8290
8300
  defaultBbox,
8291
8301
  onSaveForm: _onSaveForm = () => {},
@@ -8301,6 +8311,7 @@ const Form = ({
8301
8311
  onFormDirty: _onFormDirty = () => {},
8302
8312
  isSnapshot: _isSnapshot = false
8303
8313
  }) => {
8314
+ const [warningGeoJSONFeature, setWarningGeoJSONFeature] = React.useState(publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.geoJSON);
8304
8315
  const {
8305
8316
  t
8306
8317
  } = useWarningsTranslation();
@@ -8347,26 +8358,19 @@ const Form = ({
8347
8358
  };
8348
8359
  const onPressClear = () => {
8349
8360
  reset(getEmptyPublicWarning());
8361
+ setWarningGeoJSONFeature(undefined);
8350
8362
  };
8351
8363
  React.useEffect(() => {
8352
8364
  // sync redux with react-hook-form
8353
8365
  reset(getFormData(publicWarningDetails, object));
8354
8366
  }, [object, reset, publicWarningDetails]);
8367
+ React.useEffect(() => {
8368
+ // sync drawing on map with selected warning
8369
+ setWarningGeoJSONFeature(publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.geoJSON);
8370
+ }, [publicWarningDetails]);
8355
8371
  const errors = getErrors(_error.message);
8356
- // object is used making drawing, publicWarningDetails is used when showing the dialog from the warninglist.
8357
- const warningGeoJSONFeature = (object === null || object === void 0 ? void 0 : object.geoJSON) || (publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.geoJSON);
8358
- // Add colors, if not defined
8359
- const warningGeoJSONFeatureWithFillProps = produce(warningGeoJSONFeature, draft => {
8360
- const draftFeature = draft === null || draft === void 0 ? void 0 : draft.features[0];
8361
- if (draftFeature) {
8362
- const level = WarningLevel[publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.level] || WarningLevel[WarningLevel.moderate];
8363
- const defaultProps = getDefaultFeatureProperties(level);
8364
- if (!draftFeature.properties) {
8365
- draftFeature.properties = Object.assign({}, defaultProps);
8366
- }
8367
- Object.assign(draftFeature.properties, Object.assign(Object.assign({}, defaultProps), draftFeature.properties));
8368
- }
8369
- });
8372
+ const level = WarningLevel[publicWarningDetails === null || publicWarningDetails === void 0 ? void 0 : publicWarningDetails.level] || WarningLevel[WarningLevel.moderate];
8373
+ const geoJSONFeature = getWarningGeoJSONWithColor(level, warningGeoJSONFeature);
8370
8374
  return jsxs(ContainerWrapper, {
8371
8375
  children: [jsxs(ContainerFormWrapper, Object.assign({
8372
8376
  isReadOnly: _isReadOnly2
@@ -8421,7 +8425,7 @@ const Form = ({
8421
8425
  xs: 12
8422
8426
  }, {
8423
8427
  children: jsx(WarningsMapView, {
8424
- geojsonFeature: warningGeoJSONFeatureWithFillProps,
8428
+ geojsonFeature: geoJSONFeature,
8425
8429
  defaultBbox: defaultBbox,
8426
8430
  isSnapshot: _isSnapshot
8427
8431
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "9.20.2",
3
+ "version": "9.21.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -26,8 +26,8 @@
26
26
  "@opengeoweb/core": "*",
27
27
  "@opengeoweb/webmap": "*",
28
28
  "@opengeoweb/authentication": "*",
29
- "react-i18next": "^13.5.0",
30
- "i18next": "^23.7.19",
29
+ "react-i18next": "^14.1.2",
30
+ "i18next": "^23.11.5",
31
31
  "immer": "^10.0.3"
32
32
  },
33
33
  "peerDependencies": {