@para-ui/core 3.0.87 → 3.0.89
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/DynamicMultiBox/index.js +25 -22
- package/DynamicMultiBox/interface.d.ts +6 -6
- package/DynamicMultiBox/rowForm.d.ts +2 -0
- package/Form/index.js +4 -3
- package/FormItem/compoments/formRadioGroup/index.d.ts +1 -1
- package/FormItem/index.js +1 -1
- package/FormItem/lang/en_US.d.ts +6 -0
- package/FormItem/lang/index.d.ts +12 -0
- package/FormItem/lang/zh_CN.d.ts +6 -0
- package/FormItem/validateFunction.d.ts +1 -1
- package/README.md +13 -0
- package/_verture/{index-93ef36f9.js → index-e41350ca.js} +62 -25
- package/index.js +1 -1
- package/locale/en-US.d.ts +6 -0
- package/locale/index.d.ts +12 -0
- package/locale/index.js +14 -2
- package/locale/zh-CN.d.ts +6 -0
- package/package.json +2 -5
- package/umd/DynamicMultiBox.js +4 -4
- package/umd/Form.js +4 -4
- package/umd/FormItem.js +2 -2
- package/umd/locale.js +1 -1
package/DynamicMultiBox/index.js
CHANGED
|
@@ -305,7 +305,9 @@ var FormItem = function FormItem(props) {
|
|
|
305
305
|
};
|
|
306
306
|
|
|
307
307
|
var RowForm = function RowForm(props) {
|
|
308
|
-
var _props$
|
|
308
|
+
var _props$rowKey = props.rowKey,
|
|
309
|
+
rowKey = _props$rowKey === void 0 ? 'id' : _props$rowKey,
|
|
310
|
+
_props$valueList = props.valueList,
|
|
309
311
|
valueList = _props$valueList === void 0 ? [] : _props$valueList,
|
|
310
312
|
rowError = props.rowError,
|
|
311
313
|
_props$errors = props.errors,
|
|
@@ -338,13 +340,13 @@ var RowForm = function RowForm(props) {
|
|
|
338
340
|
othersData = __rest(data, ["style"]);
|
|
339
341
|
var formItemProps = (data === null || data === void 0 ? void 0 : data.inputType) !== 'Switch' ? Object.assign({
|
|
340
342
|
rowIndex: rowIndex,
|
|
341
|
-
id: rowValue
|
|
343
|
+
id: rowValue[rowKey],
|
|
342
344
|
value: rowValue === null || rowValue === void 0 ? void 0 : rowValue[data.name || ''],
|
|
343
345
|
error: !!(rowError === null || rowError === void 0 ? void 0 : rowError[data.name || '']),
|
|
344
346
|
helperText: rowError === null || rowError === void 0 ? void 0 : rowError[data.name || '']
|
|
345
347
|
}, othersData) : Object.assign({
|
|
346
348
|
rowIndex: rowIndex,
|
|
347
|
-
id: rowValue
|
|
349
|
+
id: rowValue[rowKey],
|
|
348
350
|
checked: rowValue === null || rowValue === void 0 ? void 0 : rowValue[data.name || '']
|
|
349
351
|
}, othersData);
|
|
350
352
|
return jsxs("div", Object.assign({
|
|
@@ -929,7 +931,9 @@ var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下
|
|
|
929
931
|
styleInject(css_248z);
|
|
930
932
|
|
|
931
933
|
var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
932
|
-
var
|
|
934
|
+
var _props$rowKey = props.rowKey,
|
|
935
|
+
rowKey = _props$rowKey === void 0 ? 'id' : _props$rowKey,
|
|
936
|
+
valueList = props.valueList,
|
|
933
937
|
_props$config = props.config,
|
|
934
938
|
config = _props$config === void 0 ? [] : _props$config,
|
|
935
939
|
_props$errors = props.errors,
|
|
@@ -1148,7 +1152,8 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1148
1152
|
required = item.required,
|
|
1149
1153
|
className = item.className,
|
|
1150
1154
|
inputType = item.inputType,
|
|
1151
|
-
style = item.style
|
|
1155
|
+
style = item.style,
|
|
1156
|
+
labelProps = item.labelProps;
|
|
1152
1157
|
var str = 'title-config-row-item';
|
|
1153
1158
|
if (inputType === 'Switch') str += ' row-form-switch';
|
|
1154
1159
|
if (className) str += ' ' + className;
|
|
@@ -1158,10 +1163,10 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1158
1163
|
className: str,
|
|
1159
1164
|
style: styleCom
|
|
1160
1165
|
}, {
|
|
1161
|
-
children: jsx(Label, {
|
|
1166
|
+
children: jsx(Label, Object.assign({
|
|
1162
1167
|
required: required,
|
|
1163
1168
|
label: label
|
|
1164
|
-
})
|
|
1169
|
+
}, labelProps))
|
|
1165
1170
|
}), index);
|
|
1166
1171
|
})
|
|
1167
1172
|
})) : titleMode === 'single' ? jsx(Label, {
|
|
@@ -1189,7 +1194,7 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1189
1194
|
}))]
|
|
1190
1195
|
}))]
|
|
1191
1196
|
}));
|
|
1192
|
-
}, [titleMode, fixedConfig, selectedConfig, isSort, isFilter, checked, onCheckChange, onRestoreDefault]);
|
|
1197
|
+
}, [titleMode, fixedConfig, selectedConfig, isSort, isFilter, checked, onCheckChange, onRestoreDefault, rowKey]);
|
|
1193
1198
|
/**
|
|
1194
1199
|
* 判断是否全部隐藏删除
|
|
1195
1200
|
* 默认全部隐藏
|
|
@@ -1201,7 +1206,7 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1201
1206
|
return false;
|
|
1202
1207
|
}
|
|
1203
1208
|
for (var i = 0, l = valueList === null || valueList === void 0 ? void 0 : valueList.length; i < l; i++) {
|
|
1204
|
-
var id = (_a = valueList[i]) === null || _a === void 0 ? void 0 : _a
|
|
1209
|
+
var id = (_a = valueList[i]) === null || _a === void 0 ? void 0 : _a[rowKey];
|
|
1205
1210
|
if (id && deleteDisable.indexOf(id) === -1) {
|
|
1206
1211
|
bol = false;
|
|
1207
1212
|
break;
|
|
@@ -1220,14 +1225,15 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1220
1225
|
return jsx(Fragment, {
|
|
1221
1226
|
children: valueList.map(function (item, rowIndex) {
|
|
1222
1227
|
var _a;
|
|
1223
|
-
var id = item
|
|
1228
|
+
var id = item[rowKey];
|
|
1224
1229
|
var rowError = (_a = errors === null || errors === void 0 ? void 0 : errors.filter(function (item) {
|
|
1225
|
-
return item
|
|
1230
|
+
return item[rowKey] === id;
|
|
1226
1231
|
})) === null || _a === void 0 ? void 0 : _a[0];
|
|
1227
1232
|
return jsxs("div", Object.assign({
|
|
1228
1233
|
className: 'content-row-form'
|
|
1229
1234
|
}, {
|
|
1230
1235
|
children: [jsx(RowForm, {
|
|
1236
|
+
rowKey: rowKey,
|
|
1231
1237
|
rowIndex: rowIndex,
|
|
1232
1238
|
valueList: valueList,
|
|
1233
1239
|
errors: errors,
|
|
@@ -1263,7 +1269,7 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1263
1269
|
})
|
|
1264
1270
|
});
|
|
1265
1271
|
}
|
|
1266
|
-
}, [valueList, isSort, isFilter, errors, fixedConfig, selectedConfig, keepLastItem, deleteRender]);
|
|
1272
|
+
}, [valueList, isSort, isFilter, errors, fixedConfig, selectedConfig, keepLastItem, deleteRender, rowKey]);
|
|
1267
1273
|
/**
|
|
1268
1274
|
* @desc 删除事件
|
|
1269
1275
|
* */
|
|
@@ -1304,12 +1310,8 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1304
1310
|
var id = UUID();
|
|
1305
1311
|
// 取出已经筛选的配置数据
|
|
1306
1312
|
var configArr = [].concat(_toConsumableArray(fixedConfig), _toConsumableArray(selectedConfig));
|
|
1307
|
-
valueArr.push(Object.assign(Object.assign({}, getNewItem(configArr, 'value')), {
|
|
1308
|
-
|
|
1309
|
-
}));
|
|
1310
|
-
errorArr.push(Object.assign(Object.assign({}, getNewItem(configArr, 'error')), {
|
|
1311
|
-
id: id
|
|
1312
|
-
}));
|
|
1313
|
+
valueArr.push(Object.assign(Object.assign({}, getNewItem(configArr, 'value')), _defineProperty({}, rowKey, id)));
|
|
1314
|
+
errorArr.push(Object.assign(Object.assign({}, getNewItem(configArr, 'error')), _defineProperty({}, rowKey, id)));
|
|
1313
1315
|
onAdd && onAdd(valueArr, errorArr);
|
|
1314
1316
|
};
|
|
1315
1317
|
/**
|
|
@@ -1329,12 +1331,12 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1329
1331
|
var onDragSort = function onDragSort(newValueList) {
|
|
1330
1332
|
// 获取排序后 id映射下标集合
|
|
1331
1333
|
var idMapIndex = newValueList.reduce(function (acc, cur, index) {
|
|
1332
|
-
return Object.assign(Object.assign({}, acc), _defineProperty({}, cur
|
|
1334
|
+
return Object.assign(Object.assign({}, acc), _defineProperty({}, cur[rowKey], index));
|
|
1333
1335
|
}, {});
|
|
1334
1336
|
// 需要交换的下标集合
|
|
1335
1337
|
var swapIds = [];
|
|
1336
1338
|
valueList.forEach(function (item, idx) {
|
|
1337
|
-
if (idx !== idMapIndex[item
|
|
1339
|
+
if (idx !== idMapIndex[item[rowKey]]) swapIds.push(idx);
|
|
1338
1340
|
});
|
|
1339
1341
|
onSort && onSort(newValueList, swapIds);
|
|
1340
1342
|
};
|
|
@@ -1363,14 +1365,15 @@ var DynamicMultiBox = function DynamicMultiBox(props) {
|
|
|
1363
1365
|
className: "multi-value-content",
|
|
1364
1366
|
ref: domRef
|
|
1365
1367
|
}, {
|
|
1366
|
-
children: [renderTitle, jsx(dist.exports.ReactSortable, Object.assign({
|
|
1368
|
+
children: [renderTitle, isSort ? jsx(dist.exports.ReactSortable, Object.assign({
|
|
1369
|
+
id: rowKey,
|
|
1367
1370
|
list: valueList,
|
|
1368
1371
|
handle: '.sort-handler',
|
|
1369
1372
|
animation: 150,
|
|
1370
1373
|
setList: onDragSort
|
|
1371
1374
|
}, {
|
|
1372
1375
|
children: renderContent
|
|
1373
|
-
}))]
|
|
1376
|
+
})) : renderContent]
|
|
1374
1377
|
})), jsxs("div", Object.assign({
|
|
1375
1378
|
className: "add-button ".concat(disabledAdd ? 'disabled-add' : 'normal-button'),
|
|
1376
1379
|
onClick: onAddEvent,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ReactNode } from "react";
|
|
7
7
|
import { TextFieldProps, SelectProps, SwitchProps, InputNumberProps, InputLangProps, ComboSelectProps, DatePickerProps } from "@para-ui/core";
|
|
8
|
+
import { LabelProps } from "../Label";
|
|
8
9
|
/**组件类型:输入框,下拉框,开关,数字输入框,国际化输入框,日期框,时间选择框,组合选择器,自定义组件*/
|
|
9
10
|
export type IInputType = 'TextField' | 'Select' | 'Switch' | 'InputNumber' | 'InputLang' | 'ComboSelect' | 'DatePicker' | 'custom';
|
|
10
11
|
/** 配置项*/
|
|
@@ -27,31 +28,28 @@ export type IConfig = {
|
|
|
27
28
|
list?: ((rowIndex: number, id: string, name: string, valueList: IValueList[]) => any[]) | any[];
|
|
28
29
|
/** 样式 */
|
|
29
30
|
style?: React.CSSProperties;
|
|
31
|
+
/** 标题样式 */
|
|
32
|
+
labelProps?: LabelProps;
|
|
30
33
|
/** 其他*/
|
|
31
34
|
[name: string]: any;
|
|
32
35
|
} & (TextFieldProps | SelectProps | SwitchProps | InputNumberProps | InputLangProps | ComboSelectProps | DatePickerProps);
|
|
33
36
|
/** value集合*/
|
|
34
37
|
export interface IValueList {
|
|
35
|
-
/** id*/
|
|
36
|
-
id: string;
|
|
37
38
|
/** 每行value值集合, name映射configItem中的name*/
|
|
38
39
|
[name: string]: any;
|
|
39
40
|
}
|
|
40
41
|
export interface IErrors {
|
|
41
|
-
/** id*/
|
|
42
|
-
id: string;
|
|
43
42
|
/** 每行错误集合,name映射configItem中的name*/
|
|
44
43
|
[name: string]: any;
|
|
45
44
|
}
|
|
46
45
|
export interface ICurrentItem {
|
|
47
46
|
/** 表单名*/
|
|
48
47
|
name?: string;
|
|
49
|
-
/** 表单所处行id*/
|
|
50
|
-
id: string;
|
|
51
48
|
/** 表单值*/
|
|
52
49
|
value?: any;
|
|
53
50
|
/** 表单所处下标*/
|
|
54
51
|
rowIndex?: number;
|
|
52
|
+
[name: string]: any;
|
|
55
53
|
}
|
|
56
54
|
/** 过滤回调出参*/
|
|
57
55
|
export interface IFilterParams {
|
|
@@ -66,6 +64,8 @@ export interface IFilterParams {
|
|
|
66
64
|
}
|
|
67
65
|
/** 主体接口定义*/
|
|
68
66
|
export interface IMultiValueProps {
|
|
67
|
+
/** 指定每行key */
|
|
68
|
+
rowKey?: string;
|
|
69
69
|
/**
|
|
70
70
|
* 组件配置项
|
|
71
71
|
*/
|
package/Form/index.js
CHANGED
|
@@ -3,7 +3,8 @@ import { _ as _slicedToArray } from '../_verture/slicedToArray-76060636.js';
|
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { DeepClone } from '@paraview/lib';
|
|
5
5
|
import React__default from 'react';
|
|
6
|
-
import { F as FormItem, v as validate } from '../_verture/index-
|
|
6
|
+
import { F as FormItem, l as localeJson, v as validate } from '../_verture/index-e41350ca.js';
|
|
7
|
+
import { u as useFormatMessage } from '../_verture/useFormatMessage-703f8b20.js';
|
|
7
8
|
import { $ as $prefixCls } from '../_verture/constant-66aa48a1.js';
|
|
8
9
|
import '../_verture/unsupportedIterableToArray-cb478f24.js';
|
|
9
10
|
import '../TextField/index.js';
|
|
@@ -35,7 +36,6 @@ import '../Radio/index.js';
|
|
|
35
36
|
import '../Select/index.js';
|
|
36
37
|
import '../_verture/defineProperty-62acccfc.js';
|
|
37
38
|
import '../Empty/index.js';
|
|
38
|
-
import '../_verture/useFormatMessage-703f8b20.js';
|
|
39
39
|
import '@para-ui/icons/Close';
|
|
40
40
|
import '@para-ui/icons/Down';
|
|
41
41
|
import '@para-ui/icons/Check';
|
|
@@ -93,6 +93,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
93
93
|
* @description 用于根据配置自动生成表单
|
|
94
94
|
*/
|
|
95
95
|
var Form = function Form(props) {
|
|
96
|
+
var intl = useFormatMessage('FormItem', localeJson);
|
|
96
97
|
var _props$className = props.className,
|
|
97
98
|
className = _props$className === void 0 ? "" : _props$className,
|
|
98
99
|
FormProps = props.FormProps,
|
|
@@ -202,7 +203,7 @@ var Form = function Form(props) {
|
|
|
202
203
|
errorCount++;
|
|
203
204
|
continue;
|
|
204
205
|
}
|
|
205
|
-
var msg = validate(tItem, refData.current.allValues[key]);
|
|
206
|
+
var msg = validate(tItem, refData.current.allValues[key], intl);
|
|
206
207
|
if (msg) {
|
|
207
208
|
errorCount++;
|
|
208
209
|
if (typeof msg === "string") refData.current.itemsCheckMessage[key] = msg;
|
package/FormItem/index.js
CHANGED
package/FormItem/lang/en_US.d.ts
CHANGED
package/FormItem/lang/index.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
zh: {
|
|
3
3
|
choseFile: string;
|
|
4
|
+
unEmpty: string;
|
|
5
|
+
maxLength: string;
|
|
6
|
+
minLength: string;
|
|
7
|
+
unRule: string;
|
|
8
|
+
minValue: string;
|
|
9
|
+
maxValue: string;
|
|
4
10
|
};
|
|
5
11
|
en: {
|
|
6
12
|
choseFile: string;
|
|
13
|
+
unEmpty: string;
|
|
14
|
+
maxLength: string;
|
|
15
|
+
minLength: string;
|
|
16
|
+
unRule: string;
|
|
17
|
+
minValue: string;
|
|
18
|
+
maxValue: string;
|
|
7
19
|
};
|
|
8
20
|
};
|
|
9
21
|
export default _default;
|
package/FormItem/lang/zh_CN.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { FormItemProps } from './index';
|
|
|
6
6
|
* @param {any} val 校验项的值
|
|
7
7
|
* @return {boolean | string} 返回校验结果或报错信息
|
|
8
8
|
*/
|
|
9
|
-
export type validateFunctionType = (item: FormItemProps, val: any) => boolean | string;
|
|
9
|
+
export type validateFunctionType = (item: FormItemProps, val: any, intl: any) => boolean | string;
|
|
10
10
|
/**
|
|
11
11
|
* 表单rules校验方法
|
|
12
12
|
* @type {validateFunctionType}
|
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## 版本: 3.0.89
|
|
2
|
+
|
|
3
|
+
para-ui/core@3.0.89 发布
|
|
4
|
+
【表单-Form】修复当单选框组的的值是boolean的时候,设置默认值为fasle选中不了的问题
|
|
5
|
+
|
|
6
|
+
## 版本: 3.0.88
|
|
7
|
+
|
|
8
|
+
para-ui/core@3.0.88 发布
|
|
9
|
+
【表单-Form】表单校验国际化
|
|
10
|
+
【动态多值框-DynamicMultiBox】增加labelProps参数,用来修改标题
|
|
11
|
+
【动态多值框-DynamicMultiBox】增加rowKey,用来自定义每行的唯一id
|
|
12
|
+
【动态多值框-DynamicMultiBox】没有拖拽,valueList不生成chosen,selected字段
|
|
13
|
+
|
|
1
14
|
## 版本: 3.0.87
|
|
2
15
|
|
|
3
16
|
para-ui/core@3.0.87 发布
|
|
@@ -24,15 +24,15 @@ var FormRadioGroup = function FormRadioGroup(props) {
|
|
|
24
24
|
var defaultValue = props.defaultValue,
|
|
25
25
|
change = props.change;
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var _React$useState = React__default.useState(defaultValue
|
|
27
|
+
* 选中的值
|
|
28
|
+
*/
|
|
29
|
+
var _React$useState = React__default.useState(defaultValue === undefined ? "" : defaultValue),
|
|
30
30
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
31
31
|
selectValue = _React$useState2[0],
|
|
32
32
|
setSelectValue = _React$useState2[1];
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
* 选中值改变
|
|
35
|
+
*/
|
|
36
36
|
var changeValue = function changeValue(value) {
|
|
37
37
|
setSelectValue(value);
|
|
38
38
|
change && change(value);
|
|
@@ -104,10 +104,14 @@ var FormCheckboxGroup = function FormCheckboxGroup(props) {
|
|
|
104
104
|
* @type {{[name: string]: validateFunctionType}}
|
|
105
105
|
*/
|
|
106
106
|
var fixedValidateFunction = {
|
|
107
|
-
'required': function required(item, val) {
|
|
107
|
+
'required': function required(item, val, intl) {
|
|
108
108
|
var _a, _b, _c, _d;
|
|
109
109
|
var vtype = _typeof(val);
|
|
110
|
-
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.required) ||
|
|
110
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.required) || intl({
|
|
111
|
+
id: 'unEmpty'
|
|
112
|
+
}, {
|
|
113
|
+
label: item.label
|
|
114
|
+
});
|
|
111
115
|
var jude = false;
|
|
112
116
|
switch (vtype) {
|
|
113
117
|
case 'string':
|
|
@@ -135,10 +139,14 @@ var fixedValidateFunction = {
|
|
|
135
139
|
}
|
|
136
140
|
return jude || error;
|
|
137
141
|
},
|
|
138
|
-
'maxlength': function maxlength(item, val) {
|
|
142
|
+
'maxlength': function maxlength(item, val, intl) {
|
|
139
143
|
var _a, _b, _c, _d, _e, _f;
|
|
140
144
|
var vtype = _typeof(val);
|
|
141
|
-
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.maxlength) ||
|
|
145
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.maxlength) || intl({
|
|
146
|
+
id: 'maxLength'
|
|
147
|
+
}, {
|
|
148
|
+
len: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.maxlength
|
|
149
|
+
});
|
|
142
150
|
var jude = false;
|
|
143
151
|
if (vtype === 'string' || vtype === 'number' && val + 1 > val) {
|
|
144
152
|
jude = !("".concat(val).length > (((_f = (_e = item.rules) === null || _e === void 0 ? void 0 : _e.validate) === null || _f === void 0 ? void 0 : _f.maxlength) || NaN));
|
|
@@ -147,10 +155,14 @@ var fixedValidateFunction = {
|
|
|
147
155
|
}
|
|
148
156
|
return jude || error;
|
|
149
157
|
},
|
|
150
|
-
'minLength': function minLength(item, val) {
|
|
158
|
+
'minLength': function minLength(item, val, intl) {
|
|
151
159
|
var _a, _b, _c, _d, _e, _f;
|
|
152
160
|
var vtype = _typeof(val);
|
|
153
|
-
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.minLength) ||
|
|
161
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.minLength) || intl({
|
|
162
|
+
id: 'minLength'
|
|
163
|
+
}, {
|
|
164
|
+
len: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.minLength
|
|
165
|
+
});
|
|
154
166
|
var jude = false;
|
|
155
167
|
if (vtype === 'string' || vtype === 'number' && val + 1 > val) {
|
|
156
168
|
jude = "".concat(val).length >= (((_f = (_e = item.rules) === null || _e === void 0 ? void 0 : _e.validate) === null || _f === void 0 ? void 0 : _f.minLength) || -1);
|
|
@@ -159,30 +171,42 @@ var fixedValidateFunction = {
|
|
|
159
171
|
}
|
|
160
172
|
return jude || error;
|
|
161
173
|
},
|
|
162
|
-
'pattern': function pattern(item, val) {
|
|
174
|
+
'pattern': function pattern(item, val, intl) {
|
|
163
175
|
var _a, _b, _c, _d;
|
|
164
176
|
var testReg = (_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.validate) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
165
|
-
var error = ((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.pattern) ||
|
|
177
|
+
var error = ((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.pattern) || intl({
|
|
178
|
+
id: 'unRule'
|
|
179
|
+
}, {
|
|
180
|
+
rule: '' + testReg
|
|
181
|
+
});
|
|
166
182
|
var jude = !val;
|
|
167
183
|
if (testReg && val && typeof testReg !== 'function') {
|
|
168
184
|
jude = testReg.test(val);
|
|
169
185
|
}
|
|
170
186
|
return jude || error;
|
|
171
187
|
},
|
|
172
|
-
'min': function min(item, val) {
|
|
188
|
+
'min': function min(item, val, intl) {
|
|
173
189
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
174
190
|
var vtype = _typeof(val);
|
|
175
|
-
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.min) ||
|
|
191
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.min) || intl({
|
|
192
|
+
id: 'minValue'
|
|
193
|
+
}, {
|
|
194
|
+
val: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.min
|
|
195
|
+
});
|
|
176
196
|
var jude = !val;
|
|
177
197
|
if (vtype === 'string' || vtype === 'number') {
|
|
178
198
|
jude = val >= (((_f = (_e = item.rules) === null || _e === void 0 ? void 0 : _e.validate) === null || _f === void 0 ? void 0 : _f.min) === undefined ? -Infinity : (_h = (_g = item.rules) === null || _g === void 0 ? void 0 : _g.validate) === null || _h === void 0 ? void 0 : _h.min);
|
|
179
199
|
}
|
|
180
200
|
return jude || error;
|
|
181
201
|
},
|
|
182
|
-
'max': function max(item, val) {
|
|
202
|
+
'max': function max(item, val, intl) {
|
|
183
203
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
184
204
|
var vtype = _typeof(val);
|
|
185
|
-
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.max) ||
|
|
205
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.max) || intl({
|
|
206
|
+
id: 'maxValue'
|
|
207
|
+
}, {
|
|
208
|
+
val: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.max
|
|
209
|
+
});
|
|
186
210
|
var jude = !val;
|
|
187
211
|
if (vtype === 'string' || vtype === 'number') {
|
|
188
212
|
jude = val <= (((_f = (_e = item.rules) === null || _e === void 0 ? void 0 : _e.validate) === null || _f === void 0 ? void 0 : _f.max) === undefined ? Infinity : (_h = (_g = item.rules) === null || _g === void 0 ? void 0 : _g.validate) === null || _h === void 0 ? void 0 : _h.max);
|
|
@@ -194,7 +218,7 @@ var fixedValidateFunction = {
|
|
|
194
218
|
* 表单rules校验方法
|
|
195
219
|
* @type {validateFunctionType}
|
|
196
220
|
*/
|
|
197
|
-
var validate = function validate(item, val) {
|
|
221
|
+
var validate = function validate(item, val, intl) {
|
|
198
222
|
var _a, _b;
|
|
199
223
|
var validateObj = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.validate;
|
|
200
224
|
if (validateObj) {
|
|
@@ -203,10 +227,10 @@ var validate = function validate(item, val) {
|
|
|
203
227
|
var tempFuc = validateObj[key];
|
|
204
228
|
var tmsg = '';
|
|
205
229
|
if (typeof tempFuc === 'function') {
|
|
206
|
-
tmsg = tempFuc(item, val);
|
|
230
|
+
tmsg = tempFuc(item, val, intl);
|
|
207
231
|
if (tmsg === false && messageObj) tmsg = messageObj[key];
|
|
208
232
|
} else if (!!tempFuc && fixedValidateFunction[key]) {
|
|
209
|
-
tmsg = fixedValidateFunction[key](item, val);
|
|
233
|
+
tmsg = fixedValidateFunction[key](item, val, intl);
|
|
210
234
|
} else if (!tempFuc) {
|
|
211
235
|
tmsg = true;
|
|
212
236
|
} else {
|
|
@@ -220,11 +244,23 @@ var validate = function validate(item, val) {
|
|
|
220
244
|
};
|
|
221
245
|
|
|
222
246
|
var en = {
|
|
223
|
-
choseFile: 'Chose File'
|
|
247
|
+
choseFile: 'Chose File',
|
|
248
|
+
unEmpty: '{label} Cannot be empty',
|
|
249
|
+
maxLength: 'The maximum length cannot be exceeded{len}',
|
|
250
|
+
minLength: 'The minimum length cannot be exceeded{len}',
|
|
251
|
+
unRule: 'The parameter does not comply with the validation rule {rule}',
|
|
252
|
+
minValue: 'The minimum value is {val}',
|
|
253
|
+
maxValue: 'The maximum value is {val}'
|
|
224
254
|
};
|
|
225
255
|
|
|
226
256
|
var zh = {
|
|
227
|
-
choseFile: '选择文件'
|
|
257
|
+
choseFile: '选择文件',
|
|
258
|
+
unEmpty: '{label}不能为空',
|
|
259
|
+
maxLength: '最大长度不能超过{len}',
|
|
260
|
+
minLength: '最小长度为{len}',
|
|
261
|
+
unRule: '参数不符合校验规则{rule}',
|
|
262
|
+
minValue: '最小值为{val}',
|
|
263
|
+
maxValue: '最大值为{val}'
|
|
228
264
|
};
|
|
229
265
|
|
|
230
266
|
var localeJson = {
|
|
@@ -247,7 +283,7 @@ var FormFile = function FormFile(props) {
|
|
|
247
283
|
buttonLabel = props.buttonLabel,
|
|
248
284
|
inputProps = props.inputProps,
|
|
249
285
|
buttonProps = props.buttonProps;
|
|
250
|
-
var intl = useFormatMessage('
|
|
286
|
+
var intl = useFormatMessage('FormItem', localeJson);
|
|
251
287
|
/**
|
|
252
288
|
* 存储文件输入框真实dom
|
|
253
289
|
* @type {HTMLInputElement}
|
|
@@ -383,6 +419,7 @@ var ItemType = function ItemType(props) {
|
|
|
383
419
|
backData = props.backData,
|
|
384
420
|
disabled = props.disabled,
|
|
385
421
|
change = props.change;
|
|
422
|
+
var intl = useFormatMessage('FormItem', localeJson);
|
|
386
423
|
var tipsStr = placeholder || "".concat(label);
|
|
387
424
|
/**
|
|
388
425
|
* 报错信息
|
|
@@ -404,7 +441,7 @@ var ItemType = function ItemType(props) {
|
|
|
404
441
|
setErrorMsg: setErrorMsg,
|
|
405
442
|
setAndValidateValue: setAndValidateValue
|
|
406
443
|
});
|
|
407
|
-
var errorMessage = validate(item, val) || '';
|
|
444
|
+
var errorMessage = validate(item, val, intl) || '';
|
|
408
445
|
setErrorMsg(errorMessage);
|
|
409
446
|
};
|
|
410
447
|
/**
|
|
@@ -723,4 +760,4 @@ var FormItem = function FormItem(props) {
|
|
|
723
760
|
}));
|
|
724
761
|
};
|
|
725
762
|
|
|
726
|
-
export { FormItem as F, validate as v };
|
|
763
|
+
export { FormItem as F, localeJson as l, validate as v };
|
package/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export { D as Dropdown } from './_verture/index-77f9e0fb.js';
|
|
|
22
22
|
export { default as DynamicMultiBox } from './DynamicMultiBox/index.js';
|
|
23
23
|
export { default as Empty } from './Empty/index.js';
|
|
24
24
|
export { default as Form } from './Form/index.js';
|
|
25
|
-
export { F as FormItem } from './_verture/index-
|
|
25
|
+
export { F as FormItem } from './_verture/index-e41350ca.js';
|
|
26
26
|
export { u as FunctionModal, F as FunctionModalProvider, a as useClose } from './_verture/modalContext-630bdb73.js';
|
|
27
27
|
export { default as GlobalContext, changeConfirmLocale, getConfirmLocale } from './GlobalContext/index.js';
|
|
28
28
|
export { default as Help } from './Help/index.js';
|
package/locale/en-US.d.ts
CHANGED
package/locale/index.d.ts
CHANGED
|
@@ -67,6 +67,12 @@ declare const _default: {
|
|
|
67
67
|
};
|
|
68
68
|
FormItem: {
|
|
69
69
|
choseFile: string;
|
|
70
|
+
unEmpty: string;
|
|
71
|
+
maxLength: string;
|
|
72
|
+
minLength: string;
|
|
73
|
+
unRule: string;
|
|
74
|
+
minValue: string;
|
|
75
|
+
maxValue: string;
|
|
70
76
|
};
|
|
71
77
|
Modal: {
|
|
72
78
|
cancel: string;
|
|
@@ -222,6 +228,12 @@ declare const _default: {
|
|
|
222
228
|
};
|
|
223
229
|
FormItem: {
|
|
224
230
|
choseFile: string;
|
|
231
|
+
unEmpty: string;
|
|
232
|
+
maxLength: string;
|
|
233
|
+
minLength: string;
|
|
234
|
+
unRule: string;
|
|
235
|
+
minValue: string;
|
|
236
|
+
maxValue: string;
|
|
225
237
|
};
|
|
226
238
|
Modal: {
|
|
227
239
|
cancel: string;
|
package/locale/index.js
CHANGED
|
@@ -65,7 +65,13 @@ var enUS = {
|
|
|
65
65
|
"refresh": "refresh"
|
|
66
66
|
},
|
|
67
67
|
"FormItem": {
|
|
68
|
-
"choseFile": "Chose File"
|
|
68
|
+
"choseFile": "Chose File",
|
|
69
|
+
"unEmpty": "{label} Cannot be empty",
|
|
70
|
+
"maxLength": "The maximum length cannot be exceeded{len}",
|
|
71
|
+
"minLength": "The minimum length cannot be exceeded{len}",
|
|
72
|
+
"unRule": "The parameter does not comply with the validation rule {rule}",
|
|
73
|
+
"minValue": "The minimum value is {val}",
|
|
74
|
+
"maxValue": "The maximum value is {val}"
|
|
69
75
|
},
|
|
70
76
|
"Modal": {
|
|
71
77
|
"cancel": "Cancel",
|
|
@@ -221,7 +227,13 @@ var zhCN = {
|
|
|
221
227
|
"refresh": "刷新"
|
|
222
228
|
},
|
|
223
229
|
"FormItem": {
|
|
224
|
-
"choseFile": "选择文件"
|
|
230
|
+
"choseFile": "选择文件",
|
|
231
|
+
"unEmpty": "{label}不能为空",
|
|
232
|
+
"maxLength": "最大长度不能超过{len}",
|
|
233
|
+
"minLength": "最小长度为{len}",
|
|
234
|
+
"unRule": "参数不符合校验规则{rule}",
|
|
235
|
+
"minValue": "最小值为{val}",
|
|
236
|
+
"maxValue": "最大值为{val}"
|
|
225
237
|
},
|
|
226
238
|
"Modal": {
|
|
227
239
|
"cancel": "取消",
|
package/locale/zh-CN.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@para-ui/core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.89",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"typings": "./index.d.ts",
|
|
7
7
|
"description": "Powered by Para FED",
|
|
@@ -160,11 +160,8 @@
|
|
|
160
160
|
},
|
|
161
161
|
"dev": {
|
|
162
162
|
"debug": [
|
|
163
|
-
"http://192.168.7.27",
|
|
164
|
-
"http://192.168.3.1:10000",
|
|
165
|
-
"http://192.168.2.83:10000",
|
|
166
163
|
"http://10.10.2.48:10000",
|
|
167
|
-
"http://
|
|
164
|
+
"http://192.168.2.124:20000"
|
|
168
165
|
]
|
|
169
166
|
}
|
|
170
167
|
}
|