@opengeoweb/sigmet-airmet 6.0.4 → 6.1.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
@@ -4,15 +4,16 @@ import { FormControlLabel, Radio, Grid, Typography, Box as Box$2, Button, Checkb
4
4
  import { useFormContext } from 'react-hook-form';
5
5
  import { useDraftFormHelpers, ReactHookFormRadioGroup, ReactHookFormSelect, ReactHookFormNumberField, isInteger, isValidMax, isValidMin, isEmpty, ReactHookFormDateTime, isValidDate, isBefore, isBetween, hasMaxFeaturePoints, hasMulitpleIntersections, ReactHookFormHiddenInput, isMaximumOneDrawing, hasIntersectionWithFIR, isValidGeoJsonCoordinates, isXHoursBefore, isAfter, isXHoursAfter, ReactHookFormTextField, isLatitude, isNonOrBothCoordinates, isLongitude, ReactHookFormFormControl, isGeometryDirty, ReactHookFormProvider, defaultFormOptions } from '@opengeoweb/form-fields';
6
6
  import { useApiContext, useApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider } from '@opengeoweb/api';
7
- import { defaultStyleProperties, defaultIntersectionStyleProperties, defaultPoint, defaultBox, defaultPolygon, DRAWMODE, addFeatureProperties, defaultDelete, MapControls, LayerManagerMapButtonConnect, LegendMapButtonConnect, MultiDimensionSelectMapButtonsConnect, MapViewConnect, MapViewLayer, TimeSliderConnect, LegendConnect, LayerManagerConnect, useMapDrawTool } from '@opengeoweb/core';
7
+ import { defaultIntersectionStyleProperties, defaultPoint, defaultBox, defaultPolygon, defaultDelete, MapControls, LayerManagerMapButtonConnect, LegendMapButtonConnect, MultiDimensionSelectMapButtonsConnect, MapViewConnect, MapViewLayer, TimeSliderConnect, LegendConnect, LayerManagerConnect, useMapDrawTool } from '@opengeoweb/core';
8
+ import { defaultStyleProperties, DRAWMODE, addFeatureProperties } from '@opengeoweb/webmap-react';
8
9
  import { CustomTooltip, ToggleMenu, useIsMounted, StatusTag, AlertBanner, ConfirmationServiceProvider, usePreventBrowserClose, useConfirmationDialog, isAxiosError, getAxiosErrorMessage, usePoller, ErrorBoundary } from '@opengeoweb/shared';
9
10
  import moment from 'moment';
10
11
  import { polygonToLineString, booleanClockwise, rewind } from '@turf/turf';
11
- import { layerTypes, mapSelectors, syncGroupsActions, mapStoreActions, defaultLayers, syncConstants } from '@opengeoweb/store';
12
12
  import { DrawFIRLand, ChevronLeft, Edit, Success, Clock } from '@opengeoweb/theme';
13
+ import { LayerType, webmapUtils } from '@opengeoweb/webmap';
13
14
  import { debounce } from 'lodash';
14
15
  import 'react-dom';
15
- import { webmapUtils } from '@opengeoweb/webmap';
16
+ import { mapSelectors, syncGroupsActions, mapStoreActions, defaultLayers, syncConstants } from '@opengeoweb/store';
16
17
  import { jsx } from 'react/jsx-runtime';
17
18
 
18
19
  function _iterableToArrayLimit(arr, i) {
@@ -1291,7 +1292,7 @@ var getFieldLabel = function getFieldLabel(title, isDisabled) {
1291
1292
  var getBaseLayers = function getBaseLayers(productConfig) {
1292
1293
  var _a, _b;
1293
1294
  return ((_b = (_a = productConfig.mapPreset) === null || _a === void 0 ? void 0 : _a.layers) === null || _b === void 0 ? void 0 : _b.filter(function (layer) {
1294
- return layer.layerType === layerTypes.LayerType.baseLayer || layer.layerType === layerTypes.LayerType.overLayer;
1295
+ return layer.layerType === LayerType.baseLayer || layer.layerType === LayerType.overLayer;
1295
1296
  })) || [];
1296
1297
  };
1297
1298
  var getMaxMovementSpeedValue = function getMaxMovementSpeedValue(unit, selectedFIR, productConfig) {
@@ -3333,6 +3334,9 @@ var shouldRetrieveTAC = function shouldRetrieveTAC(product) {
3333
3334
  return false;
3334
3335
  };
3335
3336
  var useTAC = function useTAC(initialProduct, getTAC) {
3337
+ var hasErrors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
3338
+ return false;
3339
+ };
3336
3340
  var _React$useState = React__default.useState(noTAC),
3337
3341
  _React$useState2 = _slicedToArray(_React$useState, 2),
3338
3342
  TAC = _React$useState2[0],
@@ -3369,25 +3373,35 @@ var useTAC = function useTAC(initialProduct, getTAC) {
3369
3373
  }));
3370
3374
  };
3371
3375
  React__default.useEffect(function () {
3372
- if (shouldRetrieveTAC(initialProduct)) {
3376
+ if (shouldRetrieveTAC(initialProduct) && !hasErrors()) {
3373
3377
  retrieveTAC(initialProduct);
3374
3378
  }
3375
3379
  // eslint-disable-next-line react-hooks/exhaustive-deps
3376
3380
  }, []);
3377
- var update = function update(formValues) {
3378
- if (shouldRetrieveTAC(formValues)) {
3381
+ var update = function update(formValues, hasFormErrors) {
3382
+ if (shouldRetrieveTAC(formValues) && !hasFormErrors) {
3379
3383
  retrieveTAC(formValues);
3380
3384
  } else if (isMounted.current) {
3381
3385
  setTAC(noTAC);
3382
3386
  }
3383
3387
  };
3384
- var delayedQuery = React__default.useMemo(function () {
3385
- return debounce(function (formFn) {
3386
- return update(formFn());
3387
- }, 1000);
3388
- },
3389
- // eslint-disable-next-line react-hooks/exhaustive-deps
3390
- []);
3388
+ var debouncedSearch = React__default.useRef(debounce(function (formFn, hasFormErrors) {
3389
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3390
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3391
+ while (1) switch (_context2.prev = _context2.next) {
3392
+ case 0:
3393
+ update(formFn(), hasFormErrors());
3394
+ case 1:
3395
+ case "end":
3396
+ return _context2.stop();
3397
+ }
3398
+ }, _callee2);
3399
+ }));
3400
+ }, 1000)).current;
3401
+ var delayedQuery = function delayedQuery(formFn) {
3402
+ debouncedSearch.cancel();
3403
+ debouncedSearch(formFn, hasErrors);
3404
+ };
3391
3405
  return [TAC, delayedQuery];
