@para-ui/core 4.0.0-rc.3 → 4.0.0-rc.5
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/AutoBox/index.js +72 -85
- package/AutoTips/index.js +72 -95
- package/Badge/index.js +18 -17
- package/Breadcrumbs/index.js +57 -73
- package/Button/index.js +89 -117
- package/ButtonGroup/index.js +30 -33
- package/Carousel/index.js +29 -33
- package/Cascader/index.js +7 -9
- package/Checkbox/index.js +28 -35
- package/CheckboxGroup/index.js +43 -58
- package/Collapse/index.js +52 -49
- package/CollapseBox/index.js +65 -70
- package/CollapseLayout/index.js +106 -101
- package/ColorPicker/index.js +3 -3
- package/ComboSelect/index.js +242 -330
- package/ComboSelect/utils.d.ts +0 -5
- package/Container/index.js +17 -21
- package/CopyText/index.js +50 -83
- package/DatePicker/index.js +22 -27
- package/Descriptions/index.js +50 -59
- package/Desktop/index.js +161 -180
- package/DragVerify/index.js +77 -113
- package/Drawer/index.js +82 -97
- package/Dropdown/index.js +3 -3
- package/DynamicMultiBox/index.js +219 -224
- package/DynamicMultiBox/interface.d.ts +7 -0
- package/Empty/index.js +26 -28
- package/Form/index.js +66 -74
- package/FormItem/index.js +14 -15
- package/FunctionModal/index.js +7 -14
- package/GlobalContext/index.js +17 -20
- package/Help/index.js +9 -12
- package/HelperText/index.js +11 -11
- package/InputLang/index.js +104 -124
- package/InputNumber/index.js +62 -81
- package/Label/index.js +19 -21
- package/Loading/index.js +11 -10
- package/Menu/index.js +302 -371
- package/Message/index.js +105 -114
- package/Modal/index.js +122 -148
- package/MultiBox/index.d.ts +5 -0
- package/MultiBox/index.js +111 -115
- package/Notification/index.js +105 -103
- package/OperateBtn/index.d.ts +3 -0
- package/OperateBtn/index.js +77 -107
- package/PageHeader/index.js +327 -406
- package/Pagination/index.js +107 -137
- package/ParauiProvider/index.js +20 -22
- package/PasswordRules/index.js +36 -40
- package/PopConfirm/index.js +62 -79
- package/Popover/index.js +12 -12
- package/Progress/index.js +72 -74
- package/Querying/index.js +52 -59
- package/README.md +2 -0
- package/Radio/index.js +27 -34
- package/RadioGroup/index.js +38 -52
- package/Search/index.js +35 -44
- package/Select/index.js +323 -364
- package/SelectInput/index.js +8 -13
- package/Selector/index.js +905 -796
- package/SelectorPicker/index.js +111 -133
- package/SingleBox/index.d.ts +5 -0
- package/SingleBox/index.js +92 -88
- package/Slider/index.js +46 -57
- package/Status/index.js +14 -13
- package/Stepper/index.js +25 -26
- package/Styles/theme.scss +9 -9
- package/Switch/index.js +32 -35
- package/Table/index.js +767 -963
- package/Tabs/index.js +102 -102
- package/Tag/index.js +115 -162
- package/TextEditor/index.js +81 -103
- package/TextField/index.js +142 -183
- package/TimePicker/index.js +27 -28
- package/Timeline/index.js +67 -58
- package/Title/index.js +32 -34
- package/ToggleButton/index.js +53 -52
- package/Tooltip/index.js +79 -82
- package/Transfer/index.js +160 -203
- package/Tree/index.js +7 -12
- package/Upload/index.js +527 -759
- package/Upload/interface.d.ts +5 -0
- package/_verture/{constant-0d9802f7.js → constant-5317fc89.js} +2 -2
- package/_verture/{index-f48d5ce6.js → index-0ced30f7.js} +1128 -1080
- package/_verture/{index-024bbc9b.js → index-775ad32d.js} +29 -25
- package/_verture/{index-05f7bf11.js → index-c568f272.js} +2 -2
- package/_verture/index-da9097d3.js +239 -0
- package/_verture/{index-56601c94.js → index-ef1235fb.js} +125 -134
- package/_verture/{index-de8f4428.js → index-f186b5e8.js} +315 -399
- package/_verture/intl-f2f27722.js +69 -0
- package/_verture/{modalContext-736ff215.js → modalContext-5df08980.js} +36 -64
- package/_verture/{slicedToArray-a8206399.js → slicedToArray-8223a2ef.js} +15 -2
- package/_verture/{useFormatMessage-703f8b20.js → useFormatMessage-eb13cf56.js} +5 -4
- package/_verture/{useGlobalProps-1b846a65.js → useGlobalProps-1e416658.js} +4 -3
- package/_verture/{usePopupContainer-87febeb9.js → usePopupContainer-635f66f4.js} +16 -15
- package/_verture/{util-7e1fb1e2.js → util-82646c4f.js} +5 -4
- package/_verture/{utils-06d86594.js → utils-46e99c9a.js} +34 -26
- package/index.js +21 -22
- package/locale/index.js +10 -10
- package/package.json +1 -1
- package/umd/AutoBox.js +9 -8
- package/umd/AutoTips.js +9 -8
- package/umd/Badge.js +1 -1
- package/umd/Breadcrumbs.js +9 -8
- package/umd/Button.js +9 -8
- package/umd/ButtonGroup.js +9 -8
- package/umd/Carousel.js +5 -5
- package/umd/Cascader.js +9 -8
- package/umd/Checkbox.js +9 -8
- package/umd/CheckboxGroup.js +9 -8
- package/umd/Collapse.js +8 -7
- package/umd/CollapseBox.js +1 -1
- package/umd/CollapseLayout.js +4 -4
- package/umd/ColorPicker.js +1 -1
- package/umd/ComboSelect.js +9 -8
- package/umd/Container.js +1 -1
- package/umd/CopyText.js +9 -8
- package/umd/DatePicker.js +9 -8
- package/umd/Descriptions.js +9 -8
- package/umd/Desktop.js +9 -8
- package/umd/DragVerify.js +4 -4
- package/umd/Drawer.js +9 -8
- package/umd/Dropdown.js +6 -5
- package/umd/DynamicMultiBox.js +11 -10
- package/umd/Empty.js +1 -1
- package/umd/Form.js +9 -8
- package/umd/FormItem.js +9 -8
- package/umd/FunctionModal.js +9 -8
- package/umd/GlobalContext.js +1 -1
- package/umd/Help.js +9 -8
- package/umd/HelperText.js +1 -1
- package/umd/InputLang.js +9 -8
- package/umd/InputNumber.js +9 -8
- package/umd/Label.js +9 -8
- package/umd/Loading.js +4 -4
- package/umd/Menu.js +4 -4
- package/umd/Message.js +4 -4
- package/umd/Modal.js +9 -8
- package/umd/MultiBox.js +9 -8
- package/umd/Notification.js +8 -7
- package/umd/OperateBtn.js +9 -8
- package/umd/PageHeader.js +9 -8
- package/umd/Pagination.js +9 -8
- package/umd/ParauiProvider.js +1 -1
- package/umd/PasswordRules.js +4 -4
- package/umd/PopConfirm.js +9 -8
- package/umd/Popover.js +9 -8
- package/umd/Progress.js +5 -5
- package/umd/Querying.js +1 -1
- package/umd/Radio.js +9 -8
- package/umd/RadioGroup.js +9 -8
- package/umd/Search.js +9 -8
- package/umd/Select.js +9 -8
- package/umd/SelectInput.js +9 -8
- package/umd/Selector.js +9 -8
- package/umd/SelectorPicker.js +9 -8
- package/umd/SingleBox.js +9 -8
- package/umd/Slider.js +6 -5
- package/umd/Status.js +4 -4
- package/umd/Stepper.js +9 -8
- package/umd/Switch.js +9 -8
- package/umd/Table.js +9 -8
- package/umd/Tabs.js +9 -8
- package/umd/Tag.js +9 -8
- package/umd/TextEditor.js +22 -21
- package/umd/TextField.js +9 -8
- package/umd/TimePicker.js +9 -8
- package/umd/Timeline.js +1 -1
- package/umd/Title.js +9 -8
- package/umd/ToggleButton.js +9 -8
- package/umd/Tooltip.js +9 -8
- package/umd/Transfer.js +10 -9
- package/umd/Tree.js +9 -8
- package/umd/Upload.js +10 -9
- package/umd/locale.js +1 -1
- package/_verture/index-232d890b.js +0 -327
- package/_verture/index-e9007d6a.js +0 -236
- package/_verture/intl-5c1ec055.js +0 -81
- package/_verture/toConsumableArray-8f4c9589.js +0 -19
- package/_verture/unsupportedIterableToArray-cb478f24.js +0 -16
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { _ as _slicedToArray } from './slicedToArray-a8206399.js';
|
|
4
3
|
import { TextField } from '../TextField/index.js';
|
|
4
|
+
import { b as _slicedToArray } from './slicedToArray-8223a2ef.js';
|
|
5
5
|
import { RadioGroup } from '../RadioGroup/index.js';
|
|
6
6
|
import Select from '../Select/index.js';
|
|
7
7
|
import { CheckboxGroup } from '../CheckboxGroup/index.js';
|
|
8
|
-
import { _ as _typeof } from './typeof-adeedc13.js';
|
|
9
8
|
import { Switch } from '../Switch/index.js';
|
|
10
9
|
import Delete from '@para-ui/icons/Delete';
|
|
11
10
|
import ParaLinkGroup from '@para-ui/icons/LinkGroup';
|
|
12
11
|
import AutoTips from '../AutoTips/index.js';
|
|
13
12
|
import { Button } from '../Button/index.js';
|
|
14
13
|
import UploadIcon from '@para-ui/icons/UploadFile';
|
|
15
|
-
import { u as useFormatMessage } from './useFormatMessage-
|
|
14
|
+
import { u as useFormatMessage } from './useFormatMessage-eb13cf56.js';
|
|
16
15
|
import { s as styleInject } from './style-inject.es-300983ab.js';
|
|
17
16
|
import { InputNumber } from '../InputNumber/index.js';
|
|
18
17
|
import { ComboSelect } from '../ComboSelect/index.js';
|
|
19
18
|
import HelperText from '../HelperText/index.js';
|
|
20
19
|
import clsx from 'clsx';
|
|
21
20
|
import Label from '../Label/index.js';
|
|
22
|
-
import { $ as $prefixCls } from './constant-
|
|
21
|
+
import { $ as $prefixCls } from './constant-5317fc89.js';
|
|
23
22
|
|
|
24
23
|
var FormRadioGroup = function FormRadioGroup(props) {
|
|
25
24
|
var defaultValue = props.defaultValue,
|
|
@@ -104,23 +103,23 @@ var FormCheckboxGroup = function FormCheckboxGroup(props) {
|
|
|
104
103
|
* 表单默认的校验方法
|
|
105
104
|
* @type {{[name: string]: validateFunctionType}}
|
|
106
105
|
*/
|
|
107
|
-
|
|
108
|
-
'required':
|
|
106
|
+
const fixedValidateFunction = {
|
|
107
|
+
'required': (item, val, intl) => {
|
|
109
108
|
var _a, _b, _c, _d;
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
const vtype = typeof val;
|
|
110
|
+
const error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.required) || intl({
|
|
112
111
|
id: 'unEmpty'
|
|
113
112
|
}, {
|
|
114
113
|
label: item.label
|
|
115
114
|
});
|
|
116
|
-
|
|
115
|
+
let jude = false;
|
|
117
116
|
switch (vtype) {
|
|
118
117
|
case 'string':
|
|
119
|
-
|
|
118
|
+
const disOnlySpace = item.disOnlySpace !== undefined ? item.disOnlySpace : (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.disOnlySpace;
|
|
120
119
|
if (!disOnlySpace) {
|
|
121
120
|
jude = !!val;
|
|
122
121
|
} else {
|
|
123
|
-
|
|
122
|
+
const space = /^[\s]+$/;
|
|
124
123
|
jude = !!val && !space.test(val);
|
|
125
124
|
}
|
|
126
125
|
break;
|
|
@@ -128,7 +127,7 @@ var fixedValidateFunction = {
|
|
|
128
127
|
jude = val + 1 > val;
|
|
129
128
|
break;
|
|
130
129
|
case 'object':
|
|
131
|
-
|
|
130
|
+
const str = JSON.stringify(val);
|
|
132
131
|
jude = str !== 'null' && str !== '[]' && str !== '{}';
|
|
133
132
|
break;
|
|
134
133
|
case 'boolean':
|
|
@@ -140,15 +139,15 @@ var fixedValidateFunction = {
|
|
|
140
139
|
}
|
|
141
140
|
return jude || error;
|
|
142
141
|
},
|
|
143
|
-
'maxlength':
|
|
142
|
+
'maxlength': (item, val, intl) => {
|
|
144
143
|
var _a, _b, _c, _d, _e, _f;
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
const vtype = typeof val;
|
|
145
|
+
const error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.maxlength) || intl({
|
|
147
146
|
id: 'maxLength'
|
|
148
147
|
}, {
|
|
149
148
|
len: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.maxlength
|
|
150
149
|
});
|
|
151
|
-
|
|
150
|
+
let jude = false;
|
|
152
151
|
if (vtype === 'string' || vtype === 'number' && val + 1 > val) {
|
|
153
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));
|
|
154
153
|
} else {
|
|
@@ -156,15 +155,15 @@ var fixedValidateFunction = {
|
|
|
156
155
|
}
|
|
157
156
|
return jude || error;
|
|
158
157
|
},
|
|
159
|
-
'minLength':
|
|
158
|
+
'minLength': (item, val, intl) => {
|
|
160
159
|
var _a, _b, _c, _d, _e, _f;
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
const vtype = typeof val;
|
|
161
|
+
const error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.minLength) || intl({
|
|
163
162
|
id: 'minLength'
|
|
164
163
|
}, {
|
|
165
164
|
len: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.minLength
|
|
166
165
|
});
|
|
167
|
-
|
|
166
|
+
let jude = false;
|
|
168
167
|
if (vtype === 'string' || vtype === 'number' && val + 1 > val) {
|
|
169
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);
|
|
170
169
|
} else {
|
|
@@ -172,43 +171,43 @@ var fixedValidateFunction = {
|
|
|
172
171
|
}
|
|
173
172
|
return jude || error;
|
|
174
173
|
},
|
|
175
|
-
'pattern':
|
|
174
|
+
'pattern': (item, val, intl) => {
|
|
176
175
|
var _a, _b, _c, _d;
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
const testReg = (_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.validate) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
177
|
+
const error = ((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.pattern) || intl({
|
|
179
178
|
id: 'unRule'
|
|
180
179
|
}, {
|
|
181
180
|
rule: '' + testReg
|
|
182
181
|
});
|
|
183
|
-
|
|
182
|
+
let jude = !val;
|
|
184
183
|
if (testReg && val && typeof testReg !== 'function') {
|
|
185
184
|
jude = testReg.test(val);
|
|
186
185
|
}
|
|
187
186
|
return jude || error;
|
|
188
187
|
},
|
|
189
|
-
'min':
|
|
188
|
+
'min': (item, val, intl) => {
|
|
190
189
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
const vtype = typeof val;
|
|
191
|
+
const error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.min) || intl({
|
|
193
192
|
id: 'minValue'
|
|
194
193
|
}, {
|
|
195
194
|
val: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.min
|
|
196
195
|
});
|
|
197
|
-
|
|
196
|
+
let jude = !val;
|
|
198
197
|
if (vtype === 'string' || vtype === 'number') {
|
|
199
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);
|
|
200
199
|
}
|
|
201
200
|
return jude || error;
|
|
202
201
|
},
|
|
203
|
-
'max':
|
|
202
|
+
'max': (item, val, intl) => {
|
|
204
203
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
const vtype = typeof val;
|
|
205
|
+
const error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.max) || intl({
|
|
207
206
|
id: 'maxValue'
|
|
208
207
|
}, {
|
|
209
208
|
val: (_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.max
|
|
210
209
|
});
|
|
211
|
-
|
|
210
|
+
let jude = !val;
|
|
212
211
|
if (vtype === 'string' || vtype === 'number') {
|
|
213
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);
|
|
214
213
|
}
|
|
@@ -219,14 +218,14 @@ var fixedValidateFunction = {
|
|
|
219
218
|
* 表单rules校验方法
|
|
220
219
|
* @type {validateFunctionType}
|
|
221
220
|
*/
|
|
222
|
-
|
|
221
|
+
const validate = (item, val, intl) => {
|
|
223
222
|
var _a, _b;
|
|
224
|
-
|
|
223
|
+
const validateObj = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.validate;
|
|
225
224
|
if (validateObj) {
|
|
226
|
-
|
|
227
|
-
for (
|
|
228
|
-
|
|
229
|
-
|
|
225
|
+
const messageObj = (_b = item.rules) === null || _b === void 0 ? void 0 : _b.message;
|
|
226
|
+
for (const key in validateObj) {
|
|
227
|
+
const tempFuc = validateObj[key];
|
|
228
|
+
let tmsg = '';
|
|
230
229
|
if (typeof tempFuc === 'function') {
|
|
231
230
|
tmsg = tempFuc(item, val, intl);
|
|
232
231
|
if (tmsg === false && messageObj) tmsg = messageObj[key];
|
|
@@ -247,8 +246,8 @@ var validate = function validate(item, val, intl) {
|
|
|
247
246
|
var en = {
|
|
248
247
|
choseFile: 'Chose File',
|
|
249
248
|
unEmpty: '{label} Cannot be empty',
|
|
250
|
-
maxLength: 'The maximum length cannot be exceeded{len}',
|
|
251
|
-
minLength: 'The minimum length cannot be exceeded{len}',
|
|
249
|
+
maxLength: 'The maximum length cannot be exceeded {len}',
|
|
250
|
+
minLength: 'The minimum length cannot be exceeded {len}',
|
|
252
251
|
unRule: 'The parameter does not comply with the validation rule {rule}',
|
|
253
252
|
minValue: 'The minimum value is {val}',
|
|
254
253
|
maxValue: 'The maximum value is {val}'
|
|
@@ -257,16 +256,16 @@ var en = {
|
|
|
257
256
|
var zh = {
|
|
258
257
|
choseFile: '选择文件',
|
|
259
258
|
unEmpty: '{label}不能为空',
|
|
260
|
-
maxLength: '最大长度不能超过{len}',
|
|
261
|
-
minLength: '最小长度为{len}',
|
|
259
|
+
maxLength: '最大长度不能超过{len}位',
|
|
260
|
+
minLength: '最小长度为{len}位',
|
|
262
261
|
unRule: '参数不符合校验规则{rule}',
|
|
263
262
|
minValue: '最小值为{val}',
|
|
264
263
|
maxValue: '最大值为{val}'
|
|
265
264
|
};
|
|
266
265
|
|
|
267
266
|
var localeJson = {
|
|
268
|
-
zh
|
|
269
|
-
en
|
|
267
|
+
zh,
|
|
268
|
+
en
|
|
270
269
|
};
|
|
271
270
|
|
|
272
271
|
var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.form-file {\n padding: 6px;\n font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, WenQuanYi Micro Hei, sans-serif;\n font-size: 14px;\n font-weight: 400;\n}\n.form-file .file-tips {\n min-height: 20px;\n position: relative;\n padding: 6px;\n}\n.form-file .file-tips .file-tips-item {\n position: relative;\n height: 20px;\n line-height: 16px;\n padding-right: 20px;\n}\n.form-file .file-tips .file-tips-item > [data-name=LinkGroup] {\n vertical-align: middle;\n margin-right: 9px;\n}\n.form-file .file-tips .file-tips-item .file-tips-context {\n display: inline-block;\n vertical-align: middle;\n width: calc(100% - 45px);\n color: rgb(92, 101, 115);\n}\n.form-file .file-tips .file-tips-item > [data-name=Delete] {\n display: none;\n vertical-align: middle;\n cursor: pointer;\n position: absolute;\n right: 3px;\n top: 2px;\n}\n.form-file .file-tips .file-tips-item > [data-name=Delete]:hover {\n opacity: 0.8;\n}\n.form-file .file-tips .file-tips-item:hover {\n backgroundColor: #f5f5f5;\n}\n.form-file .file-tips .file-tips-item:hover > [data-name=Delete] {\n display: inline-block;\n}";
|
|
@@ -408,53 +407,52 @@ var DefaultCompoments = function DefaultCompoments(props) {
|
|
|
408
407
|
/**
|
|
409
408
|
* form 表单操作项 类型
|
|
410
409
|
*/
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
410
|
+
const ItemType = props => {
|
|
411
|
+
const {
|
|
412
|
+
itemType,
|
|
413
|
+
error,
|
|
414
|
+
placeholder,
|
|
415
|
+
label,
|
|
416
|
+
inputProps,
|
|
417
|
+
name,
|
|
418
|
+
rules,
|
|
419
|
+
setValue,
|
|
420
|
+
setError,
|
|
421
|
+
backData,
|
|
422
|
+
disabled,
|
|
423
|
+
change,
|
|
424
|
+
isComponent
|
|
425
|
+
} = props;
|
|
426
|
+
const intl = useFormatMessage('FormItem', localeJson);
|
|
427
|
+
const tipsStr = placeholder || "".concat(label);
|
|
427
428
|
/**
|
|
428
429
|
* 报错信息
|
|
429
430
|
* @type {boolean}
|
|
430
431
|
*/
|
|
431
|
-
|
|
432
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
433
|
-
errorStatus = _React$useState2[0],
|
|
434
|
-
setErrorStatus = _React$useState2[1];
|
|
432
|
+
const [errorStatus, setErrorStatus] = React__default.useState(!!error);
|
|
435
433
|
/**
|
|
436
434
|
* 校验方法
|
|
437
435
|
*/
|
|
438
|
-
|
|
436
|
+
const validateFunction = val => {
|
|
439
437
|
setValue && setValue(name, 'value', val);
|
|
440
438
|
change && change(val);
|
|
441
439
|
// 没有校验规则直接退出
|
|
442
440
|
if (!rules) return;
|
|
443
|
-
|
|
444
|
-
setErrorMsg
|
|
445
|
-
setAndValidateValue
|
|
441
|
+
const item = Object.assign(Object.assign({}, props), {
|
|
442
|
+
setErrorMsg,
|
|
443
|
+
setAndValidateValue
|
|
446
444
|
});
|
|
447
|
-
|
|
445
|
+
const errorMessage = validate(item, val, intl) || '';
|
|
448
446
|
setErrorMsg(errorMessage);
|
|
449
447
|
};
|
|
450
448
|
/**
|
|
451
449
|
* 存储和校验数据
|
|
452
450
|
*/
|
|
453
|
-
|
|
451
|
+
const setAndValidateValue = validateFunction;
|
|
454
452
|
/**
|
|
455
453
|
* 合并设置Error状态方法
|
|
456
454
|
*/
|
|
457
|
-
|
|
455
|
+
const setErrorMsg = React__default.useCallback(msg => {
|
|
458
456
|
setError && setError(msg);
|
|
459
457
|
setErrorStatus(!!msg);
|
|
460
458
|
setValue && setValue(name, 'message', msg);
|
|
@@ -462,21 +460,21 @@ var ItemType = function ItemType(props) {
|
|
|
462
460
|
/**
|
|
463
461
|
* 传出最后的 item 对象
|
|
464
462
|
*/
|
|
465
|
-
React__default.useEffect(
|
|
466
|
-
|
|
467
|
-
setErrorMsg
|
|
468
|
-
setAndValidateValue
|
|
463
|
+
React__default.useEffect(() => {
|
|
464
|
+
const item = Object.assign(Object.assign({}, props), {
|
|
465
|
+
setErrorMsg,
|
|
466
|
+
setAndValidateValue
|
|
469
467
|
});
|
|
470
468
|
setValue && setValue(name, 'item', item);
|
|
471
469
|
}, [name, props, setErrorMsg, setValue]);
|
|
472
470
|
/**
|
|
473
471
|
* 判断显示那个
|
|
474
472
|
*/
|
|
475
|
-
|
|
473
|
+
const selectType = () => {
|
|
476
474
|
if (!isComponent && itemType && typeof itemType !== 'string' && (!itemType.name || itemType.name === 'InputType')) {
|
|
477
|
-
|
|
478
|
-
setErrorMsg
|
|
479
|
-
setAndValidateValue
|
|
475
|
+
const item = Object.assign(Object.assign({}, props), {
|
|
476
|
+
setErrorMsg,
|
|
477
|
+
setAndValidateValue
|
|
480
478
|
});
|
|
481
479
|
return itemType(item);
|
|
482
480
|
}
|
|
@@ -485,7 +483,7 @@ var ItemType = function ItemType(props) {
|
|
|
485
483
|
return jsx(FormFile, Object.assign({}, props, {
|
|
486
484
|
defaultValue: backData[name],
|
|
487
485
|
disabled: disabled,
|
|
488
|
-
onChange:
|
|
486
|
+
onChange: value => {
|
|
489
487
|
validateFunction(value);
|
|
490
488
|
}
|
|
491
489
|
}));
|
|
@@ -493,7 +491,7 @@ var ItemType = function ItemType(props) {
|
|
|
493
491
|
if (backData[name] === undefined) setValue && setValue(name, 'initValue', !!backData[name]);
|
|
494
492
|
return jsx(Switch, Object.assign({
|
|
495
493
|
defaultChecked: !!backData[name],
|
|
496
|
-
onChange:
|
|
494
|
+
onChange: checked => {
|
|
497
495
|
validateFunction(checked);
|
|
498
496
|
}
|
|
499
497
|
}, Object.assign(Object.assign({}, inputProps), {
|
|
@@ -503,7 +501,7 @@ var ItemType = function ItemType(props) {
|
|
|
503
501
|
return jsx(FormCheckboxGroup, Object.assign({
|
|
504
502
|
error: errorStatus,
|
|
505
503
|
defaultValue: backData[name],
|
|
506
|
-
change:
|
|
504
|
+
change: value => {
|
|
507
505
|
validateFunction(value);
|
|
508
506
|
},
|
|
509
507
|
list: props.list
|
|
@@ -515,7 +513,7 @@ var ItemType = function ItemType(props) {
|
|
|
515
513
|
placeholder: tipsStr,
|
|
516
514
|
defaultValue: backData[name],
|
|
517
515
|
error: errorStatus,
|
|
518
|
-
change:
|
|
516
|
+
change: value => {
|
|
519
517
|
validateFunction(value);
|
|
520
518
|
},
|
|
521
519
|
list: props.list
|
|
@@ -526,7 +524,7 @@ var ItemType = function ItemType(props) {
|
|
|
526
524
|
return jsx(FormRadioGroup, Object.assign({
|
|
527
525
|
error: errorStatus,
|
|
528
526
|
defaultValue: backData[name],
|
|
529
|
-
change:
|
|
527
|
+
change: value => {
|
|
530
528
|
validateFunction(value);
|
|
531
529
|
},
|
|
532
530
|
list: props.list
|
|
@@ -543,7 +541,7 @@ var ItemType = function ItemType(props) {
|
|
|
543
541
|
rows: 3,
|
|
544
542
|
name: name,
|
|
545
543
|
hideErrorDom: null,
|
|
546
|
-
onChange:
|
|
544
|
+
onChange: e => {
|
|
547
545
|
validateFunction(e.target.value);
|
|
548
546
|
}
|
|
549
547
|
}, inputProps));
|
|
@@ -555,7 +553,7 @@ var ItemType = function ItemType(props) {
|
|
|
555
553
|
disabled: disabled,
|
|
556
554
|
name: name,
|
|
557
555
|
hideErrorDom: null,
|
|
558
|
-
onChange:
|
|
556
|
+
onChange: val => {
|
|
559
557
|
validateFunction(val);
|
|
560
558
|
}
|
|
561
559
|
}, inputProps));
|
|
@@ -565,7 +563,7 @@ var ItemType = function ItemType(props) {
|
|
|
565
563
|
placeholder: tipsStr,
|
|
566
564
|
defaultValue: backData[name],
|
|
567
565
|
disabled: disabled,
|
|
568
|
-
onChange:
|
|
566
|
+
onChange: options => {
|
|
569
567
|
validateFunction(options);
|
|
570
568
|
}
|
|
571
569
|
}, inputProps));
|
|
@@ -577,7 +575,7 @@ var ItemType = function ItemType(props) {
|
|
|
577
575
|
placeholder: tipsStr,
|
|
578
576
|
defaultValue: backData[name],
|
|
579
577
|
disabled: disabled,
|
|
580
|
-
onChange:
|
|
578
|
+
onChange: val => {
|
|
581
579
|
validateFunction(val);
|
|
582
580
|
},
|
|
583
581
|
inputProps: inputProps
|
|
@@ -588,7 +586,7 @@ var ItemType = function ItemType(props) {
|
|
|
588
586
|
autocomplete: "off",
|
|
589
587
|
error: errorStatus,
|
|
590
588
|
placeholder: tipsStr,
|
|
591
|
-
onChange:
|
|
589
|
+
onChange: e => {
|
|
592
590
|
validateFunction(e.target.value);
|
|
593
591
|
},
|
|
594
592
|
name: name,
|
|
@@ -604,25 +602,24 @@ var ItemType = function ItemType(props) {
|
|
|
604
602
|
* 报错信息组件
|
|
605
603
|
* @description 为了解决,在主组件设置state,导致输入框中内容刷新,且失去焦点
|
|
606
604
|
*/
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
605
|
+
const ErrorTips = props => {
|
|
606
|
+
const {
|
|
607
|
+
getSetError,
|
|
608
|
+
errorMessage,
|
|
609
|
+
helperTextProps
|
|
610
|
+
} = props;
|
|
611
611
|
/**
|
|
612
612
|
* 报错信息
|
|
613
613
|
* @type {string}
|
|
614
614
|
*/
|
|
615
|
-
|
|
616
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
617
|
-
errorTips = _React$useState2[0],
|
|
618
|
-
setErrorTips = _React$useState2[1];
|
|
615
|
+
const [errorTips, setErrorTips] = React__default.useState(errorMessage || '');
|
|
619
616
|
/**
|
|
620
617
|
* 初始化传出, 设置错误信息方法
|
|
621
618
|
*/
|
|
622
|
-
React__default.useEffect(
|
|
619
|
+
React__default.useEffect(() => {
|
|
623
620
|
setErrorTips(errorMessage || '');
|
|
624
621
|
}, [errorMessage]);
|
|
625
|
-
React__default.useEffect(
|
|
622
|
+
React__default.useEffect(() => {
|
|
626
623
|
getSetError && getSetError(setErrorTips);
|
|
627
624
|
}, [getSetError]);
|
|
628
625
|
return jsx(HelperText, Object.assign({
|
|
@@ -635,7 +632,7 @@ var ErrorTips = function ErrorTips(props) {
|
|
|
635
632
|
var css_248z = "@charset \"UTF-8\";\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-form-item {\n font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, WenQuanYi Micro Hei, sans-serif;\n font-size: 14px;\n font-weight: 400;\n}\n.paraui-v4-form-item .paraui-v4-text-field {\n display: block;\n}\n.paraui-v4-form-item.paraui-v4-form-item-checkGroup .form-label .form-labe-text, .paraui-v4-form-item.paraui-v4-form-item-radioGroup .form-label .form-labe-text {\n margin-bottom: 4px;\n}\n.paraui-v4-form-item .form-label {\n display: inline-block;\n}\n.paraui-v4-form-item .form-edit > div {\n padding: 0;\n width: 100%;\n}\n.paraui-v4-form-item .form-content-vertical {\n display: inline-block;\n width: 100%;\n}";
|
|
636
633
|
styleInject(css_248z);
|
|
637
634
|
|
|
638
|
-
|
|
635
|
+
const formInputTypeJson = {
|
|
639
636
|
checkGroup: true,
|
|
640
637
|
select: true,
|
|
641
638
|
radioGroup: true,
|
|
@@ -651,32 +648,28 @@ var formInputTypeJson = {
|
|
|
651
648
|
* @author zhanzl
|
|
652
649
|
* @description 用于根据配置自动生成表单
|
|
653
650
|
*/
|
|
654
|
-
|
|
651
|
+
const FormItem = props => {
|
|
655
652
|
var _a, _b;
|
|
656
|
-
|
|
657
|
-
type =
|
|
658
|
-
labelWidth
|
|
659
|
-
tips
|
|
660
|
-
label
|
|
661
|
-
itemType
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
helperTextProps = props.helperTextProps,
|
|
677
|
-
requiredElement = props.requiredElement,
|
|
678
|
-
_props$disRequiredEle = props.disRequiredElement,
|
|
679
|
-
disRequiredElement = _props$disRequiredEle === void 0 ? false : _props$disRequiredEle;
|
|
653
|
+
const {
|
|
654
|
+
type = 'horizontal',
|
|
655
|
+
labelWidth,
|
|
656
|
+
tips,
|
|
657
|
+
label,
|
|
658
|
+
itemType,
|
|
659
|
+
InputType = itemType,
|
|
660
|
+
setValue,
|
|
661
|
+
errorMessage,
|
|
662
|
+
hideLabel,
|
|
663
|
+
backData = {},
|
|
664
|
+
defaultValue,
|
|
665
|
+
name,
|
|
666
|
+
hideError = false,
|
|
667
|
+
className = '',
|
|
668
|
+
labelProps,
|
|
669
|
+
helperTextProps,
|
|
670
|
+
requiredElement,
|
|
671
|
+
disRequiredElement = false
|
|
672
|
+
} = props;
|
|
680
673
|
if (backData[name] === undefined) {
|
|
681
674
|
backData[name] = defaultValue;
|
|
682
675
|
}
|
|
@@ -684,17 +677,17 @@ var FormItem = function FormItem(props) {
|
|
|
684
677
|
* 接受设置报错信息方法
|
|
685
678
|
* @type {Function}
|
|
686
679
|
*/
|
|
687
|
-
|
|
680
|
+
const setErrorTips = React__default.useRef();
|
|
688
681
|
/**
|
|
689
682
|
* 设置错误信息
|
|
690
683
|
*/
|
|
691
|
-
|
|
684
|
+
const setError = error => {
|
|
692
685
|
setErrorTips.current && setErrorTips.current(error);
|
|
693
686
|
};
|
|
694
687
|
/**
|
|
695
688
|
* 用于判断是否是 vertical 模式如果是则添加相应的外层
|
|
696
689
|
*/
|
|
697
|
-
|
|
690
|
+
const TypeLayout = props => {
|
|
698
691
|
return type === 'vertical' ? jsx("div", Object.assign({
|
|
699
692
|
className: "form-content-vertical form-content-vertical-".concat(name),
|
|
700
693
|
style: {
|
|
@@ -707,13 +700,13 @@ var FormItem = function FormItem(props) {
|
|
|
707
700
|
/**
|
|
708
701
|
* 展示label
|
|
709
702
|
*/
|
|
710
|
-
|
|
703
|
+
const showLabel = React__default.useCallback(() => {
|
|
711
704
|
if (!label) return '';
|
|
712
705
|
return typeof label === 'string' ? label : label(props);
|
|
713
706
|
}, [label]);
|
|
714
707
|
/** 处理className */
|
|
715
|
-
|
|
716
|
-
|
|
708
|
+
const handClass = () => {
|
|
709
|
+
let str = "".concat($prefixCls, "-form-item ").concat($prefixCls, "-form-item-").concat(name);
|
|
717
710
|
if (className) str += " ".concat(className);
|
|
718
711
|
if (typeof InputType === 'string' && formInputTypeJson[InputType]) {
|
|
719
712
|
str += " ".concat($prefixCls, "-form-item-").concat(InputType);
|
|
@@ -752,9 +745,7 @@ var FormItem = function FormItem(props) {
|
|
|
752
745
|
className: "form-error form-error-".concat(name)
|
|
753
746
|
}, {
|
|
754
747
|
children: jsx(ErrorTips, {
|
|
755
|
-
getSetError:
|
|
756
|
-
return setErrorTips.current = fuc;
|
|
757
|
-
},
|
|
748
|
+
getSetError: fuc => setErrorTips.current = fuc,
|
|
758
749
|
helperTextProps: helperTextProps,
|
|
759
750
|
errorMessage: errorMessage
|
|
760
751
|
})
|