@mediusinc/mng-commons 6.1.0 → 6.2.0

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.
@@ -1,5 +1,5 @@
1
1
  import { of, Subject, isObservable, throwError, map, tap } from 'rxjs';
2
- import { StyleLevelEnum, CommonsInternalError, DataProviderInst, LoggerService, findReflectTypeName, StyleSizeEnum, ACommonsErrorBase, toObservable, fromEnumValuesAsValueArray, fromEnumConstantsAsValueArray, getEnumConstantName, GetterPipe, copyDataListParams } from '@mediusinc/mng-commons/core';
2
+ import { StyleLevelEnum, CommonsInternalError, DataProviderInst, LoggerService, findReflectTypeName, StyleSizeEnum, ACommonsErrorBase, toObservable, objectDeepCopy, fromEnumValuesAsValueArray, fromEnumConstantsAsValueArray, getEnumConstantName, GetterPipe, copyDataListParams } from '@mediusinc/mng-commons/core';
3
3
  import * as i0 from '@angular/core';
4
4
  import { InjectionToken, Input, Directive, inject, Injector } from '@angular/core';
5
5
  import { LookupDataProviderInst } from '@mediusinc/mng-commons/form/api';
@@ -1276,14 +1276,22 @@ class AGenericFieldDescriptor {
1276
1276
  // eslint-disable-next-line @typescript-eslint/no-empty-function
1277
1277
  constructor() {
1278
1278
  this._config = {};
1279
+ this._formlyConfig = {};
1279
1280
  }
1280
1281
  get config() {
1281
1282
  return this._config;
1282
1283
  }
1284
+ get formlyConfig() {
1285
+ return this._formlyConfig;
1286
+ }
1283
1287
  withConfig(config) {
1284
1288
  this._config = config;
1285
1289
  return this;
1286
1290
  }
1291
+ withFormlyConfig(formlyConfig) {
1292
+ this._formlyConfig = formlyConfig;
1293
+ return this;
1294
+ }
1287
1295
  /**
1288
1296
  * Override toJSON implementation to prevent overflow with circular dependency.
1289
1297
  * @ignore
@@ -1305,6 +1313,7 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
1305
1313
  /** @ignore */ this._disabled = false;
1306
1314
  /** @ignore */ this._validations = [];
1307
1315
  /** @ignore */ this._asyncValidations = [];
1316
+ /** @ignore */ this._validationOpts = {};
1308
1317
  /** @ignore */ this._updateOn = 'change';
1309
1318
  /** @ignore */ this._size = FieldSizeEnum.Normal;
1310
1319
  // localization
@@ -1357,6 +1366,9 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
1357
1366
  get asyncValidations() {
1358
1367
  return this._asyncValidations;
1359
1368
  }
1369
+ get validationOpts() {
1370
+ return this._validationOpts;
1371
+ }
1360
1372
  get requiredExpression() {
1361
1373
  return this._requiredExpression;
1362
1374
  }
@@ -1514,6 +1526,10 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
1514
1526
  this._asyncValidations = this._asyncValidations.filter(v => v.name !== name);
1515
1527
  return this;
1516
1528
  }
1529
+ withValidationOpts(validationOpts) {
1530
+ this._validationOpts = validationOpts;
1531
+ return this;
1532
+ }
1517
1533
  withClassName(opts) {
1518
1534
  if (typeof opts === 'string') {
1519
1535
  this._className = {
@@ -1552,6 +1568,8 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
1552
1568
  return this._eventsSubject.asObservable();
1553
1569
  }
1554
1570
  copyFieldsTo(obj) {
1571
+ obj._config = objectDeepCopy(this._config);
1572
+ obj._formlyConfig = objectDeepCopy(this._formlyConfig);
1555
1573
  obj._label = this._label;
1556
1574
  obj._placeholder = this._placeholder;
1557
1575
  obj._labelInfoTooltip = this._labelInfoTooltip;
@@ -1578,6 +1596,7 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
1578
1596
  obj._isLocalized = this._isLocalized;
1579
1597
  obj._validations = this._validations.map(value => value.copy());
1580
1598
  obj._asyncValidations = this._asyncValidations.map(value => value.copy());
1599
+ obj._validationOpts = { ...this._validationOpts };
1581
1600
  }
1582
1601
  }
1583
1602
 
@@ -1635,6 +1654,7 @@ class AFieldGroupDescriptor extends AGenericFieldDescriptor {
1635
1654
  super();
1636
1655
  this._fields = [];
1637
1656
  this._validations = [];
1657
+ this._validationOpts = {};
1638
1658
  this._name = name;
1639
1659
  this._default = name === EDITOR_DEFAULT_GROUP_NAME;
1640
1660
  }
@@ -1648,6 +1668,9 @@ class AFieldGroupDescriptor extends AGenericFieldDescriptor {
1648
1668
  get validations() {
1649
1669
  return this._validations;
1650
1670
  }
1671
+ get validationOpts() {
1672
+ return this._validationOpts;
1673
+ }
1651
1674
  get name() {
1652
1675
  return this._name;
1653
1676
  }
@@ -1665,6 +1688,10 @@ class AFieldGroupDescriptor extends AGenericFieldDescriptor {
1665
1688
  this._validations.push(new FieldValidationDescriptor(name, validator, message, opts));
1666
1689
  return this;
1667
1690
  }
1691
+ withValidationOpts(validationOpts) {
1692
+ this._validationOpts = validationOpts;
1693
+ return this;
1694
+ }
1668
1695
  withHidden(hiddenExpression) {
1669
1696
  this._hiddenExpression = hiddenExpression;
1670
1697
  return this;
@@ -1687,9 +1714,12 @@ class FieldTabGroupDescriptor extends AFieldGroupDescriptor {
1687
1714
  }
1688
1715
  copy(skipFields = false) {
1689
1716
  const tab = new FieldTabGroupDescriptor(this.name);
1717
+ tab._config = objectDeepCopy(this._config);
1718
+ tab._formlyConfig = objectDeepCopy(this._formlyConfig);
1690
1719
  tab._title = this._title;
1691
1720
  tab._fields = this.fields.map(f => f.copy(skipFields));
1692
1721
  tab._validations = this.validations.map(v => v.copy());
1722
+ tab._validationOpts = { ...this._validationOpts };
1693
1723
  tab._hiddenExpression = this._hiddenExpression;
1694
1724
  return tab;
1695
1725
  }
@@ -1735,6 +1765,8 @@ class FieldGroupDescriptor extends AFieldGroupDescriptor {
1735
1765
  }
1736
1766
  copy(skipFields = false) {
1737
1767
  const group = new FieldGroupDescriptor(this.name);
1768
+ group._config = objectDeepCopy(this._config);
1769
+ group._formlyConfig = objectDeepCopy(this._formlyConfig);
1738
1770
  group._type = this._type;
1739
1771
  group._title = this._title;
1740
1772
  group._hiddenExpression = this._hiddenExpression;
@@ -1742,6 +1774,7 @@ class FieldGroupDescriptor extends AFieldGroupDescriptor {
1742
1774
  group._fields = this.fields.map(f => f.copy());
1743
1775
  }
1744
1776
  group._validations = this.validations.map(v => v.copy());
1777
+ group._validationOpts = { ...this._validationOpts };
1745
1778
  group._className = this._className ? { ...this._className } : undefined;
1746
1779
  return group;
1747
1780
  }