@dartech/arsenal-ui 1.4.5 → 1.4.6
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 +19 -28
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1054,8 +1054,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1054
1054
|
rules: {
|
1055
1055
|
required: required && 'Please, fill this field',
|
1056
1056
|
validate: val => {
|
1057
|
-
|
1058
|
-
if (val && validateJson) {
|
1057
|
+
if (val && validateJson && typeof val === 'string') {
|
1059
1058
|
try {
|
1060
1059
|
JSON.parse(val);
|
1061
1060
|
return true;
|
@@ -1112,7 +1111,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1112
1111
|
}
|
1113
1112
|
}, {
|
1114
1113
|
children: required ? jsxs(Fragment, {
|
1115
|
-
children: [label,
|
1114
|
+
children: [label, ' ', jsx(Box, Object.assign({
|
1116
1115
|
component: "span",
|
1117
1116
|
color: "#D6331F"
|
1118
1117
|
}, {
|
@@ -5816,11 +5815,12 @@ const PropertyFiller = ({
|
|
5816
5815
|
const {
|
5817
5816
|
control,
|
5818
5817
|
clearErrors,
|
5819
|
-
setValue
|
5820
|
-
watch
|
5818
|
+
setValue
|
5821
5819
|
} = useFormContext();
|
5822
5820
|
const {
|
5823
|
-
|
5821
|
+
field: {
|
5822
|
+
value
|
5823
|
+
},
|
5824
5824
|
fieldState: {
|
5825
5825
|
error,
|
5826
5826
|
isDirty
|
@@ -5835,11 +5835,6 @@ const PropertyFiller = ({
|
|
5835
5835
|
}
|
5836
5836
|
}
|
5837
5837
|
});
|
5838
|
-
// const value = watch(name);
|
5839
|
-
const value = useWatch({
|
5840
|
-
control,
|
5841
|
-
name
|
5842
|
-
});
|
5843
5838
|
const prevValueRef = useRef({});
|
5844
5839
|
const {
|
5845
5840
|
propertyType,
|
@@ -5913,26 +5908,22 @@ const PropertyFiller = ({
|
|
5913
5908
|
clearErrors();
|
5914
5909
|
}, [name, defaultProperyValue, clearErrors, value, setFillOption, fillOption, propertyType, setValue, property]);
|
5915
5910
|
useEffect(() => {
|
5916
|
-
|
5917
|
-
|
5918
|
-
|
5919
|
-
|
5911
|
+
var _a;
|
5912
|
+
if (!isDirty && isPropertyValueEmpty(value)) {
|
5913
|
+
if (property.isRequired && (property.defaultValue === null || property.value === null)) {
|
5914
|
+
setValue(name, (_a = prevValueRef.current[fillOption]) !== null && _a !== void 0 ? _a : defaultProperyValue);
|
5915
|
+
} else if (!property.isRequired && (property.defaultValue === null || property.value === null)) {
|
5916
|
+
setValue(name, null);
|
5917
|
+
} else if (!(isPropertyValueEmpty(property.defaultValue) || isPropertyValueEmpty(property.value))) {
|
5918
|
+
setValue(name, property.defaultValue || property.value);
|
5919
|
+
}
|
5920
5920
|
}
|
5921
|
-
}, [
|
5921
|
+
}, [value, setValue, defaultProperyValue, property, name, fillOption, isDirty]);
|
5922
5922
|
useEffect(() => {
|
5923
|
-
|
5924
|
-
|
5925
|
-
// value === undefined ||
|
5926
|
-
property.isRequired && isPropertyValueEmpty(value) && (property.defaultValue === null || property.value === null)) {
|
5927
|
-
setValue(name, (_a = prevValueRef.current[fillOption]) !== null && _a !== void 0 ? _a : defaultProperyValue, {
|
5928
|
-
shouldDirty: true
|
5929
|
-
});
|
5930
|
-
} else if ((value === undefined || value === null) && !property.isRequired && (property.defaultValue === null || property.value === null)) {
|
5931
|
-
setValue(name, null, {
|
5932
|
-
shouldDirty: true
|
5933
|
-
});
|
5923
|
+
if (!isPropertyValueEmpty(value) && property.propertyType !== PropertyType.JSON) {
|
5924
|
+
setValue(name, value);
|
5934
5925
|
}
|
5935
|
-
}, [
|
5926
|
+
}, [name, setValue, value, property]);
|
5936
5927
|
return jsxs(Grid, Object.assign({
|
5937
5928
|
xs: 12
|
5938
5929
|
}, {
|