@dartech/arsenal-ui 1.3.95 → 1.3.96
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 +26 -32
- package/package.json +1 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/BooleanValueField.d.ts +3 -2
- package/src/lib/Property/UpsertProperty/PropertyValueField/DateTimeValueField.d.ts +0 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/DateValueField.d.ts +0 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/JsonValueField.d.ts +0 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/StringValueField.d.ts +3 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/TimeValueField.d.ts +0 -1
- package/src/lib/Property/ViewProperty/PropertyItem.d.ts +0 -1
package/index.js
CHANGED
@@ -1047,15 +1047,25 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1047
1047
|
parseValue
|
1048
1048
|
} = _a,
|
1049
1049
|
otherProps = __rest(_a, ["control", "name", "mode", "label", "width", "height", "readOnly", "required", "validateJson", "hideErrorMessage", "fontSize", "validate", "parseValue"]);
|
1050
|
-
const {
|
1051
|
-
setError,
|
1052
|
-
clearErrors
|
1053
|
-
} = useFormContext();
|
1054
1050
|
const _b = useController({
|
1055
1051
|
control,
|
1056
1052
|
name,
|
1057
1053
|
rules: {
|
1058
|
-
required: required && 'Please, fill this field'
|
1054
|
+
required: required && 'Please, fill this field',
|
1055
|
+
validate: val => {
|
1056
|
+
console.log('_____', val);
|
1057
|
+
if (val && validateJson) {
|
1058
|
+
try {
|
1059
|
+
JSON.parse(val);
|
1060
|
+
return true;
|
1061
|
+
// clearErrors(name);
|
1062
|
+
} catch (error) {
|
1063
|
+
console.error(error);
|
1064
|
+
return 'Invalid JSON';
|
1065
|
+
}
|
1066
|
+
}
|
1067
|
+
return true;
|
1068
|
+
}
|
1059
1069
|
}
|
1060
1070
|
}),
|
1061
1071
|
_c = _b.field,
|
@@ -1070,30 +1080,13 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1070
1080
|
error
|
1071
1081
|
}
|
1072
1082
|
} = _b;
|
1083
|
+
console.log(error);
|
1073
1084
|
const extensions = useMemo(() => ({
|
1074
1085
|
json: [langs.json()],
|
1075
1086
|
javascript: [langs.javascript()],
|
1076
1087
|
python: [langs.python()]
|
1077
1088
|
}), []);
|
1078
1089
|
const handleChange = useCallback(value => {
|
1079
|
-
if (!value && required) {
|
1080
|
-
setError(name, {
|
1081
|
-
message: 'Required field'
|
1082
|
-
});
|
1083
|
-
} else {
|
1084
|
-
clearErrors(name);
|
1085
|
-
}
|
1086
|
-
if (validateJson) {
|
1087
|
-
try {
|
1088
|
-
JSON.parse(value);
|
1089
|
-
clearErrors(name);
|
1090
|
-
} catch (error) {
|
1091
|
-
console.error(error);
|
1092
|
-
setError(name, {
|
1093
|
-
message: 'Invalid JSON'
|
1094
|
-
});
|
1095
|
-
}
|
1096
|
-
}
|
1097
1090
|
if (parseValue) {
|
1098
1091
|
try {
|
1099
1092
|
const val = JSON.parse(value);
|
@@ -1104,7 +1097,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1104
1097
|
} else {
|
1105
1098
|
onChange(value);
|
1106
1099
|
}
|
1107
|
-
}, [
|
1100
|
+
}, [onChange, parseValue]);
|
1108
1101
|
return jsxs(Box, Object.assign({
|
1109
1102
|
display: "flex",
|
1110
1103
|
flexDirection: "column",
|
@@ -3684,14 +3677,12 @@ const PropertyAdditionalFields = ({
|
|
3684
3677
|
};
|
3685
3678
|
|
3686
3679
|
const StringValueField = ({
|
3680
|
+
control,
|
3687
3681
|
name,
|
3688
3682
|
label,
|
3689
3683
|
required,
|
3690
3684
|
restrictedValues
|
3691
3685
|
}) => {
|
3692
|
-
const {
|
3693
|
-
control
|
3694
|
-
} = useFormContext();
|
3695
3686
|
const {
|
3696
3687
|
field: {
|
3697
3688
|
onChange,
|
@@ -3910,6 +3901,7 @@ const PropertyWidget = ({
|
|
3910
3901
|
});
|
3911
3902
|
case PropertyType.STRING:
|
3912
3903
|
return jsx(StringValueField$1, {
|
3904
|
+
control: control,
|
3913
3905
|
name: name,
|
3914
3906
|
label: label,
|
3915
3907
|
restrictedValues: property.restrictedValues
|
@@ -3923,7 +3915,8 @@ const PropertyWidget = ({
|
|
3923
3915
|
} else {
|
3924
3916
|
return jsx(StringValueField$1, {
|
3925
3917
|
name: name,
|
3926
|
-
label: label
|
3918
|
+
label: label,
|
3919
|
+
control: control
|
3927
3920
|
});
|
3928
3921
|
}
|
3929
3922
|
case PropertyType.FILE:
|
@@ -3938,7 +3931,8 @@ const PropertyWidget = ({
|
|
3938
3931
|
} else {
|
3939
3932
|
return jsx(StringValueField$1, {
|
3940
3933
|
name: name,
|
3941
|
-
label: label
|
3934
|
+
label: label,
|
3935
|
+
control: control
|
3942
3936
|
});
|
3943
3937
|
}
|
3944
3938
|
case PropertyType.ANY:
|
@@ -5168,8 +5162,10 @@ const CreatePropertiesList = /*#__PURE__*/forwardRef(({
|
|
5168
5162
|
control,
|
5169
5163
|
setValue,
|
5170
5164
|
getValues,
|
5171
|
-
reset
|
5165
|
+
reset,
|
5166
|
+
trigger
|
5172
5167
|
} = useForm({
|
5168
|
+
mode: 'all',
|
5173
5169
|
defaultValues: {
|
5174
5170
|
properties
|
5175
5171
|
}
|
@@ -5196,8 +5192,6 @@ const CreatePropertiesList = /*#__PURE__*/forwardRef(({
|
|
5196
5192
|
}
|
5197
5193
|
}
|
5198
5194
|
});
|
5199
|
-
// console.log(watch());
|
5200
|
-
// const properties = useWatch({ control, name: fieldName });
|
5201
5195
|
const refs = useRef([]);
|
5202
5196
|
const handleAddParameter = useCallback(() => {
|
5203
5197
|
append(defaultPropertyValues);
|
package/package.json
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
import { Control } from 'react-hook-form';
|
2
2
|
type Props = {
|
3
|
+
control: Control<any>;
|
3
4
|
name: string;
|
4
5
|
label?: string;
|
5
6
|
};
|
6
|
-
declare const BooleanValueField: ({ name, label }: Props) => JSX.Element;
|
7
|
+
declare const BooleanValueField: ({ name, label, control }: Props) => JSX.Element;
|
7
8
|
export default BooleanValueField;
|
@@ -1,10 +1,12 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
+
import { Control } from 'react-hook-form';
|
2
3
|
type Props = {
|
4
|
+
control: Control<any>;
|
3
5
|
name: string;
|
4
6
|
label?: string;
|
5
7
|
required?: boolean;
|
6
8
|
restrictedValues?: string[];
|
7
9
|
urlValidate?: boolean;
|
8
10
|
};
|
9
|
-
declare const StringValueField: ({ name, label, required, restrictedValues, }: Props) => JSX.Element;
|
11
|
+
declare const StringValueField: ({ control, name, label, required, restrictedValues, }: Props) => JSX.Element;
|
10
12
|
export default StringValueField;
|