@dartech/arsenal-ui 1.3.57 → 1.3.58
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
CHANGED
@@ -216,7 +216,6 @@ const AlertDialog = ({
|
|
216
216
|
* @category Forms
|
217
217
|
*/
|
218
218
|
const ControlInput = _a => {
|
219
|
-
var _b;
|
220
219
|
var {
|
221
220
|
control,
|
222
221
|
validate,
|
@@ -233,7 +232,8 @@ const ControlInput = _a => {
|
|
233
232
|
const {
|
234
233
|
field: {
|
235
234
|
ref,
|
236
|
-
onChange
|
235
|
+
onChange,
|
236
|
+
value
|
237
237
|
},
|
238
238
|
fieldState: {
|
239
239
|
error
|
@@ -247,10 +247,6 @@ const ControlInput = _a => {
|
|
247
247
|
validate
|
248
248
|
}
|
249
249
|
});
|
250
|
-
const value = useWatch({
|
251
|
-
control,
|
252
|
-
name
|
253
|
-
});
|
254
250
|
return jsx(TextField, Object.assign({
|
255
251
|
fullWidth: true,
|
256
252
|
size: "small",
|
@@ -275,11 +271,7 @@ const ControlInput = _a => {
|
|
275
271
|
minRows: textarea ? 3 : 1,
|
276
272
|
value: value !== null && value !== void 0 ? value : '',
|
277
273
|
onChange: customOnChange ? customOnChange : onChange
|
278
|
-
}, textFieldProps
|
279
|
-
inputProps: Object.assign(Object.assign({}, (_b = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputProps) !== null && _b !== void 0 ? _b : {}), {
|
280
|
-
value: value !== null && value !== void 0 ? value : ''
|
281
|
-
})
|
282
|
-
}));
|
274
|
+
}, textFieldProps));
|
283
275
|
};
|
284
276
|
|
285
277
|
function useDebounce(func, delay) {
|
@@ -1036,30 +1028,33 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1036
1028
|
readOnly,
|
1037
1029
|
required = false,
|
1038
1030
|
validateJson = false,
|
1031
|
+
hideErrorMessage = false,
|
1039
1032
|
fontSize = 16,
|
1040
1033
|
validate = true,
|
1041
1034
|
parseValue
|
1042
1035
|
} = _a,
|
1043
|
-
otherProps = __rest(_a, ["control", "name", "mode", "label", "width", "height", "readOnly", "required", "validateJson", "fontSize", "validate", "parseValue"]);
|
1036
|
+
otherProps = __rest(_a, ["control", "name", "mode", "label", "width", "height", "readOnly", "required", "validateJson", "hideErrorMessage", "fontSize", "validate", "parseValue"]);
|
1044
1037
|
const {
|
1045
1038
|
setError,
|
1046
1039
|
clearErrors
|
1047
1040
|
} = useFormContext();
|
1048
1041
|
const {
|
1049
1042
|
field: {
|
1050
|
-
onChange
|
1043
|
+
onChange,
|
1044
|
+
value,
|
1045
|
+
ref: fromRef
|
1051
1046
|
},
|
1052
1047
|
fieldState: {
|
1053
1048
|
error
|
1054
1049
|
}
|
1055
1050
|
} = useController({
|
1056
1051
|
control,
|
1057
|
-
name
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
name
|
1052
|
+
name,
|
1053
|
+
rules: {
|
1054
|
+
required: required && 'Please, fill this field'
|
1055
|
+
}
|
1062
1056
|
});
|
1057
|
+
// const value = useWatch({ control, name });
|
1063
1058
|
const extensions = useMemo(() => ({
|
1064
1059
|
json: [langs.json()],
|
1065
1060
|
javascript: [langs.javascript()],
|
@@ -1118,7 +1113,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1118
1113
|
}))
|
1119
1114
|
}), jsxs(Fragment, {
|
1120
1115
|
children: [jsx(CodeMirror, Object.assign({
|
1121
|
-
ref: ref,
|
1116
|
+
ref: ref || fromRef,
|
1122
1117
|
basicSetup: {
|
1123
1118
|
autocompletion: true,
|
1124
1119
|
history: true
|
@@ -1136,7 +1131,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1136
1131
|
value: mode === 'json' && typeof value !== 'string' ? value === null ? '' : JSON.stringify(value, null, 2) : value,
|
1137
1132
|
onChange: handleChange,
|
1138
1133
|
extensions: extensions[mode]
|
1139
|
-
}, otherProps)), error && jsx(FormHelperText, Object.assign({
|
1134
|
+
}, otherProps)), error && !hideErrorMessage && jsx(FormHelperText, Object.assign({
|
1140
1135
|
error: true
|
1141
1136
|
}, {
|
1142
1137
|
children: error.message
|
@@ -3579,12 +3574,11 @@ const PropertyAdditionalFields = ({
|
|
3579
3574
|
}
|
3580
3575
|
};
|
3581
3576
|
|
3582
|
-
const JsonEditor = ({
|
3577
|
+
const JsonEditor = /*#__PURE__*/forwardRef(({
|
3583
3578
|
validate: _validate = false,
|
3584
3579
|
name,
|
3585
|
-
inputRef,
|
3586
3580
|
useParsedValue
|
3587
|
-
}) => {
|
3581
|
+
}, ref) => {
|
3588
3582
|
const {
|
3589
3583
|
control,
|
3590
3584
|
setValue,
|
@@ -3606,7 +3600,7 @@ const JsonEditor = ({
|
|
3606
3600
|
}
|
3607
3601
|
};
|
3608
3602
|
return jsx(CodeMirror, {
|
3609
|
-
ref:
|
3603
|
+
ref: ref,
|
3610
3604
|
basicSetup: {
|
3611
3605
|
autocompletion: true,
|
3612
3606
|
history: true
|
@@ -3624,7 +3618,7 @@ const JsonEditor = ({
|
|
3624
3618
|
onChange: handleChange,
|
3625
3619
|
extensions: [langs.json()]
|
3626
3620
|
});
|
3627
|
-
};
|
3621
|
+
});
|
3628
3622
|
var JsonEditor$1 = JsonEditor;
|
3629
3623
|
|
3630
3624
|
const StringValueField = ({
|
@@ -3759,7 +3753,7 @@ const PropertyWidget = ({
|
|
3759
3753
|
return jsx(JsonEditor$1, {
|
3760
3754
|
validate: true,
|
3761
3755
|
name: name,
|
3762
|
-
|
3756
|
+
ref: inputRef,
|
3763
3757
|
useParsedValue: true
|
3764
3758
|
});
|
3765
3759
|
case PropertyType.STRING:
|
@@ -3780,7 +3774,7 @@ const PropertyWidget = ({
|
|
3780
3774
|
case PropertyType.ANY:
|
3781
3775
|
return jsx(JsonEditor$1, {
|
3782
3776
|
name: name,
|
3783
|
-
|
3777
|
+
ref: inputRef
|
3784
3778
|
});
|
3785
3779
|
case PropertyType.ENTITY:
|
3786
3780
|
return jsx(DefinitionFiller, {
|
@@ -3806,7 +3800,10 @@ const usePropertyFiller = ({
|
|
3806
3800
|
}) => {
|
3807
3801
|
const valueLabel = useMemo(() => label ? `${label} (value)` : `${property.name} (value)`, [label, property]);
|
3808
3802
|
const fillOptionLabel = useMemo(() => label ? `${label} (widget)` : `${property.name} (widget)`, [label, property]);
|
3809
|
-
const propertyType = useMemo(() =>
|
3803
|
+
const propertyType = useMemo(() => {
|
3804
|
+
var _a;
|
3805
|
+
return typeof property.propertyType === 'string' ? property.propertyType : (_a = property['propertyType']) === null || _a === void 0 ? void 0 : _a['value'];
|
3806
|
+
}, [property]);
|
3810
3807
|
const [fillOption, setFillOption] = useState(null);
|
3811
3808
|
const fillOptions = useMemo(() => _multipleOptions ? getMultiplePropertyFillOptions({
|
3812
3809
|
propertyType,
|
@@ -3817,6 +3814,29 @@ const usePropertyFiller = ({
|
|
3817
3814
|
required: _required,
|
3818
3815
|
useExpression: _useExpression
|
3819
3816
|
}), [_useExpression, _required, propertyType, _multipleOptions]);
|
3817
|
+
const defaultProperyValue = useMemo(() => {
|
3818
|
+
switch (propertyType) {
|
3819
|
+
case PropertyType.STRING:
|
3820
|
+
case PropertyType.DATE:
|
3821
|
+
case PropertyType.TIME:
|
3822
|
+
case PropertyType.DATE_TIME:
|
3823
|
+
case PropertyType.ANY:
|
3824
|
+
return '';
|
3825
|
+
case PropertyType.JSON:
|
3826
|
+
return {};
|
3827
|
+
case PropertyType.BOOLEAN:
|
3828
|
+
return true;
|
3829
|
+
case PropertyType.INTEGER:
|
3830
|
+
case PropertyType.BIG_DECIMAL:
|
3831
|
+
case PropertyType.BIG_INTEGER:
|
3832
|
+
case PropertyType.DOUBLE:
|
3833
|
+
case PropertyType.LONG:
|
3834
|
+
case PropertyType.FLOAT:
|
3835
|
+
return 0;
|
3836
|
+
default:
|
3837
|
+
return {};
|
3838
|
+
}
|
3839
|
+
}, [propertyType]);
|
3820
3840
|
useEffect(() => {
|
3821
3841
|
if (!fillOption) {
|
3822
3842
|
if (isPropertyValueEmpty(value) && (fillOptions === null || fillOptions === void 0 ? void 0 : fillOptions.length)) {
|
@@ -3840,7 +3860,8 @@ const usePropertyFiller = ({
|
|
3840
3860
|
fillOptionLabel,
|
3841
3861
|
fillOption,
|
3842
3862
|
fillOptions,
|
3843
|
-
setFillOption
|
3863
|
+
setFillOption,
|
3864
|
+
defaultProperyValue
|
3844
3865
|
};
|
3845
3866
|
};
|
3846
3867
|
var usePropertyFiller$1 = usePropertyFiller;
|
@@ -3870,7 +3891,8 @@ const PropertyFiller = ({
|
|
3870
3891
|
const {
|
3871
3892
|
field: {
|
3872
3893
|
ref,
|
3873
|
-
onChange
|
3894
|
+
onChange,
|
3895
|
+
value
|
3874
3896
|
},
|
3875
3897
|
fieldState: {
|
3876
3898
|
error,
|
@@ -3883,17 +3905,15 @@ const PropertyFiller = ({
|
|
3883
3905
|
required
|
3884
3906
|
}
|
3885
3907
|
});
|
3886
|
-
const value = useWatch({
|
3887
|
-
control,
|
3888
|
-
name
|
3889
|
-
});
|
3908
|
+
// const value = useWatch({ control, name });
|
3890
3909
|
const {
|
3891
3910
|
propertyType,
|
3892
3911
|
valueLabel,
|
3893
3912
|
fillOptionLabel,
|
3894
3913
|
fillOption,
|
3895
3914
|
fillOptions,
|
3896
|
-
setFillOption
|
3915
|
+
setFillOption,
|
3916
|
+
defaultProperyValue
|
3897
3917
|
} = usePropertyFiller$1({
|
3898
3918
|
value,
|
3899
3919
|
property,
|
@@ -3915,10 +3935,10 @@ const PropertyFiller = ({
|
|
3915
3935
|
try {
|
3916
3936
|
onChange(JSON.stringify(definitionValue, null, '\t'));
|
3917
3937
|
} catch (error) {
|
3918
|
-
console.log('Stringify failed');
|
3938
|
+
console.log('Stringify failed', error);
|
3919
3939
|
}
|
3920
3940
|
} else {
|
3921
|
-
setValue(name,
|
3941
|
+
setValue(name, defaultProperyValue);
|
3922
3942
|
}
|
3923
3943
|
} else if (selectedType === 'expression' || selectedType === 'string') {
|
3924
3944
|
onChange('');
|
@@ -3943,12 +3963,12 @@ const PropertyFiller = ({
|
|
3943
3963
|
}
|
3944
3964
|
}
|
3945
3965
|
clearErrors();
|
3946
|
-
}, [name, clearErrors, value, setFillOption, onChange, fillOption, propertyType, setValue]);
|
3966
|
+
}, [name, defaultProperyValue, clearErrors, value, setFillOption, onChange, fillOption, propertyType, setValue]);
|
3947
3967
|
useEffect(() => {
|
3948
3968
|
if (value === undefined) {
|
3949
3969
|
onChange(null);
|
3950
3970
|
}
|
3951
|
-
}, [value, onChange]);
|
3971
|
+
}, [value, onChange, defaultProperyValue]);
|
3952
3972
|
return jsxs(Grid$1, Object.assign({
|
3953
3973
|
xs: 12
|
3954
3974
|
}, {
|
@@ -3987,13 +4007,21 @@ const PropertyFiller = ({
|
|
3987
4007
|
}))
|
3988
4008
|
})) : null, fillOption === 'expression' && (propertyType === PropertyType.JSON || propertyType === PropertyType.ENTITY || propertyType === PropertyType.ANY ? jsx(JsonEditor$1, {
|
3989
4009
|
name: name,
|
3990
|
-
|
4010
|
+
ref: ref
|
3991
4011
|
}) : jsx(ControlInput, {
|
3992
4012
|
control: control,
|
3993
4013
|
name: name,
|
3994
4014
|
label: valueLabel,
|
3995
4015
|
required: true,
|
3996
|
-
hideErrorMessage: true
|
4016
|
+
hideErrorMessage: true,
|
4017
|
+
onChange: e => {
|
4018
|
+
try {
|
4019
|
+
onChange(JSON.parse(e.target.value));
|
4020
|
+
} catch (err) {
|
4021
|
+
onChange(e.target.value);
|
4022
|
+
}
|
4023
|
+
},
|
4024
|
+
value: typeof value === 'string' ? value : JSON.stringify(value)
|
3997
4025
|
})), fillOption === 'string' && jsx(ControlInput, {
|
3998
4026
|
control: control,
|
3999
4027
|
name: name,
|
@@ -4002,7 +4030,7 @@ const PropertyFiller = ({
|
|
4002
4030
|
hideErrorMessage: true
|
4003
4031
|
}), fillOption === 'json_notvalid' && jsx(JsonEditor$1, {
|
4004
4032
|
name: name,
|
4005
|
-
|
4033
|
+
ref: ref
|
4006
4034
|
}), fillOption === 'widget' && jsx(PropertyWidget, {
|
4007
4035
|
property: property,
|
4008
4036
|
name: name,
|
@@ -4013,8 +4041,8 @@ const PropertyFiller = ({
|
|
4013
4041
|
}), fillOption === 'dem_builder' && jsx(CreateDefinition, {
|
4014
4042
|
title: "JSON",
|
4015
4043
|
definitionFieldName: name
|
4016
|
-
}), error && jsx(
|
4017
|
-
|
4044
|
+
}), error && jsx(FormHelperText, Object.assign({
|
4045
|
+
error: true
|
4018
4046
|
}, {
|
4019
4047
|
children: error.message
|
4020
4048
|
}))]
|
@@ -4033,18 +4061,6 @@ const MultiplePropertyWidget = ({
|
|
4033
4061
|
setValue,
|
4034
4062
|
clearErrors
|
4035
4063
|
} = useFormContext();
|
4036
|
-
// const controller = useController({
|
4037
|
-
// control,
|
4038
|
-
// name,
|
4039
|
-
// rules: {
|
4040
|
-
// validate: (val) => {
|
4041
|
-
// if (!val || (Array.isArray(val) && !val.length)) {
|
4042
|
-
// return 'Please, fill array';
|
4043
|
-
// }
|
4044
|
-
// return true;
|
4045
|
-
// },
|
4046
|
-
// },
|
4047
|
-
// });
|
4048
4064
|
const values = useWatch({
|
4049
4065
|
control,
|
4050
4066
|
name
|
@@ -4053,7 +4069,7 @@ const MultiplePropertyWidget = ({
|
|
4053
4069
|
if (values && Array.isArray(values)) {
|
4054
4070
|
setValue(`${name}.${values.length}`, null);
|
4055
4071
|
} else {
|
4056
|
-
setValue(name, [
|
4072
|
+
setValue(name, []);
|
4057
4073
|
}
|
4058
4074
|
clearErrors(name);
|
4059
4075
|
}, [name, values, setValue, clearErrors]);
|
@@ -4066,7 +4082,7 @@ const MultiplePropertyWidget = ({
|
|
4066
4082
|
direction: "column",
|
4067
4083
|
xs: 12
|
4068
4084
|
}, {
|
4069
|
-
children: [
|
4085
|
+
children: [Array.isArray(values) && values.length ? values.map((value, index) => jsx(Grid$1, Object.assign({
|
4070
4086
|
xs: 12
|
4071
4087
|
}, {
|
4072
4088
|
children: jsxs(Box, Object.assign({
|
@@ -4122,7 +4138,8 @@ const MultiplePropertyFiller = ({
|
|
4122
4138
|
}) => {
|
4123
4139
|
const {
|
4124
4140
|
control,
|
4125
|
-
clearErrors
|
4141
|
+
clearErrors,
|
4142
|
+
setValue
|
4126
4143
|
} = useFormContext();
|
4127
4144
|
const {
|
4128
4145
|
field: {
|
@@ -4136,11 +4153,10 @@ const MultiplePropertyFiller = ({
|
|
4136
4153
|
} = useController({
|
4137
4154
|
control,
|
4138
4155
|
name,
|
4156
|
+
defaultValue: [],
|
4139
4157
|
rules: {
|
4140
4158
|
validate: val => {
|
4141
|
-
if (required && !val)
|
4142
|
-
return 'Please, fill this field';
|
4143
|
-
}
|
4159
|
+
if (required && !val) return 'Please, fill this field';
|
4144
4160
|
return true;
|
4145
4161
|
}
|
4146
4162
|
}
|
@@ -4168,7 +4184,7 @@ const MultiplePropertyFiller = ({
|
|
4168
4184
|
const handleFillOptionChange = event => {
|
4169
4185
|
const selectedType = event.target.value;
|
4170
4186
|
if (selectedType === 'null') {
|
4171
|
-
|
4187
|
+
setValue(name, null);
|
4172
4188
|
} else if (selectedType === 'expression' || selectedType === 'json_valid' || selectedType === 'json_notvalid') {
|
4173
4189
|
onChange('');
|
4174
4190
|
} else if (selectedType === 'widget') {
|
@@ -4177,11 +4193,11 @@ const MultiplePropertyFiller = ({
|
|
4177
4193
|
setFillOption(selectedType);
|
4178
4194
|
clearErrors(name);
|
4179
4195
|
};
|
4180
|
-
useEffect(() => {
|
4181
|
-
|
4182
|
-
|
4183
|
-
|
4184
|
-
}, [value, onChange]);
|
4196
|
+
// useEffect(() => {
|
4197
|
+
// if (value === undefined) {
|
4198
|
+
// onChange([]);
|
4199
|
+
// }
|
4200
|
+
// }, [value, property, onChange]);
|
4185
4201
|
return jsxs(Grid$1, {
|
4186
4202
|
children: [title && jsx(Box, Object.assign({
|
4187
4203
|
mb: 2
|
@@ -4218,7 +4234,7 @@ const MultiplePropertyFiller = ({
|
|
4218
4234
|
}))
|
4219
4235
|
})) : null, fillOption === 'expression' && (propertyType === PropertyType.JSON || propertyType === PropertyType.ENTITY || propertyType === PropertyType.ANY ? jsx(JsonEditor$1, {
|
4220
4236
|
name: name,
|
4221
|
-
|
4237
|
+
ref: ref
|
4222
4238
|
}) : jsx(ControlInput, {
|
4223
4239
|
required: true,
|
4224
4240
|
hideErrorMessage: true,
|
@@ -4228,7 +4244,7 @@ const MultiplePropertyFiller = ({
|
|
4228
4244
|
})), fillOption === 'json_valid' && jsx(JsonEditor$1, {
|
4229
4245
|
validate: true,
|
4230
4246
|
name: name,
|
4231
|
-
|
4247
|
+
ref: ref,
|
4232
4248
|
useParsedValue: true
|
4233
4249
|
}), fillOption === 'widget' && jsx(MultiplePropertyWidget$1, {
|
4234
4250
|
property: property,
|
@@ -4236,8 +4252,8 @@ const MultiplePropertyFiller = ({
|
|
4236
4252
|
useExpression: useExpression,
|
4237
4253
|
required: required,
|
4238
4254
|
label: label
|
4239
|
-
}), error && jsx(
|
4240
|
-
|
4255
|
+
}), error && jsx(FormHelperText, Object.assign({
|
4256
|
+
error: true
|
4241
4257
|
}, {
|
4242
4258
|
children: error.message
|
4243
4259
|
}))]
|
@@ -5306,7 +5322,8 @@ const DefinitionFiller = ({
|
|
5306
5322
|
const stepperData = useMemo(() => {
|
5307
5323
|
if (properties) {
|
5308
5324
|
return properties.map(property => {
|
5309
|
-
|
5325
|
+
var _a;
|
5326
|
+
const propertyType = typeof property.propertyType === 'string' ? property.propertyType : (_a = property['propertyType']) === null || _a === void 0 ? void 0 : _a['value'];
|
5310
5327
|
return {
|
5311
5328
|
label: jsxs(Box, Object.assign({
|
5312
5329
|
display: "flex",
|
package/package.json
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import {
|
2
|
+
import { ReactCodeMirrorRef } from '@uiw/react-codemirror';
|
3
3
|
type Props = {
|
4
4
|
useParsedValue?: boolean;
|
5
5
|
validate?: boolean;
|
6
6
|
name: string;
|
7
|
-
inputRef: RefCallBack;
|
8
7
|
};
|
9
|
-
declare const JsonEditor: (
|
8
|
+
declare const JsonEditor: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<ReactCodeMirrorRef>>;
|
10
9
|
export default JsonEditor;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { PropertyFillType, PropertyUnion } from '../../../interfaces';
|
2
|
+
import { PropertyFillType, PropertyUnion, PropertyType } from '../../../interfaces';
|
3
3
|
type Props = {
|
4
4
|
value: unknown;
|
5
5
|
property: PropertyUnion;
|
@@ -10,7 +10,7 @@ type Props = {
|
|
10
10
|
multipleOptions?: boolean;
|
11
11
|
};
|
12
12
|
declare const usePropertyFiller: ({ value, property, label, isDirty, required, useExpression, multipleOptions, }: Props) => {
|
13
|
-
propertyType:
|
13
|
+
propertyType: PropertyType;
|
14
14
|
valueLabel: string;
|
15
15
|
fillOptionLabel: string;
|
16
16
|
fillOption: PropertyFillType;
|
@@ -20,5 +20,6 @@ declare const usePropertyFiller: ({ value, property, label, isDirty, required, u
|
|
20
20
|
sortOrder: number;
|
21
21
|
}[];
|
22
22
|
setFillOption: import("react").Dispatch<import("react").SetStateAction<PropertyFillType>>;
|
23
|
+
defaultProperyValue: {};
|
23
24
|
};
|
24
25
|
export default usePropertyFiller;
|