@opengeoweb/taf 2.6.0 → 2.9.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,13 +4,13 @@ import { TextField, SvgIcon, Grid, Box, Button, IconButton, Tooltip, Chip, Typog
4
4
  import { useFormContext, Controller, useFieldArray } from 'react-hook-form';
5
5
  import { ReactSortable, Sortable } from 'react-sortablejs';
6
6
  import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
7
- import { useApiContext, useApi, createApiInstance, ApiProvider } from '@opengeoweb/api';
8
- import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, ToolButton, ToolHeader, getAxiosErrorMessage, AlertBanner, ConfirmationServiceProvider, usePoller, ErrorBoundary } from '@opengeoweb/shared';
9
- import moment from 'moment';
7
+ import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, ToolButton, ToolHeader, isAxiosError, getAxiosErrorMessage, AlertBanner, ConfirmationServiceProvider, usePoller, ErrorBoundary } from '@opengeoweb/shared';
10
8
  import { isEqual } from 'lodash';
9
+ import moment from 'moment';
11
10
  import makeStyles from '@mui/styles/makeStyles';
12
11
  import { DragIndicator, Schedule, CheckCircle } from '@mui/icons-material';
13
12
  import ReactDOM from 'react-dom';
13
+ import { useApiContext, useApi, createApiInstance, ApiProvider } from '@opengeoweb/api';
14
14
  import LinearProgress from '@mui/material/LinearProgress';
15
15
  import DoDisturbIcon from '@mui/icons-material/DoDisturb';
16
16
  import Box$1 from '@mui/material/Box';
@@ -2315,7 +2315,7 @@ var tacHasError = function tacHasError(tac) {
2315
2315
  return tac === TAC_MISSING_DATA || tac === TAC_NOT_AVAILABLE || tac === TAC_RETRIEVING_DATA || tac === TAC_FAILED;
2316
2316
  };
