@dartech/arsenal-ui 1.3.92 → 1.3.93

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.
Files changed (2) hide show
  1. package/index.js +66 -31
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2057,7 +2057,8 @@ const ControlDate = ({
2057
2057
  rules: {
2058
2058
  required: required && 'Please, fill this field',
2059
2059
  validate: val => {
2060
- if (isMatch(val, localFormat)) {
2060
+ console.log('DATE', val);
2061
+ if (val === '' || isMatch(val, localFormat)) {
2061
2062
  return true;
2062
2063
  }
2063
2064
  return 'Incorrect date format';
@@ -3284,13 +3285,17 @@ var EntityPropertiesShortView$1 = EntityPropertiesShortView;
3284
3285
 
3285
3286
  const defaultPropertyValues$1 = {
3286
3287
  key: '',
3287
- propertyType: '',
3288
+ propertyType: null,
3288
3289
  name: '',
3289
3290
  defaultValue: '',
3291
+ value: '',
3292
+ defaultValues: [],
3290
3293
  isRequired: true,
3291
3294
  isMultiple: false,
3292
3295
  sortOrder: 0,
3293
- isEnabled: true
3296
+ isEnabled: true,
3297
+ executeValue: '',
3298
+ uiSettings: ''
3294
3299
  };
3295
3300
  const EntityAdditionalFields = ({
3296
3301
  parentPropertyFieldName,
@@ -3814,10 +3819,8 @@ const PropertyWidget = ({
3814
3819
  entityReferenceValueComponent: EntityReferenceValueComponent,
3815
3820
  fileReferenceValueComponent: FileReferenceValueComponent
3816
3821
  }) => {
3817
- const propertyType = useMemo(() => {
3818
- var _a;
3819
- return typeof property.propertyType === 'string' ? property.propertyType : (_a = property['propertyType']) === null || _a === void 0 ? void 0 : _a['value'];
3820
- }, [property]);
3822
+ var _a;
3823
+ const propertyType = typeof property.propertyType === 'string' ? property.propertyType : (_a = property['propertyType']) === null || _a === void 0 ? void 0 : _a['value'];
3821
3824
  switch (propertyType) {
3822
3825
  case PropertyType.BIG_DECIMAL:
3823
3826
  case PropertyType.FLOAT:
@@ -3993,7 +3996,7 @@ const usePropertyFiller = ({
3993
3996
  case PropertyType.FLOAT:
3994
3997
  return 0;
3995
3998
  default:
3996
- return {};
3999
+ return null;
3997
4000
  }
3998
4001
  }, [propertyType]);
3999
4002
  const needRecursionCheck = useMemo(() => propertyType === PropertyType.JSON || propertyType === PropertyType.ANY, [propertyType]);
@@ -4057,6 +4060,7 @@ const PropertyFiller = ({
4057
4060
  watch
4058
4061
  } = useFormContext();
4059
4062
  const {
4063
+ // field: { value },
4060
4064
  fieldState: {
4061
4065
  error,
4062
4066
  isDirty
@@ -4146,13 +4150,13 @@ const PropertyFiller = ({
4146
4150
  clearErrors();
4147
4151
  }, [name, defaultProperyValue, clearErrors, value, setFillOption, fillOption, propertyType, setValue, property]);
4148
4152
  useEffect(() => {
4149
- if (!isDirty && property.defaultValue && !value) {
4150
- setValue(name, property.defaultValue);
4153
+ if (!isDirty && (property.defaultValue || property.value) && !value) {
4154
+ setValue(name, property.defaultValue || property.value);
4151
4155
  }
4152
4156
  }, [isDirty, property, name, setValue, value]);
4153
4157
  useEffect(() => {
4154
4158
  var _a;
4155
- if (value === undefined || property.isRequired && value === null && !property.defaultValue) {
4159
+ if (value === undefined || property.isRequired && value === null && !(property.defaultValue || property.value)) {
4156
4160
  setValue(name, (_a = prevValueRef.current[fillOption]) !== null && _a !== void 0 ? _a : defaultProperyValue);
4157
4161
  }
4158
4162
  }, [value, setValue, defaultProperyValue, property, name, fillOption]);
@@ -4500,33 +4504,55 @@ const PropertyValueField = ({
4500
4504
  fileReferenceValueComponent
4501
4505
  }) => {
4502
4506
  const {
4503
- watch
4507
+ control
4504
4508
  } = useFormContext();
4505
- const propertyType = watch(`${propertyFieldName}.propertyType`);
4506
- const isMultiple = watch(`${propertyFieldName}.isMultiple`);
4507
- const format = watch(`${propertyFieldName}.format`);
4508
- const restrictedValues = watch(`${propertyFieldName}.restrictedValues`);
4509
- const properties = watch(`${propertyFieldName}.properties`);
4510
- const isRequired = watch(`${propertyFieldName}.isRequired`);
4509
+ const propertyType = useWatch({
4510
+ control,
4511
+ name: `${propertyFieldName}.propertyType`
4512
+ });
4513
+ const isMultiple = useWatch({
4514
+ control,
4515
+ name: `${propertyFieldName}.isMultiple`
4516
+ });
4517
+ const format = useWatch({
4518
+ control,
4519
+ name: `${propertyFieldName}.format`
4520
+ });
4521
+ const restrictedValues = useWatch({
4522
+ control,
4523
+ name: `${propertyFieldName}.restrictedValues`
4524
+ });
4525
+ const properties = useWatch({
4526
+ control,
4527
+ name: `${propertyFieldName}.properties`
4528
+ });
4529
+ const isRequired = useWatch({
4530
+ control,
4531
+ name: `${propertyFieldName}.isRequired`
4532
+ });
4511
4533
  const fillerProperty = useMemo(() => {
4512
- const typeValue = typeof propertyType === 'string' ? propertyType : propertyType.value;
4513
- return {
4534
+ return Object.assign(Object.assign(Object.assign(Object.assign({
4514
4535
  name: _label,
4515
4536
  isRequired: required !== null && required !== void 0 ? required : isRequired,
4516
- isMultiple,
4517
- format,
4518
- restrictedValues,
4519
- properties,
4520
- propertyType: typeValue,
4537
+ isMultiple
4538
+ }, !!format && {
4539
+ format
4540
+ }), {
4541
+ restrictedValues
4542
+ }), !!properties && {
4543
+ properties
4544
+ }), {
4545
+ propertyType: typeof propertyType === 'string' ? propertyType : propertyType.value,
4521
4546
  defaultValue: null,
4522
4547
  defaultValues: [],
4523
4548
  sortOrder: 0,
4524
4549
  isEnabled: true,
4525
4550
  uiSettings: null,
4526
4551
  validationNode: null
4527
- };
4528
- }, [propertyType, format, restrictedValues, isMultiple, _label, isRequired, properties, required]);
4529
- console.log('isMultiple', isMultiple);
4552
+ });
4553
+ }, [propertyType, format, restrictedValues, isMultiple, _label,
4554
+ // key,
4555
+ isRequired, properties, required]);
4530
4556
  return isMultiple ? jsx(MultiplePropertyFiller, {
4531
4557
  name: name,
4532
4558
  property: fillerProperty,
@@ -4950,9 +4976,18 @@ const CreatePropertyFormFields = ({
4950
4976
  setValue,
4951
4977
  watch
4952
4978
  } = useFormContext();
4953
- const propertyType = watch(`${propertyFieldName}.propertyType`);
4954
- const isMultiple = watch(`${propertyFieldName}.isMultiple`);
4955
- const isRequired = watch(`${propertyFieldName}.isRequired`);
4979
+ const propertyType = useWatch({
4980
+ control,
4981
+ name: `${propertyFieldName}.propertyType`
4982
+ });
4983
+ const isMultiple = useWatch({
4984
+ control,
4985
+ name: `${propertyFieldName}.isMultiple`
4986
+ });
4987
+ const isRequired = useWatch({
4988
+ control,
4989
+ name: `${propertyFieldName}.isRequired`
4990
+ });
4956
4991
  const {
4957
4992
  customCheckboxes,
4958
4993
  customFields
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dartech/arsenal-ui",
3
- "version": "1.3.92",
3
+ "version": "1.3.93",
4
4
  "author": "DAR",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"