@opengeoweb/sigmet-airmet 4.9.1 → 4.11.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.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './lib/components/MapViewGeoJson';
4
4
  export * from './lib/components/ProductList';
5
5
  export * from './lib/components/MetInfoWrapper';
6
6
  export { createApi } from './lib/utils/api';
7
+ export * from './lib/types';
package/index.esm.js CHANGED
@@ -586,9 +586,16 @@ var Direction;
586
586
  Direction["NW"] = "NW";
587
587
  Direction["NNW"] = "NNW";
588
588
  })(Direction || (Direction = {}));
589
+
590
+ var isInstanceOfSigmet = function isInstanceOfSigmet(obj) {
591
+ return 'phenomenon' in obj;
592
+ };
589
593
  var isInstanceOfCancelSigmet = function isInstanceOfCancelSigmet(obj) {
590
594
  return 'cancelsSigmetSequenceId' in obj;
591
595
  };
596
+ var isInstanceOfAirmet = function isInstanceOfAirmet(obj) {
597
+ return 'phenomenon' in obj;
598
+ };
592
599
  var isInstanceOfCancelAirmet = function isInstanceOfCancelAirmet(obj) {
593
600
  return 'cancelsAirmetSequenceId' in obj;
594
601
  };
@@ -1758,12 +1765,13 @@ var Levels = function Levels(_ref) {
1758
1765
  setValue = _useFormContext.setValue,
1759
1766
  trigger = _useFormContext.trigger,
1760
1767
  getValues = _useFormContext.getValues,
1761
- reset = _useFormContext.reset,
1762
- clearErrors = _useFormContext.clearErrors;
1768
+ clearErrors = _useFormContext.clearErrors,
1769
+ unregister = _useFormContext.unregister;
1763
1770
 
1764
1771
  var _useDraftFormHelpers = useDraftFormHelpers(),
1765
1772
  isRequired = _useDraftFormHelpers.isRequired;
1766
1773
 
1774
+ var levelInfoMode = watch('levelInfoMode');
1767
1775
  var config = productType === 'sigmet' ? sigmetConfig : airmetConfig;
1768
1776
 
1769
1777
  var _useProductSettings = useProductSettings(config),
@@ -1772,6 +1780,11 @@ var Levels = function Levels(_ref) {
1772
1780
  var selectedFIR = watch('locationIndicatorATSR'); // Get allowed level units based on selected FIR - if no FIR selected, allow all default units
1773
1781
 
1774
1782
  var allowedLevelUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'level_unit', LevelUnits);
1783
+ React__default.useEffect(function () {
1784
+ if (levelInfoMode !== 'BETW') {
1785
+ unregister('lowerLevel');
1786
+ }
1787
+ }, [levelInfoMode, unregister]);
1775
1788
  return /*#__PURE__*/React__default.createElement(ProductFormFieldLayout, {
1776
1789
  title: "Levels",
1777
1790
  sx: styles$2.containerItem
@@ -1789,29 +1802,18 @@ var Levels = function Levels(_ref) {
1789
1802
  isReadOnly: isReadOnly,
1790
1803
  onChange: function onChange() {
1791
1804
  // Reset default value for the level value to '' so when it rerenders it uses this empty default value
1792
- var currentValues = getValues();
1793
- reset(Object.assign(Object.assign({}, currentValues), {
1794
- level: {
1795
- unit: 'FL',
1796
- value: null
1797
- }
1798
- }), {
1799
- keepErrors: true,
1800
- keepDirty: true,
1801
- keepIsSubmitted: false,
1802
- keepTouched: false,
1803
- keepIsValid: false
1804
- }); // Clear out errors for the levels
1805
+ setValue('level.unit', 'FL');
1806
+ setValue('level.value', null); // Clear out errors for the levels
1805
1807
 
1806
1808
  clearErrors(['level', 'lowerLevel']);
1807
1809
  }
1808
1810
  }, /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
1809
1811
  value: "AT",
1810
1812
  label: "At",
1811
- checked: watch('levelInfoMode') === 'AT' || watch('levelInfoMode') === 'TOPS',
1813
+ checked: levelInfoMode === 'AT' || levelInfoMode === 'TOPS',
1812
1814
  "data-testid": "levels-AT",
1813
1815
  disabled: isDisabled
1814
- }), watch('levelInfoMode') === 'AT' || watch('levelInfoMode') === 'TOPS' ? /*#__PURE__*/React__default.createElement(Grid, {
1816
+ }), levelInfoMode === 'AT' || levelInfoMode === 'TOPS' ? /*#__PURE__*/React__default.createElement(Grid, {
1815
1817
  item: true,
1816
1818
  xs: 12,
1817
1819
  container: true,
@@ -1824,7 +1826,7 @@ var Levels = function Levels(_ref) {
1824
1826
  md: 3
1825
1827
  }, /*#__PURE__*/React__default.createElement(FormControlLabel, {
1826
1828
  control: /*#__PURE__*/React__default.createElement(Checkbox, {
1827
- checked: watch('levelInfoMode') === 'TOPS',
1829
+ checked: levelInfoMode === 'TOPS',
1828
1830
  onChange: function onChange() {
1829
1831
  setValue('levelInfoMode', getValues('levelInfoMode') === 'AT' ? 'TOPS' : 'AT', {
1830
1832
  shouldDirty: true
@@ -1898,10 +1900,10 @@ var Levels = function Levels(_ref) {
1898
1900
  }))) : null, /*#__PURE__*/React__default.createElement(RadioButtonAndLabel, {
1899
1901
  value: "BETW",
1900
1902
  label: "Between",
1901
- checked: watch('levelInfoMode') === 'BETW' || watch('levelInfoMode') === 'BETW_SFC',
1903
+ checked: levelInfoMode === 'BETW' || levelInfoMode === 'BETW_SFC',
1902
1904
  "data-testid": "levels-BETW",
1903
1905
  disabled: isDisabled
1904
- }), watch('levelInfoMode') === 'BETW' || watch('levelInfoMode') === 'BETW_SFC' ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
1906
+ }), levelInfoMode === 'BETW' || levelInfoMode === 'BETW_SFC' ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
1905
1907
  item: true,
1906
1908
  xs: 12,
1907
1909
  container: true,
@@ -1922,7 +1924,7 @@ var Levels = function Levels(_ref) {
1922
1924
  isRequired: isRequired,
1923
1925
  validateLevelUnitCombinations: function validateLevelUnitCombinations(value) {
1924
1926
  return (// level step depends on the unit
1925
- _validateLevelUnitCombinations(value, watch('levelInfoMode') === 'BETW_SFC' ? 'SFC' : getValues('lowerLevel.unit')) === true
1927
+ _validateLevelUnitCombinations(value, levelInfoMode === 'BETW_SFC' ? 'SFC' : getValues('lowerLevel.unit')) === true
1926
1928
  );
1927
1929
  }
1928
1930
  }
@@ -1989,7 +1991,7 @@ var Levels = function Levels(_ref) {
1989
1991
  md: 3
1990
1992
  }, /*#__PURE__*/React__default.createElement(FormControlLabel, {
1991
1993
  control: /*#__PURE__*/React__default.createElement(Checkbox, {
1992
- checked: watch('levelInfoMode') === 'BETW_SFC',
1994
+ checked: levelInfoMode === 'BETW_SFC',
1993
1995
  onChange: function onChange() {
1994
1996
  getValues('level.unit') && trigger('level.unit');
1995
1997
  setValue('levelInfoMode', getValues('levelInfoMode') === 'BETW' ? 'BETW_SFC' : 'BETW', {
@@ -2002,7 +2004,7 @@ var Levels = function Levels(_ref) {
2002
2004
  }),
2003
2005
  "data-testid": "levels-SFC",
2004
2006
  label: "SFC"
2005
- })), watch('levelInfoMode') !== 'BETW_SFC' && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
2007
+ })), levelInfoMode !== 'BETW_SFC' && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
2006
2008
  item: true,
2007
2009
  xs: 4,
2008
2010
  md: 3
@@ -2076,9 +2078,9 @@ var Levels = function Levels(_ref) {
2076
2078
  value: "ABV",
2077
2079
  label: "Above",
2078
2080
  disabled: isDisabled,
2079
- checked: watch('levelInfoMode') === 'ABV' || watch('levelInfoMode') === 'TOPS_ABV',
2081
+ checked: levelInfoMode === 'ABV' || levelInfoMode === 'TOPS_ABV',
2080
2082
  "data-testid": "levels-ABV"
2081
- }), watch('levelInfoMode') === 'ABV' || watch('levelInfoMode') === 'TOPS_ABV' ? /*#__PURE__*/React__default.createElement(Grid, {
2083
+ }), levelInfoMode === 'ABV' || levelInfoMode === 'TOPS_ABV' ? /*#__PURE__*/React__default.createElement(Grid, {
2082
2084
  item: true,
2083
2085
  xs: 12,
2084
2086
  container: true,
@@ -2091,7 +2093,7 @@ var Levels = function Levels(_ref) {
2091
2093
  md: 3
2092
2094
  }, /*#__PURE__*/React__default.createElement(FormControlLabel, {
2093
2095
  control: /*#__PURE__*/React__default.createElement(Checkbox, {
2094
- checked: watch('levelInfoMode') === 'TOPS_ABV',
2096
+ checked: levelInfoMode === 'TOPS_ABV',
2095
2097
  onChange: function onChange() {
2096
2098
  setValue('levelInfoMode', getValues('levelInfoMode') === 'ABV' ? 'TOPS_ABV' : 'ABV', {
2097
2099
  shouldDirty: true
@@ -2312,19 +2314,6 @@ var Phenomenon = function Phenomenon(_ref) {
2312
2314
  setValue('movementType', null);
2313
2315
  }
2314
2316
 
2315
- if (!isSigmet) {
2316
- if (getValues('phenomenon') !== 'SFC_VIS') {
2317
- setValue('visibilityValue', null);
2318
- setValue('visibilityCause', null);
2319
- }
2320
-
2321
- if (getValues('phenomenon') !== 'SFC_WIND') {
2322
- setValue('windDirection', null);
2323
- setValue('windUnit', null);
2324
- setValue('windSpeed', null);
2325
- }
2326
- }
2327
-
2328
2317
  _onChange();
2329
2318
 
2330
2319
  return trigger([].concat(_toConsumableArray(getValues('validDateStart') ? ['validDateStart'] : []), _toConsumableArray(getValues('validDateEnd') ? ['validDateEnd'] : [])));
@@ -2496,7 +2485,8 @@ var Progress = function Progress(_ref) {
2496
2485
  watch = _useFormContext.watch,
2497
2486
  getValues = _useFormContext.getValues,
2498
2487
  trigger = _useFormContext.trigger,
2499
- errors = _useFormContext.formState.errors;
2488
+ errors = _useFormContext.formState.errors,
2489
+ unregister = _useFormContext.unregister;
2500
2490
 
2501
2491
  var _useDraftFormHelpers = useDraftFormHelpers(),
2502
2492
  isRequired = _useDraftFormHelpers.isRequired,
@@ -2511,6 +2501,18 @@ var Progress = function Progress(_ref) {
2511
2501
  var selectedFIR = watch('locationIndicatorATSR'); // Get allowed movement units based on selected FIR - if no FIR selected, allow all units
2512
2502
 
2513
2503
  var allowedMovementUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'movement_unit', MovementUnit);
2504
+ React__default.useEffect(function () {
2505
+ if (movementType !== 'MOVEMENT') {
2506
+ unregister('movementDirection');
2507
+ unregister('movementSpeed');
2508
+ unregister('movementUnit');
2509
+ }
2510
+
2511
+ if (movementType !== 'FORECAST_POSITION') {
2512
+ unregister('endGeometry');
2513
+ unregister('endGeometryIntersect');
2514
+ }
2515
+ }, [movementType, unregister]);
2514
2516
  return /*#__PURE__*/React__default.createElement(ProductFormFieldLayout, {
2515
2517
  title: "Progress",
2516
2518
  sx: styles$2.containerItem
@@ -3376,7 +3378,8 @@ var CloudLevels = function CloudLevels(_ref) {
3376
3378
  watch = _useFormContext.watch,
3377
3379
  setValue = _useFormContext.setValue,
3378
3380
  trigger = _useFormContext.trigger,
3379
- getValues = _useFormContext.getValues;
3381
+ getValues = _useFormContext.getValues,
3382
+ unregister = _useFormContext.unregister;
3380
3383
 
3381
3384
  var _useDraftFormHelpers = useDraftFormHelpers(),
3382
3385
  isRequired = _useDraftFormHelpers.isRequired;
@@ -3384,9 +3387,15 @@ var CloudLevels = function CloudLevels(_ref) {
3384
3387
  var _useProductSettings = useProductSettings(airmetConfig),
3385
3388
  allowedUnits = _useProductSettings.allowedUnits;
3386
3389
 
3387
- var selectedFIR = watch('locationIndicatorATSR'); // Get allowed cloud level units based on selected FIR - if no FIR selected, allow all default units
3390
+ var selectedFIR = watch('locationIndicatorATSR');
3391
+ var cloudLevelInfoMode = watch('cloudLevelInfoMode'); // Get allowed cloud level units based on selected FIR - if no FIR selected, allow all default units
3388
3392
 
3389
3393
  var allowedCloudLevelUnitsForFir = getAllowedUnits(selectedFIR, allowedUnits, 'cloud_level_unit', CloudLevelUnits);
3394
+ React__default.useEffect(function () {
3395
+ if (cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV') {
3396
+ unregister('cloudLowerLevel');
3397
+ }
3398
+ }, [cloudLevelInfoMode, unregister]);
3390
3399
  return /*#__PURE__*/React__default.createElement(Grid, {
3391
3400
  item: true,
3392
3401
  container: true,
@@ -3418,12 +3427,12 @@ var CloudLevels = function CloudLevels(_ref) {
3418
3427
  }, /*#__PURE__*/React__default.createElement(Grid, {
3419
3428
  item: true,
3420
3429
  xs: 4
3421
- }, (!isReadOnly || watch('cloudLevelInfoMode') === 'BETW_ABV' || watch('cloudLevelInfoMode') === 'BETW_SFC_ABV') && /*#__PURE__*/React__default.createElement(ReactHookFormFormControl, {
3430
+ }, (!isReadOnly || cloudLevelInfoMode === 'BETW_ABV' || cloudLevelInfoMode === 'BETW_SFC_ABV') && /*#__PURE__*/React__default.createElement(ReactHookFormFormControl, {
3422
3431
  disabled: isDisabled,
3423
3432
  isReadOnly: isReadOnly
3424
3433
  }, /*#__PURE__*/React__default.createElement(FormControlLabel, {
3425
3434
  control: /*#__PURE__*/React__default.createElement(Checkbox, {
3426
- checked: watch('cloudLevelInfoMode') === 'BETW_ABV' || watch('cloudLevelInfoMode') === 'BETW_SFC_ABV',
3435
+ checked: cloudLevelInfoMode === 'BETW_ABV' || cloudLevelInfoMode === 'BETW_SFC_ABV',
3427
3436
  onChange: function onChange() {
3428
3437
  switch (getValues('cloudLevelInfoMode')) {
3429
3438
  case 'BETW':
@@ -3531,12 +3540,12 @@ var CloudLevels = function CloudLevels(_ref) {
3531
3540
  }, /*#__PURE__*/React__default.createElement(Grid, {
3532
3541
  item: true,
3533
3542
  xs: 4
3534
- }, (!isReadOnly || watch('cloudLevelInfoMode') === 'BETW_SFC' || watch('cloudLevelInfoMode') === 'BETW_SFC_ABV') && /*#__PURE__*/React__default.createElement(ReactHookFormFormControl, {
3543
+ }, (!isReadOnly || cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV') && /*#__PURE__*/React__default.createElement(ReactHookFormFormControl, {
3535
3544
  disabled: isDisabled,
3536
3545
  isReadOnly: isReadOnly
3537
3546
  }, /*#__PURE__*/React__default.createElement(FormControlLabel, {
3538
3547
  control: /*#__PURE__*/React__default.createElement(Checkbox, {
3539
- checked: watch('cloudLevelInfoMode') === 'BETW_SFC' || watch('cloudLevelInfoMode') === 'BETW_SFC_ABV',
3548
+ checked: cloudLevelInfoMode === 'BETW_SFC' || cloudLevelInfoMode === 'BETW_SFC_ABV',
3540
3549
  onChange: function onChange() {
3541
3550
  switch (getValues('cloudLevelInfoMode')) {
3542
3551
  case 'BETW':
@@ -3570,7 +3579,7 @@ var CloudLevels = function CloudLevels(_ref) {
3570
3579
  }),
3571
3580
  "data-testid": "cloudLevels-SFC",
3572
3581
  label: "SFC"
3573
- }))), watch('cloudLevelInfoMode') !== 'BETW_SFC' && watch('cloudLevelInfoMode') !== 'BETW_SFC_ABV' && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
3582
+ }))), cloudLevelInfoMode !== 'BETW_SFC' && cloudLevelInfoMode !== 'BETW_SFC_ABV' && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
3574
3583
  item: true,
3575
3584
  xs: 3
3576
3585
  }, /*#__PURE__*/React__default.createElement(ReactHookFormSelect, {
@@ -4111,6 +4120,23 @@ var ProductFormLayout = function ProductFormLayout(_a) {
4111
4120
  }, children));
4112
4121
  };
4113
4122
 
4123
+ var useConditionalFields$1 = function useConditionalFields() {
4124
+ var _useFormContext = useFormContext(),
4125
+ watch = _useFormContext.watch,
4126
+ unregister = _useFormContext.unregister; // phenomenon: VA_CLD
4127
+
4128
+
4129
+ var hasVolcanicAshes = watch('phenomenon') === 'VA_CLD';
4130
+ React__default.useEffect(function () {
4131
+ if (!hasVolcanicAshes) {
4132
+ unregister(['vaSigmetVolcanoName', 'vaSigmetVolcanoCoordinates.latitude', 'vaSigmetVolcanoCoordinates.longitude']);
4133
+ }
4134
+ }, [hasVolcanicAshes, unregister]);
4135
+ return {
4136
+ hasVolcanicAshes: hasVolcanicAshes
4137
+ };
4138
+ };
4139
+
4114
4140
  var SigmetForm = function SigmetForm(_ref) {
4115
4141
  var mode = _ref.mode,
4116
4142
  _ref$isCancelSigmet = _ref.isCancelSigmet,
@@ -4125,10 +4151,10 @@ var SigmetForm = function SigmetForm(_ref) {
4125
4151
  var _useApiContext = useApiContext(),
4126
4152
  api = _useApiContext.api;
4127
4153
 
4128
- var _useFormContext = useFormContext(),
4129
- watch = _useFormContext.watch,
4130
- setValue = _useFormContext.setValue,
4131
- handleSubmit = _useFormContext.handleSubmit;
4154
+ var _useFormContext2 = useFormContext(),
4155
+ watch = _useFormContext2.watch,
4156
+ setValue = _useFormContext2.setValue,
4157
+ handleSubmit = _useFormContext2.handleSubmit;
4132
4158
 
4133
4159
  var _React$useState = React__default.useState(mode === 'view'),
4134
4160
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -4209,6 +4235,9 @@ var SigmetForm = function SigmetForm(_ref) {
4209
4235
  }
4210
4236
  }, [drawMode.start, drawMode.end, isReadOnly, isDisabled]);
4211
4237
 
4238
+ var _useConditionalFields = useConditionalFields$1(),
4239
+ hasVolcanicAshes = _useConditionalFields.hasVolcanicAshes;
4240
+
4212
4241
  var renderForm = function renderForm() {
4213
4242
  return /*#__PURE__*/React__default.createElement(Grid, {
4214
4243
  container: true,
@@ -4227,7 +4256,7 @@ var SigmetForm = function SigmetForm(_ref) {
4227
4256
  isReadOnly: isReadOnly,
4228
4257
  helperText: helperText,
4229
4258
  onChange: onChangeForm
4230
- }), !isCancelSigmet && watch('phenomenon') === 'VA_CLD' && /*#__PURE__*/React__default.createElement(VolcanicFields, {
4259
+ }), !isCancelSigmet && hasVolcanicAshes && /*#__PURE__*/React__default.createElement(VolcanicFields, {
4231
4260
  isDisabled: isDisabled,
4232
4261
  isReadOnly: isReadOnly,
4233
4262
  helperText: helperText
@@ -4324,6 +4353,48 @@ var SigmetForm = function SigmetForm(_ref) {
4324
4353
  }, renderForm()));
4325
4354
  };
4326
4355
 
4356
+ var useConditionalFields = function useConditionalFields() {
4357
+ var _useFormContext = useFormContext(),
4358
+ watch = _useFormContext.watch,
4359
+ unregister = _useFormContext.unregister; // phenomenon: SFC_VIS
4360
+
4361
+
4362
+ var phenomenon = watch('phenomenon');
4363
+ var hasSurfaceVisiblity = phenomenon === 'SFC_VIS';
4364
+ React__default.useEffect(function () {
4365
+ if (!hasSurfaceVisiblity) {
4366
+ unregister(['visibilityValue', 'visibilityCause']);
4367
+ }
4368
+ }, [hasSurfaceVisiblity, unregister]); // phenomenon: SFC_WIND
4369
+
4370
+ var hasSurfaceWind = watch('phenomenon') === 'SFC_WIND';
4371
+ React__default.useEffect(function () {
4372
+ if (!hasSurfaceWind) {
4373
+ unregister(['windDirection', 'windUnit', 'windSpeed']);
4374
+ }
4375
+ }, [hasSurfaceWind, unregister]); // phenomenon: SFC_WIND, SFC_VIS, BKN_CLD, OVC_CLD
4376
+
4377
+ var hasLevels = phenomenon !== 'SFC_WIND' && phenomenon !== 'SFC_VIS' && phenomenon !== 'BKN_CLD' && phenomenon !== 'OVC_CLD';
4378
+ React__default.useEffect(function () {
4379
+ if (!hasLevels) {
4380
+ unregister(['levelInfoMode', 'level', 'lowerLevel']);
4381
+ }
4382
+ }, [hasLevels, unregister]); // phenomenon: BKN_CLD
4383
+
4384
+ var hasCloudLevels = phenomenon === 'BKN_CLD' || phenomenon === 'OVC_CLD';
4385
+ React__default.useEffect(function () {
4386
+ if (!hasCloudLevels) {
4387
+ unregister(['cloudLevelInfoMode', 'cloudLevel', 'cloudLowerLevel']);
4388
+ }
4389
+ }, [hasCloudLevels, unregister]);
4390
+ return {
4391
+ hasSurfaceVisiblity: hasSurfaceVisiblity,
4392
+ hasSurfaceWind: hasSurfaceWind,
4393
+ hasLevels: hasLevels,
4394
+ hasCloudLevels: hasCloudLevels
4395
+ };
4396
+ };
4397
+
4327
4398
  var AirmetForm = function AirmetForm(_ref) {
4328
4399
  var mode = _ref.mode,
4329
4400
  _ref$isCancelAirmet = _ref.isCancelAirmet,
@@ -4338,12 +4409,10 @@ var AirmetForm = function AirmetForm(_ref) {
4338
4409
  var _useApiContext = useApiContext(),
4339
4410
  api = _useApiContext.api;
4340
4411
 
4341
- var _useFormContext = useFormContext(),
4342
- watch = _useFormContext.watch,
4343
- setValue = _useFormContext.setValue,
4344
- handleSubmit = _useFormContext.handleSubmit;
4345
-
4346
- var phenomenon = watch('phenomenon');
4412
+ var _useFormContext2 = useFormContext(),
4413
+ watch = _useFormContext2.watch,
4414
+ setValue = _useFormContext2.setValue,
4415
+ handleSubmit = _useFormContext2.handleSubmit;
4347
4416
 
4348
4417
  var _React$useState = React__default.useState(mode === 'view'),
4349
4418
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -4402,6 +4471,12 @@ var AirmetForm = function AirmetForm(_ref) {
4402
4471
  }
4403
4472
  }, [drawMode.start, isReadOnly, isDisabled]);
4404
4473
 
4474
+ var _useConditionalFields = useConditionalFields(),
4475
+ hasSurfaceVisiblity = _useConditionalFields.hasSurfaceVisiblity,
4476
+ hasSurfaceWind = _useConditionalFields.hasSurfaceWind,
4477
+ hasLevels = _useConditionalFields.hasLevels,
4478
+ hasCloudLevels = _useConditionalFields.hasCloudLevels;
4479
+
4405
4480
  var renderForm = function renderForm() {
4406
4481
  return /*#__PURE__*/React__default.createElement(Grid, {
4407
4482
  container: true,
@@ -4412,11 +4487,11 @@ var AirmetForm = function AirmetForm(_ref) {
4412
4487
  isDisabled: isDisabled,
4413
4488
  isReadOnly: isReadOnly,
4414
4489
  onChange: onChangeForm
4415
- }), !isCancelAirmet && phenomenon === 'SFC_VIS' && /*#__PURE__*/React__default.createElement(SurfaceVisibility, {
4490
+ }), !isCancelAirmet && hasSurfaceVisiblity && /*#__PURE__*/React__default.createElement(SurfaceVisibility, {
4416
4491
  isReadOnly: isReadOnly,
4417
4492
  isDisabled: isDisabled,
4418
4493
  onChange: onChangeForm
4419
- }), !isCancelAirmet && phenomenon === 'SFC_WIND' && /*#__PURE__*/React__default.createElement(SurfaceWind, {
4494
+ }), !isCancelAirmet && hasSurfaceWind && /*#__PURE__*/React__default.createElement(SurfaceWind, {
4420
4495
  isReadOnly: isReadOnly,
4421
4496
  isDisabled: isDisabled,
4422
4497
  onChange: onChangeForm
@@ -4449,12 +4524,12 @@ var AirmetForm = function AirmetForm(_ref) {
4449
4524
  setDrawModeType: function setDrawModeType(mapDrawMode, StartOrEndDrawing) {
4450
4525
  _setDrawModeType(mapDrawMode, StartOrEndDrawing, updateStartDrawing);
4451
4526
  }
4452
- }), !isCancelAirmet && phenomenon !== 'SFC_WIND' && phenomenon !== 'SFC_VIS' && phenomenon !== 'BKN_CLD' && phenomenon !== 'OVC_CLD' && /*#__PURE__*/React__default.createElement(Levels, {
4527
+ }), !isCancelAirmet && hasLevels && /*#__PURE__*/React__default.createElement(Levels, {
4453
4528
  isDisabled: isDisabled,
4454
4529
  isReadOnly: isReadOnly,
4455
4530
  onChange: onChangeForm,
4456
4531
  productType: "airmet"
4457
- }), !isCancelAirmet && (phenomenon === 'BKN_CLD' || phenomenon === 'OVC_CLD') && /*#__PURE__*/React__default.createElement(CloudLevels, {
4532
+ }), !isCancelAirmet && hasCloudLevels && /*#__PURE__*/React__default.createElement(CloudLevels, {
4458
4533
  isDisabled: isDisabled,
4459
4534
  isReadOnly: isReadOnly,
4460
4535
  onChange: onChangeForm
@@ -5119,8 +5194,9 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
5119
5194
  };
5120
5195
 
5121
5196
  var onToggleDialog = function onToggleDialog() {
5197
+ var shouldRefreshList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
5122
5198
  setLoader(false);
5123
- toggleDialogStatus();
5199
+ toggleDialogStatus(shouldRefreshList);
5124
5200
  };
5125
5201
 
5126
5202
  var showConfirmDialog = function showConfirmDialog(action) {
@@ -5140,7 +5216,7 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
5140
5216
  switch (action) {
5141
5217
  case 'CLOSED':
5142
5218
  if (mode === 'view' || !isDirty) {
5143
- onToggleDialog();
5219
+ onToggleDialog(false);
5144
5220
  } else {
5145
5221
  toggleIsDraft(true);
5146
5222
  showConfirmDialog(action).then(function () {
@@ -5150,7 +5226,7 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
5150
5226
  })["catch"](function (reason) {
5151
5227
  if (reason === 'CANCELLED') {
5152
5228
  // close without save
5153
- onToggleDialog();
5229
+ onToggleDialog(false);
5154
5230
  }
5155
5231
  });
5156
5232
  }
@@ -5172,7 +5248,7 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
5172
5248
  showConfirmDialog(action).then(function () {
5173
5249
  // If we're discarding a new SIGMET/AIRMET - just close the dialog
5174
5250
  if (mode === 'new') {
5175
- onToggleDialog();
5251
+ onToggleDialog(false);
5176
5252
  } else {
5177
5253
  // If we're discarding an existing SIGMET/AIRMET - make call to BE
5178
5254
  postProduct(product, action);
@@ -5295,7 +5371,7 @@ var ProductFormDialog = function ProductFormDialog(_ref) {
5295
5371
  return /*#__PURE__*/React.createElement(ReactHookFormProvider, {
5296
5372
  options: Object.assign(Object.assign({}, defaultFormOptions), {
5297
5373
  defaultValues: product,
5298
- shouldUnregister: true
5374
+ values: product
5299
5375
  })
5300
5376
  }, /*#__PURE__*/React.createElement(ConfirmationServiceProvider, null, /*#__PURE__*/React.createElement(ProductFormDialogContent, {
5301
5377
  isOpen: isOpen,
@@ -5353,8 +5429,9 @@ var MetInfoWrapper = function MetInfoWrapper(_ref) {
5353
5429
  }, [selectedProduct]);
5354
5430
 
5355
5431
  var toggleDialogOpen = function toggleDialogOpen() {
5432
+ var shouldRefreshList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
5356
5433
  // Refresh list on closing dialog
5357
- if (isFormDialogOpen === true) getNewProductList();
5434
+ if (isFormDialogOpen === true && shouldRefreshList) getNewProductList();
5358
5435
  setIsFormDialogOpen(!isFormDialogOpen);
5359
5436
  };
5360
5437
 
@@ -5431,4 +5508,4 @@ var createApi = function createApi(props) {
5431
5508
  return getApiRoutes(axiosInstance);
5432
5509
  };
5433
5510
 
5434
- export { AirmetForm, ContentDialog, MapViewGeoJson, MetInfoWrapper, ProductList, ProductListRow, SigmetForm, createApi };
5511
+ export { AirmetForm, AirmetPhenomena, CloudLevelUnits, ContentDialog, Direction, LevelUnits, MapDrawMode, MapViewGeoJson, MetInfoWrapper, MovementUnit, ProductList, ProductListRow, ProductStatusDescription, SigmetForm, SigmetPhenomena, StartOrEndDrawing, VisibilityCause, WindUnit, createApi, isInstanceOfAirmet, isInstanceOfCancelAirmet, isInstanceOfCancelSigmet, isInstanceOfCancelSigmetOrAirmet, isInstanceOfSigmet, isInstanceOfSigmetOrAirmet };