@signalplus/params-about 1.0.3 → 1.0.4-alpha

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
@@ -172,12 +172,38 @@ interface ParamGroupEditorData {
172
172
  valueType?: ParamType;
173
173
  descriptionUrl?: string;
174
174
  }
175
+ interface ParamItem {
176
+ parentId?: number | string;
177
+ paramId: number | string;
178
+ name?: string;
179
+ key?: string;
180
+ valueType: ParamType;
181
+ description?: string;
182
+ descriptionUrl?: string;
183
+ rank?: number;
184
+ value?: Record<string, any>;
185
+ defaultValue?: Record<string, any>;
186
+ children?: ParamItem[];
187
+ }
188
+ interface LocalParamItem extends Omit<ParamItem, 'paramId' | 'children' | 'childrenList'> {
189
+ paramId?: number | string;
190
+ /**
191
+ * 前端字段,用于本地建立参数与参数组之间的关系
192
+ * 提交到服务端不解析
193
+ * */
194
+ $paramId: number | string;
195
+ children?: LocalParamItem[];
196
+ }
175
197
  interface ParamGroupEditorProps extends Required<Pick<ImageUploadProps, 'getSignedUrl' | 'handleUpload'>> {
176
198
  /**
177
199
  * 传了表示为有父级
178
200
  * */
179
201
  parentOptions?: ParentSelectorProps['parentOptions'];
180
202
  initialValues?: Partial<ParamGroupEditorData>;
203
+ paramList: LocalParamItem[];
204
+ projectName: string;
205
+ templateName: string;
206
+ parentNames?: string;
181
207
  onChange?(data: ParamGroupEditorData): void;
182
208
  onSubmit?(data: ParamGroupEditorData): any;
183
209
  }
@@ -305,6 +331,7 @@ declare function expiryValidator(val: string, enableEmpty?: boolean): "Should no
305
331
  declare function expiriesValidator(val: string[]): string;
306
332
  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";
307
333
  declare function isExpired(val?: string): boolean;
334
+ declare function sameGroupNameValidator(val: string, paramList: LocalParamItem[], projectName: string, templateName: string, parentNames?: string): string | undefined;
308
335
  declare function validatorCvt(validator: (val: any, values: any) => ValidateInfo['string'], form?: () => any): (_: any, val: any) => Promise<any>;
309
336
 
310
- export { BaseInputProps, ParamForm, ParamFormData, ParamFormModal, ParamFormProps, ParamGroupEditor, ParamGroupEditorData, ParamGroupEditorModal, ParamGroupEditorModalEl, ParamGroupEditorProps, ParamMover, ParamMoverData, ParamMoverModal, ParamMoverModalEl, ParamMoverProps, ParamMoverState, ParamRenderer, ParamRendererProps, ParamType, ParamTypeConfig, ParamTypeOptions, ParamValueEditor, ParamValueEditorData, ParamValueEditorModal, ParamValueEditorModalEl, ParamValueEditorProps, ParamValueStruct, ValidateInfo, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, keyValidator, numRangeValidator, paramValidator, validatorCvt };
337
+ export { BaseInputProps, LocalParamItem, ParamForm, ParamFormData, ParamFormModal, ParamFormProps, ParamGroupEditor, ParamGroupEditorData, ParamGroupEditorModal, ParamGroupEditorModalEl, ParamGroupEditorProps, ParamItem, ParamMover, ParamMoverData, ParamMoverModal, ParamMoverModalEl, ParamMoverProps, ParamMoverState, ParamRenderer, ParamRendererProps, ParamType, ParamTypeConfig, ParamTypeOptions, ParamValueEditor, ParamValueEditorData, ParamValueEditorModal, ParamValueEditorModalEl, ParamValueEditorProps, ParamValueStruct, ValidateInfo, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, keyValidator, numRangeValidator, paramValidator, sameGroupNameValidator, validatorCvt };
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Bundle of @signalplus/params-about
3
- * Generated: 2022-06-16
4
- * Version: 1.0.3
3
+ * Generated: 2023-05-06
4
+ * Version: 1.0.4-alpha
5
5
  * License: MIT
6
6
  * Author: 2631541504@qq.com
7
7
  */
@@ -278,7 +278,7 @@ function numRangeValidator(val, enableEmpty) {
278
278
  return "Max: ".concat(error);
279
279
  }
280
280
 
281
- return val.min > val.max ? 'Max should bigger than Min' : '';
281
+ return +val.min > +val.max ? 'Max should bigger than Min' : '';
282
282
  }
