@dartech/arsenal-ui 1.3.58 → 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 CHANGED
@@ -216,6 +216,7 @@ const AlertDialog = ({
216
216
  * @category Forms
217
217
  */
218
218
  const ControlInput = _a => {
219
+ var _b;
219
220
  var {
220
221
  control,
221
222
  validate,
@@ -229,25 +230,31 @@ const ControlInput = _a => {
229
230
  onChange: customOnChange
230
231
  } = _a,
231
232
  textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "textarea", "hideErrorMessage", "onChange"]);
232
- const {
233
- field: {
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
+ {
234
244
  ref,
235
- onChange,
236
- value
237
- },
238
- fieldState: {
239
- error
240
- }
241
- } = useController({
242
- name,
245
+ onChange
246
+ } = _d,
247
+ fieldProps = __rest(_d, ["ref", "onChange"]),
248
+ {
249
+ fieldState: {
250
+ error
251
+ }
252
+ } = _c;
253
+ const value = useWatch({
243
254
  control,
244
- defaultValue,
245
- rules: {
246
- required: required && 'Please, fill this field',
247
- validate
248
- }
255
+ name
249
256
  });
250
- return jsx(TextField, Object.assign({
257
+ return jsx(TextField, Object.assign({}, fieldProps, {
251
258
  fullWidth: true,
252
259
  size: "small",
253
260
  variant: "outlined",
@@ -270,7 +277,10 @@ const ControlInput = _a => {
270
277
  multiline: textarea,
271
278
  minRows: textarea ? 3 : 1,
272
279
  value: value !== null && value !== void 0 ? value : '',
273
- onChange: customOnChange ? customOnChange : onChange
280
+ onChange: customOnChange ? customOnChange : onChange,
281
+ inputProps: Object.assign(Object.assign({}, (_b = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputProps) !== null && _b !== void 0 ? _b : {}), {
282
+ value: value !== null && value !== void 0 ? value : ''
283
+ })
274
284
  }, textFieldProps));
275
285
  };
276
286
 
@@ -410,23 +420,26 @@ const ControlSelect = _a => {
410
420
  options = []
411
421
  } = _a,
412
422
  textFieldProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange", "labelKey", "valueKey", "options"]);
413
- const {
414
- field: {
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
+ {
415
434
  ref,
416
435
  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
- });
436
+ } = _d,
437
+ fieldProps = __rest(_d, ["ref", "onChange"]),
438
+ {
439
+ fieldState: {
440
+ error
441
+ }
442
+ } = _c;
430
443
  const value = useWatch({
431
444
  control,
432
445
  name
@@ -444,7 +457,7 @@ const ControlSelect = _a => {
444
457
  customOnChange(null);
445
458
  } else onChange(null);
446
459
  }, [onChange, customOnChange]);
447
- return jsx(TextField, Object.assign({
460
+ return jsx(TextField, Object.assign({}, fieldProps, {
448
461
  select: true,
449
462
  fullWidth: true,
450
463
  size: "small",
@@ -518,19 +531,22 @@ const ControlCheckbox = _a => {
518
531
  onChange: customOnChange
519
532
  } = _a,
520
533
  checkboxProps = __rest(_a, ["control", "validate", "name", "label", "required", "defaultValue", "disabled", "hideErrorMessage", "onChange"]);
521
- const {
522
- field: {
534
+ const _b = useController({
535
+ name,
536
+ control,
537
+ defaultValue: false
538
+ }),
539
+ _c = _b.field,
540
+ {
523
541
  ref,
524
542
  onChange
525
- },
526
- fieldState: {
527
- error
528
- }
529
- } = useController({
530
- name,
531
- control,
532
- defaultValue: false
533
- });
543
+ } = _c,
544
+ fieldProps = __rest(_c, ["ref", "onChange"]),
545
+ {
546
+ fieldState: {
547
+ error
548
+ }
549
+ } = _b;
534
550
  const value = useWatch({
535
551
  control,
536
552
  name
@@ -556,7 +572,7 @@ const ControlCheckbox = _a => {
556
572
  disabled: disabled
557
573
  }, {
558
574
  children: [jsx(FormControlLabel, {
559
- control: jsx(Checkbox, Object.assign({
575
+ control: jsx(Checkbox, Object.assign({}, fieldProps, {
560
576
  checked: checked,
561
577
  onChange: customOnChange ? customOnChange : onChange,
562
578
  name: name,
@@ -591,23 +607,26 @@ const ControlRadio = ({
591
607
  row,
592
608
  radioProps
593
609
  }) => {
594
- const {
595
- field: {
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
+ {
596
621
  ref,
597
622
  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
- });
623
+ } = _b,
624
+ fieldProps = __rest(_b, ["ref", "onChange"]),
625
+ {
626
+ fieldState: {
627
+ error
628
+ }
629
+ } = _a;
611
630
  const value = useWatch({
612
631
  control,
613
632
  name
@@ -628,7 +647,7 @@ const ControlRadio = ({
628
647
  id: "radio-buttons-group"
629
648
  }, {
630
649
  children: label
631
- })), jsx(RadioGroup, Object.assign({
650
+ })), jsx(RadioGroup, Object.assign({}, fieldProps, {
632
651
  row: row,
633
652
  "aria-labelledby": "radio-buttons-group",
634
653
  ref: ref,
@@ -1041,8 +1060,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
1041
1060
  const {
1042
1061
  field: {
1043
1062
  onChange,
1044
- value,
1045
- ref: fromRef
1063
+ ref: formRef
1046
1064
  },
1047
1065
  fieldState: {
1048
1066
  error
@@ -1054,7 +1072,10 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
1054
1072
  required: required && 'Please, fill this field'
1055
1073
  }
1056
1074
  });
1057
- // const value = useWatch({ control, name });
1075
+ const value = useWatch({
1076
+ control,
1077
+ name
1078
+ });
1058
1079
  const extensions = useMemo(() => ({
1059
1080
  json: [langs.json()],
1060
1081
  javascript: [langs.javascript()],
@@ -1113,7 +1134,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
1113
1134
  }))
1114
1135
  }), jsxs(Fragment, {
1115
1136
  children: [jsx(CodeMirror, Object.assign({
1116
- ref: ref || fromRef,
1137
+ ref: ref || formRef,
1117
1138
  basicSetup: {
1118
1139
  autocompletion: true,
1119
1140
  history: true
@@ -1836,7 +1857,7 @@ const ControlNumberInput = _a => {
1836
1857
  name = '',
1837
1858
  label = '',
1838
1859
  required = false,
1839
- defaultValue,
1860
+ defaultValue = null,
1840
1861
  disabled = false,
1841
1862
  hideErrorMessage = false,
1842
1863
  onChange: customOnChange,
@@ -1844,35 +1865,35 @@ const ControlNumberInput = _a => {
1844
1865
  valueAsNumber = true
1845
1866
  } = _a,
1846
1867
  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';
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;
1867
1882
  }
1868
- return true;
1869
1883
  }
1870
- }
1871
- });
1872
- const value = useWatch({
1873
- control,
1874
- name
1875
- });
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;
1876
1897
  const handleChange = event => {
1877
1898
  var _a;
1878
1899
  const lastData = event.nativeEvent['data'] || event.target.value;
@@ -1897,7 +1918,7 @@ const ControlNumberInput = _a => {
1897
1918
  onChange(event.target.value);
1898
1919
  }
1899
1920
  };
1900
- return jsx(TextField, Object.assign({
1921
+ return jsx(TextField, Object.assign({}, fieldProps, {
1901
1922
  fullWidth: true,
1902
1923
  size: "small",
1903
1924
  variant: "outlined",
@@ -1917,13 +1938,12 @@ const ControlNumberInput = _a => {
1917
1938
  error: !!error,
1918
1939
  helperText: !hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message),
1919
1940
  disabled: disabled,
1920
- value: value !== null && value !== void 0 ? value : ''
1921
- }, textFieldProps, {
1941
+ value: value !== null && value !== void 0 ? value : '',
1922
1942
  onChange: handleChange,
1923
1943
  inputProps: Object.assign(Object.assign({}, (_b = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputProps) !== null && _b !== void 0 ? _b : {}), {
1924
1944
  value: value !== null && value !== void 0 ? value : ''
1925
1945
  })
1926
- }));
1946
+ }, textFieldProps));
1927
1947
  };
1928
1948
 
1929
1949
  const ControlSwitch = _a => {
@@ -1933,15 +1953,15 @@ const ControlSwitch = _a => {
1933
1953
  label
1934
1954
  } = _a,
1935
1955
  switchProps = __rest(_a, ["control", "name", "label"]);
1936
- const {
1937
- field: {
1956
+ const _b = useController({
1957
+ control,
1958
+ name
1959
+ }).field,
1960
+ {
1938
1961
  ref,
1939
1962
  onChange
1940
- }
1941
- } = useController({
1942
- control,
1943
- name
1944
- });
1963
+ } = _b,
1964
+ fieldProps = __rest(_b, ["ref", "onChange"]);
1945
1965
  const value = useWatch({
1946
1966
  control,
1947
1967
  name
@@ -1974,7 +1994,7 @@ const ControlSwitch = _a => {
1974
1994
  return jsx(FormControlLabel, {
1975
1995
  label: label,
1976
1996
  name: name,
1977
- control: jsx(Switch, Object.assign({
1997
+ control: jsx(Switch, Object.assign({}, fieldProps, {
1978
1998
  color: "primary",
1979
1999
  size: "small",
1980
2000
  inputRef: ref,
@@ -2121,27 +2141,30 @@ const ControlTime = ({
2121
2141
  format: _format = TIME_DEFAULT_FORMAT,
2122
2142
  hideErrorMessage: _hideErrorMessage = false
2123
2143
  }) => {
2124
- const {
2125
- field: {
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
+ {
2126
2159
  onChange,
2127
2160
  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';
2161
+ } = _b,
2162
+ fieldProps = __rest(_b, ["onChange", "ref"]),
2163
+ {
2164
+ fieldState: {
2165
+ error
2142
2166
  }
2143
- }
2144
- });
2167
+ } = _a;
2145
2168
  const value = useWatch({
2146
2169
  control,
2147
2170
  name
@@ -2160,7 +2183,7 @@ const ControlTime = ({
2160
2183
  setFieldValue(parsedValue);
2161
2184
  }
2162
2185
  }, [value, _format]);
2163
- return jsx(TimePicker, {
2186
+ return jsx(TimePicker, Object.assign({}, fieldProps, {
2164
2187
  mask: "",
2165
2188
  inputRef: ref,
2166
2189
  label: required ? jsxs(Fragment, {
@@ -2185,7 +2208,7 @@ const ControlTime = ({
2185
2208
  error: !!error,
2186
2209
  helperText: !_hideErrorMessage && (error === null || error === void 0 ? void 0 : error.message)
2187
2210
  }))
2188
- });
2211
+ }));
2189
2212
  };
2190
2213
 
2191
2214
  const ControlArrayInput = ({
@@ -3614,7 +3637,7 @@ const JsonEditor = /*#__PURE__*/forwardRef(({
3614
3637
  zIndex: 0,
3615
3638
  isolation: 'isolate'
3616
3639
  },
3617
- value: typeof value !== 'string' ? value === null ? '' : JSON.stringify(value, null, 2) : value,
3640
+ value: typeof value !== 'string' ? value === null ? '' : JSON.stringify(value) : value,
3618
3641
  onChange: handleChange,
3619
3642
  extensions: [langs.json()]
3620
3643
  });
@@ -3682,13 +3705,12 @@ const StringValueField = ({
3682
3705
  };
3683
3706
  var StringValueField$1 = StringValueField;
3684
3707
 
3685
- const PropertyWidget = ({
3708
+ const PropertyWidget = /*#__PURE__*/forwardRef(({
3686
3709
  property,
3687
3710
  name,
3688
3711
  label,
3689
- useExpression,
3690
- inputRef
3691
- }) => {
3712
+ useExpression
3713
+ }, ref) => {
3692
3714
  const {
3693
3715
  control
3694
3716
  } = useFormContext();
@@ -3699,7 +3721,6 @@ const PropertyWidget = ({
3699
3721
  case PropertyType.DOUBLE:
3700
3722
  return jsx(ControlNumberInput, {
3701
3723
  decimal: true,
3702
- required: true,
3703
3724
  hideErrorMessage: true,
3704
3725
  control: control,
3705
3726
  name: name,
@@ -3709,8 +3730,10 @@ const PropertyWidget = ({
3709
3730
  case PropertyType.INTEGER:
3710
3731
  case PropertyType.BIG_INTEGER:
3711
3732
  case PropertyType.LONG:
3712
- return jsx(ControlNumberInput, {
3713
- required: true,
3733
+ return jsx(ControlNumberInput
3734
+ // required
3735
+ , {
3736
+ // required
3714
3737
  hideErrorMessage: true,
3715
3738
  control: control,
3716
3739
  name: name,
@@ -3723,8 +3746,10 @@ const PropertyWidget = ({
3723
3746
  name: name
3724
3747
  });
3725
3748
  case PropertyType.DATE:
3726
- return jsx(ControlDate, {
3727
- required: true,
3749
+ return jsx(ControlDate
3750
+ // required
3751
+ , {
3752
+ // required
3728
3753
  hideErrorMessage: true,
3729
3754
  control: control,
3730
3755
  name: name,
@@ -3732,8 +3757,10 @@ const PropertyWidget = ({
3732
3757
  format: property.format
3733
3758
  });
3734
3759
  case PropertyType.TIME:
3735
- return jsx(ControlTime, {
3736
- required: true,
3760
+ return jsx(ControlTime
3761
+ // required
3762
+ , {
3763
+ // required
3737
3764
  hideErrorMessage: true,
3738
3765
  control: control,
3739
3766
  name: name,
@@ -3741,8 +3768,10 @@ const PropertyWidget = ({
3741
3768
  format: property.format
3742
3769
  });
3743
3770
  case PropertyType.DATE_TIME:
3744
- return jsx(ControlDateTime, {
3745
- required: true,
3771
+ return jsx(ControlDateTime
3772
+ // required
3773
+ , {
3774
+ // required
3746
3775
  hideErrorMessage: true,
3747
3776
  control: control,
3748
3777
  name: name,
@@ -3753,12 +3782,14 @@ const PropertyWidget = ({
3753
3782
  return jsx(JsonEditor$1, {
3754
3783
  validate: true,
3755
3784
  name: name,
3756
- ref: inputRef,
3785
+ ref: ref,
3757
3786
  useParsedValue: true
3758
3787
  });
3759
3788
  case PropertyType.STRING:
3760
- return jsx(StringValueField$1, {
3761
- required: true,
3789
+ return jsx(StringValueField$1
3790
+ // required={!property.isRequired}
3791
+ , {
3792
+ // required={!property.isRequired}
3762
3793
  name: name,
3763
3794
  label: label,
3764
3795
  restrictedValues: property.restrictedValues
@@ -3774,7 +3805,7 @@ const PropertyWidget = ({
3774
3805
  case PropertyType.ANY:
3775
3806
  return jsx(JsonEditor$1, {
3776
3807
  name: name,
3777
- ref: inputRef
3808
+ ref: ref
3778
3809
  });
3779
3810
  case PropertyType.ENTITY:
3780
3811
  return jsx(DefinitionFiller, {
@@ -3787,7 +3818,7 @@ const PropertyWidget = ({
3787
3818
  children: "No widget"
3788
3819
  });
3789
3820
  }
3790
- };
3821
+ });
3791
3822
 
3792
3823
  const usePropertyFiller = ({
3793
3824
  value,
@@ -3815,28 +3846,31 @@ const usePropertyFiller = ({
3815
3846
  useExpression: _useExpression
3816
3847
  }), [_useExpression, _required, propertyType, _multipleOptions]);
3817
3848
  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]);
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]);
3840
3874
  useEffect(() => {
3841
3875
  if (!fillOption) {
3842
3876
  if (isPropertyValueEmpty(value) && (fillOptions === null || fillOptions === void 0 ? void 0 : fillOptions.length)) {
@@ -3901,11 +3935,11 @@ const PropertyFiller = ({
3901
3935
  } = useController({
3902
3936
  name,
3903
3937
  control,
3938
+ defaultValue: property.defaultValue,
3904
3939
  rules: {
3905
3940
  required
3906
3941
  }
3907
3942
  });
3908
- // const value = useWatch({ control, name });
3909
3943
  const {
3910
3944
  propertyType,
3911
3945
  valueLabel,
@@ -3938,7 +3972,7 @@ const PropertyFiller = ({
3938
3972
  console.log('Stringify failed', error);
3939
3973
  }
3940
3974
  } else {
3941
- setValue(name, defaultProperyValue);
3975
+ setValue(name, property.defaultValue || defaultProperyValue);
3942
3976
  }
3943
3977
  } else if (selectedType === 'expression' || selectedType === 'string') {
3944
3978
  onChange('');
@@ -3956,19 +3990,19 @@ const PropertyFiller = ({
3956
3990
  onChange(definitionValue);
3957
3991
  } catch (error) {
3958
3992
  onChange(defaultArrayValue);
3959
- console.log('Parse failed');
3993
+ // console.log('Parse failed');
3960
3994
  }
3961
3995
  } else {
3962
3996
  onChange(defaultArrayValue);
3963
3997
  }
3964
3998
  }
3965
3999
  clearErrors();
3966
- }, [name, defaultProperyValue, clearErrors, value, setFillOption, onChange, fillOption, propertyType, setValue]);
4000
+ }, [name, defaultProperyValue, clearErrors, value, setFillOption, onChange, fillOption, propertyType, setValue, property]);
3967
4001
  useEffect(() => {
3968
4002
  if (value === undefined) {
3969
- onChange(null);
4003
+ onChange(property.defaultValue || defaultProperyValue);
3970
4004
  }
3971
- }, [value, onChange, defaultProperyValue]);
4005
+ }, [value, onChange, defaultProperyValue, property]);
3972
4006
  return jsxs(Grid$1, Object.assign({
3973
4007
  xs: 12
3974
4008
  }, {
@@ -4007,21 +4041,14 @@ const PropertyFiller = ({
4007
4041
  }))
4008
4042
  })) : null, fillOption === 'expression' && (propertyType === PropertyType.JSON || propertyType === PropertyType.ENTITY || propertyType === PropertyType.ANY ? jsx(JsonEditor$1, {
4009
4043
  name: name,
4010
- ref: ref
4044
+ ref: ref,
4045
+ useParsedValue: true
4011
4046
  }) : jsx(ControlInput, {
4012
4047
  control: control,
4013
4048
  name: name,
4014
4049
  label: valueLabel,
4015
4050
  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)
4051
+ hideErrorMessage: true
4025
4052
  })), fillOption === 'string' && jsx(ControlInput, {
4026
4053
  control: control,
4027
4054
  name: name,
@@ -4036,7 +4063,7 @@ const PropertyFiller = ({
4036
4063
  name: name,
4037
4064
  useExpression: useExpression,
4038
4065
  label: valueLabel,
4039
- inputRef: ref,
4066
+ ref: ref,
4040
4067
  required: required
4041
4068
  }), fillOption === 'dem_builder' && jsx(CreateDefinition, {
4042
4069
  title: "JSON",
@@ -4153,7 +4180,7 @@ const MultiplePropertyFiller = ({
4153
4180
  } = useController({
4154
4181
  control,
4155
4182
  name,
4156
- defaultValue: [],
4183
+ defaultValue: property.defaultValue,
4157
4184
  rules: {
4158
4185
  validate: val => {
4159
4186
  if (required && !val) return 'Please, fill this field';
@@ -4193,11 +4220,11 @@ const MultiplePropertyFiller = ({
4193
4220
  setFillOption(selectedType);
4194
4221
  clearErrors(name);
4195
4222
  };
4196
- // useEffect(() => {
4197
- // if (value === undefined) {
4198
- // onChange([]);
4199
- // }
4200
- // }, [value, property, onChange]);
4223
+ useEffect(() => {
4224
+ if (value === undefined) {
4225
+ onChange(property.isRequired ? [] : null);
4226
+ }
4227
+ }, [value, property, onChange]);
4201
4228
  return jsxs(Grid$1, {
4202
4229
  children: [title && jsx(Box, Object.assign({
4203
4230
  mb: 2
@@ -4562,7 +4589,7 @@ const ValidationNodeSelector = ({
4562
4589
  content: jsxs(Fragment, {
4563
4590
  children: [jsxs(Box, Object.assign({
4564
4591
  display: "flex",
4565
- alignItems: "center"
4592
+ alignItems: "flex-end"
4566
4593
  }, {
4567
4594
  children: [jsx(ControlSelect, {
4568
4595
  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.59",
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;