3392
3406
  };
3393
3407
  var ProductFormTAC = function ProductFormTAC(_ref) {
@@ -8130,14 +8144,18 @@ var SigmetForm = function SigmetForm(_ref) {
8130
8144
  var _useFormContext2 = useFormContext(),
8131
8145
  watch = _useFormContext2.watch,
8132
8146
  setValue = _useFormContext2.setValue,
8133
- handleSubmit = _useFormContext2.handleSubmit;
8147
+ handleSubmit = _useFormContext2.handleSubmit,
8148
+ errors = _useFormContext2.formState.errors;
8149
+ var getHasFormErrors = function getHasFormErrors() {
8150
+ return Object.keys(errors).length > 0;
8151
+ };
8134
8152
  var _React$useState = React__default.useState(mode === 'view'),
8135
8153
  _React$useState2 = _slicedToArray(_React$useState, 2),
8136
8154
  isDisabled = _React$useState2[0],
8137
8155
  setIsDisabled = _React$useState2[1];
8138
8156
  var isReadOnly = mode === 'view';
8139
8157
  var helperText = isDisabled ? '' : 'Optional';
8140
- var _useTAC = useTAC(initialSigmet !== null ? initialSigmet : initialCancelSigmet, api.getSigmetTAC),
8158
+ var _useTAC = useTAC(initialSigmet !== null ? initialSigmet : initialCancelSigmet, api.getSigmetTAC, getHasFormErrors),
8141
8159
  _useTAC2 = _slicedToArray(_useTAC, 2),
8142
8160
  tac = _useTAC2[0],
8143
8161
  updateTac = _useTAC2[1];
@@ -8378,14 +8396,18 @@ var AirmetForm = function AirmetForm(_ref) {
8378
8396
  setValue = _useFormContext2.setValue,
8379
8397
  handleSubmit = _useFormContext2.handleSubmit,
8380
8398
  getValues = _useFormContext2.getValues,
8381
- trigger = _useFormContext2.trigger;
8399
+ trigger = _useFormContext2.trigger,
8400
+ errors = _useFormContext2.formState.errors;
8401
+ var getHasFormErrors = function getHasFormErrors() {
8402
+ return Object.keys(errors).length > 0;
8403
+ };
8382
8404
  var _React$useState = React__default.useState(mode === 'view'),
8383
8405
  _React$useState2 = _slicedToArray(_React$useState, 2),
8384
8406
  isDisabled = _React$useState2[0],
8385
8407
  setIsDisabled = _React$useState2[1];
8386
8408
  var isReadOnly = mode === 'view';
8387
8409
  var helperText = isDisabled ? '' : 'Optional';
8388
- var _useTAC = useTAC(initialAirmet !== null ? initialAirmet : initialCancelAirmet, api.getAirmetTAC),
8410
+ var _useTAC = useTAC(initialAirmet !== null ? initialAirmet : initialCancelAirmet, api.getAirmetTAC, getHasFormErrors),
8389
8411
  _useTAC2 = _slicedToArray(_useTAC, 2),
8390
8412
  tac = _useTAC2[0],
8391
8413
  updateTac = _useTAC2[1];
@@ -13748,7 +13770,7 @@ var CancelSigmetVolcanicMovements = function CancelSigmetVolcanicMovements(_ref)
13748
13770
  key: "UNKNOWN",
13749
13771
  value: "UNKNOWN",
13750
13772
  control: /*#__PURE__*/React__default.createElement(Radio, null),
13751
- label: "Don't know"
13773
+ label: "Cancel VA SIGMET without VA MOV TO information"
13752
13774
  })));
