@dartech/arsenal-ui 1.3.62 → 1.3.64

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
@@ -1214,22 +1214,10 @@ const JsonView = ({
1214
1214
  height: _height = '200px',
1215
1215
  fontSize: _fontSize = 16
1216
1216
  }) => {
1217
- const stringValue = useMemo(() => {
1218
- if (typeof value === 'string') {
1219
- return value;
1220
- } else if (typeof value === 'object') {
1221
- try {
1222
- return JSON.stringify(value, null, 2);
1223
- } catch (error) {
1224
- return 'Failed to stringify Object';
1225
- }
1226
- }
1227
- return '';
1228
- }, [value]);
1229
1217
  return jsx(CodeMirror, {
1230
1218
  readOnly: true,
1231
1219
  width: "100%",
1232
- value: stringValue,
1220
+ value: typeof value === 'string' ? value : JSON.stringify(value, null, 2),
1233
1221
  height: _height,
1234
1222
  basicSetup: {
1235
1223
  autocompletion: true,
@@ -1447,7 +1435,8 @@ const formatTableRowValue = ({
1447
1435
  const digitsOnly = new RegExp('^[-+]?[0-9]+$');
1448
1436
  const floatsOnly = new RegExp(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/);
1449
1437
  const isExpression = value => {
1450
- return typeof value === 'string' ? value.includes('$(') : false;
1438
+ // return typeof value === 'string' ? value.includes('$(') : false;
1439
+ return typeof value === 'string' ? /\$(?:S?JS)?\(/g.test(value) : false;
1451
1440
  };
1452
1441
  const isDateType = propertyType => {
1453
1442
  return propertyType === PropertyType.DATE || propertyType === PropertyType.DATE_TIME || propertyType === PropertyType.TIME;
@@ -3715,17 +3704,16 @@ const PropertyWidget = ({
3715
3704
  });
3716
3705
  // return <JsonEditor validate name={name} ref={ref} useParsedValue />;
3717
3706
  case PropertyType.STRING:
3718
- return jsx(StringValueField$1
3719
- // required={!property.isRequired}
3720
- , {
3721
- // required={!property.isRequired}
3707
+ return jsx(StringValueField$1, {
3722
3708
  name: name,
3723
3709
  label: label,
3724
3710
  restrictedValues: property.restrictedValues
3725
3711
  });
3726
3712
  case PropertyType.ENTITY_REFERENCE:
3727
- return jsx(ControlInput, {
3728
- required: true,
3713
+ return jsx(ControlInput
3714
+ // required
3715
+ , {
3716
+ // required
3729
3717
  hideErrorMessage: true,
3730
3718
  name: name,
3731
3719
  label: label,
@@ -3803,7 +3791,7 @@ const usePropertyFiller = ({
3803
3791
  const checkFillOption = useCallback(() => {
3804
3792
  if (isExpression(value) && fillOption !== 'expression') {
3805
3793
  setFillOption('expression');
3806
- } else if (value !== null && value !== undefined && !isExpression(value) && fillOption !== 'widget') {
3794
+ } else if (value !== null && value !== undefined && !isExpression(value) && fillOption !== 'widget' && fillOption !== 'string') {
3807
3795
  setFillOption('widget');
3808
3796
  }
3809
3797
  }, [value, fillOption]);
@@ -3868,7 +3856,10 @@ const PropertyFiller = ({
3868
3856
  control,
3869
3857
  defaultValue: property.defaultValue,
3870
3858
  rules: {
3871
- required
3859
+ validate: val => {
3860
+ if (required && val === null) return 'Please, fill this field555';
3861
+ return true;
3862
+ }
3872
3863
  }
3873
3864
  });
3874
3865
  const {
@@ -3921,7 +3912,6 @@ const PropertyFiller = ({
3921
3912
  setValue(name, definitionValue);
3922
3913
  } catch (error) {
3923
3914
  setValue(name, defaultArrayValue);
3924
- // console.log('Parse failed');
3925
3915
  }
3926
3916
  } else {
3927
3917
  setValue(name, defaultArrayValue);
@@ -3935,10 +3925,10 @@ const PropertyFiller = ({
3935
3925
  }
3936
3926
  }, [isDirty, property, name, setValue]);
3937
3927
  useEffect(() => {
3938
- if (property.isRequired && !value) {
3928
+ if (value === undefined || property.isRequired && value === null && !property.defaultValue) {
3939
3929
  setValue(name, defaultProperyValue);
3940
3930
  }
3941
- }, [value, setValue, defaultProperyValue, property, name, isDirty]);
3931
+ }, [value, setValue, defaultProperyValue, property, name]);
3942
3932
  return jsxs(Grid$1, Object.assign({
3943
3933
  xs: 12
3944
3934
  }, {
@@ -3975,9 +3965,7 @@ const PropertyFiller = ({
3975
3965
  }), option.value))
3976
3966
  }))]
3977
3967
  }))
3978
- })) : null, fillOption === 'expression' && (propertyType === PropertyType.JSON || propertyType === PropertyType.ENTITY || propertyType === PropertyType.ANY ?
3979
- // <JsonEditor validate name={name} useParsedValue />
3980
- jsx(ControlAceEditor, {
3968
+ })) : null, fillOption === 'expression' && (propertyType === PropertyType.JSON || propertyType === PropertyType.ENTITY || propertyType === PropertyType.ANY ? jsx(ControlAceEditor, {
3981
3969
  name: name,
3982
3970
  control: control,
3983
3971
  label: valueLabel,
@@ -3988,17 +3976,13 @@ const PropertyFiller = ({
3988
3976
  control: control,
3989
3977
  name: name,
3990
3978
  label: valueLabel,
3991
- required: true,
3992
3979
  hideErrorMessage: true
3993
3980
  })), fillOption === 'string' && jsx(ControlInput, {
3994
3981
  control: control,
3995
3982
  name: name,
3996
3983
  label: valueLabel,
3997
- required: true,
3998
3984
  hideErrorMessage: true
3999
- }), fillOption === 'json_notvalid' &&
4000
- // <JsonEditor validate name={name} />
4001
- jsx(ControlAceEditor, {
3985
+ }), fillOption === 'json_notvalid' && jsx(ControlAceEditor, {
4002
3986
  name: name,
4003
3987
  control: control,
4004
3988
  label: valueLabel,
@@ -4008,8 +3992,7 @@ const PropertyFiller = ({
4008
3992
  property: property,
4009
3993
  name: name,
4010
3994
  useExpression: useExpression,
4011
- label: valueLabel,
4012
- required: required
3995
+ label: valueLabel
4013
3996
  }), fillOption === 'dem_builder' && jsx(CreateDefinition, {
4014
3997
  title: "JSON",
4015
3998
  definitionFieldName: name
@@ -4224,6 +4207,7 @@ const MultiplePropertyFiller = ({
4224
4207
  }, [value, property, onChange]);
4225
4208
  useEffect(() => {
4226
4209
  if (value && !selectTouched) {
4210
+ setSelectTouched(true);
4227
4211
  checkFillOption();
4228
4212
  }
4229
4213
  }, [checkFillOption, selectTouched, value]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dartech/arsenal-ui",
3
- "version": "1.3.62",
3
+ "version": "1.3.64",
4
4
  "author": "DAR",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -6,7 +6,6 @@ type Props = {
6
6
  name: string;
7
7
  label?: string;
8
8
  useExpression?: boolean;
9
- required?: boolean;
10
9
  control: Control<any>;
11
10
  };
12
11
  export declare const PropertyWidget: ({ property, name, label, useExpression, control }: Props) => JSX.Element;