283
283
  function expiryValidator(val, enableEmpty) {
284
284
  var error = emptyValidator(val, enableEmpty);
@@ -324,6 +324,14 @@ function isExpired(val) {
324
324
  var expireTime = dayjs("".concat(expiry.format('YYYY-MM-DD'), "T08:00Z"));
325
325
  return now >= expireTime;
326
326
  }
327
+ function sameGroupNameValidator(val, paramList, projectName, templateName, parentNames) {
328
+ var error = emptyValidator(val);
329
+ if (error) return error;
330
+ var hasSame = paramList.some(function (_it) {
331
+ return _it.name === val;
332
+ });
333
+ return hasSame ? "\u8BE5\u53C2\u6570\u7EC4\u540D\u79F0\u5728".concat(projectName, ">").concat(templateName).concat(parentNames ? '>' + parentNames : '', "\u4E0B\u5DF2\u5B58\u5728") : undefined;
334
+ }
327
335
  function validatorCvt(validator, form) {
328
336
  return function (_, val) {
329
337
  var $form = form === null || form === void 0 ? void 0 : form();
@@ -1176,10 +1184,10 @@ var ParamTypeConfig = (_ParamTypeConfig = {}, _defineProperty(_ParamTypeConfig,
1176
1184
  return "The ".concat(i + 1, "th item: at least one parameter must be specified between AUM and ABS");
1177
1185
  }
1178
1186
 
1179
- if ((!isNullLike(val === null || val === void 0 ? void 0 : val.minAbs) || !isNullLike(val === null || val === void 0 ? void 0 : val.maxAbs)) && val.minAbs >= val.maxAbs) // return { [i]: { minAbs: 'Min ABS should smaller than Max ABS' } }
1187
+ if ((!isNullLike(val === null || val === void 0 ? void 0 : val.minAbs) || !isNullLike(val === null || val === void 0 ? void 0 : val.maxAbs)) && +val.minAbs >= +val.maxAbs) // return { [i]: { minAbs: 'Min ABS should smaller than Max ABS' } }
1180
1188
  return "The ".concat(i + 1, "th item: Min ABS should smaller than Max ABS");
1181
1189
 
1182
- if ((!isNullLike(val === null || val === void 0 ? void 0 : val.minAumPercentage) || !isNullLike(val === null || val === void 0 ? void 0 : val.maxAumPercentage)) && val.minAumPercentage >= val.maxAumPercentage) {
1190
+ if ((!isNullLike(val === null || val === void 0 ? void 0 : val.minAumPercentage) || !isNullLike(val === null || val === void 0 ? void 0 : val.maxAumPercentage)) && +val.minAumPercentage >= +val.maxAumPercentage) {
1183
1191
  // return {
1184
1192
  // [i]: { minAumPercentage: 'Min AUM should smaller than Max AUM' },
1185
1193
  // }
@@ -1952,7 +1960,7 @@ var ParamGroupEditor = /*#__PURE__*/function (_PureComponent) {
1952
1960
  }));
1953
1961
  },
1954
1962
  validator: validatorCvt(function (val) {
1955
- return emptyValidator(val);
1963
+ return sameGroupNameValidator(val, _this2.props.paramList, _this2.props.projectName, _this2.props.templateName, _this2.props.parentNames);
1956
1964
  })
1957
1965
  }, {
1958
1966
  label: '业务流程图',
@@ -1962,10 +1970,7 @@ var ParamGroupEditor = /*#__PURE__*/function (_PureComponent) {
1962
1970
  getSignedUrl: _this2.props.getSignedUrl,
1963
1971
  handleUpload: _this2.props.handleUpload
1964
1972
  }));
1965
- },
1966
- validator: isFirstLevel ? validatorCvt(function (val) {
1967
- return emptyValidator(val);
1968
- }) : undefined
1973
+ }
1969
1974
  }];
1970
1975
 
1971
1976
  if (!isFirstLevel) {
@@ -2419,4 +2424,4 @@ var ParamMoverModal = /*#__PURE__*/function () {
2419
2424
 
2420
2425
  _defineProperty(ParamMoverModal, "el", new ReactGlobalComp('param-mover-modal', ParamMoverModalEl));
2421
2426
 
2422
- export { ParamForm, ParamFormModal, ParamGroupEditor, ParamGroupEditorModal, ParamGroupEditorModalEl, ParamMover, ParamMoverModal, ParamMoverModalEl, ParamRenderer, ParamType, ParamTypeConfig, ParamTypeOptions, ParamValueEditor, ParamValueEditorModal, ParamValueEditorModalEl, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, keyValidator, numRangeValidator, paramValidator, validatorCvt };
2427
+ export { ParamForm, ParamFormModal, ParamGroupEditor, ParamGroupEditorModal, ParamGroupEditorModalEl, ParamMover, ParamMoverModal, ParamMoverModalEl, ParamRenderer, ParamType, ParamTypeConfig, ParamTypeOptions, ParamValueEditor, ParamValueEditorModal, ParamValueEditorModalEl, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, keyValidator, numRangeValidator, paramValidator, sameGroupNameValidator, validatorCvt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalplus/params-about",
3
- "version": "1.0.3",
3
+ "version": "1.0.4-alpha",
4
4
  "description": "A description for the module",
5
5
  "main": "./lib/umd/index.js",
6
6
  "module": "./lib/es/index.js",