@dartech/arsenal-ui 1.3.58 → 1.3.60

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
@@ -70,7 +70,6 @@ import StepLabel from '@mui/material/StepLabel';
70
70
  import StepContent from '@mui/material/StepContent';
71
71
  import StepConnector from '@mui/material/StepConnector';
72
72
  import Select from '@mui/material/Select';
73
- import CloseIcon from '@mui/icons-material/Close';
74
73
  import InputLabel from '@mui/material/InputLabel';
75
74
  import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
76
75
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
@@ -216,6 +215,7 @@ const AlertDialog = ({
216
215
  * @category Forms
217
216
  */
218
217
  const ControlInput = _a => {
218
+ var _b;
219
219
  var {
220
220
  control,
221
221
  validate,
@@ -229,25 +229,31 @@ const ControlInput = _a => {
229
229
  onChange: customOnChange
230
230
  } = _a,
231
231
  textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "textarea", "hideErrorMessage", "onChange"]);
232
- const {
233
- field: {
232
+ const _c = useController({
233
+ name,
234
+ control,
235
+ defaultValue,
236
+ rules: {
237
+ required: required && 'Please, fill this field',
238
+ validate
239
+ }
240
+ }),
241
+ _d = _c.field,
242
+ {
234
243
  ref,
235
- onChange,
236
- value
237
- },
238
- fieldState: {
239
- error
240
- }
241
- } = useController({
242
- name,
244
+ onChange
245
+ } = _d,
246
+ fieldProps = __rest(_d, ["ref", "onChange"]),
247
+ {
248
+ fieldState: {
249
+ error
250
+ }
251
+ } = _c;
252
+ const value = useWatch({
243
253
  control,
244
- defaultValue,
245
- rules: {
246
- required: required && 'Please, fill this field',
247
- validate
248
- }
254
+ name
249
255
  });
250
- return jsx(TextField, Object.assign({
256
+ return jsx(TextField, Object.assign({}, fieldProps, {
251
257
  fullWidth: true,
252
258
  size: "small",
253
259
  variant: "outlined",
@@ -270,7 +276,10 @@ const ControlInput = _a => {
270
276
  multiline: textarea,
271
277
  minRows: textarea ? 3 : 1,
272
278
  value: value !== null && value !== void 0 ? value : '',
273
- onChange: customOnChange ? customOnChange : onChange
279
+ onChange: customOnChange ? customOnChange : onChange,
280
+ inputProps: Object.assign(Object.assign({}, (_b = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputProps) !== null && _b !== void 0 ? _b : {}), {
281
+ value: value !== null && value !== void 0 ? value : ''
282
+ })
274
283
  }, textFieldProps));
275
284
  };
276
285
 
@@ -410,23 +419,26 @@ const ControlSelect = _a => {
410
419
  options = []
411
420
  } = _a,
412
421
  textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "labelKey", "valueKey", "options"]);
413
- const {
414
- field: {
422
+ const _c = useController({
423
+ name,
424
+ control,
425
+ defaultValue,
426
+ rules: {
427
+ required: required && 'Please, fill this field',
428
+ validate
429
+ }
430
+ }),
431
+ _d = _c.field,
432
+ {
415
433
  ref,
416
434
  onChange
417
- },
418
- fieldState: {
419
- error
420
- }
421
- } = useController({
422
- name,
423
- control,
424
- defaultValue,
425
- rules: {
426
- required: required && 'Please, fill this field',
427
- validate
428
- }
429
- });
435
+ } = _d,
436
+ fieldProps = __rest(_d, ["ref", "onChange"]),
437
+ {
438
+ fieldState: {
439
+ error
440
+ }
441
+ } = _c;
430
442
  const value = useWatch({
431
443
  control,
432
444
  name
@@ -444,7 +456,7 @@ const ControlSelect = _a => {
444
456
  customOnChange(null);
445
457
  } else onChange(null);
446
458
  }, [onChange, customOnChange]);
447
- return jsx(TextField, Object.assign({
459
+ return jsx(TextField, Object.assign({}, fieldProps, {
448
460
  select: true,
449
461
  fullWidth: true,
450
462
  size: "small",
@@ -518,19 +530,22 @@ const ControlCheckbox = _a => {
518
530
  onChange: customOnChange
519
531
  } = _a,
520
532
  checkboxProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange"]);
521
- const {
522
- field: {
533
+ const _b = useController({
534
+ name,
535
+ control,
536
+ defaultValue: false
537
+ }),
538
+ _c = _b.field,
539
+ {
523
540
  ref,
524
541
  onChange
525
- },
526
- fieldState: {
527
- error
528
- }
529
- } = useController({
530
- name,
531
- control,
532
- defaultValue: false
533
- });
542
+ } = _c,
543
+ fieldProps = __rest(_c, ["ref", "onChange"]),
544
+ {
545
+ fieldState: {
546
+ error
547
+ }
548
+ } = _b;
534
549
  const value = useWatch({
535
550
  control,
536
551
  name
@@ -556,7 +571,7 @@ const ControlCheckbox = _a => {
556
571
  disabled: disabled
557
572
  }, {
558
573
  children: [jsx(FormControlLabel, {
559
- control: jsx(Checkbox, Object.assign({
574
+ control: jsx(Checkbox, Object.assign({}, fieldProps, {
560
575
  checked: checked,
561
576
  onChange: customOnChange ? customOnChange : onChange,
562
577
  name: name,
@@ -591,23 +606,26 @@ const ControlRadio = ({
591
606
  row,
592
607
  radioProps
593
608
  }) => {
594
- const {
595
- field: {
609
+ const _a = useController({
610
+ name,
611
+ control,
612
+ defaultValue,
613
+ rules: {
614
+ required: required && 'Please, fill this field',
615
+ validate
616
+ }
617
+ }),
618
+ _b = _a.field,
619
+ {
596
620
  ref,
597
621
  onChange
598
- },
599
- fieldState: {
600
- error
601
- }
602
- } = useController({
603
- name,
604
- control,
605
- defaultValue,
606
- rules: {
607
- required: required && 'Please, fill this field',
608
- validate
609
- }
610
- });
622
+ } = _b,
623
+ fieldProps = __rest(_b, ["ref", "onChange"]),
624
+ {
625
+ fieldState: {
626
+ error
627
+ }
628
+ } = _a;
611
629
  const value = useWatch({
612
630
  control,
613
631
  name
@@ -628,7 +646,7 @@ const ControlRadio = ({
628
646
  id: "radio-buttons-group"
629
647
  }, {
630
648
  children: label
631
- })), jsx(RadioGroup, Object.assign({
649
+ })), jsx(RadioGroup, Object.assign({}, fieldProps, {
632
650
  row: row,
633
651
  "aria-labelledby": "radio-buttons-group",
634
652
  ref: ref,
@@ -1041,8 +1059,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
1041
1059
  const {
1042
1060
  field: {
1043
1061
  onChange,
1044
- value,
1045
- ref: fromRef
1062
+ ref: formRef
1046
1063
  },
1047
1064
  fieldState: {
1048
1065
  error
@@ -1054,7 +1071,10 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
1054
1071
  required: required && 'Please, fill this field'
1055
1072
  }
1056
1073
  });
1057
- // const value = useWatch({ control, name });
1074
+ const value = useWatch({
1075
+ control,
1076
+ name
1077
+ });
1058
1078
  const extensions = useMemo(() => ({
1059
1079
  json: [langs.json()],
1060
1080
  javascript: [langs.javascript()],
@@ -1113,7 +1133,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
1113
1133
  }))
1114
1134
  }), jsxs(Fragment, {
1115
1135
  children: [jsx(CodeMirror, Object.assign({
1116
- ref: ref || fromRef,
1136
+ ref: ref || formRef,
1117
1137
  basicSetup: {
1118
1138
  autocompletion: true,
1119
1139
  history: true
@@ -1836,7 +1856,7 @@ const ControlNumberInput = _a => {
1836
1856
  name = '',
1837
1857
  label = '',
1838
1858
  required = false,
1839
- defaultValue,
1859
+ defaultValue = null,
1840
1860
  disabled = false,
1841
1861
  hideErrorMessage = false,
1842
1862
  onChange: customOnChange,
@@ -1844,35 +1864,35 @@ const ControlNumberInput = _a => {
1844
1864
  valueAsNumber = true
1845
1865
  } = _a,
1846
1866
  textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "decimal", "valueAsNumber"]);
1847
- const {
1848
- field: {
1849
- ref,
1850
- onChange
1851
- },
1852
- fieldState: {
1853
- error
1854
- }
1855
- } = useController({
1856
- name,
1857
- control,
1858
- defaultValue,
1859
- rules: {
1860
- required: required && 'Please, fill this field',
1861
- validate: val => {
1862
- if (val === null || val === 0) return true;
1863
- if (decimal && !floatsOnly.test(val) || /^-*0+$/.test(val)) {
1864
- return 'Not valid number';
1865
- } else if (!decimal && !digitsOnly.test(val)) {
1866
- return 'Not valid integer';
1867
+ const _c = useController({
1868
+ name,
1869
+ control,
1870
+ defaultValue,
1871
+ rules: {
1872
+ required: required && 'Please, fill this field',
1873
+ validate: val => {
1874
+ if (val === null || val === 0) return true;
1875
+ if (decimal && !floatsOnly.test(val) || /^-*0+$/.test(val)) {
1876
+ return 'Not valid number';
1877
+ } else if (!decimal && !digitsOnly.test(val)) {
1878
+ return 'Not valid integer';
1879
+ }
1880
+ return true;
1867
1881
  }
1868
- return true;
1869
1882
  }
1870
- }
1871
- });
1872
- const value = useWatch({
1873
- control,
1874
- name
1875
- });
1883
+ }),
1884
+ _d = _c.field,
1885
+ {
1886
+ ref,
1887
+ onChange,
1888
+ value
1889
+ } = _d,
1890
+ fieldProps = __rest(_d, ["ref", "onChange", "value"]),
1891
+ {
1892
+ fieldState: {
1893
+ error
1894
+ }
1895
+ } = _c;
1876
1896
  const handleChange = event => {
1877
1897
  var _a;
1878
1898
  const lastData = event.nativeEvent['data'] || event.target.value;
@@ -1897,7 +1917,7 @@ const ControlNumberInput = _a => {
1897
1917
  onChange(event.target.value);
1898
1918
  }
1899
1919
  };
1900
- return jsx(TextField, Object.assign({
1920
+ return jsx(TextField, Object.assign({}, fieldProps, {
1901
1921
  fullWidth: true,
1902
1922
  size: "small",
1903
1923
  variant: "outlined",
@@ -1917,13 +1937,12 @@ const ControlNumberInput = _a => {
1917
1937
  error: !!error,
1918
1938
  helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
1919
1939
  disabled: disabled,
1920
- value: value !== null && value !== void 0 ? value : ''
1921
- }, textFieldProps, {
1940
+ value: value !== null && value !== void 0 ? value : '',
1922
1941
  onChange: handleChange,
1923
1942
  inputProps: Object.assign(Object.assign({}, (_b = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputProps) !== null && _b !== void 0 ? _b : {}), {
1924
1943
  value: value !== null && value !== void 0 ? value : ''
1925
1944
  })
1926
- }));
1945
+ }, textFieldProps));
1927
1946
  };
1928
1947
 
1929
1948
  const ControlSwitch = _a => {
@@ -1933,15 +1952,15 @@ const ControlSwitch = _a => {
1933
1952
  label
1934
1953
  } = _a,
1935
1954
  switchProps = __rest(_a, ["control", "name", "label"]);
1936
- const {
1937
- field: {
1955
+ const _b = useController({
1956
+ control,
1957
+ name
1958
+ }).field,
1959
+ {
1938
1960
  ref,
1939
1961
  onChange
1940
- }
1941
- } = useController({
1942
- control,
1943
- name
1944
- });
1962
+ } = _b,
1963
+ fieldProps = __rest(_b, ["ref", "onChange"]);
1945
1964
  const value = useWatch({
1946
1965
  control,
1947
1966
  name
@@ -1974,7 +1993,7 @@ const ControlSwitch = _a => {
1974
1993
  return jsx(FormControlLabel, {
1975
1994
  label: label,
1976
1995
  name: name,
1977
- control: jsx(Switch, Object.assign({
1996
+ control: jsx(Switch, Object.assign({}, fieldProps, {
1978
1997
  color: "primary",
1979
1998
  size: "small",
1980
1999
  inputRef: ref,
@@ -2121,27 +2140,30 @@ const ControlTime = ({
2121
2140
  format: _format = TIME_DEFAULT_FORMAT,
2122
2141
  hideErrorMessage: _hideErrorMessage = false
2123
2142
  }) => {
2124
- const {
2125
- field: {
2143
+ const _a = useController({
2144
+ control,
2145
+ name,
2146
+ rules: {
2147
+ required: required && 'Please, fill this field',
2148
+ validate: val => {
2149
+ if (isMatch(val, _format)) {
2150
+ return true;
2151
+ }
2152
+ return 'Incorrect date format';
2153
+ }
2154
+ }
2155
+ }),
2156
+ _b = _a.field,
2157
+ {
2126
2158
  onChange,
2127
2159
  ref
2128
- },
2129
- fieldState: {
2130
- error
2131
- }
2132
- } = useController({
2133
- control,
2134
- name,
2135
- rules: {
2136
- required: required && 'Please, fill this field',
2137
- validate: val => {
2138
- if (isMatch(val, _format)) {
2139
- return true;
2140
- }
2141
- return 'Incorrect date format';
2160
+ } = _b,
2161
+ fieldProps = __rest(_b, ["onChange", "ref"]),
2162
+ {
2163
+ fieldState: {
2164
+ error
2142
2165
  }
2143
- }
2144
- });
2166
+ } = _a;
2145
2167
  const value = useWatch({
2146
2168
  control,
2147
2169
  name
@@ -2160,7 +2182,7 @@ const ControlTime = ({
2160
2182
  setFieldValue(parsedValue);
2161
2183
  }
2162
2184
  }, [value, _format]);
2163
- return jsx(TimePicker, {
2185
+ return jsx(TimePicker, Object.assign({}, fieldProps, {
2164
2186
  mask: "",
2165
2187
  inputRef: ref,
2166
2188
  label: required ? jsxs(Fragment, {
@@ -2185,7 +2207,7 @@ const ControlTime = ({
2185
2207
  error: !!error,
2186
2208
  helperText: !_hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message)
2187
2209
  }))
2188
- });
2210
+ }));
2189
2211
  };
2190
2212
 
2191
2213
  const ControlArrayInput = ({
@@ -3614,7 +3636,7 @@ const JsonEditor = /*#__PURE__*/forwardRef(({
3614
3636
  zIndex: 0,
3615
3637
  isolation: 'isolate'
3616
3638
  },
3617
- value: typeof value !== 'string' ? value === null ? '' : JSON.stringify(value, null, 2) : value,
3639
+ value: typeof value !== 'string' ? value === null ? '' : JSON.stringify(value) : value,
3618
3640
  onChange: handleChange,
3619
3641
  extensions: [langs.json()]
3620
3642
  });
@@ -3682,13 +3704,12 @@ const StringValueField = ({
3682
3704
  };
3683
3705
  var StringValueField$1 = StringValueField;
3684
3706
 
3685
- const PropertyWidget = ({
3707
+ const PropertyWidget = /*#__PURE__*/forwardRef(({
3686
3708
  property,
3687
3709
  name,
3688
3710
  label,
3689
- useExpression,
3690
- inputRef
3691
- }) => {
3711
+ useExpression
3712
+ }, ref) => {
3692
3713
  const {
3693
3714
  control
3694
3715
  } = useFormContext();
@@ -3699,7 +3720,6 @@ const PropertyWidget = ({
3699
3720
  case PropertyType.DOUBLE:
3700
3721
  return jsx(ControlNumberInput, {
3701
3722
  decimal: true,
3702
- required: true,
3703
3723
  hideErrorMessage: true,
3704
3724
  control: control,
3705
3725
  name: name,
@@ -3709,8 +3729,10 @@ const PropertyWidget = ({
3709
3729
  case PropertyType.INTEGER:
3710
3730
  case PropertyType.BIG_INTEGER:
3711
3731
  case PropertyType.LONG:
3712
- return jsx(ControlNumberInput, {
3713
- required: true,
3732
+ return jsx(ControlNumberInput
3733
+ // required
3734
+ , {
3735
+ // required
3714
3736
  hideErrorMessage: true,
3715
3737
  control: control,
3716
3738
  name: name,
@@ -3723,8 +3745,10 @@ const PropertyWidget = ({
3723
3745
  name: name
3724
3746
  });
3725
3747
  case PropertyType.DATE:
3726
- return jsx(ControlDate, {
3727
- required: true,
3748
+ return jsx(ControlDate
3749
+ // required
3750
+ , {
3751
+ // required
3728
3752
  hideErrorMessage: true,
3729
3753
  control: control,
3730
3754
  name: name,
@@ -3732,8 +3756,10 @@ const PropertyWidget = ({
3732
3756
  format: property.format
3733
3757
  });
3734
3758
  case PropertyType.TIME:
3735
- return jsx(ControlTime, {
3736
- required: true,
3759
+ return jsx(ControlTime
3760
+ // required
3761
+ , {
3762
+ // required
3737
3763
  hideErrorMessage: true,
3738
3764
  control: control,
3739
3765
  name: name,
@@ -3741,8 +3767,10 @@ const PropertyWidget = ({
3741
3767
  format: property.format
3742
3768
  });
3743
3769
  case PropertyType.DATE_TIME:
3744
- return jsx(ControlDateTime, {
3745
- required: true,
3770
+ return jsx(ControlDateTime
3771
+ // required
3772
+ , {
3773
+ // required
3746
3774
  hideErrorMessage: true,
3747
3775
  control: control,
3748
3776
  name: name,
@@ -3753,12 +3781,14 @@ const PropertyWidget = ({
3753
3781
  return jsx(JsonEditor$1, {
3754
3782
  validate: true,
3755
3783
  name: name,
3756
- ref: inputRef,
3784
+ ref: ref,
3757
3785
  useParsedValue: true
3758
3786
  });
3759
3787
  case PropertyType.STRING:
3760
- return jsx(StringValueField$1, {
3761
- required: true,
3788
+ return jsx(StringValueField$1
3789
+ // required={!property.isRequired}
3790
+ , {
3791
+ // required={!property.isRequired}
3762
3792
  name: name,
3763
3793
  label: label,
3764
3794
  restrictedValues: property.restrictedValues
@@ -3774,7 +3804,7 @@ const PropertyWidget = ({
3774
3804
  case PropertyType.ANY:
3775
3805
  return jsx(JsonEditor$1, {
3776
3806
  name: name,
3777
- ref: inputRef
3807
+ ref: ref
3778
3808
  });
3779
3809
  case PropertyType.ENTITY:
3780
3810
  return jsx(DefinitionFiller, {
@@ -3787,7 +3817,7 @@ const PropertyWidget = ({
3787
3817
  children: "No widget"
3788
3818
  });
3789
3819
  }
3790
- };
3820
+ });
3791
3821
 
3792
3822
  const usePropertyFiller = ({
3793
3823
  value,
@@ -3815,28 +3845,31 @@ const usePropertyFiller = ({
3815
3845
  useExpression: _useExpression
3816
3846
  }), [_useExpression, _required, propertyType, _multipleOptions]);
3817
3847
  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]);
3848
+ if (property.isRequired || property.isMultiple) {
3849
+ switch (propertyType) {
3850
+ case PropertyType.STRING:
3851
+ case PropertyType.DATE:
3852
+ case PropertyType.TIME:
3853
+ case PropertyType.DATE_TIME:
3854
+ case PropertyType.ENTITY_REFERENCE:
3855
+ case PropertyType.ANY:
3856
+ return '';
3857
+ case PropertyType.JSON:
3858
+ return {};
3859
+ case PropertyType.BOOLEAN:
3860
+ return true;
3861
+ case PropertyType.INTEGER:
3862
+ case PropertyType.BIG_DECIMAL:
3863
+ case PropertyType.BIG_INTEGER:
3864
+ case PropertyType.DOUBLE:
3865
+ case PropertyType.LONG:
3866
+ case PropertyType.FLOAT:
3867
+ return 0;
3868
+ default:
3869
+ return {};
3870
+ }
3871
+ } else return null;
3872
+ }, [propertyType, property]);
3840
3873
  useEffect(() => {
3841
3874
  if (!fillOption) {
3842
3875
  if (isPropertyValueEmpty(value) && (fillOptions === null || fillOptions === void 0 ? void 0 : fillOptions.length)) {
@@ -3901,11 +3934,11 @@ const PropertyFiller = ({
3901
3934
  } = useController({
3902
3935
  name,
3903
3936
  control,
3937
+ defaultValue: property.defaultValue,
3904
3938
  rules: {
3905
3939
  required
3906
3940
  }
3907
3941
  });
3908
- // const value = useWatch({ control, name });
3909
3942
  const {
3910
3943
  propertyType,
3911
3944
  valueLabel,
@@ -3938,7 +3971,7 @@ const PropertyFiller = ({
3938
3971
  console.log('Stringify failed', error);
3939
3972
  }
3940
3973
  } else {
3941
- setValue(name, defaultProperyValue);
3974
+ setValue(name, property.defaultValue || defaultProperyValue);
3942
3975
  }
3943
3976
  } else if (selectedType === 'expression' || selectedType === 'string') {
3944
3977
  onChange('');
@@ -3956,19 +3989,19 @@ const PropertyFiller = ({
3956
3989
  onChange(definitionValue);
3957
3990
  } catch (error) {
3958
3991
  onChange(defaultArrayValue);
3959
- console.log('Parse failed');
3992
+ // console.log('Parse failed');
3960
3993
  }
3961
3994
  } else {
3962
3995
  onChange(defaultArrayValue);
3963
3996
  }
3964
3997
  }
3965
3998
  clearErrors();
3966
- }, [name, defaultProperyValue, clearErrors, value, setFillOption, onChange, fillOption, propertyType, setValue]);
3999
+ }, [name, defaultProperyValue, clearErrors, value, setFillOption, onChange, fillOption, propertyType, setValue, property]);
3967
4000
  useEffect(() => {
3968
4001
  if (value === undefined) {
3969
- onChange(null);
4002
+ onChange(property.defaultValue || defaultProperyValue);
3970
4003
  }
3971
- }, [value, onChange, defaultProperyValue]);
4004
+ }, [value, onChange, defaultProperyValue, property]);
3972
4005
  return jsxs(Grid$1, Object.assign({
3973
4006
  xs: 12
3974
4007
  }, {
@@ -4007,21 +4040,14 @@ const PropertyFiller = ({
4007
4040
  }))
4008
4041
  })) : null, fillOption === 'expression' && (propertyType === PropertyType.JSON || propertyType === PropertyType.ENTITY || propertyType === PropertyType.ANY ? jsx(JsonEditor$1, {
4009
4042
  name: name,
4010
- ref: ref
4043
+ ref: ref,
4044
+ useParsedValue: true
4011
4045
  }) : jsx(ControlInput, {
4012
4046
  control: control,
4013
4047
  name: name,
4014
4048
  label: valueLabel,
4015
4049
  required: 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)
4050
+ hideErrorMessage: true
4025
4051
  })), fillOption === 'string' && jsx(ControlInput, {
4026
4052
  control: control,
4027
4053
  name: name,
@@ -4036,7 +4062,7 @@ const PropertyFiller = ({
4036
4062
  name: name,
4037
4063
  useExpression: useExpression,
4038
4064
  label: valueLabel,
4039
- inputRef: ref,
4065
+ ref: ref,
4040
4066
  required: required
4041
4067
  }), fillOption === 'dem_builder' && jsx(CreateDefinition, {
4042
4068
  title: "JSON",
@@ -4108,9 +4134,13 @@ const MultiplePropertyWidget = ({
4108
4134
  size: "small",
4109
4135
  onClick: () => handleDeleteValue(index)
4110
4136
  }, {
4111
- children: jsx(CloseIcon, {
4137
+ children: jsx(SvgIcon, Object.assign({
4112
4138
  fontSize: "small"
4113
- })
4139
+ }, {
4140
+ children: jsx("path", {
4141
+ d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
4142
+ })
4143
+ }))
4114
4144
  }))
4115
4145
  }))]
4116
4146
  }))
@@ -4153,7 +4183,7 @@ const MultiplePropertyFiller = ({
4153
4183
  } = useController({
4154
4184
  control,
4155
4185
  name,
4156
- defaultValue: [],
4186
+ defaultValue: property.defaultValue,
4157
4187
  rules: {
4158
4188
  validate: val => {
4159
4189
  if (required && !val) return 'Please, fill this field';
@@ -4188,16 +4218,17 @@ const MultiplePropertyFiller = ({
4188
4218
  } else if (selectedType === 'expression' || selectedType === 'json_valid' || selectedType === 'json_notvalid') {
4189
4219
  onChange('');
4190
4220
  } else if (selectedType === 'widget') {
4221
+ console.log('WiDGET??');
4191
4222
  onChange([]);
4192
4223
  }
4193
4224
  setFillOption(selectedType);
4194
4225
  clearErrors(name);
4195
4226
  };
4196
- // useEffect(() => {
4197
- // if (value === undefined) {
4198
- // onChange([]);
4199
- // }
4200
- // }, [value, property, onChange]);
4227
+ useEffect(() => {
4228
+ if (value === undefined) {
4229
+ onChange(property.isRequired ? [] : null);
4230
+ }
4231
+ }, [value, property, onChange]);
4201
4232
  return jsxs(Grid$1, {
4202
4233
  children: [title && jsx(Box, Object.assign({
4203
4234
  mb: 2
@@ -4562,7 +4593,7 @@ const ValidationNodeSelector = ({
4562
4593
  content: jsxs(Fragment, {
4563
4594
  children: [jsxs(Box, Object.assign({
4564
4595
  display: "flex",
4565
- alignItems: "center"
4596
+ alignItems: "flex-end"
4566
4597
  }, {
4567
4598
  children: [jsx(ControlSelect, {
4568
4599
  required: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dartech/arsenal-ui",
3
- "version": "1.3.58",
3
+ "version": "1.3.60",
4
4
  "author": "DAR",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -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: ({ property, name, label, useExpression, inputRef }: Props) => JSX.Element;
10
+ export declare const PropertyWidget: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<any>>;
13
11
  export default PropertyWidget;