@dartech/arsenal-ui 1.3.40 → 1.3.42
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.js +35 -13
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1979,6 +1979,7 @@ const ControlDate = ({
|
|
1979
1979
|
format: _format = DATE_DEFAULT_FORMAT,
|
1980
1980
|
hideErrorMessage: _hideErrorMessage = false
|
1981
1981
|
}) => {
|
1982
|
+
const [localFormat, setLocalFormat] = useState(DATE_DEFAULT_FORMAT);
|
1982
1983
|
const {
|
1983
1984
|
field,
|
1984
1985
|
fieldState: {
|
@@ -1990,7 +1991,7 @@ const ControlDate = ({
|
|
1990
1991
|
rules: {
|
1991
1992
|
required: required && 'Please, fill this field',
|
1992
1993
|
validate: val => {
|
1993
|
-
if (isMatch(val,
|
1994
|
+
if (isMatch(val, localFormat)) {
|
1994
1995
|
return true;
|
1995
1996
|
}
|
1996
1997
|
return 'Incorrect date format';
|
@@ -1998,16 +1999,25 @@ const ControlDate = ({
|
|
1998
1999
|
}
|
1999
2000
|
});
|
2000
2001
|
const handleChange = useCallback(date => {
|
2001
|
-
field.onChange(isValid(date) ? format(date,
|
2002
|
-
}, [field,
|
2002
|
+
field.onChange(isValid(date) ? format(date, localFormat) : date);
|
2003
|
+
}, [field, localFormat]);
|
2004
|
+
useEffect(() => {
|
2005
|
+
const fixedTimeZone = _format.replace(/[Z,z,x]+/g, 'XX');
|
2006
|
+
try {
|
2007
|
+
isMatch(format(new Date(), fixedTimeZone), fixedTimeZone);
|
2008
|
+
setLocalFormat(fixedTimeZone);
|
2009
|
+
} catch (e) {
|
2010
|
+
console.error(e);
|
2011
|
+
}
|
2012
|
+
}, [_format]);
|
2003
2013
|
return jsx(DatePicker, Object.assign({}, field, {
|
2004
2014
|
label: required ? jsxs(Fragment, {
|
2005
2015
|
children: [label, " ", jsx("span", {
|
2006
2016
|
children: "*"
|
2007
2017
|
})]
|
2008
2018
|
}) : label,
|
2009
|
-
inputFormat:
|
2010
|
-
value:
|
2019
|
+
inputFormat: localFormat,
|
2020
|
+
value: localFormat ? parse(field.value, localFormat, new Date()) : field.value,
|
2011
2021
|
onChange: handleChange,
|
2012
2022
|
renderInput: props => jsx(TextField, Object.assign({}, props, {
|
2013
2023
|
fullWidth: true,
|
@@ -2033,6 +2043,7 @@ const ControlDateTime = ({
|
|
2033
2043
|
format: _format = DATE_TIME_DEFAULT_FORMAT,
|
2034
2044
|
hideErrorMessage: _hideErrorMessage = false
|
2035
2045
|
}) => {
|
2046
|
+
const [localFormat, setLocalFormat] = useState(DATE_TIME_DEFAULT_FORMAT);
|
2036
2047
|
const {
|
2037
2048
|
field,
|
2038
2049
|
fieldState: {
|
@@ -2044,7 +2055,7 @@ const ControlDateTime = ({
|
|
2044
2055
|
rules: {
|
2045
2056
|
required: required && 'Please, fill this field',
|
2046
2057
|
validate: val => {
|
2047
|
-
if (isMatch(val,
|
2058
|
+
if (isMatch(val, localFormat)) {
|
2048
2059
|
return true;
|
2049
2060
|
}
|
2050
2061
|
return 'Incorrect date format';
|
@@ -2052,8 +2063,17 @@ const ControlDateTime = ({
|
|
2052
2063
|
}
|
2053
2064
|
});
|
2054
2065
|
const handleChange = useCallback(date => {
|
2055
|
-
field.onChange(isValid(date) ? format(date,
|
2056
|
-
}, [field,
|
2066
|
+
field.onChange(isValid(date) ? format(date, localFormat) : date);
|
2067
|
+
}, [field, localFormat]);
|
2068
|
+
useEffect(() => {
|
2069
|
+
const fixedTimeZone = _format.replace(/[Z,z,x]+/g, 'XX');
|
2070
|
+
try {
|
2071
|
+
isMatch(format(new Date(), fixedTimeZone), fixedTimeZone);
|
2072
|
+
setLocalFormat(fixedTimeZone);
|
2073
|
+
} catch (e) {
|
2074
|
+
console.error(e);
|
2075
|
+
}
|
2076
|
+
}, [_format]);
|
2057
2077
|
return jsx(DateTimePicker, Object.assign({}, field, {
|
2058
2078
|
ampm: false,
|
2059
2079
|
label: required ? jsxs(Fragment, {
|
@@ -2061,8 +2081,8 @@ const ControlDateTime = ({
|
|
2061
2081
|
children: "*"
|
2062
2082
|
})]
|
2063
2083
|
}) : label,
|
2064
|
-
value:
|
2065
|
-
inputFormat:
|
2084
|
+
value: localFormat ? parse(field.value, localFormat, new Date()) : field.value,
|
2085
|
+
inputFormat: localFormat,
|
2066
2086
|
onChange: handleChange,
|
2067
2087
|
renderInput: props => jsx(TextField, Object.assign({}, props, {
|
2068
2088
|
fullWidth: true,
|
@@ -3882,12 +3902,14 @@ const PropertyFiller = ({
|
|
3882
3902
|
required,
|
3883
3903
|
useExpression
|
3884
3904
|
});
|
3885
|
-
const handleFillOptionChange = event => {
|
3905
|
+
const handleFillOptionChange = useCallback(event => {
|
3886
3906
|
const selectedType = event.target.value;
|
3887
3907
|
if (selectedType === 'null') {
|
3888
|
-
onChange(null);
|
3908
|
+
// onChange(null);
|
3909
|
+
clearErrors(name);
|
3889
3910
|
// register(name, { value: null });
|
3890
3911
|
} else if (selectedType === 'widget') {
|
3912
|
+
clearErrors(name);
|
3891
3913
|
if (propertyType === PropertyType.JSON && value && typeof value !== 'string' && fillOption === 'dem_builder' && 'properties' in value) {
|
3892
3914
|
const definitionValue = Object.assign(Object.assign({}, value), {
|
3893
3915
|
properties: propertiesArrayToObject(value.property || [])
|
@@ -3924,7 +3946,7 @@ const PropertyFiller = ({
|
|
3924
3946
|
}
|
3925
3947
|
setFillOption(selectedType);
|
3926
3948
|
clearErrors(name);
|
3927
|
-
};
|
3949
|
+
}, [name, clearErrors, value, setFillOption, onChange, fillOption, propertyType]);
|
3928
3950
|
useEffect(() => {
|
3929
3951
|
if (value === undefined) {
|
3930
3952
|
onChange(null);
|