@dartech/arsenal-ui 1.3.57 → 1.3.59
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 +242 -198
- package/package.json +1 -1
- package/src/lib/Forms/ControlAceEditor.d.ts +1 -0
- package/src/lib/Property/PropertyFiller/JsonEditor.d.ts +2 -3
- package/src/lib/Property/PropertyFiller/usePropertyFiller.d.ts +3 -2
- package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +1 -3
package/index.js
CHANGED
@@ -230,28 +230,31 @@ const ControlInput = _a => {
|
|
230
230
|
onChange: customOnChange
|
231
231
|
} = _a,
|
232
232
|
textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "textarea", "hideErrorMessage", "onChange"]);
|
233
|
-
const {
|
234
|
-
|
233
|
+
const _c = useController({
|
234
|
+
name,
|
235
|
+
control,
|
236
|
+
defaultValue,
|
237
|
+
rules: {
|
238
|
+
required: required && 'Please, fill this field',
|
239
|
+
validate
|
240
|
+
}
|
241
|
+
}),
|
242
|
+
_d = _c.field,
|
243
|
+
{
|
235
244
|
ref,
|
236
245
|
onChange
|
237
|
-
},
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
defaultValue,
|
245
|
-
rules: {
|
246
|
-
required: required && 'Please, fill this field',
|
247
|
-
validate
|
248
|
-
}
|
249
|
-
});
|
246
|
+
} = _d,
|
247
|
+
fieldProps = __rest(_d, ["ref", "onChange"]),
|
248
|
+
{
|
249
|
+
fieldState: {
|
250
|
+
error
|
251
|
+
}
|
252
|
+
} = _c;
|
250
253
|
const value = useWatch({
|
251
254
|
control,
|
252
255
|
name
|
253
256
|
});
|
254
|
-
return jsx(TextField, Object.assign({
|
257
|
+
return jsx(TextField, Object.assign({}, fieldProps, {
|
255
258
|
fullWidth: true,
|
256
259
|
size: "small",
|
257
260
|
variant: "outlined",
|
@@ -274,12 +277,11 @@ const ControlInput = _a => {
|
|
274
277
|
multiline: textarea,
|
275
278
|
minRows: textarea ? 3 : 1,
|
276
279
|
value: value !== null && value !== void 0 ? value : '',
|
277
|
-
onChange: customOnChange ? customOnChange : onChange
|
278
|
-
}, textFieldProps, {
|
280
|
+
onChange: customOnChange ? customOnChange : onChange,
|
279
281
|
inputProps: Object.assign(Object.assign({}, (_b = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputProps) !== null && _b !== void 0 ? _b : {}), {
|
280
282
|
value: value !== null && value !== void 0 ? value : ''
|
281
283
|
})
|
282
|
-
}));
|
284
|
+
}, textFieldProps));
|
283
285
|
};
|
284
286
|
|
285
287
|
function useDebounce(func, delay) {
|
@@ -418,23 +420,26 @@ const ControlSelect = _a => {
|
|
418
420
|
options = []
|
419
421
|
} = _a,
|
420
422
|
textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "labelKey", "valueKey", "options"]);
|
421
|
-
const {
|
422
|
-
|
423
|
+
const _c = useController({
|
424
|
+
name,
|
425
|
+
control,
|
426
|
+
defaultValue,
|
427
|
+
rules: {
|
428
|
+
required: required && 'Please, fill this field',
|
429
|
+
validate
|
430
|
+
}
|
431
|
+
}),
|
432
|
+
_d = _c.field,
|
433
|
+
{
|
423
434
|
ref,
|
424
435
|
onChange
|
425
|
-
},
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
defaultValue,
|
433
|
-
rules: {
|
434
|
-
required: required && 'Please, fill this field',
|
435
|
-
validate
|
436
|
-
}
|
437
|
-
});
|
436
|
+
} = _d,
|
437
|
+
fieldProps = __rest(_d, ["ref", "onChange"]),
|
438
|
+
{
|
439
|
+
fieldState: {
|
440
|
+
error
|
441
|
+
}
|
442
|
+
} = _c;
|
438
443
|
const value = useWatch({
|
439
444
|
control,
|
440
445
|
name
|
@@ -452,7 +457,7 @@ const ControlSelect = _a => {
|
|
452
457
|
customOnChange(null);
|
453
458
|
} else onChange(null);
|
454
459
|
}, [onChange, customOnChange]);
|
455
|
-
return jsx(TextField, Object.assign({
|
460
|
+
return jsx(TextField, Object.assign({}, fieldProps, {
|
456
461
|
select: true,
|
457
462
|
fullWidth: true,
|
458
463
|
size: "small",
|
@@ -526,19 +531,22 @@ const ControlCheckbox = _a => {
|
|
526
531
|
onChange: customOnChange
|
527
532
|
} = _a,
|
528
533
|
checkboxProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange"]);
|
529
|
-
const {
|
530
|
-
|
534
|
+
const _b = useController({
|
535
|
+
name,
|
536
|
+
control,
|
537
|
+
defaultValue: false
|
538
|
+
}),
|
539
|
+
_c = _b.field,
|
540
|
+
{
|
531
541
|
ref,
|
532
542
|
onChange
|
533
|
-
},
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
defaultValue: false
|
541
|
-
});
|
543
|
+
} = _c,
|
544
|
+
fieldProps = __rest(_c, ["ref", "onChange"]),
|
545
|
+
{
|
546
|
+
fieldState: {
|
547
|
+
error
|
548
|
+
}
|
549
|
+
} = _b;
|
542
550
|
const value = useWatch({
|
543
551
|
control,
|
544
552
|
name
|
@@ -564,7 +572,7 @@ const ControlCheckbox = _a => {
|
|
564
572
|
disabled: disabled
|
565
573
|
}, {
|
566
574
|
children: [jsx(FormControlLabel, {
|
567
|
-
control: jsx(Checkbox, Object.assign({
|
575
|
+
control: jsx(Checkbox, Object.assign({}, fieldProps, {
|
568
576
|
checked: checked,
|
569
577
|
onChange: customOnChange ? customOnChange : onChange,
|
570
578
|
name: name,
|
@@ -599,23 +607,26 @@ const ControlRadio = ({
|
|
599
607
|
row,
|
600
608
|
radioProps
|
601
609
|
}) => {
|
602
|
-
const {
|
603
|
-
|
610
|
+
const _a = useController({
|
611
|
+
name,
|
612
|
+
control,
|
613
|
+
defaultValue,
|
614
|
+
rules: {
|
615
|
+
required: required && 'Please, fill this field',
|
616
|
+
validate
|
617
|
+
}
|
618
|
+
}),
|
619
|
+
_b = _a.field,
|
620
|
+
{
|
604
621
|
ref,
|
605
622
|
onChange
|
606
|
-
},
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
defaultValue,
|
614
|
-
rules: {
|
615
|
-
required: required && 'Please, fill this field',
|
616
|
-
validate
|
617
|
-
}
|
618
|
-
});
|
623
|
+
} = _b,
|
624
|
+
fieldProps = __rest(_b, ["ref", "onChange"]),
|
625
|
+
{
|
626
|
+
fieldState: {
|
627
|
+
error
|
628
|
+
}
|
629
|
+
} = _a;
|
619
630
|
const value = useWatch({
|
620
631
|
control,
|
621
632
|
name
|
@@ -636,7 +647,7 @@ const ControlRadio = ({
|
|
636
647
|
id: "radio-buttons-group"
|
637
648
|
}, {
|
638
649
|
children: label
|
639
|
-
})), jsx(RadioGroup, Object.assign({
|
650
|
+
})), jsx(RadioGroup, Object.assign({}, fieldProps, {
|
640
651
|
row: row,
|
641
652
|
"aria-labelledby": "radio-buttons-group",
|
642
653
|
ref: ref,
|
@@ -1036,25 +1047,30 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1036
1047
|
readOnly,
|
1037
1048
|
required = false,
|
1038
1049
|
validateJson = false,
|
1050
|
+
hideErrorMessage = false,
|
1039
1051
|
fontSize = 16,
|
1040
1052
|
validate = true,
|
1041
1053
|
parseValue
|
1042
1054
|
} = _a,
|
1043
|
-
otherProps = __rest(_a, ["control", "name", "mode", "label", "width", "height", "readOnly", "required", "validateJson", "fontSize", "validate", "parseValue"]);
|
1055
|
+
otherProps = __rest(_a, ["control", "name", "mode", "label", "width", "height", "readOnly", "required", "validateJson", "hideErrorMessage", "fontSize", "validate", "parseValue"]);
|
1044
1056
|
const {
|
1045
1057
|
setError,
|
1046
1058
|
clearErrors
|
1047
1059
|
} = useFormContext();
|
1048
1060
|
const {
|
1049
1061
|
field: {
|
1050
|
-
onChange
|
1062
|
+
onChange,
|
1063
|
+
ref: formRef
|
1051
1064
|
},
|
1052
1065
|
fieldState: {
|
1053
1066
|
error
|
1054
1067
|
}
|
1055
1068
|
} = useController({
|
1056
1069
|
control,
|
1057
|
-
name
|
1070
|
+
name,
|
1071
|
+
rules: {
|
1072
|
+
required: required && 'Please, fill this field'
|
1073
|
+
}
|
1058
1074
|
});
|
1059
1075
|
const value = useWatch({
|
1060
1076
|
control,
|
@@ -1118,7 +1134,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1118
1134
|
}))
|
1119
1135
|
}), jsxs(Fragment, {
|
1120
1136
|
children: [jsx(CodeMirror, Object.assign({
|
1121
|
-
ref: ref,
|
1137
|
+
ref: ref || formRef,
|
1122
1138
|
basicSetup: {
|
1123
1139
|
autocompletion: true,
|
1124
1140
|
history: true
|
@@ -1136,7 +1152,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1136
1152
|
value: mode === 'json' && typeof value !== 'string' ? value === null ? '' : JSON.stringify(value, null, 2) : value,
|
1137
1153
|
onChange: handleChange,
|
1138
1154
|
extensions: extensions[mode]
|
1139
|
-
}, otherProps)), error && jsx(FormHelperText, Object.assign({
|
1155
|
+
}, otherProps)), error && !hideErrorMessage && jsx(FormHelperText, Object.assign({
|
1140
1156
|
error: true
|
1141
1157
|
}, {
|
1142
1158
|
children: error.message
|
@@ -1841,7 +1857,7 @@ const ControlNumberInput = _a => {
|
|
1841
1857
|
name = '',
|
1842
1858
|
label = '',
|
1843
1859
|
required = false,
|
1844
|
-
defaultValue,
|
1860
|
+
defaultValue = null,
|
1845
1861
|
disabled = false,
|
1846
1862
|
hideErrorMessage = false,
|
1847
1863
|
onChange: customOnChange,
|
@@ -1849,35 +1865,35 @@ const ControlNumberInput = _a => {
|
|
1849
1865
|
valueAsNumber = true
|
1850
1866
|
} = _a,
|
1851
1867
|
textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "decimal", "valueAsNumber"]);
|
1852
|
-
const {
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
validate: val => {
|
1867
|
-
if (val === null || val === 0) return true;
|
1868
|
-
if (decimal && !floatsOnly.test(val) || /^-*0+$/.test(val)) {
|
1869
|
-
return 'Not valid number';
|
1870
|
-
} else if (!decimal && !digitsOnly.test(val)) {
|
1871
|
-
return 'Not valid integer';
|
1868
|
+
const _c = useController({
|
1869
|
+
name,
|
1870
|
+
control,
|
1871
|
+
defaultValue,
|
1872
|
+
rules: {
|
1873
|
+
required: required && 'Please, fill this field',
|
1874
|
+
validate: val => {
|
1875
|
+
if (val === null || val === 0) return true;
|
1876
|
+
if (decimal && !floatsOnly.test(val) || /^-*0+$/.test(val)) {
|
1877
|
+
return 'Not valid number';
|
1878
|
+
} else if (!decimal && !digitsOnly.test(val)) {
|
1879
|
+
return 'Not valid integer';
|
1880
|
+
}
|
1881
|
+
return true;
|
1872
1882
|
}
|
1873
|
-
return true;
|
1874
1883
|
}
|
1875
|
-
}
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1884
|
+
}),
|
1885
|
+
_d = _c.field,
|
1886
|
+
{
|
1887
|
+
ref,
|
1888
|
+
onChange,
|
1889
|
+
value
|
1890
|
+
} = _d,
|
1891
|
+
fieldProps = __rest(_d, ["ref", "onChange", "value"]),
|
1892
|
+
{
|
1893
|
+
fieldState: {
|
1894
|
+
error
|
1895
|
+
}
|
1896
|
+
} = _c;
|
1881
1897
|
const handleChange = event => {
|
1882
1898
|
var _a;
|
1883
1899
|
const lastData = event.nativeEvent['data'] || event.target.value;
|
@@ -1902,7 +1918,7 @@ const ControlNumberInput = _a => {
|
|
1902
1918
|
onChange(event.target.value);
|
1903
1919
|
}
|
1904
1920
|
};
|
1905
|
-
return jsx(TextField, Object.assign({
|
1921
|
+
return jsx(TextField, Object.assign({}, fieldProps, {
|
1906
1922
|
fullWidth: true,
|
1907
1923
|
size: "small",
|
1908
1924
|
variant: "outlined",
|
@@ -1922,13 +1938,12 @@ const ControlNumberInput = _a => {
|
|
1922
1938
|
error: !!error,
|
1923
1939
|
helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
|
1924
1940
|
disabled: disabled,
|
1925
|
-
value: value !== null && value !== void 0 ? value : ''
|
1926
|
-
}, textFieldProps, {
|
1941
|
+
value: value !== null && value !== void 0 ? value : '',
|
1927
1942
|
onChange: handleChange,
|
1928
1943
|
inputProps: Object.assign(Object.assign({}, (_b = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputProps) !== null && _b !== void 0 ? _b : {}), {
|
1929
1944
|
value: value !== null && value !== void 0 ? value : ''
|
1930
1945
|
})
|
1931
|
-
}));
|
1946
|
+
}, textFieldProps));
|
1932
1947
|
};
|
1933
1948
|
|
1934
1949
|
const ControlSwitch = _a => {
|
@@ -1938,15 +1953,15 @@ const ControlSwitch = _a => {
|
|
1938
1953
|
label
|
1939
1954
|
} = _a,
|
1940
1955
|
switchProps = __rest(_a, ["control", "name", "label"]);
|
1941
|
-
const {
|
1942
|
-
|
1956
|
+
const _b = useController({
|
1957
|
+
control,
|
1958
|
+
name
|
1959
|
+
}).field,
|
1960
|
+
{
|
1943
1961
|
ref,
|
1944
1962
|
onChange
|
1945
|
-
}
|
1946
|
-
|
1947
|
-
control,
|
1948
|
-
name
|
1949
|
-
});
|
1963
|
+
} = _b,
|
1964
|
+
fieldProps = __rest(_b, ["ref", "onChange"]);
|
1950
1965
|
const value = useWatch({
|
1951
1966
|
control,
|
1952
1967
|
name
|
@@ -1979,7 +1994,7 @@ const ControlSwitch = _a => {
|
|
1979
1994
|
return jsx(FormControlLabel, {
|
1980
1995
|
label: label,
|
1981
1996
|
name: name,
|
1982
|
-
control: jsx(Switch, Object.assign({
|
1997
|
+
control: jsx(Switch, Object.assign({}, fieldProps, {
|
1983
1998
|
color: "primary",
|
1984
1999
|
size: "small",
|
1985
2000
|
inputRef: ref,
|
@@ -2126,27 +2141,30 @@ const ControlTime = ({
|
|
2126
2141
|
format: _format = TIME_DEFAULT_FORMAT,
|
2127
2142
|
hideErrorMessage: _hideErrorMessage = false
|
2128
2143
|
}) => {
|
2129
|
-
const {
|
2130
|
-
|
2144
|
+
const _a = useController({
|
2145
|
+
control,
|
2146
|
+
name,
|
2147
|
+
rules: {
|
2148
|
+
required: required && 'Please, fill this field',
|
2149
|
+
validate: val => {
|
2150
|
+
if (isMatch(val, _format)) {
|
2151
|
+
return true;
|
2152
|
+
}
|
2153
|
+
return 'Incorrect date format';
|
2154
|
+
}
|
2155
|
+
}
|
2156
|
+
}),
|
2157
|
+
_b = _a.field,
|
2158
|
+
{
|
2131
2159
|
onChange,
|
2132
2160
|
ref
|
2133
|
-
},
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
control,
|
2139
|
-
name,
|
2140
|
-
rules: {
|
2141
|
-
required: required && 'Please, fill this field',
|
2142
|
-
validate: val => {
|
2143
|
-
if (isMatch(val, _format)) {
|
2144
|
-
return true;
|
2145
|
-
}
|
2146
|
-
return 'Incorrect date format';
|
2161
|
+
} = _b,
|
2162
|
+
fieldProps = __rest(_b, ["onChange", "ref"]),
|
2163
|
+
{
|
2164
|
+
fieldState: {
|
2165
|
+
error
|
2147
2166
|
}
|
2148
|
-
}
|
2149
|
-
});
|
2167
|
+
} = _a;
|
2150
2168
|
const value = useWatch({
|
2151
2169
|
control,
|
2152
2170
|
name
|
@@ -2165,7 +2183,7 @@ const ControlTime = ({
|
|
2165
2183
|
setFieldValue(parsedValue);
|
2166
2184
|
}
|
2167
2185
|
}, [value, _format]);
|
2168
|
-
return jsx(TimePicker, {
|
2186
|
+
return jsx(TimePicker, Object.assign({}, fieldProps, {
|
2169
2187
|
mask: "",
|
2170
2188
|
inputRef: ref,
|
2171
2189
|
label: required ? jsxs(Fragment, {
|
@@ -2190,7 +2208,7 @@ const ControlTime = ({
|
|
2190
2208
|
error: !!error,
|
2191
2209
|
helperText: !_hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message)
|
2192
2210
|
}))
|
2193
|
-
});
|
2211
|
+
}));
|
2194
2212
|
};
|
2195
2213
|
|
2196
2214
|
const ControlArrayInput = ({
|
@@ -3579,12 +3597,11 @@ const PropertyAdditionalFields = ({
|
|
3579
3597
|
}
|
3580
3598
|
};
|
3581
3599
|
|
3582
|
-
const JsonEditor = ({
|
3600
|
+
const JsonEditor = /*#__PURE__*/forwardRef(({
|
3583
3601
|
validate: _validate = false,
|
3584
3602
|
name,
|
3585
|
-
inputRef,
|
3586
3603
|
useParsedValue
|
3587
|
-
}) => {
|
3604
|
+
}, ref) => {
|
3588
3605
|
const {
|
3589
3606
|
control,
|
3590
3607
|
setValue,
|
@@ -3606,7 +3623,7 @@ const JsonEditor = ({
|
|
3606
3623
|
}
|
3607
3624
|
};
|
3608
3625
|
return jsx(CodeMirror, {
|
3609
|
-
ref:
|
3626
|
+
ref: ref,
|
3610
3627
|
basicSetup: {
|
3611
3628
|
autocompletion: true,
|
3612
3629
|
history: true
|
@@ -3620,11 +3637,11 @@ const JsonEditor = ({
|
|
3620
3637
|
zIndex: 0,
|
3621
3638
|
isolation: 'isolate'
|
3622
3639
|
},
|
3623
|
-
value: typeof value !== 'string' ? value === null ? '' : JSON.stringify(value
|
3640
|
+
value: typeof value !== 'string' ? value === null ? '' : JSON.stringify(value) : value,
|
3624
3641
|
onChange: handleChange,
|
3625
3642
|
extensions: [langs.json()]
|
3626
3643
|
});
|
3627
|
-
};
|
3644
|
+
});
|
3628
3645
|
var JsonEditor$1 = JsonEditor;
|
3629
3646
|
|
3630
3647
|
const StringValueField = ({
|
@@ -3688,13 +3705,12 @@ const StringValueField = ({
|
|
3688
3705
|
};
|
3689
3706
|
var StringValueField$1 = StringValueField;
|
3690
3707
|
|
3691
|
-
const PropertyWidget = ({
|
3708
|
+
const PropertyWidget = /*#__PURE__*/forwardRef(({
|
3692
3709
|
property,
|
3693
3710
|
name,
|
3694
3711
|
label,
|
3695
|
-
useExpression
|
3696
|
-
|
3697
|
-
}) => {
|
3712
|
+
useExpression
|
3713
|
+
}, ref) => {
|
3698
3714
|
const {
|
3699
3715
|
control
|
3700
3716
|
} = useFormContext();
|
@@ -3705,7 +3721,6 @@ const PropertyWidget = ({
|
|
3705
3721
|
case PropertyType.DOUBLE:
|
3706
3722
|
return jsx(ControlNumberInput, {
|
3707
3723
|
decimal: true,
|
3708
|
-
required: true,
|
3709
3724
|
hideErrorMessage: true,
|
3710
3725
|
control: control,
|
3711
3726
|
name: name,
|
@@ -3715,8 +3730,10 @@ const PropertyWidget = ({
|
|
3715
3730
|
case PropertyType.INTEGER:
|
3716
3731
|
case PropertyType.BIG_INTEGER:
|
3717
3732
|
case PropertyType.LONG:
|
3718
|
-
return jsx(ControlNumberInput
|
3719
|
-
|
3733
|
+
return jsx(ControlNumberInput
|
3734
|
+
// required
|
3735
|
+
, {
|
3736
|
+
// required
|
3720
3737
|
hideErrorMessage: true,
|
3721
3738
|
control: control,
|
3722
3739
|
name: name,
|
@@ -3729,8 +3746,10 @@ const PropertyWidget = ({
|
|
3729
3746
|
name: name
|
3730
3747
|
});
|
3731
3748
|
case PropertyType.DATE:
|
3732
|
-
return jsx(ControlDate
|
3733
|
-
|
3749
|
+
return jsx(ControlDate
|
3750
|
+
// required
|
3751
|
+
, {
|
3752
|
+
// required
|
3734
3753
|
hideErrorMessage: true,
|
3735
3754
|
control: control,
|
3736
3755
|
name: name,
|
@@ -3738,8 +3757,10 @@ const PropertyWidget = ({
|
|
3738
3757
|
format: property.format
|
3739
3758
|
});
|
3740
3759
|
case PropertyType.TIME:
|
3741
|
-
return jsx(ControlTime
|
3742
|
-
|
3760
|
+
return jsx(ControlTime
|
3761
|
+
// required
|
3762
|
+
, {
|
3763
|
+
// required
|
3743
3764
|
hideErrorMessage: true,
|
3744
3765
|
control: control,
|
3745
3766
|
name: name,
|
@@ -3747,8 +3768,10 @@ const PropertyWidget = ({
|
|
3747
3768
|
format: property.format
|
3748
3769
|
});
|
3749
3770
|
case PropertyType.DATE_TIME:
|
3750
|
-
return jsx(ControlDateTime
|
3751
|
-
|
3771
|
+
return jsx(ControlDateTime
|
3772
|
+
// required
|
3773
|
+
, {
|
3774
|
+
// required
|
3752
3775
|
hideErrorMessage: true,
|
3753
3776
|
control: control,
|
3754
3777
|
name: name,
|
@@ -3759,12 +3782,14 @@ const PropertyWidget = ({
|
|
3759
3782
|
return jsx(JsonEditor$1, {
|
3760
3783
|
validate: true,
|
3761
3784
|
name: name,
|
3762
|
-
|
3785
|
+
ref: ref,
|
3763
3786
|
useParsedValue: true
|
3764
3787
|
});
|
3765
3788
|
case PropertyType.STRING:
|
3766
|
-
return jsx(StringValueField$1
|
3767
|
-
|
3789
|
+
return jsx(StringValueField$1
|
3790
|
+
// required={!property.isRequired}
|
3791
|
+
, {
|
3792
|
+
// required={!property.isRequired}
|
3768
3793
|
name: name,
|
3769
3794
|
label: label,
|
3770
3795
|
restrictedValues: property.restrictedValues
|
@@ -3780,7 +3805,7 @@ const PropertyWidget = ({
|
|
3780
3805
|
case PropertyType.ANY:
|
3781
3806
|
return jsx(JsonEditor$1, {
|
3782
3807
|
name: name,
|
3783
|
-
|
3808
|
+
ref: ref
|
3784
3809
|
});
|
3785
3810
|
case PropertyType.ENTITY:
|
3786
3811
|
return jsx(DefinitionFiller, {
|
@@ -3793,7 +3818,7 @@ const PropertyWidget = ({
|
|
3793
3818
|
children: "No widget"
|
3794
3819
|
});
|
3795
3820
|
}
|
3796
|
-
};
|
3821
|
+
});
|
3797
3822
|
|
3798
3823
|
const usePropertyFiller = ({
|
3799
3824
|
value,
|
@@ -3806,7 +3831,10 @@ const usePropertyFiller = ({
|
|
3806
3831
|
}) => {
|
3807
3832
|
const valueLabel = useMemo(() => label ? `${label} (value)` : `${property.name} (value)`, [label, property]);
|
3808
3833
|
const fillOptionLabel = useMemo(() => label ? `${label} (widget)` : `${property.name} (widget)`, [label, property]);
|
3809
|
-
const propertyType = useMemo(() =>
|
3834
|
+
const propertyType = useMemo(() => {
|
3835
|
+
var _a;
|
3836
|
+
return typeof property.propertyType === 'string' ? property.propertyType : (_a = property['propertyType']) === null || _a === void 0 ? void 0 : _a['value'];
|
3837
|
+
}, [property]);
|
3810
3838
|
const [fillOption, setFillOption] = useState(null);
|
3811
3839
|
const fillOptions = useMemo(() => _multipleOptions ? getMultiplePropertyFillOptions({
|
3812
3840
|
propertyType,
|
@@ -3817,6 +3845,32 @@ const usePropertyFiller = ({
|
|
3817
3845
|
required: _required,
|
3818
3846
|
useExpression: _useExpression
|
3819
3847
|
}), [_useExpression, _required, propertyType, _multipleOptions]);
|
3848
|
+
const defaultProperyValue = useMemo(() => {
|
3849
|
+
if (property.isRequired) {
|
3850
|
+
switch (propertyType) {
|
3851
|
+
case PropertyType.STRING:
|
3852
|
+
case PropertyType.DATE:
|
3853
|
+
case PropertyType.TIME:
|
3854
|
+
case PropertyType.DATE_TIME:
|
3855
|
+
case PropertyType.ENTITY_REFERENCE:
|
3856
|
+
case PropertyType.ANY:
|
3857
|
+
return '';
|
3858
|
+
case PropertyType.JSON:
|
3859
|
+
return {};
|
3860
|
+
case PropertyType.BOOLEAN:
|
3861
|
+
return true;
|
3862
|
+
case PropertyType.INTEGER:
|
3863
|
+
case PropertyType.BIG_DECIMAL:
|
3864
|
+
case PropertyType.BIG_INTEGER:
|
3865
|
+
case PropertyType.DOUBLE:
|
3866
|
+
case PropertyType.LONG:
|
3867
|
+
case PropertyType.FLOAT:
|
3868
|
+
return 0;
|
3869
|
+
default:
|
3870
|
+
return {};
|
3871
|
+
}
|
3872
|
+
} else return null;
|
3873
|
+
}, [propertyType, property]);
|
3820
3874
|
useEffect(() => {
|
3821
3875
|
if (!fillOption) {
|
3822
3876
|
if (isPropertyValueEmpty(value) && (fillOptions === null || fillOptions === void 0 ? void 0 : fillOptions.length)) {
|
@@ -3840,7 +3894,8 @@ const usePropertyFiller = ({
|
|
3840
3894
|
fillOptionLabel,
|
3841
3895
|
fillOption,
|
3842
3896
|
fillOptions,
|
3843
|
-
setFillOption
|
3897
|
+
setFillOption,
|
3898
|
+
defaultProperyValue
|
3844
3899
|
};
|
3845
3900
|
};
|
3846
3901
|
var usePropertyFiller$1 = usePropertyFiller;
|
@@ -3870,7 +3925,8 @@ const PropertyFiller = ({
|
|
3870
3925
|
const {
|
3871
3926
|
field: {
|
3872
3927
|
ref,
|
3873
|
-
onChange
|
3928
|
+
onChange,
|
3929
|
+
value
|
3874
3930
|
},
|
3875
3931
|
fieldState: {
|
3876
3932
|
error,
|
@@ -3879,21 +3935,19 @@ const PropertyFiller = ({
|
|
3879
3935
|
} = useController({
|
3880
3936
|
name,
|
3881
3937
|
control,
|
3938
|
+
defaultValue: property.defaultValue,
|
3882
3939
|
rules: {
|
3883
3940
|
required
|
3884
3941
|
}
|
3885
3942
|
});
|
3886
|
-
const value = useWatch({
|
3887
|
-
control,
|
3888
|
-
name
|
3889
|
-
});
|
3890
3943
|
const {
|
3891
3944
|
propertyType,
|
3892
3945
|
valueLabel,
|
3893
3946
|
fillOptionLabel,
|
3894
3947
|
fillOption,
|
3895
3948
|
fillOptions,
|
3896
|
-
setFillOption
|
3949
|
+
setFillOption,
|
3950
|
+
defaultProperyValue
|
3897
3951
|
} = usePropertyFiller$1({
|
3898
3952
|
value,
|
3899
3953
|
property,
|
@@ -3915,10 +3969,10 @@ const PropertyFiller = ({
|
|
3915
3969
|
try {
|
3916
3970
|
onChange(JSON.stringify(definitionValue, null, '\t'));
|
3917
3971
|
} catch (error) {
|
3918
|
-
console.log('Stringify failed');
|
3972
|
+
console.log('Stringify failed', error);
|
3919
3973
|
}
|
3920
3974
|
} else {
|
3921
|
-
setValue(name,
|
3975
|
+
setValue(name, property.defaultValue || defaultProperyValue);
|
3922
3976
|
}
|
3923
3977
|
} else if (selectedType === 'expression' || selectedType === 'string') {
|
3924
3978
|
onChange('');
|
@@ -3936,19 +3990,19 @@ const PropertyFiller = ({
|
|
3936
3990
|
onChange(definitionValue);
|
3937
3991
|
} catch (error) {
|
3938
3992
|
onChange(defaultArrayValue);
|
3939
|
-
console.log('Parse failed');
|
3993
|
+
// console.log('Parse failed');
|
3940
3994
|
}
|
3941
3995
|
} else {
|
3942
3996
|
onChange(defaultArrayValue);
|
3943
3997
|
}
|
3944
3998
|
}
|
3945
3999
|
clearErrors();
|
3946
|
-
}, [name, clearErrors, value, setFillOption, onChange, fillOption, propertyType, setValue]);
|
4000
|
+
}, [name, defaultProperyValue, clearErrors, value, setFillOption, onChange, fillOption, propertyType, setValue, property]);
|
3947
4001
|
useEffect(() => {
|
3948
4002
|
if (value === undefined) {
|
3949
|
-
onChange(
|
4003
|
+
onChange(property.defaultValue || defaultProperyValue);
|
3950
4004
|
}
|
3951
|
-
}, [value, onChange]);
|
4005
|
+
}, [value, onChange, defaultProperyValue, property]);
|
3952
4006
|
return jsxs(Grid$1, Object.assign({
|
3953
4007
|
xs: 12
|
3954
4008
|
}, {
|
@@ -3987,7 +4041,8 @@ const PropertyFiller = ({
|
|
3987
4041
|
}))
|
3988
4042
|
})) : null, fillOption === 'expression' && (propertyType === PropertyType.JSON || propertyType === PropertyType.ENTITY || propertyType === PropertyType.ANY ? jsx(JsonEditor$1, {
|
3989
4043
|
name: name,
|
3990
|
-
|
4044
|
+
ref: ref,
|
4045
|
+
useParsedValue: true
|
3991
4046
|
}) : jsx(ControlInput, {
|
3992
4047
|
control: control,
|
3993
4048
|
name: name,
|
@@ -4002,19 +4057,19 @@ const PropertyFiller = ({
|
|
4002
4057
|
hideErrorMessage: true
|
4003
4058
|
}), fillOption === 'json_notvalid' && jsx(JsonEditor$1, {
|
4004
4059
|
name: name,
|
4005
|
-
|
4060
|
+
ref: ref
|
4006
4061
|
}), fillOption === 'widget' && jsx(PropertyWidget, {
|
4007
4062
|
property: property,
|
4008
4063
|
name: name,
|
4009
4064
|
useExpression: useExpression,
|
4010
4065
|
label: valueLabel,
|
4011
|
-
|
4066
|
+
ref: ref,
|
4012
4067
|
required: required
|
4013
4068
|
}), fillOption === 'dem_builder' && jsx(CreateDefinition, {
|
4014
4069
|
title: "JSON",
|
4015
4070
|
definitionFieldName: name
|
4016
|
-
}), error && jsx(
|
4017
|
-
|
4071
|
+
}), error && jsx(FormHelperText, Object.assign({
|
4072
|
+
error: true
|
4018
4073
|
}, {
|
4019
4074
|
children: error.message
|
4020
4075
|
}))]
|
@@ -4033,18 +4088,6 @@ const MultiplePropertyWidget = ({
|
|
4033
4088
|
setValue,
|
4034
4089
|
clearErrors
|
4035
4090
|
} = 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
4091
|
const values = useWatch({
|
4049
4092
|
control,
|
4050
4093
|
name
|
@@ -4053,7 +4096,7 @@ const MultiplePropertyWidget = ({
|
|
4053
4096
|
if (values && Array.isArray(values)) {
|
4054
4097
|
setValue(`${name}.${values.length}`, null);
|
4055
4098
|
} else {
|
4056
|
-
setValue(name, [
|
4099
|
+
setValue(name, []);
|
4057
4100
|
}
|
4058
4101
|
clearErrors(name);
|
4059
4102
|
}, [name, values, setValue, clearErrors]);
|
@@ -4066,7 +4109,7 @@ const MultiplePropertyWidget = ({
|
|
4066
4109
|
direction: "column",
|
4067
4110
|
xs: 12
|
4068
4111
|
}, {
|
4069
|
-
children: [
|
4112
|
+
children: [Array.isArray(values) && values.length ? values.map((value, index) => jsx(Grid$1, Object.assign({
|
4070
4113
|
xs: 12
|
4071
4114
|
}, {
|
4072
4115
|
children: jsxs(Box, Object.assign({
|
@@ -4122,7 +4165,8 @@ const MultiplePropertyFiller = ({
|
|
4122
4165
|
}) => {
|
4123
4166
|
const {
|
4124
4167
|
control,
|
4125
|
-
clearErrors
|
4168
|
+
clearErrors,
|
4169
|
+
setValue
|
4126
4170
|
} = useFormContext();
|
4127
4171
|
const {
|
4128
4172
|
field: {
|
@@ -4136,11 +4180,10 @@ const MultiplePropertyFiller = ({
|
|
4136
4180
|
} = useController({
|
4137
4181
|
control,
|
4138
4182
|
name,
|
4183
|
+
defaultValue: property.defaultValue,
|
4139
4184
|
rules: {
|
4140
4185
|
validate: val => {
|
4141
|
-
if (required && !val)
|
4142
|
-
return 'Please, fill this field';
|
4143
|
-
}
|
4186
|
+
if (required && !val) return 'Please, fill this field';
|
4144
4187
|
return true;
|
4145
4188
|
}
|
4146
4189
|
}
|
@@ -4168,7 +4211,7 @@ const MultiplePropertyFiller = ({
|
|
4168
4211
|
const handleFillOptionChange = event => {
|
4169
4212
|
const selectedType = event.target.value;
|
4170
4213
|
if (selectedType === 'null') {
|
4171
|
-
|
4214
|
+
setValue(name, null);
|
4172
4215
|
} else if (selectedType === 'expression' || selectedType === 'json_valid' || selectedType === 'json_notvalid') {
|
4173
4216
|
onChange('');
|
4174
4217
|
} else if (selectedType === 'widget') {
|
@@ -4179,9 +4222,9 @@ const MultiplePropertyFiller = ({
|
|
4179
4222
|
};
|
4180
4223
|
useEffect(() => {
|
4181
4224
|
if (value === undefined) {
|
4182
|
-
onChange(null);
|
4225
|
+
onChange(property.isRequired ? [] : null);
|
4183
4226
|
}
|
4184
|
-
}, [value, onChange]);
|
4227
|
+
}, [value, property, onChange]);
|
4185
4228
|
return jsxs(Grid$1, {
|
4186
4229
|
children: [title && jsx(Box, Object.assign({
|
4187
4230
|
mb: 2
|
@@ -4218,7 +4261,7 @@ const MultiplePropertyFiller = ({
|
|
4218
4261
|
}))
|
4219
4262
|
})) : null, fillOption === 'expression' && (propertyType === PropertyType.JSON || propertyType === PropertyType.ENTITY || propertyType === PropertyType.ANY ? jsx(JsonEditor$1, {
|
4220
4263
|
name: name,
|
4221
|
-
|
4264
|
+
ref: ref
|
4222
4265
|
}) : jsx(ControlInput, {
|
4223
4266
|
required: true,
|
4224
4267
|
hideErrorMessage: true,
|
@@ -4228,7 +4271,7 @@ const MultiplePropertyFiller = ({
|
|
4228
4271
|
})), fillOption === 'json_valid' && jsx(JsonEditor$1, {
|
4229
4272
|
validate: true,
|
4230
4273
|
name: name,
|
4231
|
-
|
4274
|
+
ref: ref,
|
4232
4275
|
useParsedValue: true
|
4233
4276
|
}), fillOption === 'widget' && jsx(MultiplePropertyWidget$1, {
|
4234
4277
|
property: property,
|
@@ -4236,8 +4279,8 @@ const MultiplePropertyFiller = ({
|
|
4236
4279
|
useExpression: useExpression,
|
4237
4280
|
required: required,
|
4238
4281
|
label: label
|
4239
|
-
}), error && jsx(
|
4240
|
-
|
4282
|
+
}), error && jsx(FormHelperText, Object.assign({
|
4283
|
+
error: true
|
4241
4284
|
}, {
|
4242
4285
|
children: error.message
|
4243
4286
|
}))]
|
@@ -4546,7 +4589,7 @@ const ValidationNodeSelector = ({
|
|
4546
4589
|
content: jsxs(Fragment, {
|
4547
4590
|
children: [jsxs(Box, Object.assign({
|
4548
4591
|
display: "flex",
|
4549
|
-
alignItems: "
|
4592
|
+
alignItems: "flex-end"
|
4550
4593
|
}, {
|
4551
4594
|
children: [jsx(ControlSelect, {
|
4552
4595
|
required: true,
|
@@ -5306,7 +5349,8 @@ const DefinitionFiller = ({
|
|
5306
5349
|
const stepperData = useMemo(() => {
|
5307
5350
|
if (properties) {
|
5308
5351
|
return properties.map(property => {
|
5309
|
-
|
5352
|
+
var _a;
|
5353
|
+
const propertyType = typeof property.propertyType === 'string' ? property.propertyType : (_a = property['propertyType']) === null || _a === void 0 ? void 0 : _a['value'];
|
5310
5354
|
return {
|
5311
5355
|
label: jsxs(Box, Object.assign({
|
5312
5356
|
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;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { RefCallBack } from 'react-hook-form';
|
3
2
|
import { PropertyUnion } from '../../../interfaces';
|
4
3
|
type Props = {
|
5
4
|
property: PropertyUnion;
|
@@ -7,7 +6,6 @@ type Props = {
|
|
7
6
|
label?: string;
|
8
7
|
useExpression?: boolean;
|
9
8
|
required?: boolean;
|
10
|
-
inputRef: RefCallBack;
|
11
9
|
};
|
12
|
-
export declare const PropertyWidget: (
|
10
|
+
export declare const PropertyWidget: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<any>>;
|
13
11
|
export default PropertyWidget;
|