@signalplus/params-about 1.0.4 → 1.0.5-alpha1
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 +32 -5
- package/lib/es/index.js +15 -10
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ declare class ParamRenderer extends PureComponent<ParamRendererProps> {
|
|
|
39
39
|
key?: string | undefined;
|
|
40
40
|
defaultValue?: any;
|
|
41
41
|
Comp: React.ComponentType<BaseInputProps>;
|
|
42
|
-
validator?(value: any): string;
|
|
42
|
+
validator?(value: any, enableEmpty?: boolean | undefined): string;
|
|
43
43
|
required?: boolean | undefined;
|
|
44
44
|
};
|
|
45
45
|
get value(): any;
|
|
@@ -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
|
}
|
|
@@ -277,12 +303,12 @@ declare const ParamTypeConfig: Record<ParamType, {
|
|
|
277
303
|
key?: string;
|
|
278
304
|
defaultValue?: any;
|
|
279
305
|
Comp: React.ComponentType<BaseInputProps>;
|
|
280
|
-
validator?(value: any): string;
|
|
306
|
+
validator?(value: any, enableEmpty?: boolean): string;
|
|
281
307
|
required?: boolean;
|
|
282
308
|
}>;
|
|
283
309
|
declare function paramValidator(val: any, values: {
|
|
284
310
|
valueType: ParamType;
|
|
285
|
-
}): string;
|
|
311
|
+
}, enableEmpty?: boolean): string;
|
|
286
312
|
declare const ParamTypeOptions: {
|
|
287
313
|
value: number;
|
|
288
314
|
label: string;
|
|
@@ -290,7 +316,7 @@ declare const ParamTypeOptions: {
|
|
|
290
316
|
key?: string | undefined;
|
|
291
317
|
defaultValue?: any;
|
|
292
318
|
Comp: React.ComponentType<BaseInputProps>;
|
|
293
|
-
validator?(value: any): string;
|
|
319
|
+
validator?(value: any, enableEmpty?: boolean | undefined): string;
|
|
294
320
|
required?: boolean | undefined;
|
|
295
321
|
}[];
|
|
296
322
|
|
|
@@ -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:
|
|
4
|
-
* Version: 1.0.
|
|
3
|
+
* Generated: 2023-05-08
|
|
4
|
+
* Version: 1.0.5-alpha1
|
|
5
5
|
* License: MIT
|
|
6
6
|
* Author: 2631541504@qq.com
|
|
7
7
|
*/
|
|
@@ -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();
|
|
@@ -1212,13 +1220,13 @@ var ParamTypeConfig = (_ParamTypeConfig = {}, _defineProperty(_ParamTypeConfig,
|
|
|
1212
1220
|
Comp: Text,
|
|
1213
1221
|
validator: emptyValidator
|
|
1214
1222
|
}), _ParamTypeConfig);
|
|
1215
|
-
function paramValidator(val, values) {
|
|
1223
|
+
function paramValidator(val, values, enableEmpty) {
|
|
1216
1224
|
var _config$validator;
|
|
1217
1225
|
|
|
1218
1226
|
var config = ParamTypeConfig[values.valueType];
|
|
1219
1227
|
if (!config) return '';
|
|
1220
1228
|
var value = config.key ? val === null || val === void 0 ? void 0 : val[config.key] : val;
|
|
1221
|
-
return ((_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, value)) || '';
|
|
1229
|
+
return ((_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, value, enableEmpty)) || '';
|
|
1222
1230
|
}
|
|
1223
1231
|
var ParamTypeOptions = Object.entries(ParamTypeConfig).map(function (_ref) {
|
|
1224
1232
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -1952,7 +1960,7 @@ var ParamGroupEditor = /*#__PURE__*/function (_PureComponent) {
|
|
|
1952
1960
|
}));
|
|
1953
1961
|
},
|
|
1954
1962
|
validator: validatorCvt(function (val) {
|
|
1955
|
-
return
|
|
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 };
|