@opengeoweb/sigmet-airmet 14.1.0 → 14.2.1

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
@@ -960,14 +960,6 @@ function _regeneratorRuntime() {
960
960
  * */
961
961
  var SA_NAMESPACE = 'sigmetairmet';
962
962
  var ns = [SA_NAMESPACE, FORM_FIELDS_NAMESPACE];
963
- var translateKeyOutsideComponents = function translateKeyOutsideComponents(key, params) {
964
- if (params === void 0) {
965
- params = undefined;
966
- }
967
- return i18n.t(key, Object.assign({
968
- ns: ns
969
- }, params));
970
- };
971
963
  var useSigmetAirmetTranslation = function useSigmetAirmetTranslation() {
972
964
  return useTranslation(ns);
973
965
  };
@@ -1003,7 +995,7 @@ var safeFetch = /*#__PURE__*/function () {
1003
995
  _context.prev = 12;
1004
996
  _context.t0 = _context["catch"](3);
1005
997
  newError = Object.assign({}, _context.t0, {
1006
- name: translateKeyOutsideComponents('error-backend')
998
+ name: i18n.t('error-backend')
1007
999
  });
1008
1000
  throw newError;
1009
1001
  case 16:
@@ -6952,12 +6944,12 @@ var ValidFrom = function ValidFrom(_ref) {
6952
6944
  var productConfig = _ref.productConfig,
6953
6945
  isDisabled = _ref.isDisabled,
6954
6946
  isReadOnly = _ref.isReadOnly,
6955
- _ref$isAmending = _ref.isAmending,
6956
- isAmending = _ref$isAmending === void 0 ? false : _ref$isAmending,
6957
6947
  _ref$onChange = _ref.onChange,
6958
6948
  _onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
6959
6949
  _ref$onUserChange = _ref.onUserChange,
6960
- onUserChange = _ref$onUserChange === void 0 ? function () {} : _ref$onUserChange;
6950
+ onUserChange = _ref$onUserChange === void 0 ? function () {} : _ref$onUserChange,
6951
+ _ref$lockBecauseActiv = _ref.lockBecauseActive,
6952
+ lockBecauseActive = _ref$lockBecauseActiv === void 0 ? false : _ref$lockBecauseActiv;
6961
6953
  var _useSigmetAirmetTrans = useSigmetAirmetTranslation(),
6962
6954
  t = _useSigmetAirmetTrans.t;
6963
6955
  var _useFormContext = useFormContext(),
@@ -6967,13 +6959,13 @@ var ValidFrom = function ValidFrom(_ref) {
6967
6959
  var _useDraftFormHelpers = useDraftFormHelpers(),
6968
6960
  isRequired = _useDraftFormHelpers.isRequired;
6969
6961
  var label = getFieldLabel(t, t('date-and-time'), isReadOnly);
6970
- // Update input field to now if amending exceeds the current minute
6962
+ // Only auto-sync to now when amending an already-active SIGMET
6971
6963
  React__default.useEffect(function () {
6972
- if (!isAmending) {
6973
- return undefined;
6964
+ if (!lockBecauseActive) {
6965
+ return;
6974
6966
  }
6975
6967
  var updateNow = function updateNow() {
6976
- setValue('validDateStart', dateUtils.getCurrentTimeAsString(), {
6968
+ return setValue('validDateStart', dateUtils.getCurrentTimeAsString(), {
6977
6969
  shouldValidate: true
6978
6970
  });
6979
6971
  };
@@ -6984,13 +6976,28 @@ var ValidFrom = function ValidFrom(_ref) {
6984
6976
  updateNow();
6985
6977
  intervalId = setInterval(updateNow, 60000);
6986
6978
  }, msUntilNextMinute);
6979
+ // eslint-disable-next-line consistent-return
6987
6980
  return function () {
6988
6981
  clearTimeout(timeoutId);
6989
6982
  if (intervalId) {
6990
6983
  clearInterval(intervalId);
6991
6984
  }
6992
6985
  };
6993
- }, [isAmending, setValue]);
6986
+ }, [lockBecauseActive, setValue]);
6987
+ var nowIso = dateUtils.getCurrentTimeAsString();
6988
+ var rules = lockBecauseActive ? {} : {
6989
+ validate: {
6990
+ isRequired: isRequired,
6991
+ isValidDate: dateUtils.isValidIsoDateString,
6992
+ isValueBeforeCurrentTime: function isValueBeforeCurrentTime(value) {
6993
+ return isXHoursBefore(value, nowIso, 0) || t('valid-from-before-current-error');
6994
+ },
6995
+ isCurrentTimeXHoursBeforeValue: function isCurrentTimeXHoursBeforeValue(value) {
6996
+ var hours = getHoursBeforeValidity(getValues('phenomenon'), getValues('locationIndicatorATSR'), productConfig);
6997
+ return isXHoursBefore(nowIso, value, hours) || getValidFromXHoursBeforeMessage(t, hours);
6998
+ }
6999
+ }
7000
+ };
6994
7001
  return jsx(ProductFormFieldLayout, {
6995
7002
  title: t('valid-from'),
6996
7003
  children: jsx(ReactHookFormDateTime, {
@@ -6998,28 +7005,13 @@ var ValidFrom = function ValidFrom(_ref) {
6998
7005
  name: "validDateStart",
6999
7006
  label: label,
7000
7007
  defaultNullValue: getDefaultValidFromValue(productConfig),
7001
- rules: isAmending ? {} // skip validation, auto-controlled
7002
- : {
7003
- validate: {
7004
- isRequired: isRequired,
7005
- isValidDate: dateUtils.isValidIsoDateString,
7006
- // The validity start cannot be before the current time
7007
- isValueBeforeCurrentTime: function isValueBeforeCurrentTime(value) {
7008
- return isXHoursBefore(value, dateUtils.getCurrentTimeAsString(), 0) || t('valid-from-before-current-error');
7009
- },
7010
- // The current time can be no more than 4 hours before the validity start (12 for VA/TC SIGMET)
7011
- isCurrentTimeXHoursBeforeValue: function isCurrentTimeXHoursBeforeValue(value) {
7012
- var isValid = isXHoursBefore(dateUtils.getCurrentTimeAsString(), value, getHoursBeforeValidity(getValues('phenomenon'), getValues('locationIndicatorATSR'), productConfig));
7013
- return isValid || getValidFromXHoursBeforeMessage(t, getHoursBeforeValidity(getValues('phenomenon'), getValues('locationIndicatorATSR'), productConfig));
7014
- }
7015
- }
7016
- },
7008
+ rules: rules,
7017
7009
  onChange: function onChange() {
7018
7010
  onUserChange == null || onUserChange();
7019
7011
  triggerValidations(['validDateEnd', 'observationOrForecastTime'], getValues, trigger);
7020
7012
  _onChange();
7021
7013
  },
7022
- disabled: isDisabled || isAmending,
7014
+ disabled: isDisabled || lockBecauseActive,
7023
7015
  isReadOnly: isReadOnly,
7024
7016
  "data-testid": "valid-from",
7025
7017
  sx: Object.assign({}, styles$2.helperText, {
@@ -8470,7 +8462,7 @@ var SigmetForm = function SigmetForm(_ref) {
8470
8462
  getTAC = _ref.getTAC,
8471
8463
  storedGeoJSON = _ref.storedGeoJSON,
8472
8464
  storedEndGeoJSON = _ref.storedEndGeoJSON,
8473
- isAmending = _ref.isAmending;
8465
+ lockValidFrom = _ref.lockValidFrom;
8474
8466
  var _useSigmetAirmetTrans = useSigmetAirmetTranslation(),
8475
8467
  t = _useSigmetAirmetTrans.t;
8476
8468
  var _useTACApi = useTACApi(),
@@ -8713,12 +8705,12 @@ var SigmetForm = function SigmetForm(_ref) {
8713
8705
  }) : null, jsx(ValidFrom, {
8714
8706
  productConfig: productConfig,
8715
8707
  isDisabled: isDisabled,
8716
- isAmending: isAmending,
8717
8708
  isReadOnly: isReadOnly,
8718
8709
  onChange: onChangeForm,
8719
8710
  onUserChange: function onUserChange() {
8720
8711
  return setHasUserChangedTime(true);
8721
- }
8712
+ },
8713
+ lockBecauseActive: lockValidFrom
8722
8714
  }), jsx(ValidUntil, {
8723
8715
  productConfig: productConfig,
8724
8716
  isDisabled: isDisabled,
@@ -8872,7 +8864,7 @@ var AirmetForm = function AirmetForm(_ref) {
8872
8864
  product = _ref.product,
8873
8865
  getTAC = _ref.getTAC,
8874
8866
  storedGeoJSON = _ref.storedGeoJSON,
8875
- isAmending = _ref.isAmending;
8867
+ lockValidFrom = _ref.lockValidFrom;
8876
8868
  var _useFormContext2 = useFormContext(),
8877
8869
  watch = _useFormContext2.watch,
8878
8870
  setValue = _useFormContext2.setValue,
@@ -9054,12 +9046,12 @@ var AirmetForm = function AirmetForm(_ref) {
9054
9046
  }), jsx(ValidFrom, {
9055
9047
  productConfig: productConfig,
9056
9048
  isDisabled: isDisabled,
9057
- isAmending: isAmending,
9058
9049
  isReadOnly: isReadOnly,
9059
9050
  onChange: onChangeForm,
9060
9051
  onUserChange: function onUserChange() {
9061
9052
  return setHasUserChangedTime(true);
9062
- }
9053
+ },
9054
+ lockBecauseActive: lockValidFrom
9063
9055
  }), jsx(ValidUntil, {
9064
9056
  productConfig: productConfig,
9065
9057
  isDisabled: isDisabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/sigmet-airmet",
3
- "version": "14.1.0",
3
+ "version": "14.2.1",
4
4
  "description": "GeoWeb Sigmet/Airmet library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,17 +8,17 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/api": "14.1.0",
12
- "@opengeoweb/shared": "14.1.0",
13
- "@opengeoweb/theme": "14.1.0",
14
- "@opengeoweb/store": "14.1.0",
15
- "@opengeoweb/webmap": "14.1.0",
16
- "@opengeoweb/webmap-react": "14.1.0",
11
+ "@opengeoweb/api": "14.2.1",
12
+ "@opengeoweb/shared": "14.2.1",
13
+ "@opengeoweb/theme": "14.2.1",
14
+ "@opengeoweb/store": "14.2.1",
15
+ "@opengeoweb/webmap": "14.2.1",
16
+ "@opengeoweb/webmap-react": "14.2.1",
17
17
  "react-redux": "^9.2.0",
18
- "@opengeoweb/core": "14.1.0",
19
- "@opengeoweb/authentication": "14.1.0",
18
+ "@opengeoweb/core": "14.2.1",
19
+ "@opengeoweb/authentication": "14.2.1",
20
20
  "@mui/system": "^7.3.2",
21
- "@opengeoweb/form-fields": "14.1.0",
21
+ "@opengeoweb/form-fields": "14.2.1",
22
22
  "react-hook-form": "^7.50.1",
23
23
  "axios": "^1.7.7",
24
24
  "lodash": "^4.17.21",
@@ -12,7 +12,7 @@ export interface AirmetFormProps {
12
12
  data: string;
13
13
  }>;
14
14
  storedGeoJSON?: GeoJSON.FeatureCollection;
15
- isAmending?: boolean;
15
+ lockValidFrom?: boolean;
16
16
  }
17
17
  declare const AirmetForm: React.FC<AirmetFormProps>;
18
18
  export default AirmetForm;
@@ -4,7 +4,7 @@ import { ConfigurableFormFieldProps, ProductConfig } from '../../../types';
4
4
  export declare const getValidFromXHoursBeforeMessage: (t: TFunction, hours: number) => string;
5
5
  export declare const getDefaultValidFromValue: (productConfig: ProductConfig) => string;
6
6
  interface ValidFromProps extends ConfigurableFormFieldProps {
7
- isAmending?: boolean;
7
+ lockBecauseActive?: boolean;
8
8
  }
9
9
  declare const ValidFrom: React.FC<ValidFromProps>;
10
10
  export default ValidFrom;
@@ -14,7 +14,7 @@ export interface SigmetFormProps {
14
14
  }>;
15
15
  storedGeoJSON?: GeoJSON.FeatureCollection;
16
16
  storedEndGeoJSON?: GeoJSON.FeatureCollection;
17
- isAmending?: boolean;
17
+ lockValidFrom?: boolean;
18
18
  }
19
19
  declare const SigmetForm: React.FC<SigmetFormProps>;
20
20
  export default SigmetForm;
@@ -2,6 +2,6 @@ import i18n from 'i18next';
2
2
  import { UseTranslationResponse } from 'react-i18next';
3
3
  export declare const SA_NAMESPACE = "sigmetairmet";
4
4
  export declare const initSigmetAirmetI18n: () => void;
5
- export declare const translateKeyOutsideComponents: (key: string, params?: Record<string, string | number> | undefined) => string;
5
+ export declare const translateInTestsAndStories: (key: string, params?: Record<string, string | number> | undefined) => string;
6
6
  export declare const useSigmetAirmetTranslation: () => UseTranslationResponse<typeof SA_NAMESPACE, typeof i18n>;
7
7
  export { i18n };