2317
2317
  var useTACGenerator = function useTACGenerator(taf, requestTAC) {
2318
- var _React$useState = React__default.useState(taf.status === 'NEW' ? TAC_NOT_AVAILABLE : TAC_RETRIEVING_DATA),
2318
+ var _React$useState = React__default.useState(!taf || taf.status === 'NEW' ? TAC_NOT_AVAILABLE : TAC_RETRIEVING_DATA),
2319
2319
  _React$useState2 = _slicedToArray(_React$useState, 2),
2320
2320
  TAC = _React$useState2[0],
2321
2321
  setTAC = _React$useState2[1];
@@ -2323,14 +2323,30 @@ var useTACGenerator = function useTACGenerator(taf, requestTAC) {
2323
2323
  var _useIsMounted = useIsMounted(),
2324
2324
  isMounted = _useIsMounted.isMounted;
2325
2325
 
2326
+ var controller = React__default.useRef(null);
2327
+
2328
+ var onSetTac = function onSetTac(newTAC) {
2329
+ if (controller.current) {
2330
+ controller.current.abort();
2331
+ }
2332
+
2333
+ setTAC(newTAC);
2334
+ };
2335
+
2326
2336
  var retrieveTAC = React__default.useCallback(function (tafToPost) {
2327
2337
  if (shouldRetrieveTAC(tafToPost)) {
2328
- requestTAC(tafToPost).then(function (result) {
2338
+ if (controller.current) {
2339
+ controller.current.abort();
2340
+ }
2341
+
2342
+ controller.current = new AbortController();
2343
+ setTAC(TAC_RETRIEVING_DATA);
2344
+ requestTAC(tafToPost, controller.current.signal).then(function (result) {
2329
2345
  if (isMounted.current) {
2330
2346
  setTAC(result.data);
2331
2347
  }
2332
- })["catch"](function () {
2333
- if (isMounted.current) {
2348
+ })["catch"](function (error) {
2349
+ if (isMounted && error.message !== 'canceled') {
2334
2350
  setTAC(TAC_FAILED);
2335
2351
  }
2336
2352
  });
@@ -2339,12 +2355,12 @@ var useTACGenerator = function useTACGenerator(taf, requestTAC) {
2339
2355
  }
2340
2356
  }, [isMounted, requestTAC]);
2341
2357
  React__default.useEffect(function () {
2342
- if (taf.status !== 'NEW') {
2358
+ if (taf && taf.status !== 'NEW') {
2343
2359
  retrieveTAC(taf);
2344
2360
  } // eslint-disable-next-line react-hooks/exhaustive-deps
2345
2361
 
2346
2362
  }, []);
2347
- return [TAC, retrieveTAC];
2363
+ return [TAC, retrieveTAC, onSetTac];
2348
2364
  };
2349
2365
  var useDragOrder = function useDragOrder(trigger, move, onFormBlur) {
2350
2366
  var _React$useState3 = React__default.useState(null),
@@ -2533,9 +2549,14 @@ var prepareTafValues = function prepareTafValues(_taf, tafAction) {
2533
2549
  // If action is AMEND/CORRECT/DRAFT_AMEND/DRAFT_CORRECTION - add previous valid start and end
2534
2550
  // If action is AMEND/DRAFT_AMEND - update validity start time to current time
2535
2551
  var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
2552
+ var formattedBaseForecast = formatFormValues(taf.baseForecast);
2553
+ var baseForecast = Object.assign(Object.assign(Object.assign({}, emptyBaseForecast), formattedBaseForecast), {
2554
+ weather: Object.assign(Object.assign({}, emptyBaseForecast.weather), formattedBaseForecast.weather),
2555
+ cloud: Object.assign(Object.assign({}, emptyBaseForecast.cloud), formattedBaseForecast.cloud)
2556
+ });
2536
2557
  return Object.assign(Object.assign(Object.assign(Object.assign({}, taf), {
2537
2558
  messageType: getMessageType(taf, tafAction),
2538
- baseForecast: Object.assign(Object.assign({}, emptyBaseForecast), formatFormValues(taf.baseForecast))
2559
+ baseForecast: baseForecast
2539
2560
  }), taf.changeGroups && {
2540
2561
  changeGroups: taf.changeGroups.map(formatFormValues)
2541
2562
  }), addEmptyChangeGroup && {
@@ -3883,6 +3904,9 @@ var useTafModuleContext = function useTafModuleContext() {
3883
3904
  var useTafModuleState = function useTafModuleState(_ref) {
3884
3905
  var onPreventCloseView = _ref.onPreventCloseView;
3885
3906
 
3907
+ var _useApiContext = useApiContext(),
3908
+ api = _useApiContext.api;
3909
+
3886
3910
  var _React$useState = React.useState(function () {
3887
3911
  return new Promise(function () {
3888
3912
  return true;
@@ -3902,6 +3926,12 @@ var useTafModuleState = function useTafModuleState(_ref) {
3902
3926
  isFormDirty = _React$useState6[0],
3903
3927
  setIsFormDirty = _React$useState6[1];
3904
3928
 
3929
+ var _useTACGenerator = useTACGenerator(undefined, api.getTAC),
3930
+ _useTACGenerator2 = _slicedToArray(_useTACGenerator, 3),
3931
+ TAC = _useTACGenerator2[0],
3932
+ updateTAC = _useTACGenerator2[1],
3933
+ setTAC = _useTACGenerator2[2];
3934
+
3905
3935
  var onRegisterValidateForm = function onRegisterValidateForm(promiseToRegister) {
3906
3936
  registerValidateForm(function () {
3907
3937
  return promiseToRegister;
@@ -3920,6 +3950,9 @@ var useTafModuleState = function useTafModuleState(_ref) {
3920
3950
  registerValidateForm: onRegisterValidateForm,
3921
3951
  tafAction: tafAction,
3922
3952
  setTafAction: setTafAction,
3953
+ TAC: TAC,
3954
+ updateTAC: updateTAC,
3955
+ setTAC: setTAC,
3923
3956
  isFormDirty: isFormDirty,
3924
3957
  setIsFormDirty: onChangeFormDirty
3925
3958
  };
@@ -3967,11 +4000,11 @@ var TafForm = function TafForm(_ref) {
3967
4000
  var _useTafModuleContext = useTafModuleContext(),
3968
4001
  registerValidateForm = _useTafModuleContext.registerValidateForm,
3969
4002
  tafAction = _useTafModuleContext.tafAction,
4003
+ setIsFormDirty = _useTafModuleContext.setIsFormDirty,
3970
4004
  setTafAction = _useTafModuleContext.setTafAction,
3971
- setIsFormDirty = _useTafModuleContext.setIsFormDirty;
3972
-
3973
- var _useApiContext = useApiContext(),
3974
- api = _useApiContext.api;
4005
+ TAC = _useTafModuleContext.TAC,
4006
+ updateTAC = _useTafModuleContext.updateTAC,
4007
+ setTAC = _useTafModuleContext.setTAC;
3975
4008
 
3976
4009
  var _useIsMounted = useIsMounted(),
3977
4010
  isMounted = _useIsMounted.isMounted;
@@ -3995,15 +4028,20 @@ var TafForm = function TafForm(_ref) {
3995
4028
  delayedFormValues = _React$useState2[0],
3996
4029
  setDelayedFormValues = _React$useState2[1];
3997
4030
 
3998
- var _useTACGenerator = useTACGenerator(tafFromBackend.taf, api.getTAC),
3999
- _useTACGenerator2 = _slicedToArray(_useTACGenerator, 2),
4000
- TAC = _useTACGenerator2[0],
4001
- updateTAC = _useTACGenerator2[1];
4002
-
4003
4031
  var hasErrors = Object.keys(errors).length;
4004
4032
 
4005
4033
  var onFormBlur = function onFormBlur() {
4006
- setDelayedFormValues(getValues());
4034
+ if (!isEqual(getValues(), delayedFormValues)) {
4035
+ setDelayedFormValues(getValues());
4036
+ }
4037
+ };
4038
+
4039
+ var resetTAC = function resetTAC() {
4040
+ if (originalTaf.status !== 'NEW') {
4041
+ updateTAC(originalTaf);
4042
+ } else {
4043
+ setTAC(TAC_NOT_AVAILABLE);
4044
+ }
4007
4045
  };
4008
4046
 
4009
4047
  React__default.useEffect(function () {
@@ -4072,6 +4110,7 @@ var TafForm = function TafForm(_ref) {
4072
4110
  if (isFormDirty) {
4073
4111
  showConfirmDialog(action).then(function () {
4074
4112
  resetForm(undefined, isDefaultDisabled);
4113
+ resetTAC();
4075
4114
  });
4076
4115
  } else {
4077
4116
  resetForm(undefined, isDefaultDisabled);
@@ -4248,6 +4287,7 @@ var TafForm = function TafForm(_ref) {
4248
4287
  registerValidateForm(onValidateFormPromise); // set default taf action
4249
4288
 
4250
4289
  setTafAction(fromStatusToAction(originalTaf.status));
4290
+ resetTAC();
4251
4291
  return function () {
4252
4292
  reset({});
4253
4293
  }; // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -4550,7 +4590,7 @@ var prepareTafExportValues = function prepareTafExportValues(tafToCopy, currentT
4550
4590
  _convertedCopy$change = convertedCopy.changeGroups,
4551
4591
  changeGroups = _convertedCopy$change === void 0 ? [] : _convertedCopy$change;
4552
4592
  return Object.assign(Object.assign({}, currentTaf), {
4553
- baseForecast: Object.assign(Object.assign(Object.assign({}, emptyBaseForecast), baseForecast), {
4593
+ baseForecast: Object.assign(Object.assign({}, baseForecast), {
4554
4594
  valid: (_a = currentTaf === null || currentTaf === void 0 ? void 0 : currentTaf.baseForecast) === null || _a === void 0 ? void 0 : _a.valid
4555
4595
  }),
4556
4596
  changeGroups: changeGroups
@@ -4704,6 +4744,9 @@ var TacContainer = function TacContainer(_ref) {
4704
4744
  trigger = _useFormContext.trigger,
4705
4745
  setValue = _useFormContext.setValue;
4706
4746
 
4747
+ var _useTafModuleContext = useTafModuleContext(),
4748
+ updateTAC = _useTafModuleContext.updateTAC;
4749
+
4707
4750
  var handleExport = function handleExport() {
4708
4751
  var currentTaf = getValues();
4709
4752
  var newTaf = prepareTafExportValues(taf, currentTaf);
@@ -4716,6 +4759,7 @@ var TacContainer = function TacContainer(_ref) {
4716
4759
  setTimeout(function () {
4717
4760
  trigger(); // trigger all fields validation
4718
4761
  }, 0);
4762
+ updateTAC(convertTafValuesToObject(newTaf));
4719
4763
  };
4720
4764
 
4721
4765
  React__default.useEffect(function () {
@@ -5190,7 +5234,7 @@ var parseErrorMessage = function parseErrorMessage(error, params) {
5190
5234
  } : {
5191
5235
  type: 'SERVER',
5192
5236
  title: 'An error has occurred while saving, please try again',
5193
- message: getAxiosErrorMessage(error)
5237
+ message: isAxiosError(error) ? getAxiosErrorMessage(error) : error.message
5194
5238
  };
5195
5239
  };
5196
5240
 
@@ -5561,7 +5605,9 @@ var TafLayout = function TafLayout(_ref) {
5561
5605
  setLocations(updatedLocations); // update active index
5562
5606
 
5563
5607
  var newActiveIndex = updatedLocations.findIndex(function (location) {
5564
- return location.taf.previousId === locations[activeTafIndex].taf.uuid;
5608
+ var _a, _b, _c;
5609
+
5610
+ return ((_a = location === null || location === void 0 ? void 0 : location.taf) === null || _a === void 0 ? void 0 : _a.previousId) === ((_c = (_b = locations[activeTafIndex]) === null || _b === void 0 ? void 0 : _b.taf) === null || _c === void 0 ? void 0 : _c.uuid);
5565
5611
  });
5566
5612
  var newIndex = newActiveIndex !== -1 ? newActiveIndex : activeTafIndex;
5567
5613
  setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -5651,7 +5697,8 @@ var TafLayout = function TafLayout(_ref) {
5651
5697
  variant: "outlined",
5652
5698
  sx: {
5653
5699
  marginBottom: '12px',
5654
- position: 'relative'
5700
+ position: 'relative',
5701
+ minHeight: locations.length * 62 + 32
5655
5702
  }
5656
5703
  }, /*#__PURE__*/React__default.createElement(TacOverviewMobile, {
5657
5704
  upcomingTafs: upcoming,
@@ -5710,18 +5757,30 @@ var TafWrapper = function TafWrapper(_a) {
5710
5757
  }, children)));
5711
5758
  };
5712
5759
 
5760
+ /* *
5761
+ * Licensed under the Apache License, Version 2.0 (the "License");
5762
+ * you may not use this file except in compliance with the License.
5763
+ * You may obtain a copy of the License at
5764
+ *
5765
+ * http://www.apache.org/licenses/LICENSE-2.0
5766
+ *
5767
+ * Unless required by applicable law or agreed to in writing, software
5768
+ * distributed under the License is distributed on an "AS IS" BASIS,
5769
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5770
+ * See the License for the specific language governing permissions and
5771
+ * limitations under the License.
5772
+ *
5773
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5774
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
5775
+ * */
5776
+
5713
5777
  var TafModule = function TafModule() {
5714
5778
  var _useApiContext = useApiContext(),
5715
5779
  api = _useApiContext.api;
5716
5780
 
5717
- var _React$useState = React.useState(false),
5718
- _React$useState2 = _slicedToArray(_React$useState, 2),
5719
- isLoading = _React$useState2[0],
5720
- setLoading = _React$useState2[1];
5721
-
5722
5781
  var _useApi = useApi(api.getTafList),
5723
5782
  getTafListError = _useApi.error,
5724
- isFetchingInitial = _useApi.isLoading,
5783
+ isLoading = _useApi.isLoading,
5725
5784
  tafList = _useApi.result,
5726
5785
  fetchNewTafList = _useApi.fetchApiData;
5727
5786
 
@@ -5729,45 +5788,11 @@ var TafModule = function TafModule() {
5729
5788
  return fetchNewTafList({});
5730
5789
  });
5731
5790
 
5732
- var reFetchNewTafList = function reFetchNewTafList() {
5733
- return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
5734
- return regeneratorRuntime.wrap(function _callee$(_context) {
5735
- while (1) {
5736
- switch (_context.prev = _context.next) {
5737
- case 0:
5738
- _context.prev = 0;
5739
- setLoading(true);
5740
- _context.next = 4;
5741
- return fetchNewTafList({});
5742
-
5743
- case 4:
5744
- setLoading(false);
5745
- _context.next = 10;
5746
- break;
5747
-
5748
- case 7:
5749
- _context.prev = 7;
5750
- _context.t0 = _context["catch"](0);
5751
- setLoading(false);
5752
-
5753
- case 10:
5754
- case "end":
5755
- return _context.stop();
5756
- }
5757
- }
5758
- }, _callee, null, [[0, 7]]);
5759
- }));
5791
+ var onPostTaf = function onPostTaf() {
5792
+ fetchNewTafList({});
5760
5793
  };
5761
5794
 
5762
5795
  var hasTafListError = getTafListError !== null;
5763
-
5764
- if (isFetchingInitial) {
5765
- return /*#__PURE__*/React.createElement(LinearProgress, {
5766
- color: "secondary",
5767
- "data-testid": "loading-bar"
5768
- });
5769
- }
5770
-
5771
5796
  return /*#__PURE__*/React.createElement(Box, {
5772
5797
  component: "div",
5773
5798
  id: "tafmodule",
@@ -5785,10 +5810,13 @@ var TafModule = function TafModule() {
5785
5810
  title: "An error has occurred while retrieving the list",
5786
5811
  info: getTafListError.message,
5787
5812
  dataTestId: "taf-list-error",
5788
- shouldClose: true
5813
+ actionButtonProps: {
5814
+ title: 'Try again',
5815
+ onClick: fetchNewTafList
5816
+ }
5789
5817
  }), /*#__PURE__*/React.createElement(TafLayout, {
5790
5818
  tafList: tafList,
5791
- onPostTaf: reFetchNewTafList
5819
+ onPostTaf: onPostTaf
5792
5820
  }));
5793
5821
  };
5794
5822
 
@@ -5796,22 +5824,6 @@ var Wrapper = function Wrapper(props) {
5796
5824
  return /*#__PURE__*/React.createElement(TafWrapper, Object.assign({}, props), /*#__PURE__*/React.createElement(TafModule, null));
5797
5825
  };
5798
5826
 
5799
- /* *
5800
- * Licensed under the Apache License, Version 2.0 (the "License");
5801
- * you may not use this file except in compliance with the License.
5802
- * You may obtain a copy of the License at
5803
- *
5804
- * http://www.apache.org/licenses/LICENSE-2.0
5805
- *
5806
- * Unless required by applicable law or agreed to in writing, software
5807
- * distributed under the License is distributed on an "AS IS" BASIS,
5808
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5809
- * See the License for the specific language governing permissions and
5810
- * limitations under the License.
5811
- *
5812
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5813
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
5814
- * */
5815
5827
  var createApi$1 = function createApi(url, appUrl, auth, setAuth, authTokenUrl, authClientId) {
5816
5828
  var axiosInstance = createApiInstance(url, appUrl, auth, setAuth, authTokenUrl, authClientId);
5817
5829
  return {
@@ -5822,8 +5834,10 @@ var createApi$1 = function createApi(url, appUrl, auth, setAuth, authTokenUrl, a
5822
5834
  postTaf: function postTaf(formData) {
5823
5835
  return axiosInstance.post('/taf', Object.assign({}, formData));
5824
5836
  },
5825
- getTAC: function getTAC(tafData) {
5826
- return axiosInstance.post('/taf2tac', Object.assign({}, tafData));
5837
+ getTAC: function getTAC(tafData, signal) {
5838
+ return axiosInstance.post.apply(axiosInstance, ['/taf2tac'].concat([Object.assign({}, tafData)].concat(_toConsumableArray(signal ? [{
5839
+ signal: signal
5840
+ }] : []))));
5827
5841
  }
5828
5842
  };
5829
5843
  };
@@ -6747,12 +6761,17 @@ var fakeAmendmentTaf = {
6747
6761
  var fakeTafTac = 'TAF EHAM 0812/0918 20020G35KT 0500 SN BKN040\nBECMG 0814/0816 0700 BKN001=';
6748
6762
 
6749
6763
  var fakePromise = function fakePromise(withRandomError) {
6764
+ var signal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
6750
6765
  return new Promise(function (resolve, reject) {
6751
- setTimeout(function () {
6766
+ var timer = setTimeout(function () {
6752
6767
  if (!withRandomError) return resolve();
6753
6768
  var randomError = Math.floor(Math.random() * 4) + 1;
6754
6769
  return randomError === 4 ? reject(new Error('something went wrong')) : resolve();
6755
6770
  }, 300);
6771
+ signal === null || signal === void 0 ? void 0 : signal.signal.addEventListener('abort', function () {
6772
+ clearTimeout(timer);
6773
+ reject(new Error('canceled'));
6774
+ });
6756
6775
  });
6757
6776
  };
6758
6777
 
@@ -6762,8 +6781,8 @@ var fakeAxiosInstance = {
6762
6781
  return fakePromise(false);
6763
6782
  },
6764
6783
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6765
- post: function post(_url, _params) {
6766
- return fakePromise(false);
6784
+ post: function post(_url, _params, _signal) {
6785
+ return fakePromise(false, _signal);
6767
6786
  }
6768
6787
  };
6769
6788
  var createApi = function createApi() {
@@ -6777,20 +6796,21 @@ var createApi = function createApi() {
6777
6796
  };
6778
6797
  });
6779
6798
  },
6780
- getTAC: function getTAC() {
6781
- // eslint-disable-next-line no-console
6782
- return fakeAxiosInstance.post('/taf2tac').then(function () {
6783
- return {
6784
- data: fakeTafTac
6785
- };
6786
- });
6787
- },
6788
6799
  postTaf: function postTaf(_postTaf) {
6789
6800
  // eslint-disable-next-line no-console
6790
6801
  console.log("The new status of the taf will be ".concat(_postTaf.changeStatusTo)); // eslint-disable-next-line no-console
6791
6802
 
6792
6803
  console.log('form has been posted with following values:', _postTaf.taf);
6793
6804
  return fakeAxiosInstance.post('/taf', _postTaf);
6805
+ },
6806
+ getTAC: function getTAC(tafData, signal) {
6807
+ return fakeAxiosInstance.post.apply(fakeAxiosInstance, ['/taf2tac'].concat([Object.assign({}, tafData)].concat(_toConsumableArray(signal ? [{
6808
+ signal: signal
6809
+ }] : [])))).then(function () {
6810
+ return {
6811
+ data: fakeTafTac
6812
+ };
6813
+ });
6794
6814
  }
6795
6815
  };
6796
6816
  };
package/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('react-hook-form'), require('react-sortablejs'), require('@opengeoweb/form-fields'), require('@opengeoweb/api'), require('@opengeoweb/shared'), require('moment'), require('lodash'), require('@mui/styles/makeStyles'), require('@mui/icons-material'), require('react-dom'), require('@mui/material/LinearProgress'), require('@mui/icons-material/DoDisturb'), require('@mui/material/Box')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'react-sortablejs', '@opengeoweb/form-fields', '@opengeoweb/api', '@opengeoweb/shared', 'moment', 'lodash', '@mui/styles/makeStyles', '@mui/icons-material', 'react-dom', '@mui/material/LinearProgress', '@mui/icons-material/DoDisturb', '@mui/material/Box'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.material, global.reactHookForm, global.reactSortablejs, global.formFields, global.api, global.shared, global.moment, global.lodash, global.makeStyles, global.iconsMaterial, global.ReactDOM, global.LinearProgress, global.DoDisturbIcon, global.Box));
5
- })(this, (function (exports, React, material, reactHookForm, reactSortablejs, formFields, api, shared, moment, lodash, makeStyles, iconsMaterial, ReactDOM, LinearProgress, DoDisturbIcon, Box) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('react-hook-form'), require('react-sortablejs'), require('@opengeoweb/form-fields'), require('@opengeoweb/shared'), require('lodash'), require('moment'), require('@mui/styles/makeStyles'), require('@mui/icons-material'), require('react-dom'), require('@opengeoweb/api'), require('@mui/material/LinearProgress'), require('@mui/icons-material/DoDisturb'), require('@mui/material/Box')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'react-sortablejs', '@opengeoweb/form-fields', '@opengeoweb/shared', 'lodash', 'moment', '@mui/styles/makeStyles', '@mui/icons-material', 'react-dom', '@opengeoweb/api', '@mui/material/LinearProgress', '@mui/icons-material/DoDisturb', '@mui/material/Box'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.material, global.reactHookForm, global.reactSortablejs, global.formFields, global.shared, global.lodash, global.moment, global.makeStyles, global.iconsMaterial, global.ReactDOM, global.api, global.LinearProgress, global.DoDisturbIcon, global.Box));
5
+ })(this, (function (exports, React, material, reactHookForm, reactSortablejs, formFields, shared, lodash, moment, makeStyles, iconsMaterial, ReactDOM, api, LinearProgress, DoDisturbIcon, Box) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -2319,19 +2319,35 @@
2319
2319
  return tac === TAC_MISSING_DATA || tac === TAC_NOT_AVAILABLE || tac === TAC_RETRIEVING_DATA || tac === TAC_FAILED;
2320
2320
  };
2321
2321
  var useTACGenerator = function useTACGenerator(taf, requestTAC) {
2322
- var _a = __read(React__default["default"].useState(taf.status === 'NEW' ? TAC_NOT_AVAILABLE : TAC_RETRIEVING_DATA), 2),
2322
+ var _a = __read(React__default["default"].useState(!taf || taf.status === 'NEW' ? TAC_NOT_AVAILABLE : TAC_RETRIEVING_DATA), 2),
2323
2323
  TAC = _a[0],
2324
2324
  setTAC = _a[1];
2325
2325
 
2326
2326
  var isMounted = shared.useIsMounted().isMounted;
2327
+ var controller = React__default["default"].useRef(null);
2328
+
2329
+ var onSetTac = function onSetTac(newTAC) {
2330
+ if (controller.current) {
2331
+ controller.current.abort();
2332
+ }
2333
+
2334
+ setTAC(newTAC);
2335
+ };
2336
+
2327
2337
  var retrieveTAC = React__default["default"].useCallback(function (tafToPost) {
2328
2338
  if (shouldRetrieveTAC(tafToPost)) {
2329
- requestTAC(tafToPost).then(function (result) {
2339
+ if (controller.current) {
2340
+ controller.current.abort();
2341
+ }
2342
+
2343
+ controller.current = new AbortController();
2344
+ setTAC(TAC_RETRIEVING_DATA);
2345
+ requestTAC(tafToPost, controller.current.signal).then(function (result) {
2330
2346
  if (isMounted.current) {
2331
2347
  setTAC(result.data);
2332
2348
  }
2333
- })["catch"](function () {
2334
- if (isMounted.current) {
2349
+ })["catch"](function (error) {
2350
+ if (isMounted && error.message !== 'canceled') {
2335
2351
  setTAC(TAC_FAILED);
2336
2352
  }
2337
2353
  });
@@ -2340,12 +2356,12 @@
2340
2356
  }
2341
2357
  }, [isMounted, requestTAC]);
2342
2358
  React__default["default"].useEffect(function () {
2343
- if (taf.status !== 'NEW') {
2359
+ if (taf && taf.status !== 'NEW') {
2344
2360
  retrieveTAC(taf);
2345
2361
  } // eslint-disable-next-line react-hooks/exhaustive-deps
2346
2362
 
2347
2363
  }, []);
2348
- return [TAC, retrieveTAC];
2364
+ return [TAC, retrieveTAC, onSetTac];
2349
2365
  };
2350
2366
  var useDragOrder = function useDragOrder(trigger, move, onFormBlur) {
2351
2367
  var _a = __read(React__default["default"].useState(null), 2),
@@ -2535,9 +2551,16 @@
2535
2551
 
2536
2552
 
2537
2553
  var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
2554
+ var formattedBaseForecast = formatFormValues(taf.baseForecast);
2555
+
2556
+ var baseForecast = __assign(__assign(__assign({}, emptyBaseForecast), formattedBaseForecast), {
2557
+ weather: __assign(__assign({}, emptyBaseForecast.weather), formattedBaseForecast.weather),
2558
+ cloud: __assign(__assign({}, emptyBaseForecast.cloud), formattedBaseForecast.cloud)
2559
+ });
2560
+
2538
2561
  return __assign(__assign(__assign(__assign({}, taf), {
2539
2562
  messageType: getMessageType(taf, tafAction),
2540
- baseForecast: __assign(__assign({}, emptyBaseForecast), formatFormValues(taf.baseForecast))
2563
+ baseForecast: baseForecast
2541
2564
  }), taf.changeGroups && {
2542
2565
  changeGroups: taf.changeGroups.map(formatFormValues)
2543
2566
  }), addEmptyChangeGroup && {
@@ -3857,6 +3880,7 @@
3857
3880
  };
3858
3881
  var useTafModuleState = function useTafModuleState(_a) {
3859
3882
  var onPreventCloseView = _a.onPreventCloseView;
3883
+ var api$1 = api.useApiContext().api;
3860
3884
 
3861
3885
  var _b = __read(React__namespace.useState(function () {
3862
3886
  return new Promise(function () {
@@ -3874,6 +3898,11 @@
3874
3898
  isFormDirty = _d[0],
3875
3899
  setIsFormDirty = _d[1];
3876
3900
 
3901
+ var _e = __read(useTACGenerator(undefined, api$1.getTAC), 3),
3902
+ TAC = _e[0],
3903
+ updateTAC = _e[1],
3904
+ setTAC = _e[2];
3905
+
3877
3906
  var onRegisterValidateForm = function onRegisterValidateForm(promiseToRegister) {
3878
3907
  registerValidateForm(function () {
3879
3908
  return promiseToRegister;
@@ -3892,6 +3921,9 @@
3892
3921
  registerValidateForm: onRegisterValidateForm,
3893
3922
  tafAction: tafAction,
3894
3923
  setTafAction: setTafAction,
3924
+ TAC: TAC,
3925
+ updateTAC: updateTAC,
3926
+ setTAC: setTAC,
3895
3927
  isFormDirty: isFormDirty,
3896
3928
  setIsFormDirty: onChangeFormDirty
3897
3929
  };
@@ -3939,10 +3971,12 @@
3939
3971
  var _h = useTafModuleContext(),
3940
3972
  registerValidateForm = _h.registerValidateForm,
3941
3973
  tafAction = _h.tafAction,
3974
+ setIsFormDirty = _h.setIsFormDirty,
3942
3975
  setTafAction = _h.setTafAction,
3943
- setIsFormDirty = _h.setIsFormDirty;
3976
+ TAC = _h.TAC,
3977
+ updateTAC = _h.updateTAC,
3978
+ setTAC = _h.setTAC;
3944
3979
 
3945
- var api$1 = api.useApiContext().api;
3946
3980
  var isMounted = shared.useIsMounted().isMounted;
3947
3981
 
3948
3982
  var _j = reactHookForm.useFormContext(),
@@ -3963,14 +3997,20 @@
3963
3997
  delayedFormValues = _k[0],
3964
3998
  setDelayedFormValues = _k[1];
3965
3999
 
3966
- var _l = __read(useTACGenerator(tafFromBackend.taf, api$1.getTAC), 2),
3967
- TAC = _l[0],
3968
- updateTAC = _l[1];
3969
-
3970
4000
  var hasErrors = Object.keys(errors).length;
3971
4001
 
3972
4002
  var onFormBlur = function onFormBlur() {
3973
- setDelayedFormValues(getValues());
4003
+ if (!lodash.isEqual(getValues(), delayedFormValues)) {
4004
+ setDelayedFormValues(getValues());
4005
+ }
4006
+ };
4007
+
4008
+ var resetTAC = function resetTAC() {
4009
+ if (originalTaf.status !== 'NEW') {
4010
+ updateTAC(originalTaf);
4011
+ } else {
4012
+ setTAC(TAC_NOT_AVAILABLE);
4013
+ }
3974
4014
  };
3975
4015
 
3976
4016
  React__default["default"].useEffect(function () {
@@ -4043,6 +4083,7 @@
4043
4083
  if (isFormDirty) {
4044
4084
  showConfirmDialog(action).then(function () {
4045
4085
  resetForm(undefined, isDefaultDisabled);
4086
+ resetTAC();
4046
4087
  });
4047
4088
  } else {
4048
4089
  resetForm(undefined, isDefaultDisabled);
@@ -4109,19 +4150,19 @@
4109
4150
  }
4110
4151
  };
4111
4152
 
4112
- var _m = reactHookForm.useFieldArray({
4153
+ var _l = reactHookForm.useFieldArray({
4113
4154
  control: control,
4114
4155
  name: 'changeGroups'
4115
4156
  }),
4116
- fields = _m.fields,
4117
- insert = _m.insert,
4118
- remove = _m.remove,
4119
- move = _m.move;
4157
+ fields = _l.fields,
4158
+ insert = _l.insert,
4159
+ remove = _l.remove,
4160
+ move = _l.move;
4120
4161
 
4121
- var _o = useDragOrder(trigger, move, onFormBlur),
4122
- onChangeOrder = _o.onChangeOrder,
4123
- onStartDrag = _o.onStartDrag,
4124
- activeDraggingIndex = _o.activeDraggingIndex;
4162
+ var _m = useDragOrder(trigger, move, onFormBlur),
4163
+ onChangeOrder = _m.onChangeOrder,
4164
+ onStartDrag = _m.onStartDrag,
4165
+ activeDraggingIndex = _m.activeDraggingIndex;
4125
4166
 
4126
4167
  var onRemoverow = function onRemoverow(index) {
4127
4168
  confirmDialog({
@@ -4202,9 +4243,9 @@
4202
4243
  });
4203
4244
  };
4204
4245
 
4205
- var _p = __read(React__default["default"].useState(false), 2),
4206
- shouldValidate = _p[0],
4207
- setShouldValidate = _p[1];
4246
+ var _o = __read(React__default["default"].useState(false), 2),
4247
+ shouldValidate = _o[0],
4248
+ setShouldValidate = _o[1];
4208
4249
 
4209
4250
  React__default["default"].useEffect(function () {
4210
4251
  setIsDisabled(isDefaultDisabled);
@@ -4232,6 +4273,7 @@
4232
4273
  registerValidateForm(onValidateFormPromise); // set default taf action
4233
4274
 
4234
4275
  setTafAction(fromStatusToAction(originalTaf.status));
4276
+ resetTAC();
4235
4277
  return function () {
4236
4278
  reset({});
4237
4279
  }; // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -4540,7 +4582,7 @@
4540
4582
  _b = convertedCopy.changeGroups,
4541
4583
  changeGroups = _b === void 0 ? [] : _b;
4542
4584
  return __assign(__assign({}, currentTaf), {
4543
- baseForecast: __assign(__assign(__assign({}, emptyBaseForecast), baseForecast), {
4585
+ baseForecast: __assign(__assign({}, baseForecast), {
4544
4586
  valid: (_a = currentTaf === null || currentTaf === void 0 ? void 0 : currentTaf.baseForecast) === null || _a === void 0 ? void 0 : _a.valid
4545
4587
  }),
4546
4588
  changeGroups: changeGroups
@@ -4708,6 +4750,8 @@
4708
4750
  trigger = _e.trigger,
4709
4751
  setValue = _e.setValue;
4710
4752
 
4753
+ var updateTAC = useTafModuleContext().updateTAC;
4754
+
4711
4755
  var handleExport = function handleExport() {
4712
4756
  var currentTaf = getValues();
4713
4757
  var newTaf = prepareTafExportValues(taf, currentTaf);
@@ -4720,6 +4764,7 @@
4720
4764
  setTimeout(function () {
4721
4765
  trigger(); // trigger all fields validation
4722
4766
  }, 0);
4767
+ updateTAC(convertTafValuesToObject(newTaf));
4723
4768
  };
4724
4769
 
4725
4770
  React__default["default"].useEffect(function () {
@@ -5158,7 +5203,7 @@
5158
5203
  } : {
5159
5204
  type: 'SERVER',
5160
5205
  title: 'An error has occurred while saving, please try again',
5161
- message: shared.getAxiosErrorMessage(error)
5206
+ message: shared.isAxiosError(error) ? shared.getAxiosErrorMessage(error) : error.message
5162
5207
  };
5163
5208
  };
5164
5209
 
@@ -5557,7 +5602,9 @@
5557
5602
  setLocations(updatedLocations); // update active index
5558
5603
 
5559
5604
  var newActiveIndex = updatedLocations.findIndex(function (location) {
5560
- return location.taf.previousId === locations[activeTafIndex].taf.uuid;
5605
+ var _a, _b, _c;
5606
+
5607
+ return ((_a = location === null || location === void 0 ? void 0 : location.taf) === null || _a === void 0 ? void 0 : _a.previousId) === ((_c = (_b = locations[activeTafIndex]) === null || _b === void 0 ? void 0 : _b.taf) === null || _c === void 0 ? void 0 : _c.uuid);
5561
5608
  });
5562
5609
  var newIndex = newActiveIndex !== -1 ? newActiveIndex : activeTafIndex;
5563
5610
  setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -5647,7 +5694,8 @@
5647
5694
  variant: "outlined",
5648
5695
  sx: {
5649
5696
  marginBottom: '12px',
5650
- position: 'relative'
5697
+ position: 'relative',
5698
+ minHeight: locations.length * 62 + 32
5651
5699
  }
5652
5700
  }, /*#__PURE__*/React__default["default"].createElement(TacOverviewMobile, {
5653
5701
  upcomingTafs: upcoming,
@@ -5709,65 +5757,21 @@
5709
5757
  var TafModule = function TafModule() {
5710
5758
  var api$1 = api.useApiContext().api;
5711
5759
 
5712
- var _a = __read(React__namespace.useState(false), 2),
5713
- isLoading = _a[0],
5714
- setLoading = _a[1];
5715
-
5716
- var _b = api.useApi(api$1.getTafList),
5717
- getTafListError = _b.error,
5718
- isFetchingInitial = _b.isLoading,
5719
- tafList = _b.result,
5720
- fetchNewTafList = _b.fetchApiData;
5760
+ var _a = api.useApi(api$1.getTafList),
5761
+ getTafListError = _a.error,
5762
+ isLoading = _a.isLoading,
5763
+ tafList = _a.result,
5764
+ fetchNewTafList = _a.fetchApiData;
5721
5765
 
5722
5766
  shared.usePoller([tafList, getTafListError], function () {
5723
5767
  return fetchNewTafList({});
5724
5768
  });
5725
5769
 
5726
- var reFetchNewTafList = function reFetchNewTafList() {
5727
- return __awaiter(void 0, void 0, void 0, function () {
5728
- return __generator(this, function (_a) {
5729
- switch (_a.label) {
5730
- case 0:
5731
- _a.trys.push([0, 2,, 3]);
5732
-
5733
- setLoading(true);
5734
- return [4
5735
- /*yield*/
5736
- , fetchNewTafList({})];
5737
-
5738
- case 1:
5739
- _a.sent();
5740
-
5741
- setLoading(false);
5742
- return [3
5743
- /*break*/
5744
- , 3];
5745
-
5746
- case 2:
5747
- _a.sent();
5748
- setLoading(false);
5749
- return [3
5750
- /*break*/
5751
- , 3];
5752
-
5753
- case 3:
5754
- return [2
5755
- /*return*/
5756
- ];
5757
- }
5758
- });
5759
- });
5770
+ var onPostTaf = function onPostTaf() {
5771
+ fetchNewTafList({});
5760
5772
  };
5761
5773
 
5762
5774
  var hasTafListError = getTafListError !== null;
5763
-
5764
- if (isFetchingInitial) {
5765
- return /*#__PURE__*/React__namespace.createElement(LinearProgress__default["default"], {
5766
- color: "secondary",
5767
- "data-testid": "loading-bar"
5768
- });
5769
- }
5770
-
5771
5775
  return /*#__PURE__*/React__namespace.createElement(material.Box, {
5772
5776
  component: "div",
5773
5777
  id: "tafmodule",
@@ -5785,10 +5789,13 @@
5785
5789
  title: "An error has occurred while retrieving the list",
5786
5790
  info: getTafListError.message,
5787
5791
  dataTestId: "taf-list-error",
5788
- shouldClose: true
5792
+ actionButtonProps: {
5793
+ title: 'Try again',
5794
+ onClick: fetchNewTafList
5795
+ }
5789
5796
  }), /*#__PURE__*/React__namespace.createElement(TafLayout, {
5790
5797
  tafList: tafList,
5791
- onPostTaf: reFetchNewTafList
5798
+ onPostTaf: onPostTaf
5792
5799
  }));
5793
5800
  };
5794
5801
 
@@ -5806,8 +5813,10 @@
5806
5813
  postTaf: function postTaf(formData) {
5807
5814
  return axiosInstance.post('/taf', __assign({}, formData));
5808
5815
  },
5809
- getTAC: function getTAC(tafData) {
5810
- return axiosInstance.post('/taf2tac', __assign({}, tafData));
5816
+ getTAC: function getTAC(tafData, signal) {
5817
+ return axiosInstance.post.apply(axiosInstance, __spreadArray(['/taf2tac'], __read(__spreadArray([__assign({}, tafData)], __read(signal ? [{
5818
+ signal: signal
5819
+ }] : [])))));
5811
5820
  }
5812
5821
  };
5813
5822
  };
@@ -6727,13 +6736,21 @@
6727
6736
 
6728
6737
  var fakeTafTac = 'TAF EHAM 0812/0918 20020G35KT 0500 SN BKN040\nBECMG 0814/0816 0700 BKN001=';
6729
6738
 
6730
- var fakePromise = function fakePromise(withRandomError) {
6739
+ var fakePromise = function fakePromise(withRandomError, signal) {
6740
+ if (signal === void 0) {
6741
+ signal = null;
6742
+ }
6743
+
6731
6744
  return new Promise(function (resolve, reject) {
6732
- setTimeout(function () {
6745
+ var timer = setTimeout(function () {
6733
6746
  if (!withRandomError) return resolve();
6734
6747
  var randomError = Math.floor(Math.random() * 4) + 1;
6735
6748
  return randomError === 4 ? reject(new Error('something went wrong')) : resolve();
6736
6749
  }, 300);
6750
+ signal === null || signal === void 0 ? void 0 : signal.signal.addEventListener('abort', function () {
6751
+ clearTimeout(timer);
6752
+ reject(new Error('canceled'));
6753
+ });
6737
6754
  });
6738
6755
  };
6739
6756
 
@@ -6743,8 +6760,8 @@
6743
6760
  return fakePromise(false);
6744
6761
  },
6745
6762
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6746
- post: function post(_url, _params) {
6747
- return fakePromise(false);
6763
+ post: function post(_url, _params, _signal) {
6764
+ return fakePromise(false, _signal);
6748
6765
  }
6749
6766
  };
6750
6767
  var createApi = function createApi() {
@@ -6758,20 +6775,21 @@
6758
6775
  };
6759
6776
  });
6760
6777
  },
6761
- getTAC: function getTAC() {
6762
- // eslint-disable-next-line no-console
6763
- return fakeAxiosInstance.post('/taf2tac').then(function () {
6764
- return {
6765
- data: fakeTafTac
6766
- };
6767
- });
6768
- },
6769
6778
  postTaf: function postTaf(_postTaf) {
6770
6779
  // eslint-disable-next-line no-console
6771
6780
  console.log("The new status of the taf will be " + _postTaf.changeStatusTo); // eslint-disable-next-line no-console
6772
6781
 
6773
6782
  console.log('form has been posted with following values:', _postTaf.taf);
6774
6783
  return fakeAxiosInstance.post('/taf', _postTaf);
6784
+ },
6785
+ getTAC: function getTAC(tafData, signal) {
6786
+ return fakeAxiosInstance.post.apply(fakeAxiosInstance, __spreadArray(['/taf2tac'], __read(__spreadArray([__assign({}, tafData)], __read(signal ? [{
6787
+ signal: signal
6788
+ }] : []))))).then(function () {
6789
+ return {
6790
+ data: fakeTafTac
6791
+ };
6792
+ });
6775
6793
  }
6776
6794
  };
6777
6795
  };
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { UseFormOptions } from 'react-hook-form';
3
+ import { Theme } from '@mui/material';
4
+ export interface TafThemeApiProviderProps {
5
+ createApiFunc?: any;
6
+ children: React.ReactNode;
7
+ theme?: Theme;
8
+ }
9
+ export declare const TafThemeApiProvider: React.FC<TafThemeApiProviderProps>;
10
+ interface TafThemeFormProviderProps {
11
+ children: React.ReactNode;
12
+ options?: UseFormOptions;
13
+ theme?: Theme;
14
+ }
15
+ export declare const TafThemeFormProvider: React.FC<TafThemeFormProviderProps>;
16
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Providers';
@@ -29,9 +29,9 @@ export declare const TAC_NOT_AVAILABLE = "No TAC available";
29
29
  export declare const TAC_RETRIEVING_DATA = "Retrieving TAC";
30
30
  export declare const TAC_FAILED = "Failed to retrieve TAC";
31
31
  export declare const tacHasError: (tac: string) => boolean;
32
- export declare const useTACGenerator: (taf: Taf, requestTAC: (postTaf: unknown) => Promise<{
32
+ export declare const useTACGenerator: (taf: Taf, requestTAC: (postTaf: unknown, abortSignal?: AbortSignal) => Promise<{
33
33
  data: string;
34
- }>) => [string, (tafToPost: any) => void];
34
+ }>) => [string, (tafToPost: any) => void, (newTAC: string) => void];
35
35
  export declare type SortableField = {
36
36
  id: string;
37
37
  chosen: boolean;
@@ -3,11 +3,11 @@ declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
- export declare const TafLayoutLightTheme: {
6
+ export declare const LocationTabsLightTheme: {
7
7
  (): React.ReactElement;
8
8
  storyName: string;
9
9
  };
10
- export declare const TafLayoutDarkTheme: {
10
+ export declare const LocationTabsDarkTheme: {
11
11
  (): React.ReactElement;
12
12
  storyName: string;
13
13
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  interface ExportButtonProps {
3
- onClick: any;
3
+ onClick: () => void;
4
4
  isHidden: boolean;
5
5
  }
6
6
  declare const ExportButton: React.FC<ExportButtonProps>;
@@ -21,7 +21,7 @@ interface TafPanelProps {
21
21
  setIsFormDisabled?: (isDisabled: boolean) => void;
22
22
  error?: TafError;
23
23
  }
24
- export declare const usePostTafRequest: (request: (params?: unknown) => Promise<void>, errorParser?: (error: AxiosError, params: TafFromFrontEnd) => TafError) => {
24
+ export declare const usePostTafRequest: (request: (params?: unknown) => Promise<void>, errorParser?: (error: AxiosError | Error, params: TafFromFrontEnd) => TafError) => {
25
25
  isLoading: boolean;
26
26
  error: TafError;
27
27
  setError: (newError: AxiosError) => void;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { BaseTaf, TafActions } from '../../types';
2
+ import { BaseTaf, Taf, TafActions } from '../../types';
3
3
  declare type ValidateFormPromise = () => Promise<void | BaseTaf>;
4
4
  interface TafModuleMethods {
5
5
  onPreventCloseView?: (shouldPreventClose: boolean) => void;
@@ -9,6 +9,9 @@ interface TafModuleContextState {
9
9
  registerValidateForm: (promiseToRegister: ValidateFormPromise) => void;
10
10
  tafAction: TafActions;
11
11
  setTafAction: (action: TafActions) => void;
12
+ TAC: string;
13
+ updateTAC: (taf: Taf) => void;
14
+ setTAC: (tac: string) => void;
12
15
  isFormDirty: boolean;
13
16
  setIsFormDirty: (isDirty: boolean) => void;
14
17
  }
@@ -1,6 +1,6 @@
1
1
  export declare const fakeTafTac = "TAF EHAM 0812/0918 20020G35KT 0500 SN BKN040\nBECMG 0814/0816 0700 BKN001=";
2
2
  export declare const fakeAxiosInstance: {
3
3
  get: (_url: any, _params?: any) => Promise<void>;
4
- post: (_url: any, _params?: any) => Promise<void>;
4
+ post: (_url: any, _params?: any, _signal?: any) => Promise<void>;
5
5
  };
6
6
  export declare const createApi: () => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/taf",
3
- "version": "2.6.0",
3
+ "version": "2.9.0",
4
4
  "description": "GeoWeb TAF library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,16 +14,16 @@
14
14
  "peerDependencies": {
15
15
  "react": "^17.0.2",
16
16
  "@mui/material": "^5.2.8",
17
- "@opengeoweb/api": "2.6.0",
17
+ "@opengeoweb/api": "2.9.0",
18
18
  "axios": "^0.25.0",
19
- "@opengeoweb/shared": "2.6.0",
20
- "@opengeoweb/theme": "2.6.0",
19
+ "@opengeoweb/shared": "2.9.0",
20
+ "@opengeoweb/theme": "2.9.0",
21
21
  "@mui/styles": "^5.2.3",
22
22
  "@mui/icons-material": "^5.2.5",
23
23
  "react-draggable": "^4.4.3",
24
24
  "re-resizable": "^6.9.0",
25
25
  "lodash": "^4.17.20",
26
- "@opengeoweb/form-fields": "2.6.0",
26
+ "@opengeoweb/form-fields": "2.9.0",
27
27
  "react-hook-form": "^6.12.1",
28
28
  "moment": "^2.29.0",
29
29
  "moment-timezone": "^0.5.31",
@@ -1,25 +0,0 @@
1
- import * as React from 'react';
2
- import { UseFormOptions } from 'react-hook-form';
3
- import { Theme } from '@mui/material';
4
- interface WrapperProps {
5
- children: React.ReactNode;
6
- theme?: Theme;
7
- }
8
- export interface TestWrapperProps extends WrapperProps {
9
- createApiFunc?: () => void;
10
- }
11
- export declare const TestWrapper: React.FC<TestWrapperProps>;
12
- interface ApiTestWrapperProps extends WrapperProps {
13
- postTaf?: unknown;
14
- getTafList?: unknown;
15
- getTAC?: unknown;
16
- }
17
- export declare const ApiTestWrapper: React.FC<ApiTestWrapperProps>;
18
- interface TestFormWrapperProps {
19
- children: React.ReactNode;
20
- options?: UseFormOptions;
21
- theme?: Theme;
22
- }
23
- export declare const TestFormWrapper: React.FC<TestFormWrapperProps>;
24
- export declare const StoryWrapper: React.FC<WrapperProps>;
25
- export {};