@para-ui/core 2.2.6 → 2.2.7-beta
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.d.ts +34 -34
- package/AutoBox/index.js +203 -15
- package/AutoTips/index.d.ts +27 -27
- package/AutoTips/index.js +84 -15
- package/Breadcrumbs/index.d.ts +39 -39
- package/Breadcrumbs/index.js +227 -15
- package/Button/SplitButton.d.ts +62 -61
- package/Button/index.d.ts +71 -56
- package/Button/index.js +348 -14
- package/Button/lang/en_US.d.ts +4 -4
- package/Button/lang/index.d.ts +9 -9
- package/Button/lang/zh_CN.d.ts +4 -4
- package/ButtonGroup/index.d.ts +33 -33
- package/ButtonGroup/index.js +128 -14
- package/Carousel/index.d.ts +30 -30
- package/Carousel/index.js +74 -15
- package/Cascader/index.d.ts +52 -52
- package/Cascader/index.js +166 -15
- package/Cascader/lang/en_US.d.ts +4 -4
- package/Cascader/lang/index.d.ts +9 -9
- package/Cascader/lang/zh_CN.d.ts +4 -4
- package/Checkbox/index.d.ts +40 -40
- package/Checkbox/index.js +105 -14
- package/CheckboxGroup/index.d.ts +46 -46
- package/CheckboxGroup/index.js +138 -14
- package/Collapse/collapsePanel.d.ts +30 -30
- package/Collapse/index.d.ts +57 -57
- package/Collapse/index.js +171 -15
- package/Collapse/motion.d.ts +5 -5
- package/Collapse/util.d.ts +11 -11
- package/CollapseBox/index.d.ts +27 -27
- package/CollapseBox/index.js +164 -15
- package/CollapseBox/util.d.ts +5 -5
- package/ColorPicker/index.d.ts +4 -4
- package/ColorPicker/index.js +4 -1
- package/ComboSelect/WithTabsCombo/index.d.ts +11 -11
- package/ComboSelect/WithTabsCombo/interface.d.ts +141 -141
- package/ComboSelect/index.d.ts +11 -11
- package/ComboSelect/index.js +1803 -14
- package/ComboSelect/interface.d.ts +140 -143
- package/ComboSelect/lang/en_US.d.ts +8 -8
- package/ComboSelect/lang/index.d.ts +17 -17
- package/ComboSelect/lang/zh_CN.d.ts +8 -8
- package/ComboSelect/utils.d.ts +12 -12
- package/Container/index.d.ts +77 -77
- package/Container/index.js +239 -15
- package/DatePicker/PickerButton.d.ts +3 -3
- package/DatePicker/PickerTag.d.ts +3 -3
- package/DatePicker/generatePicker/generateRangePicker.d.ts +4 -4
- package/DatePicker/generatePicker/generateSinglePicker.d.ts +11 -11
- package/DatePicker/generatePicker/index.d.ts +77 -77
- package/DatePicker/index.d.ts +18 -18
- package/DatePicker/index.js +733 -14
- package/DatePicker/lang/en_US.d.ts +3 -3
- package/DatePicker/lang/index.d.ts +7 -7
- package/DatePicker/lang/zh_CN.d.ts +3 -3
- package/DatePicker/util.d.ts +20 -20
- package/Desktop/index.d.ts +57 -55
- package/Desktop/index.js +853 -14
- package/Drawer/index.d.ts +11 -11
- package/Drawer/index.js +186 -14
- package/Drawer/interface.d.ts +83 -83
- package/Drawer/lang/en_US.d.ts +5 -5
- package/Drawer/lang/index.d.ts +11 -11
- package/Drawer/lang/zh_CN.d.ts +5 -5
- package/Dropdown/index.d.ts +25 -0
- package/Dropdown/index.js +67 -0
- package/Empty/images/index.d.ts +3 -2
- package/Empty/index.d.ts +30 -30
- package/Empty/index.js +644 -14
- package/Empty/lang/en_US.d.ts +6 -6
- package/Empty/lang/index.d.ts +13 -13
- package/Empty/lang/zh_CN.d.ts +6 -6
- package/Form/index.d.ts +181 -181
- package/Form/index.js +384 -14
- package/FormItem/compoments/defaultCompoments/index.d.ts +19 -19
- package/FormItem/compoments/formCheckboxGroup/index.d.ts +8 -8
- package/FormItem/compoments/formFile/index.d.ts +38 -38
- package/FormItem/compoments/formRadioGroup/index.d.ts +8 -8
- package/FormItem/compoments/formSelect/index.d.ts +18 -18
- package/FormItem/errorTips.d.ts +12 -12
- package/FormItem/index.d.ts +152 -152
- package/FormItem/index.js +81 -14
- package/FormItem/itemType.d.ts +42 -42
- package/FormItem/validateFunction.d.ts +15 -15
- package/FunctionModal/dialog.d.ts +58 -58
- package/FunctionModal/index.d.ts +8 -8
- package/FunctionModal/index.js +39 -14
- package/FunctionModal/modalContext.d.ts +15 -14
- package/GlobalContext/componentsProps.d.ts +19 -19
- package/GlobalContext/confirmLocale.d.ts +7 -7
- package/GlobalContext/index.d.ts +28 -28
- package/GlobalContext/index.js +41 -16
- package/GlobalContext/intl.d.ts +34 -34
- package/GlobalContext/useFormatMessage.d.ts +3 -3
- package/Help/index.d.ts +18 -20
- package/Help/index.js +39 -15
- package/HelperText/index.d.ts +19 -19
- package/HelperText/index.js +29 -15
- package/Hooks/useGlobalProps.d.ts +1 -1
- package/InputLang/index.d.ts +49 -49
- package/InputLang/index.js +270 -14
- package/InputNumber/index.d.ts +74 -74
- package/InputNumber/index.js +308 -14
- package/Label/index.d.ts +35 -35
- package/Label/index.js +81 -14
- package/Loading/index.d.ts +17 -17
- package/Loading/index.js +47 -15
- package/Menu/footerExpansion.d.ts +9 -9
- package/Menu/index.d.ts +10 -10
- package/Menu/index.js +1232 -14
- package/Menu/interface.d.ts +139 -139
- package/Menu/logo.d.ts +9 -9
- package/Menu/verticalMenuList.d.ts +14 -14
- package/Message/index.d.ts +73 -73
- package/Message/index.js +222 -15
- package/Modal/Confirm/index.d.ts +65 -66
- package/Modal/index.d.ts +90 -61
- package/Modal/index.js +443 -14
- package/Modal/lang/en_US.d.ts +5 -5
- package/Modal/lang/index.d.ts +11 -11
- package/Modal/lang/zh_CN.d.ts +5 -5
- package/MultiBox/index.d.ts +54 -54
- package/MultiBox/index.js +231 -14
- package/Notification/index.d.ts +52 -52
- package/Notification/index.js +266 -15
- package/OperateBtn/index.d.ts +59 -59
- package/OperateBtn/index.js +260 -14
- package/OperateBtn/lang/en_US.d.ts +4 -4
- package/OperateBtn/lang/index.d.ts +9 -9
- package/OperateBtn/lang/zh_CN.d.ts +4 -4
- package/PageHeader/horizontalMeun.d.ts +9 -9
- package/PageHeader/horizontalMeunRight.d.ts +9 -9
- package/PageHeader/index.d.ts +10 -10
- package/PageHeader/index.js +1171 -14
- package/PageHeader/interface.d.ts +167 -167
- package/Pagination/index.d.ts +33 -33
- package/Pagination/index.js +469 -14
- package/Pagination/lang/en_US.d.ts +8 -8
- package/Pagination/lang/index.d.ts +17 -17
- package/Pagination/lang/zh_CN.d.ts +8 -8
- package/ParauiProvider/index.d.ts +8 -12
- package/ParauiProvider/index.js +53 -15
- package/PopConfirm/index.d.ts +58 -56
- package/PopConfirm/index.js +189 -14
- package/PopConfirm/lang/en_US.d.ts +5 -5
- package/PopConfirm/lang/index.d.ts +11 -11
- package/PopConfirm/lang/zh_CN.d.ts +5 -5
- package/Popover/index.d.ts +14 -14
- package/Popover/index.js +66 -15
- package/Progress/Line.d.ts +47 -47
- package/Progress/Steps.d.ts +17 -17
- package/Progress/index.d.ts +81 -81
- package/Progress/index.js +358 -20
- package/Progress/utils.d.ts +6 -6
- package/Querying/images/index.d.ts +3 -2
- package/Querying/index.d.ts +26 -26
- package/Querying/index.js +762 -14
- package/Querying/lang/en_US.d.ts +4 -4
- package/Querying/lang/index.d.ts +9 -9
- package/Querying/lang/zh_CN.d.ts +4 -4
- package/Radio/index.d.ts +38 -38
- package/Radio/index.js +94 -14
- package/RadioGroup/index.d.ts +47 -47
- package/RadioGroup/index.js +128 -14
- package/Search/index.d.ts +56 -56
- package/Search/index.js +220 -14
- package/Select/index.d.ts +86 -86
- package/Select/index.js +1288 -14
- package/Select/lang/en_US.d.ts +5 -5
- package/Select/lang/index.d.ts +11 -11
- package/Select/lang/zh_CN.d.ts +5 -5
- package/SelectInput/index.d.ts +11 -11
- package/SelectInput/index.js +51 -14
- package/SingleBox/index.d.ts +42 -42
- package/SingleBox/index.js +194 -14
- package/Slider/index.d.ts +14 -14
- package/Slider/index.js +125 -15
- package/Slider/interface.d.ts +102 -102
- package/Split/index.d.ts +7 -7
- package/Split/index.js +134 -15
- package/Stepper/icons.d.ts +5 -5
- package/Stepper/index.d.ts +49 -39
- package/Stepper/index.js +99 -15
- package/Switch/index.d.ts +78 -78
- package/Switch/index.js +73 -14
- package/Table/index.d.ts +10 -10
- package/Table/index.js +2725 -14
- package/Table/interface.d.ts +202 -202
- package/Table/lang/en_US.d.ts +6 -6
- package/Table/lang/index.d.ts +13 -13
- package/Table/lang/zh_CN.d.ts +6 -6
- package/Table/tableBody.d.ts +9 -9
- package/Table/tableBodyElement/index.d.ts +15 -15
- package/Table/tableBodyInterface.d.ts +67 -67
- package/Table/tableContainer/index.d.ts +16 -16
- package/Table/tableElement/index.d.ts +17 -17
- package/Table/tableHead.d.ts +9 -9
- package/Table/tableHeadElement/index.d.ts +15 -15
- package/Table/tableHeadInterface.d.ts +26 -30
- package/Table/tablePagination.d.ts +9 -9
- package/Table/tablePaginationInterFace.d.ts +24 -24
- package/Table/tdElement/index.d.ts +15 -15
- package/Table/thElement/index.d.ts +15 -15
- package/Table/trElement/index.d.ts +15 -15
- package/Table/util.d.ts +16 -16
- package/Tabs/index.d.ts +69 -48
- package/Tabs/index.js +218 -14
- package/Tabs/lang/en_US.d.ts +4 -0
- package/Tabs/lang/index.d.ts +9 -0
- package/Tabs/lang/zh_CN.d.ts +4 -0
- package/Tag/TagGroup.d.ts +66 -66
- package/Tag/index.d.ts +34 -34
- package/Tag/index.js +286 -14
- package/Test/index.d.ts +3 -2
- package/Test/index.js +9 -16
- package/TextField/index.d.ts +93 -93
- package/TextField/index.js +686 -14
- package/TimePicker/index.d.ts +22 -22
- package/TimePicker/index.js +77 -14
- package/TimePicker/locale/en_US.d.ts +3 -3
- package/TimePicker/locale/zh_CN.d.ts +3 -3
- package/TimePicker/style/index.d.ts +1 -1
- package/Timeline/TimelineItem.d.ts +23 -0
- package/Timeline/index.d.ts +31 -22
- package/Timeline/index.js +150 -15
- package/ToggleButton/ToggleButtonGroup.d.ts +49 -49
- package/ToggleButton/index.d.ts +49 -49
- package/ToggleButton/index.js +200 -14
- package/Tooltip/index.d.ts +11 -14
- package/Tooltip/index.js +335 -15
- package/Tooltip/interface.d.ts +21 -0
- package/Tooltip/utils.d.ts +22 -0
- package/Transfer/index.d.ts +18 -17
- package/Transfer/index.js +343 -14
- package/Transfer/lang/en_US.d.ts +6 -6
- package/Transfer/lang/index.d.ts +13 -13
- package/Transfer/lang/zh_CN.d.ts +6 -6
- package/Tree/OperateBar/index.d.ts +13 -13
- package/Tree/Tree.d.ts +4 -4
- package/Tree/index.d.ts +5 -5
- package/Tree/index.js +35 -14
- package/Tree/interface.d.ts +209 -207
- package/Tree/lang/en_US.d.ts +8 -8
- package/Tree/lang/index.d.ts +17 -17
- package/Tree/lang/zh_CN.d.ts +8 -8
- package/Tree/utils/tools.d.ts +26 -26
- package/Tree/utils/treeUtil.d.ts +15 -15
- package/Upload/Dragger/index.d.ts +10 -10
- package/Upload/ErroTip/index.d.ts +13 -13
- package/Upload/ImageUpload/index.d.ts +14 -14
- package/Upload/ImgCrop/EasyCrop.d.ts +17 -17
- package/Upload/ImgCrop/constants.d.ts +7 -7
- package/Upload/ImgCrop/index.d.ts +6 -6
- package/Upload/ImgCrop/interface.d.ts +24 -24
- package/Upload/UploadList/index.d.ts +5 -5
- package/Upload/index.d.ts +15 -15
- package/Upload/index.js +1542 -14
- package/Upload/interface.d.ts +134 -134
- package/Upload/lang/en_US.d.ts +12 -12
- package/Upload/lang/index.d.ts +25 -25
- package/Upload/lang/zh_CN.d.ts +12 -12
- package/_verture/defineProperty-0590dc61.js +16 -0
- package/_verture/index-2c0ecd8d.js +778 -0
- package/_verture/index-342379c6.js +391 -0
- package/_verture/index-a369ca3f.js +4 -0
- package/_verture/index-e2881a53.js +16 -0
- package/_verture/index-ee85b1cd.js +1555 -0
- package/_verture/intl-336570e4.js +65 -0
- package/_verture/modalContext-e7cc8067.js +228 -0
- package/_verture/slicedToArray-d7722f4b.js +62 -0
- package/_verture/style-inject.es-300983ab.js +28 -0
- package/_verture/toConsumableArray-f8047a75.js +19 -0
- package/_verture/tslib.es6-55ed4bd2.js +38 -0
- package/_verture/typeof-498dd2b1.js +11 -0
- package/_verture/useFormatMessage-ac9d6acf.js +20 -0
- package/_verture/useGlobalProps-af9a2af6.js +12 -0
- package/index.d.ts +128 -128
- package/index.js +160 -19
- package/package.json +54 -21
- package/Popper/index.d.ts +0 -13
- package/Popper/index.js +0 -16
- package/README.md +0 -501
- package/cdn/AutoBox/index.js +0 -29
- package/cdn/AutoTips/index.js +0 -40
- package/cdn/Breadcrumbs/index.js +0 -53
- package/cdn/Button/index.js +0 -79
- package/cdn/ButtonGroup/index.js +0 -79
- package/cdn/Carousel/index.js +0 -6
- package/cdn/Cascader/index.js +0 -42
- package/cdn/Checkbox/index.js +0 -53
- package/cdn/CheckboxGroup/index.js +0 -53
- package/cdn/Collapse/index.js +0 -27
- package/cdn/CollapseBox/index.js +0 -1
- package/cdn/ColorPicker/index.js +0 -1
- package/cdn/ComboSelect/index.js +0 -438
- package/cdn/Container/index.js +0 -1
- package/cdn/DatePicker/index.js +0 -185
- package/cdn/Desktop/index.js +0 -24
- package/cdn/Drawer/index.js +0 -84
- package/cdn/Empty/index.js +0 -1
- package/cdn/Form/index.js +0 -477
- package/cdn/FormItem/index.js +0 -477
- package/cdn/FunctionModal/index.js +0 -144
- package/cdn/GlobalContext/index.js +0 -1
- package/cdn/Help/index.js +0 -53
- package/cdn/HelperText/index.js +0 -1
- package/cdn/InputLang/index.js +0 -144
- package/cdn/InputNumber/index.js +0 -118
- package/cdn/Label/index.js +0 -53
- package/cdn/Loading/index.js +0 -14
- package/cdn/Menu/index.js +0 -40
- package/cdn/Message/index.js +0 -53
- package/cdn/Modal/index.js +0 -144
- package/cdn/MultiBox/index.js +0 -131
- package/cdn/Notification/index.js +0 -66
- package/cdn/OperateBtn/index.js +0 -92
- package/cdn/PageHeader/index.js +0 -92
- package/cdn/Pagination/index.js +0 -214
- package/cdn/ParauiProvider/index.js +0 -9
- package/cdn/PopConfirm/index.js +0 -131
- package/cdn/Popover/index.js +0 -16
- package/cdn/Popper/index.js +0 -26
- package/cdn/Progress/index.js +0 -58
- package/cdn/Querying/index.js +0 -1
- package/cdn/Radio/index.js +0 -53
- package/cdn/RadioGroup/index.js +0 -53
- package/cdn/Search/index.js +0 -144
- package/cdn/Select/index.js +0 -131
- package/cdn/SelectInput/index.js +0 -131
- package/cdn/SingleBox/index.js +0 -131
- package/cdn/Slider/index.js +0 -16
- package/cdn/Split/index.js +0 -1
- package/cdn/Stepper/index.js +0 -154
- package/cdn/Switch/index.js +0 -71
- package/cdn/Table/index.js +0 -292
- package/cdn/Tabs/index.js +0 -165
- package/cdn/Tag/index.js +0 -27
- package/cdn/Test/index.js +0 -1
- package/cdn/TextField/index.js +0 -105
- package/cdn/TimePicker/index.js +0 -185
- package/cdn/Timeline/index.js +0 -16
- package/cdn/ToggleButton/index.js +0 -79
- package/cdn/Tooltip/index.js +0 -40
- package/cdn/Transfer/index.js +0 -170
- package/cdn/Tree/index.js +0 -170
- package/cdn/Upload/index.js +0 -252
- package/style.css +0 -72
|
@@ -0,0 +1,778 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { _ as _slicedToArray } from './slicedToArray-d7722f4b.js';
|
|
4
|
+
import { TextField } from '../TextField/index.js';
|
|
5
|
+
import { RadioGroup } from '../RadioGroup/index.js';
|
|
6
|
+
import Select from '../Select/index.js';
|
|
7
|
+
import { CheckboxGroup } from '../CheckboxGroup/index.js';
|
|
8
|
+
import { _ as _typeof } from './typeof-498dd2b1.js';
|
|
9
|
+
import { Switch } from '../Switch/index.js';
|
|
10
|
+
import Delete from '@para-ui/icons/Delete';
|
|
11
|
+
import ParaLinkGroup from '@para-ui/icons/LinkGroup';
|
|
12
|
+
import AutoTips from '../AutoTips/index.js';
|
|
13
|
+
import { Button } from '../Button/index.js';
|
|
14
|
+
import { s as styleInject } from './style-inject.es-300983ab.js';
|
|
15
|
+
import { InputNumber } from '../InputNumber/index.js';
|
|
16
|
+
import ComboSelect from '../ComboSelect/index.js';
|
|
17
|
+
import HelperText from '../HelperText/index.js';
|
|
18
|
+
import clsx from 'clsx';
|
|
19
|
+
import Label from '../Label/index.js';
|
|
20
|
+
|
|
21
|
+
var FormRadioGroup = function FormRadioGroup(props) {
|
|
22
|
+
var defaultValue = props.defaultValue,
|
|
23
|
+
change = props.change;
|
|
24
|
+
/**
|
|
25
|
+
* 选中的值
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
var _React$useState = React__default.useState(defaultValue || ''),
|
|
29
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
30
|
+
selectValue = _React$useState2[0],
|
|
31
|
+
setSelectValue = _React$useState2[1];
|
|
32
|
+
/**
|
|
33
|
+
* 选中值改变
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
var changeValue = function changeValue(value) {
|
|
38
|
+
setSelectValue(value);
|
|
39
|
+
change && change(value);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return jsx(RadioGroup, Object.assign({
|
|
43
|
+
value: selectValue,
|
|
44
|
+
onChange: changeValue
|
|
45
|
+
}, props));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var FormSelect = function FormSelect(props) {
|
|
49
|
+
var _props$defaultValue = props.defaultValue,
|
|
50
|
+
defaultValue = _props$defaultValue === void 0 ? '' : _props$defaultValue,
|
|
51
|
+
change = props.change,
|
|
52
|
+
value = props.value;
|
|
53
|
+
/**
|
|
54
|
+
* 选中的值
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
var _React$useState = React__default.useState(value !== undefined ? value : defaultValue),
|
|
58
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
59
|
+
selectValue = _React$useState2[0],
|
|
60
|
+
setSelectValue = _React$useState2[1];
|
|
61
|
+
/**
|
|
62
|
+
* 选中值改变
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
var changeValue = function changeValue(value) {
|
|
67
|
+
setSelectValue(value);
|
|
68
|
+
change && change(value);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
React__default.useEffect(function () {
|
|
72
|
+
setSelectValue(value);
|
|
73
|
+
}, [value]);
|
|
74
|
+
return jsx(Select, Object.assign({
|
|
75
|
+
labelMode: "inside",
|
|
76
|
+
onChange: changeValue
|
|
77
|
+
}, props, {
|
|
78
|
+
value: selectValue
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
var FormCheckboxGroup = function FormCheckboxGroup(props) {
|
|
83
|
+
var defaultValue = props.defaultValue,
|
|
84
|
+
change = props.change;
|
|
85
|
+
/**
|
|
86
|
+
* 选中的值
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
var _React$useState = React__default.useState(defaultValue || []),
|
|
90
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
91
|
+
selectValue = _React$useState2[0],
|
|
92
|
+
setSelectValue = _React$useState2[1];
|
|
93
|
+
/**
|
|
94
|
+
* 选中值改变
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
var changeValue = function changeValue(value) {
|
|
99
|
+
setSelectValue(value);
|
|
100
|
+
change && change(value);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return jsx(CheckboxGroup, Object.assign({
|
|
104
|
+
value: selectValue,
|
|
105
|
+
onChange: changeValue
|
|
106
|
+
}, props));
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 表单默认的校验方法
|
|
111
|
+
* @type {{[name: string]: validateFunctionType}}
|
|
112
|
+
*/
|
|
113
|
+
var fixedValidateFunction = {
|
|
114
|
+
'required': function required(item, val) {
|
|
115
|
+
var _a, _b, _c, _d;
|
|
116
|
+
|
|
117
|
+
var vtype = _typeof(val);
|
|
118
|
+
|
|
119
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.required) || "".concat(item.label, "\u4E0D\u80FD\u4E3A\u7A7A");
|
|
120
|
+
var jude = false;
|
|
121
|
+
|
|
122
|
+
switch (vtype) {
|
|
123
|
+
case 'string':
|
|
124
|
+
var 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;
|
|
125
|
+
|
|
126
|
+
if (!disOnlySpace) {
|
|
127
|
+
jude = !!val;
|
|
128
|
+
} else {
|
|
129
|
+
var space = /^[\s]+$/;
|
|
130
|
+
jude = !!val && !space.test(val);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case 'number':
|
|
136
|
+
jude = val + 1 > val;
|
|
137
|
+
break;
|
|
138
|
+
|
|
139
|
+
case 'object':
|
|
140
|
+
var str = JSON.stringify(val);
|
|
141
|
+
jude = str !== 'null' && str !== '[]' && str !== '{}';
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
case 'boolean':
|
|
145
|
+
jude = val !== undefined;
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
default:
|
|
149
|
+
jude = !!val;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return jude || error;
|
|
154
|
+
},
|
|
155
|
+
'maxlength': function maxlength(item, val) {
|
|
156
|
+
var _a, _b, _c, _d, _e, _f;
|
|
157
|
+
|
|
158
|
+
var vtype = _typeof(val);
|
|
159
|
+
|
|
160
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.maxlength) || "\u6700\u5927\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7".concat((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.maxlength);
|
|
161
|
+
var jude = false;
|
|
162
|
+
|
|
163
|
+
if (vtype === 'string' || vtype === 'number' && val + 1 > val) {
|
|
164
|
+
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));
|
|
165
|
+
} else {
|
|
166
|
+
jude = !val;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return jude || error;
|
|
170
|
+
},
|
|
171
|
+
'minLength': function minLength(item, val) {
|
|
172
|
+
var _a, _b, _c, _d, _e, _f;
|
|
173
|
+
|
|
174
|
+
var vtype = _typeof(val);
|
|
175
|
+
|
|
176
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.minLength) || "\u6700\u5C0F\u957F\u5EA6\u4E3A".concat((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.minLength);
|
|
177
|
+
var jude = false;
|
|
178
|
+
|
|
179
|
+
if (vtype === 'string' || vtype === 'number' && val + 1 > val) {
|
|
180
|
+
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);
|
|
181
|
+
} else {
|
|
182
|
+
jude = !val;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return jude || error;
|
|
186
|
+
},
|
|
187
|
+
'pattern': function pattern(item, val) {
|
|
188
|
+
var _a, _b, _c, _d;
|
|
189
|
+
|
|
190
|
+
var testReg = (_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.validate) === null || _b === void 0 ? void 0 : _b.pattern;
|
|
191
|
+
var error = ((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.pattern) || "\u53C2\u6570\u4E0D\u7B26\u5408\u6821\u9A8C\u89C4\u5219: ".concat(testReg);
|
|
192
|
+
var jude = !val;
|
|
193
|
+
|
|
194
|
+
if (testReg && val && typeof testReg !== 'function') {
|
|
195
|
+
jude = testReg.test(val);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return jude || error;
|
|
199
|
+
},
|
|
200
|
+
'min': function min(item, val) {
|
|
201
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
202
|
+
|
|
203
|
+
var vtype = _typeof(val);
|
|
204
|
+
|
|
205
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.min) || "\u6700\u5C0F\u503C\u4E3A".concat((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.min);
|
|
206
|
+
var jude = !val;
|
|
207
|
+
|
|
208
|
+
if (vtype === 'string' || vtype === 'number') {
|
|
209
|
+
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);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return jude || error;
|
|
213
|
+
},
|
|
214
|
+
'max': function max(item, val) {
|
|
215
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
216
|
+
|
|
217
|
+
var vtype = _typeof(val);
|
|
218
|
+
|
|
219
|
+
var error = ((_b = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.max) || "\u6700\u5927\u503C\u4E3A".concat((_d = (_c = item.rules) === null || _c === void 0 ? void 0 : _c.validate) === null || _d === void 0 ? void 0 : _d.max);
|
|
220
|
+
var jude = !val;
|
|
221
|
+
|
|
222
|
+
if (vtype === 'string' || vtype === 'number') {
|
|
223
|
+
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);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return jude || error;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* 表单rules校验方法
|
|
231
|
+
* @type {validateFunctionType}
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
var validate = function validate(item, val) {
|
|
235
|
+
var _a, _b;
|
|
236
|
+
|
|
237
|
+
var validateObj = (_a = item.rules) === null || _a === void 0 ? void 0 : _a.validate;
|
|
238
|
+
|
|
239
|
+
if (validateObj) {
|
|
240
|
+
var messageObj = (_b = item.rules) === null || _b === void 0 ? void 0 : _b.message;
|
|
241
|
+
console.log('validateObj');
|
|
242
|
+
|
|
243
|
+
for (var key in validateObj) {
|
|
244
|
+
var tempFuc = validateObj[key];
|
|
245
|
+
var tmsg = '';
|
|
246
|
+
|
|
247
|
+
if (typeof tempFuc === 'function') {
|
|
248
|
+
tmsg = tempFuc(item, val);
|
|
249
|
+
if (tmsg === false && messageObj) tmsg = messageObj[key];
|
|
250
|
+
} else if (!!tempFuc && fixedValidateFunction[key]) {
|
|
251
|
+
tmsg = fixedValidateFunction[key](item, val);
|
|
252
|
+
} else if (!!!tempFuc) {
|
|
253
|
+
tmsg = true;
|
|
254
|
+
} else {
|
|
255
|
+
console.log("\u9879\u76EE: ".concat(item.label, ", \u81EA\u5B9A\u4E49\u6821\u9A8C\u89C4\u5219: ").concat(key, ", \u65B9\u6CD5\u672A\u5B9A\u4E49"));
|
|
256
|
+
tmsg = true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (tmsg !== true) return tmsg || '';
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return false;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-file-box {\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.paraui-file-box .para-file-tips {\n min-height: 20px;\n position: relative;\n padding: 6px;\n}\n.paraui-file-box .para-file-tips .file-tips-item {\n position: relative;\n height: 20px;\n line-height: 16px;\n padding-right: 20px;\n}\n.paraui-file-box .para-file-tips .file-tips-item > [data-name=LinkGroup] {\n vertical-align: middle;\n margin-right: 9px;\n}\n.paraui-file-box .para-file-tips .file-tips-item .file-tips-context {\n display: inline-block;\n vertical-align: middle;\n width: calc(100% - 45px);\n color: rgba(46, 55, 67, 0.7);\n}\n.paraui-file-box .para-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.paraui-file-box .para-file-tips .file-tips-item > [data-name=Delete]:hover {\n opacity: 0.8;\n}\n.paraui-file-box .para-file-tips .file-tips-item:hover {\n backgroundColor: #f5f5f5;\n}\n.paraui-file-box .para-file-tips .file-tips-item:hover > [data-name=Delete] {\n display: inline-block;\n}";
|
|
267
|
+
styleInject(css_248z$1);
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 文件组件
|
|
271
|
+
*/
|
|
272
|
+
|
|
273
|
+
var FormFile = function FormFile(props) {
|
|
274
|
+
var _props$fileType = props.fileType,
|
|
275
|
+
fileType = _props$fileType === void 0 ? '' : _props$fileType,
|
|
276
|
+
defaultValue = props.defaultValue,
|
|
277
|
+
onChange = props.onChange,
|
|
278
|
+
disabled = props.disabled,
|
|
279
|
+
buttonLabel = props.buttonLabel,
|
|
280
|
+
inputProps = props.inputProps,
|
|
281
|
+
buttonProps = props.buttonProps;
|
|
282
|
+
/**
|
|
283
|
+
* 存储文件输入框真实dom
|
|
284
|
+
* @type {HTMLInputElement}
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
var inputFileEl = React__default.useRef(null);
|
|
288
|
+
/**
|
|
289
|
+
* 模拟点击选择文件
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
var inputFileClick = function inputFileClick() {
|
|
293
|
+
var _a;
|
|
294
|
+
|
|
295
|
+
console.log('inputFileClick', inputFileEl.current);
|
|
296
|
+
(_a = inputFileEl.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* 文件改变
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
var fileChange = function fileChange(value) {
|
|
304
|
+
var val = value !== undefined ? value : inputFileEl.current.files;
|
|
305
|
+
setSelectedFile(val);
|
|
306
|
+
onChange && onChange(val);
|
|
307
|
+
if (value === null) inputFileEl.current.value = null;
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* @type {string}
|
|
311
|
+
* 已选择的文件
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
var _React$useState = React__default.useState(),
|
|
316
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
317
|
+
selectedFile = _React$useState2[0],
|
|
318
|
+
setSelectedFile = _React$useState2[1];
|
|
319
|
+
/**
|
|
320
|
+
* 初始化操作
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
React__default.useEffect(function () {
|
|
325
|
+
if (defaultValue) {
|
|
326
|
+
if (typeof defaultValue === 'string') {
|
|
327
|
+
setSelectedFile(defaultValue);
|
|
328
|
+
} else {
|
|
329
|
+
setSelectedFile(defaultValue);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}, [defaultValue]);
|
|
333
|
+
return jsxs("div", Object.assign({
|
|
334
|
+
className: 'para-file-box paraui-file-box'
|
|
335
|
+
}, {
|
|
336
|
+
children: [!disabled && jsx(Button, Object.assign({
|
|
337
|
+
variant: "outlined"
|
|
338
|
+
}, buttonProps, {
|
|
339
|
+
onClick: inputFileClick
|
|
340
|
+
}, {
|
|
341
|
+
children: buttonLabel || '选择文件'
|
|
342
|
+
})), jsx("input", Object.assign({}, inputProps, {
|
|
343
|
+
ref: inputFileEl,
|
|
344
|
+
type: "file",
|
|
345
|
+
onInput: function onInput() {
|
|
346
|
+
return fileChange();
|
|
347
|
+
},
|
|
348
|
+
hidden: true,
|
|
349
|
+
accept: typeof fileType === 'string' ? fileType : fileType.join(',')
|
|
350
|
+
})), selectedFile && selectedFile[0] && jsx("div", Object.assign({
|
|
351
|
+
className: "para-file-tips ".concat(disabled && 'para-file-tips-disabled' || '')
|
|
352
|
+
}, {
|
|
353
|
+
children: jsxs("div", Object.assign({
|
|
354
|
+
className: "file-tips-item"
|
|
355
|
+
}, {
|
|
356
|
+
children: [jsx(ParaLinkGroup, {}), jsx("span", Object.assign({
|
|
357
|
+
className: "file-tips-context"
|
|
358
|
+
}, {
|
|
359
|
+
children: jsx(AutoTips, {
|
|
360
|
+
children: typeof selectedFile === 'string' ? selectedFile : selectedFile[0].name
|
|
361
|
+
})
|
|
362
|
+
})), !disabled && jsx(Delete, {
|
|
363
|
+
onClick: function onClick() {
|
|
364
|
+
return fileChange(null);
|
|
365
|
+
}
|
|
366
|
+
})]
|
|
367
|
+
}))
|
|
368
|
+
}))]
|
|
369
|
+
}));
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @module src\FormItem\compoments\defaultCompoments\index.tsx
|
|
374
|
+
* @author zhanzl
|
|
375
|
+
* @date 2022/06/02
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
var DefaultCompoments = function DefaultCompoments(props) {
|
|
379
|
+
var error = props.error,
|
|
380
|
+
placeholder = props.placeholder,
|
|
381
|
+
defaultValue = props.defaultValue,
|
|
382
|
+
disabled = props.disabled,
|
|
383
|
+
_onChange = props.onChange,
|
|
384
|
+
inputProps = props.inputProps,
|
|
385
|
+
moudle = props.moudle;
|
|
386
|
+
|
|
387
|
+
var _React$useState = React__default.useState(defaultValue),
|
|
388
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
389
|
+
dValue = _React$useState2[0],
|
|
390
|
+
setDvalue = _React$useState2[1]; // 监听defaultValue改变
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
React__default.useEffect(function () {
|
|
394
|
+
setDvalue(defaultValue);
|
|
395
|
+
}, [defaultValue]);
|
|
396
|
+
return moudle(Object.assign(Object.assign({
|
|
397
|
+
error: error,
|
|
398
|
+
placeholder: placeholder,
|
|
399
|
+
value: dValue,
|
|
400
|
+
disabled: disabled
|
|
401
|
+
}, inputProps), {
|
|
402
|
+
onChange: function onChange(e) {
|
|
403
|
+
var _a;
|
|
404
|
+
|
|
405
|
+
var tVal = ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value) || e;
|
|
406
|
+
setDvalue(tVal);
|
|
407
|
+
|
|
408
|
+
_onChange(tVal);
|
|
409
|
+
}
|
|
410
|
+
}));
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* form 表单操作项 类型
|
|
415
|
+
*/
|
|
416
|
+
|
|
417
|
+
var ItemType = function ItemType(props) {
|
|
418
|
+
var ItemType = props.ItemType,
|
|
419
|
+
error = props.error,
|
|
420
|
+
placeholder = props.placeholder,
|
|
421
|
+
label = props.label,
|
|
422
|
+
inputProps = props.inputProps,
|
|
423
|
+
name = props.name,
|
|
424
|
+
rules = props.rules,
|
|
425
|
+
setValue = props.setValue,
|
|
426
|
+
setError = props.setError,
|
|
427
|
+
backData = props.backData,
|
|
428
|
+
disabled = props.disabled,
|
|
429
|
+
change = props.change;
|
|
430
|
+
var tipsStr = placeholder || "".concat(label);
|
|
431
|
+
/**
|
|
432
|
+
* 报错信息
|
|
433
|
+
* @type {boolean}
|
|
434
|
+
*/
|
|
435
|
+
|
|
436
|
+
var _React$useState = React__default.useState(!!error),
|
|
437
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
438
|
+
errorStatus = _React$useState2[0],
|
|
439
|
+
setErrorStatus = _React$useState2[1];
|
|
440
|
+
/**
|
|
441
|
+
* 校验方法
|
|
442
|
+
*/
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
var validateFunction = function validateFunction(val) {
|
|
446
|
+
setValue && setValue(name, 'value', val);
|
|
447
|
+
change && change(val); // 没有校验规则直接退出
|
|
448
|
+
|
|
449
|
+
if (!rules) return;
|
|
450
|
+
var item = Object.assign(Object.assign({}, props), {
|
|
451
|
+
setErrorMsg: setErrorMsg,
|
|
452
|
+
setAndValidateValue: setAndValidateValue
|
|
453
|
+
});
|
|
454
|
+
var errorMessage = validate(item, val) || '';
|
|
455
|
+
setErrorMsg(errorMessage);
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* 存储和校验数据
|
|
459
|
+
*/
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
var setAndValidateValue = validateFunction;
|
|
463
|
+
/**
|
|
464
|
+
* 合并设置Error状态方法
|
|
465
|
+
*/
|
|
466
|
+
|
|
467
|
+
var setErrorMsg = React__default.useCallback(function (msg) {
|
|
468
|
+
setError && setError(msg);
|
|
469
|
+
setErrorStatus(!!msg);
|
|
470
|
+
setValue && setValue(name, 'message', msg);
|
|
471
|
+
}, [name, setError, setValue]);
|
|
472
|
+
/**
|
|
473
|
+
* 传出最后的 item 对象
|
|
474
|
+
*/
|
|
475
|
+
|
|
476
|
+
React__default.useEffect(function () {
|
|
477
|
+
var item = Object.assign(Object.assign({}, props), {
|
|
478
|
+
setErrorMsg: setErrorMsg,
|
|
479
|
+
setAndValidateValue: setAndValidateValue
|
|
480
|
+
});
|
|
481
|
+
setValue && setValue(name, 'item', item);
|
|
482
|
+
}, [name, props, setErrorMsg, setValue]);
|
|
483
|
+
/**
|
|
484
|
+
* 判断显示那个
|
|
485
|
+
*/
|
|
486
|
+
|
|
487
|
+
var selectType = function selectType() {
|
|
488
|
+
if (ItemType && typeof ItemType !== 'string' && (!ItemType.name || ItemType.name === 'InputType')) {
|
|
489
|
+
var item = Object.assign(Object.assign({}, props), {
|
|
490
|
+
setErrorMsg: setErrorMsg,
|
|
491
|
+
setAndValidateValue: setAndValidateValue
|
|
492
|
+
});
|
|
493
|
+
return ItemType(item);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
switch (ItemType) {
|
|
497
|
+
case 'file':
|
|
498
|
+
return jsx(FormFile, Object.assign({}, props, {
|
|
499
|
+
defaultValue: backData[name],
|
|
500
|
+
disabled: disabled,
|
|
501
|
+
onChange: function onChange(value) {
|
|
502
|
+
validateFunction(value);
|
|
503
|
+
}
|
|
504
|
+
}));
|
|
505
|
+
|
|
506
|
+
case 'switch':
|
|
507
|
+
if (backData[name] === undefined) setValue && setValue(name, 'initValue', !!backData[name]);
|
|
508
|
+
return jsx(Switch, Object.assign({
|
|
509
|
+
compact: true,
|
|
510
|
+
defaultChecked: !!backData[name],
|
|
511
|
+
onChange: function onChange(checked) {
|
|
512
|
+
validateFunction(checked);
|
|
513
|
+
}
|
|
514
|
+
}, Object.assign(Object.assign({}, inputProps), {
|
|
515
|
+
disabled: disabled
|
|
516
|
+
})));
|
|
517
|
+
|
|
518
|
+
case 'checkGroup':
|
|
519
|
+
return jsx(FormCheckboxGroup, Object.assign({
|
|
520
|
+
error: errorStatus,
|
|
521
|
+
defaultValue: backData[name],
|
|
522
|
+
change: function change(value) {
|
|
523
|
+
validateFunction(value);
|
|
524
|
+
},
|
|
525
|
+
list: props.list
|
|
526
|
+
}, Object.assign(Object.assign({}, inputProps), {
|
|
527
|
+
disabled: disabled
|
|
528
|
+
})));
|
|
529
|
+
|
|
530
|
+
case 'select':
|
|
531
|
+
return jsx(FormSelect, Object.assign({
|
|
532
|
+
placeholder: tipsStr,
|
|
533
|
+
defaultValue: backData[name],
|
|
534
|
+
error: errorStatus,
|
|
535
|
+
change: function change(value) {
|
|
536
|
+
validateFunction(value);
|
|
537
|
+
},
|
|
538
|
+
list: props.list
|
|
539
|
+
}, Object.assign({
|
|
540
|
+
disabled: disabled
|
|
541
|
+
}, inputProps)));
|
|
542
|
+
|
|
543
|
+
case 'radioGroup':
|
|
544
|
+
return jsx(FormRadioGroup, Object.assign({
|
|
545
|
+
error: errorStatus,
|
|
546
|
+
defaultValue: backData[name],
|
|
547
|
+
change: function change(value) {
|
|
548
|
+
validateFunction(value);
|
|
549
|
+
},
|
|
550
|
+
list: props.list
|
|
551
|
+
}, Object.assign({
|
|
552
|
+
disabled: disabled
|
|
553
|
+
}, inputProps)));
|
|
554
|
+
|
|
555
|
+
case 'textarea':
|
|
556
|
+
return jsx(TextField, Object.assign({
|
|
557
|
+
error: errorStatus,
|
|
558
|
+
placeholder: tipsStr,
|
|
559
|
+
defaultValue: backData[name] || '',
|
|
560
|
+
disabled: disabled,
|
|
561
|
+
multiline: true,
|
|
562
|
+
rows: 3,
|
|
563
|
+
name: name,
|
|
564
|
+
onChange: function onChange(e) {
|
|
565
|
+
validateFunction(e.target.value);
|
|
566
|
+
}
|
|
567
|
+
}, inputProps));
|
|
568
|
+
|
|
569
|
+
case 'number':
|
|
570
|
+
return jsx(InputNumber, Object.assign({
|
|
571
|
+
error: errorStatus,
|
|
572
|
+
placeholder: tipsStr,
|
|
573
|
+
defaultValue: backData[name],
|
|
574
|
+
disabled: disabled,
|
|
575
|
+
name: name,
|
|
576
|
+
onChange: function onChange(val) {
|
|
577
|
+
validateFunction(val);
|
|
578
|
+
}
|
|
579
|
+
}, inputProps));
|
|
580
|
+
|
|
581
|
+
case 'comboSelect':
|
|
582
|
+
return jsx(ComboSelect, Object.assign({
|
|
583
|
+
error: errorStatus,
|
|
584
|
+
placeholder: tipsStr,
|
|
585
|
+
defaultValue: backData[name],
|
|
586
|
+
disabled: disabled,
|
|
587
|
+
onChange: function onChange(options) {
|
|
588
|
+
validateFunction(options);
|
|
589
|
+
}
|
|
590
|
+
}, inputProps));
|
|
591
|
+
|
|
592
|
+
default:
|
|
593
|
+
if (ItemType && typeof ItemType !== 'string') {
|
|
594
|
+
return jsx(DefaultCompoments, {
|
|
595
|
+
moudle: ItemType,
|
|
596
|
+
error: errorStatus,
|
|
597
|
+
placeholder: tipsStr,
|
|
598
|
+
defaultValue: backData[name],
|
|
599
|
+
disabled: disabled,
|
|
600
|
+
onChange: function onChange(val) {
|
|
601
|
+
validateFunction(val);
|
|
602
|
+
},
|
|
603
|
+
inputProps: inputProps
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return jsx(TextField, Object.assign({
|
|
608
|
+
defaultValue: backData[name] || '',
|
|
609
|
+
error: errorStatus,
|
|
610
|
+
placeholder: tipsStr,
|
|
611
|
+
onChange: function onChange(e) {
|
|
612
|
+
validateFunction(e.target.value);
|
|
613
|
+
},
|
|
614
|
+
name: name,
|
|
615
|
+
disabled: disabled
|
|
616
|
+
}, inputProps));
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
return selectType();
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* 报错信息组件
|
|
625
|
+
* @description 为了解决,在主组件设置state,导致输入框中内容刷新,且失去焦点
|
|
626
|
+
*/
|
|
627
|
+
|
|
628
|
+
var ErrorTips = function ErrorTips(props) {
|
|
629
|
+
var getSetError = props.getSetError,
|
|
630
|
+
errorMessage = props.errorMessage,
|
|
631
|
+
helperTextProps = props.helperTextProps;
|
|
632
|
+
/**
|
|
633
|
+
* 报错信息
|
|
634
|
+
* @type {string}
|
|
635
|
+
*/
|
|
636
|
+
|
|
637
|
+
var _React$useState = React__default.useState(errorMessage || ''),
|
|
638
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
639
|
+
errorTips = _React$useState2[0],
|
|
640
|
+
setErrorTips = _React$useState2[1];
|
|
641
|
+
/**
|
|
642
|
+
* 初始化传出, 设置错误信息方法
|
|
643
|
+
*/
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
React__default.useEffect(function () {
|
|
647
|
+
setErrorTips(errorMessage || '');
|
|
648
|
+
}, [errorMessage]);
|
|
649
|
+
React__default.useEffect(function () {
|
|
650
|
+
getSetError && getSetError(setErrorTips);
|
|
651
|
+
}, [getSetError]);
|
|
652
|
+
return jsx(HelperText, Object.assign({
|
|
653
|
+
className: "para-error-tips",
|
|
654
|
+
error: true,
|
|
655
|
+
helperText: errorTips
|
|
656
|
+
}, helperTextProps));
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-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-form-item .para-form-label {\n display: inline-block;\n}\n.paraui-form-item .para-form-edit > div {\n padding: 0;\n width: 100%;\n}\n.paraui-form-item .para-form-edit > div .paraui-helper-text {\n display: none;\n}\n.paraui-form-item .para-form-edit-snack > div .paraui-helper-text {\n display: block;\n}\n.paraui-form-item .para-form-edit .paraui-input-number .paraui-text-field {\n padding: 0px;\n}\n.paraui-form-item .para-form-edit .paraui-check-box-group > label,\n.paraui-form-item .para-form-edit .paraui-radio-group > label {\n display: none;\n}\n.paraui-form-item .para-form-edit .paraui-check-box-group > div,\n.paraui-form-item .para-form-edit .paraui-radio-group > div {\n margin-top: 4px;\n}\n.paraui-form-item .para-form-content-vertical {\n display: inline-block;\n width: 100%;\n}";
|
|
660
|
+
styleInject(css_248z);
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* form 表单单行组件
|
|
664
|
+
* @author zhanzl
|
|
665
|
+
* @description 用于根据配置自动生成表单
|
|
666
|
+
*/
|
|
667
|
+
|
|
668
|
+
var FormItem = function FormItem(props) {
|
|
669
|
+
var _a, _b;
|
|
670
|
+
|
|
671
|
+
var _props$type = props.type,
|
|
672
|
+
type = _props$type === void 0 ? 'horizontal' : _props$type,
|
|
673
|
+
labelWidth = props.labelWidth,
|
|
674
|
+
tips = props.tips,
|
|
675
|
+
label = props.label,
|
|
676
|
+
InputType = props.InputType,
|
|
677
|
+
setValue = props.setValue,
|
|
678
|
+
errorMessage = props.errorMessage,
|
|
679
|
+
hideLabel = props.hideLabel,
|
|
680
|
+
_props$backData = props.backData,
|
|
681
|
+
backData = _props$backData === void 0 ? {} : _props$backData,
|
|
682
|
+
defaultValue = props.defaultValue,
|
|
683
|
+
name = props.name,
|
|
684
|
+
_props$hideError = props.hideError,
|
|
685
|
+
hideError = _props$hideError === void 0 ? false : _props$hideError,
|
|
686
|
+
_props$className = props.className,
|
|
687
|
+
className = _props$className === void 0 ? '' : _props$className,
|
|
688
|
+
labelProps = props.labelProps,
|
|
689
|
+
helperTextProps = props.helperTextProps,
|
|
690
|
+
requiredElement = props.requiredElement,
|
|
691
|
+
_props$disRequiredEle = props.disRequiredElement,
|
|
692
|
+
disRequiredElement = _props$disRequiredEle === void 0 ? false : _props$disRequiredEle;
|
|
693
|
+
|
|
694
|
+
if (backData[name] === undefined) {
|
|
695
|
+
backData[name] = defaultValue;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* 接受设置报错信息方法
|
|
699
|
+
* @type {Function}
|
|
700
|
+
*/
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
var setErrorTips = React__default.useRef();
|
|
704
|
+
/**
|
|
705
|
+
* 设置错误信息
|
|
706
|
+
*/
|
|
707
|
+
|
|
708
|
+
var setError = function setError(error) {
|
|
709
|
+
setErrorTips.current && setErrorTips.current(error);
|
|
710
|
+
};
|
|
711
|
+
/**
|
|
712
|
+
* 用于判断是否是 vertical 模式如果是则添加相应的外层
|
|
713
|
+
*/
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
var TypeLayout = function TypeLayout(props) {
|
|
717
|
+
return type === 'vertical' ? jsx("div", Object.assign({
|
|
718
|
+
className: "para-form-content-vertical para-form-content-vertical-".concat(name),
|
|
719
|
+
style: {
|
|
720
|
+
width: "calc(100% - ".concat(labelWidth, "px)")
|
|
721
|
+
}
|
|
722
|
+
}, {
|
|
723
|
+
children: props.children
|
|
724
|
+
})) : props.children;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* 展示label
|
|
728
|
+
*/
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
var showLabel = React__default.useCallback(function () {
|
|
732
|
+
if (!label) return '';
|
|
733
|
+
return typeof label === 'string' ? label : label(props);
|
|
734
|
+
}, [label]);
|
|
735
|
+
return jsxs("div", Object.assign({
|
|
736
|
+
className: "para-form-item paraui-form-item paraui-form-item-".concat(name, " ").concat(className)
|
|
737
|
+
}, {
|
|
738
|
+
children: [!hideLabel && jsx("div", Object.assign({
|
|
739
|
+
className: clsx("para-form-label para-form-label-".concat(name), type === 'vertical' && 'para-form-label-vertical'),
|
|
740
|
+
style: {
|
|
741
|
+
width: type === 'vertical' ? "".concat(labelWidth, "px") : ''
|
|
742
|
+
}
|
|
743
|
+
}, {
|
|
744
|
+
children: jsx(Label, Object.assign({
|
|
745
|
+
className: clsx('para-form-labe-text', tips && 'para-form-labe-text-hastips'),
|
|
746
|
+
label: showLabel(),
|
|
747
|
+
required: !!((_b = (_a = props === null || props === void 0 ? void 0 : props.rules) === null || _a === void 0 ? void 0 : _a.validate) === null || _b === void 0 ? void 0 : _b.required),
|
|
748
|
+
tooltip: tips,
|
|
749
|
+
tooltipIcon: disRequiredElement ? '' : requiredElement
|
|
750
|
+
}, labelProps))
|
|
751
|
+
})), jsxs(TypeLayout, {
|
|
752
|
+
children: [jsx("div", Object.assign({
|
|
753
|
+
className: "para-form-edit para-form-edit-".concat(name)
|
|
754
|
+
}, {
|
|
755
|
+
children: !props.children ? jsx(ItemType, Object.assign({
|
|
756
|
+
setError: setError,
|
|
757
|
+
error: !!errorMessage,
|
|
758
|
+
ItemType: InputType,
|
|
759
|
+
backData: backData
|
|
760
|
+
}, props, {
|
|
761
|
+
setValue: setValue
|
|
762
|
+
})) : props.children
|
|
763
|
+
})), !hideError && jsx("div", Object.assign({
|
|
764
|
+
className: "para-form-error para-form-error-".concat(name)
|
|
765
|
+
}, {
|
|
766
|
+
children: jsx(ErrorTips, {
|
|
767
|
+
getSetError: function getSetError(fuc) {
|
|
768
|
+
return setErrorTips.current = fuc;
|
|
769
|
+
},
|
|
770
|
+
helperTextProps: helperTextProps,
|
|
771
|
+
errorMessage: errorMessage
|
|
772
|
+
})
|
|
773
|
+
}))]
|
|
774
|
+
})]
|
|
775
|
+
}));
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
export { FormItem as F, validate as v };
|