@signalplus/params-about 0.1.25 → 0.1.28

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.d.ts CHANGED
@@ -77,6 +77,7 @@ interface ParamFormData {
77
77
  }
78
78
  interface ParamFormProps {
79
79
  parentOptions: ParentSelectorProps['parentOptions'];
80
+ allKeys: string[];
80
81
  expiriesOptions: string[];
81
82
  initialValues?: Partial<ParamFormData>;
82
83
  groupEditable?: boolean;
@@ -308,7 +309,7 @@ declare function numRangeValidator(val: {
308
309
  }, enableEmpty?: boolean): string;
309
310
  declare function expiryValidator(val: string, enableEmpty?: boolean): "Should not be empty" | "" | "Out of format";
310
311
  declare function expiriesValidator(val: string[]): string;
311
- declare function keyValidator(val: string): "Should not be empty" | "" | "Out of format: should be a combination of the following chars `_.0-9a-zA-Z`";
312
+ declare function keyValidator(val: string, allKeys: string[]): "Should not be empty" | "" | "Out of format: should be a combination of the following chars `_.0-9a-zA-Z`" | "This key has been used";
312
313
  declare function isExpired(val?: string): boolean;
313
314
  declare function validatorCvt(validator: (val: any, values: any) => ValidateInfo['string'], form?: () => any): (_: any, val: any) => Promise<any>;
314
315
 
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Bundle of @signalplus/params-about
3
3
  * Generated: 2022-04-12
4
- * Version: 0.1.25
4
+ * Version: 0.1.28
5
5
  * License: MIT
6
6
  * Author: 2631541504@qq.com
7
7
  */
@@ -409,10 +409,19 @@ function expiriesValidator(val) {
409
409
 
410
410
  return '';
411
411
  }
412
- function keyValidator(val) {
412
+ function keyValidator(val, allKeys) {
413
413
  var error = emptyValidator(val);
414
414
  if (error) return error;
415
- return /^[_.a-zA-Z0-9]+$/.test(val) ? '' : 'Out of format: should be a combination of the following chars `_.0-9a-zA-Z`';
415
+
416
+ if (/^[_.a-zA-Z0-9]+$/.test(val)) {
417
+ return 'Out of format: should be a combination of the following chars `_.0-9a-zA-Z`';
418
+ }
419
+
420
+ var has = allKeys.some(function (it) {
421
+ return val === it;
422
+ });
423
+ if (has) return 'This key has been used';
424
+ return '';
416
425
  }
417
426
  function isExpired(val) {
418
427
  if (!val) return false;
@@ -751,6 +760,10 @@ var TextArray = /*#__PURE__*/function (_PureComponent) {
751
760
 
752
761
  _defineProperty(_assertThisInitialized(_this), "value", []);
753
762
 
763
+ _defineProperty(_assertThisInitialized(_this), "isEmptyItem", function (item) {
764
+ return !item.trim();
765
+ });
766
+
754
767
  _defineProperty(_assertThisInitialized(_this), "onChange", function (i, e) {
755
768
  var _this$props$onChange, _this$props;
756
769
 
@@ -759,7 +772,7 @@ var TextArray = /*#__PURE__*/function (_PureComponent) {
759
772
  var value = _toConsumableArray(_this.value);
760
773
 
761
774
  value[i] = val;
762
- (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
775
+ (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value);
763
776
  });
764
777
 
765
778
  _defineProperty(_assertThisInitialized(_this), "onAdd", function (i) {
@@ -777,7 +790,7 @@ var TextArray = /*#__PURE__*/function (_PureComponent) {
777
790
  var value = _toConsumableArray(_this.value);
778
791
 
779
792
  value.splice(i, 1);
780
- (_this$props$onChange3 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props3, value);
793
+ (_this$props$onChange3 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props3, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value);
781
794
  });
782
795
 
783
796
  return _this;
@@ -786,9 +799,10 @@ var TextArray = /*#__PURE__*/function (_PureComponent) {
786
799
  _createClass(TextArray, [{
787
800
  key: "render",
788
801
  value: function render() {
789
- var _this2 = this;
802
+ var _this$props$value,
803
+ _this2 = this;
790
804
 
791
- this.value = this.props.value || [];
805
+ this.value = ((_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.slice()) || [];
792
806
  if (!this.value.length) this.value.push('');
793
807
  return /*#__PURE__*/React.createElement("div", {
794
808
  className: classNames('param-text-array', {
@@ -973,6 +987,12 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
973
987
 
974
988
  _defineProperty(_assertThisInitialized(_this), "value", []);
975
989
 
990
+ _defineProperty(_assertThisInitialized(_this), "isEmptyItem", function (item) {
991
+ var _item$expiry;
992
+
993
+ return !((_item$expiry = item.expiry) === null || _item$expiry === void 0 ? void 0 : _item$expiry.trim()) && isNullLike(item.minAumPercentage) && isNullLike(item.maxAumPercentage) && isNullLike(item.minAbs) && isNullLike(item.maxAbs);
994
+ });
995
+
976
996
  _defineProperty(_assertThisInitialized(_this), "onChange", function (i, val, key) {
977
997
  var _this$props$onChange, _this$props;
978
998
 
@@ -982,7 +1002,7 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
982
1002
  expiry: ''
983
1003
  };
984
1004
  if (key) value[i][key] = val;else value[i] = _objectSpread2(_objectSpread2({}, value[i]), val);
985
- (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
1005
+ (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value);
986
1006
  });
987
1007
 
988
1008
  _defineProperty(_assertThisInitialized(_this), "onAdd", function (i) {
@@ -1003,7 +1023,7 @@ var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
1003
1023
  var value = _toConsumableArray(_this.value);
1004
1024
 
1005
1025
  value.splice(i, 1);
1006
- (_this$props$onChange3 = (_this$props4 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props4, value);
1026
+ (_this$props$onChange3 = (_this$props4 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props4, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value);
1007
1027
  (_this$props$onBlur2 = (_this$props5 = _this.props).onBlur) === null || _this$props$onBlur2 === void 0 ? void 0 : _this$props$onBlur2.call(_this$props5);
1008
1028
  });
1009
1029
 
@@ -1392,7 +1412,9 @@ var ParamForm = /*#__PURE__*/function (_PureComponent) {
1392
1412
  }, props));
1393
1413
  },
1394
1414
  required: true,
1395
- validator: validatorCvt(keyValidator)
1415
+ validator: validatorCvt(function (val) {
1416
+ return keyValidator(val, _this2.props.allKeys);
1417
+ })
1396
1418
  }, {
1397
1419
  label: '参数名称',
1398
1420
  name: 'name',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalplus/params-about",
3
- "version": "0.1.25",
3
+ "version": "0.1.28",
4
4
  "description": "A description for the module",
5
5
  "main": "./lib/umd/index.js",
6
6
  "module": "./lib/es/index.js",