13753
13775
  };
13754
13776
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/sigmet-airmet",
3
- "version": "6.0.4",
3
+ "version": "6.1.0",
4
4
  "description": "GeoWeb Sigmet/Airmet library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -13,14 +13,15 @@
13
13
  "dependencies": {
14
14
  "@mui/material": "5.12.0",
15
15
  "@mui/system": "5.14.5",
16
- "@opengeoweb/api": "6.0.4",
17
- "@opengeoweb/authentication": "6.0.4",
18
- "@opengeoweb/core": "6.0.4",
19
- "@opengeoweb/form-fields": "6.0.4",
20
- "@opengeoweb/shared": "6.0.4",
21
- "@opengeoweb/store": "6.0.4",
22
- "@opengeoweb/theme": "6.0.4",
23
- "@opengeoweb/webmap": "6.0.4",
16
+ "@opengeoweb/api": "6.1.0",
17
+ "@opengeoweb/authentication": "6.1.0",
18
+ "@opengeoweb/core": "6.1.0",
19
+ "@opengeoweb/form-fields": "6.1.0",
20
+ "@opengeoweb/shared": "6.1.0",
21
+ "@opengeoweb/store": "6.1.0",
22
+ "@opengeoweb/theme": "6.1.0",
23
+ "@opengeoweb/webmap": "6.1.0",
24
+ "@opengeoweb/webmap-react": "6.0.4",
24
25
  "@redux-eggs/redux-toolkit": "2.2.0",
25
26
  "@redux-eggs/saga-extension": "2.2.0",
26
27
  "@reduxjs/toolkit": "1.9.5",
@@ -5,7 +5,7 @@ export declare const noTAC = "Missing data: no TAC can be generated";
5
5
  export declare const shouldRetrieveTAC: (product: AviationProduct) => boolean;
6
6
  export declare const useTAC: (initialProduct: AviationProduct, getTAC: (product: AviationProduct) => Promise<{
7
7
  data: string;
8
- }>) => [string, any];
8
+ }>, hasErrors?: () => boolean) => [string, any];
9
9
  interface ProductFormTACProps {
10
10
  tac: string;
11
11
  }