@opengeoweb/sigmet-airmet 9.26.0 → 9.27.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
|
@@ -2957,9 +2957,6 @@ const getMaxHoursOfValidity = (phenomenon, fir, config) => {
|
|
|
2957
2957
|
const getValidFromDelayTimeMinutesFromConfig = config => {
|
|
2958
2958
|
return config.valid_from_delay_minutes;
|
|
2959
2959
|
};
|
|
2960
|
-
const getDefaultValidityMinutesFromConfig = config => {
|
|
2961
|
-
return config.default_validity_minutes;
|
|
2962
|
-
};
|
|
2963
2960
|
const getOmitChangeFromConfig = config => {
|
|
2964
2961
|
return config.omit_change_va_and_rdoact_cloud === true;
|
|
2965
2962
|
};
|
|
@@ -4798,9 +4795,16 @@ const getValidFromXHoursBeforeMessage = hours => translateKeyOutsideComponents('
|
|
|
4798
4795
|
});
|
|
4799
4796
|
const getDefaultValidFromValue = productConfig => {
|
|
4800
4797
|
const validFromDelayTimeMinutes = getValidFromDelayTimeMinutesFromConfig(productConfig);
|
|
4801
|
-
|
|
4798
|
+
const dateWithDelay = dateUtils.add(dateUtils.utc(), {
|
|
4802
4799
|
minutes: validFromDelayTimeMinutes
|
|
4803
|
-
})
|
|
4800
|
+
});
|
|
4801
|
+
const minutes = dateWithDelay.getUTCMinutes();
|
|
4802
|
+
// Calculate the minutes needed to round up to the next half hour
|
|
4803
|
+
const extraMinutes = minutes <= 30 ? 30 - minutes : 60 - minutes;
|
|
4804
|
+
const roundedDate = dateUtils.add(dateWithDelay, {
|
|
4805
|
+
minutes: extraMinutes
|
|
4806
|
+
});
|
|
4807
|
+
return dateUtils.dateToString(roundedDate);
|
|
4804
4808
|
};
|
|
4805
4809
|
const ValidFrom = ({
|
|
4806
4810
|
productConfig,
|
|
@@ -4849,12 +4853,16 @@ const ValidFrom = ({
|
|
|
4849
4853
|
}));
|
|
4850
4854
|
};
|
|
4851
4855
|
|
|
4852
|
-
const getDefaultValidUntilValue = productConfig => {
|
|
4853
|
-
const
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4856
|
+
const getDefaultValidUntilValue = (productConfig, phenomenon, fir, validFrom) => {
|
|
4857
|
+
const maxHoursOfValidity = getMaxHoursOfValidity(phenomenon, fir || '', productConfig);
|
|
4858
|
+
// Set default validity to 2 hours for thunderstorms, otherwise use maxHoursOfValidity
|
|
4859
|
+
const defaultHoursOfValidity = ['EMBD_TS', 'EMBD_TSGR', 'FRQ_TS', 'FRQ_TSGR', 'OBSC_TS', 'OBSC_TSGR', 'SQL_TSGR', 'ISOL_TS', 'ISOL_TSGR', 'OCNL_TS', 'OCNL_TSGR'].includes(phenomenon) ? 2 : maxHoursOfValidity;
|
|
4860
|
+
// Use validFrom if provided, otherwise use current UTC time
|
|
4861
|
+
const baseDate = validFrom ? new Date(validFrom) : dateUtils.utc();
|
|
4862
|
+
const dateWithValidity = dateUtils.add(baseDate, {
|
|
4863
|
+
hours: defaultHoursOfValidity
|
|
4864
|
+
});
|
|
4865
|
+
return dateUtils.dateToString(dateWithValidity);
|
|
4858
4866
|
};
|
|
4859
4867
|
const ValidUntil = ({
|
|
4860
4868
|
productConfig,
|
|
@@ -4867,13 +4875,33 @@ const ValidUntil = ({
|
|
|
4867
4875
|
} = useSigmetAirmetTranslation();
|
|
4868
4876
|
const {
|
|
4869
4877
|
getValues,
|
|
4870
|
-
trigger
|
|
4878
|
+
trigger,
|
|
4879
|
+
watch,
|
|
4880
|
+
setValue
|
|
4871
4881
|
} = useFormContext();
|
|
4872
4882
|
const {
|
|
4873
4883
|
isRequired
|
|
4874
4884
|
} = useDraftFormHelpers();
|
|
4875
4885
|
const dateAndTime = t('date-and-time');
|
|
4876
4886
|
const label = getFieldLabel(dateAndTime, isReadOnly);
|
|
4887
|
+
const [defaultValidUntilValue, setDefaultValidUntilValue] = React__default.useState(getDefaultValidUntilValue(productConfig, getValues('phenomenon'), getValues('locationIndicatorATSR'), getValues('validDateStart')));
|
|
4888
|
+
const phenomenon = watch('phenomenon');
|
|
4889
|
+
const locationIndicatorATSR = watch('locationIndicatorATSR');
|
|
4890
|
+
const validFrom = watch('validDateStart');
|
|
4891
|
+
React__default.useEffect(() => {
|
|
4892
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
4893
|
+
const updateValues = () => {
|
|
4894
|
+
const newDefaultValidUntilValue = getDefaultValidUntilValue(productConfig, phenomenon, locationIndicatorATSR, validFrom);
|
|
4895
|
+
if (newDefaultValidUntilValue !== defaultValidUntilValue) {
|
|
4896
|
+
setDefaultValidUntilValue(newDefaultValidUntilValue);
|
|
4897
|
+
setValue('validDateEnd', newDefaultValidUntilValue, {
|
|
4898
|
+
shouldValidate: false
|
|
4899
|
+
});
|
|
4900
|
+
trigger('validDateEnd');
|
|
4901
|
+
}
|
|
4902
|
+
};
|
|
4903
|
+
updateValues();
|
|
4904
|
+
}, [phenomenon, locationIndicatorATSR, validFrom, setValue, productConfig, trigger, defaultValidUntilValue]);
|
|
4877
4905
|
return jsx(ProductFormFieldLayout, Object.assign({
|
|
4878
4906
|
title: t('valid-until')
|
|
4879
4907
|
}, {
|
|
@@ -4881,14 +4909,12 @@ const ValidUntil = ({
|
|
|
4881
4909
|
disablePast: true,
|
|
4882
4910
|
name: "validDateEnd",
|
|
4883
4911
|
label: label,
|
|
4884
|
-
defaultNullValue:
|
|
4912
|
+
defaultNullValue: defaultValidUntilValue,
|
|
4885
4913
|
rules: {
|
|
4886
4914
|
validate: {
|
|
4887
4915
|
isRequired,
|
|
4888
4916
|
isValidDate: dateUtils.isValidIsoDateString,
|
|
4889
|
-
// Validity end has to be after validity start
|
|
4890
4917
|
isAfter: value => value ? dateUtils.isAfter(value, getValues('validDateStart')) || t('valid-until-time') : true,
|
|
4891
|
-
// Validity end can be no more than 4 hours after validity start (6 for VA/TC SIGMET)
|
|
4892
4918
|
isXHoursAfter: value => isXHoursAfter(value, getValues('validDateStart'), getMaxHoursOfValidity(getValues('phenomenon'), getValues('locationIndicatorATSR'), productConfig)) || t('valid-until-time-error', {
|
|
4893
4919
|
hours: getMaxHoursOfValidity(getValues('phenomenon'), getValues('locationIndicatorATSR'), productConfig)
|
|
4894
4920
|
})
|
|
@@ -4897,11 +4923,13 @@ const ValidUntil = ({
|
|
|
4897
4923
|
disabled: isDisabled,
|
|
4898
4924
|
isReadOnly: isReadOnly,
|
|
4899
4925
|
onChange: () => {
|
|
4926
|
+
// Trigger validation after any change
|
|
4900
4927
|
triggerValidations(['validDateStart', 'observationOrForecastTime'], getValues, trigger);
|
|
4901
4928
|
_onChange();
|
|
4902
4929
|
},
|
|
4930
|
+
"data-testid": "valid-until",
|
|
4903
4931
|
sx: styles$2.helperText
|
|
4904
|
-
})
|
|
4932
|
+
}, defaultValidUntilValue)
|
|
4905
4933
|
}));
|
|
4906
4934
|
};
|
|
4907
4935
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/sigmet-airmet",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.27.0",
|
|
4
4
|
"description": "GeoWeb Sigmet/Airmet library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"react-i18next": "^14.1.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"react": "18"
|
|
33
|
+
"react": "18",
|
|
34
|
+
"@emotion/react": "*",
|
|
35
|
+
"@emotion/styled": "*"
|
|
34
36
|
},
|
|
35
37
|
"module": "./index.esm.js",
|
|
36
38
|
"type": "module",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ConfigurableFormFieldProps, ProductConfig } from '../../../types';
|
|
3
|
-
export declare const getDefaultValidUntilValue: (productConfig: ProductConfig) => string;
|
|
3
|
+
export declare const getDefaultValidUntilValue: (productConfig: ProductConfig, phenomenon?: string, fir?: string, validFrom?: string) => string;
|
|
4
4
|
declare const ValidUntil: React.FC<ConfigurableFormFieldProps>;
|
|
5
5
|
export default ValidUntil;
|