@cloudbase/weda-ui 0.2.10 → 0.2.14
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/CHANGELOG.md +240 -0
- package/package.json +61 -40
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/configs/components/button.json +7 -3
- package/src/configs/components/form/richText.json +1 -1
- package/src/configs/components/form/uploader.json +29 -1
- package/src/configs/components/form/uploaderFile.json +158 -0
- package/src/configs/components/image.json +12 -3
- package/src/configs/components/link.json +3 -3
- package/src/configs/components/richtextview.json +2 -2
- package/src/configs/components/scrollVeiw.json +5 -5
- package/src/configs/components/swiper.json +6 -6
- package/src/configs/components/tabs.json +3 -3
- package/src/configs/components/text.json +39 -4
- package/src/configs/index.js +5 -3
- package/src/mp/.gitignore +10 -0
- package/src/mp/components/button/index.js +1 -0
- package/src/mp/components/button/index.wxss +8 -0
- package/src/mp/components/form/select/index.js +18 -0
- package/src/mp/components/form/uploader/index.js +26 -29
- package/src/mp/components/form/uploaderFile/index.js +233 -0
- package/src/mp/components/form/uploaderFile/index.json +9 -0
- package/src/mp/components/form/uploaderFile/index.wxml +46 -0
- package/src/mp/components/form/uploaderFile/index.wxss +105 -0
- package/src/mp/components/text/index.js +33 -0
- package/src/mp/components/text/index.wxml +1 -1
- package/src/mp/components/text/index.wxss +18 -0
- package/src/mp/index.json +1 -0
- package/src/mp/utils/platform.js +20 -0
- package/src/mp/utils/tcb.js +11 -0
- package/src/web/.DS_Store +0 -0
- package/src/web/actions/showModal/{index.jsx → index.tsx} +53 -3
- package/src/web/components/auth/index.js +2 -2
- package/src/web/components/button/index.css +9 -0
- package/src/web/components/button/{index.jsx → index.tsx} +27 -41
- package/src/web/components/container/{index.jsx → index.tsx} +6 -10
- package/src/web/components/drawer/index.tsx +57 -0
- package/src/web/components/form/checkbox/{index.jsx → index.tsx} +24 -48
- package/src/web/components/form/enumSelect/MultipleSelect.jsx +1 -6
- package/src/web/components/form/enumSelect/{NormalSelect.jsx → NormalSelect.tsx} +3 -14
- package/src/web/components/form/form/index.tsx +48 -0
- package/src/web/components/form/formcell/{index.jsx → index.tsx} +6 -13
- package/src/web/components/form/input/index.css +39 -0
- package/src/web/components/form/input/{index.jsx → index.tsx} +33 -67
- package/src/web/components/form/radio/{index.jsx → index.tsx} +19 -42
- package/src/web/components/form/{renderDecorator.jsx → renderDecorator.tsx} +1 -3
- package/src/web/components/form/select/{h5.jsx → h5.tsx} +18 -62
- package/src/web/components/form/select/{index.jsx → index.tsx} +51 -94
- package/src/web/components/form/select/region/{cities.js → cities.ts} +1 -1
- package/src/web/components/form/select/region/{index.js → index.ts} +3 -3
- package/src/web/components/form/select/region/{provinces.js → provinces.ts} +1 -1
- package/src/web/components/form/select/region/{regions.js → regions.ts} +1 -1
- package/src/web/components/form/select/time.jsx +2 -2
- package/src/web/components/form/switch/{index.jsx → index.tsx} +30 -47
- package/src/web/components/form/textarea/{index.jsx → index.tsx} +22 -55
- package/src/web/components/form/tips/{index.jsx → index.tsx} +8 -22
- package/src/web/components/form/types.d.ts +12 -0
- package/src/web/components/form/uploader/{index.jsx → index.tsx} +16 -14
- package/src/web/components/form/uploader/{uploader.h5.jsx → uploader.h5.tsx} +67 -57
- package/src/web/components/form/uploader/{uploader.pc.jsx → uploader.pc.tsx} +26 -43
- package/src/web/components/form/uploaderFile/fail.svg +12 -0
- package/src/web/components/form/uploaderFile/index.css +423 -0
- package/src/web/components/form/uploaderFile/index.jsx +30 -0
- package/src/web/components/form/uploaderFile/pending.svg +18 -0
- package/src/web/components/form/uploaderFile/success.svg +12 -0
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +578 -0
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +507 -0
- package/src/web/components/image/{image.jsx → image.tsx} +8 -21
- package/src/web/components/image/{index.jsx → index.tsx} +22 -37
- package/src/web/components/index.js +36 -1
- package/src/web/components/link/{index.jsx → index.tsx} +19 -36
- package/src/web/components/modal/{index.jsx → index.tsx} +22 -9
- package/src/web/components/picker/{datePicker.jsx → datePicker.tsx} +11 -12
- package/src/web/components/picker/{picker.jsx → picker.tsx} +7 -10
- package/src/web/components/picker/{timePicker.jsx → timePicker.tsx} +8 -16
- package/src/web/components/richText/{const.js → const.ts} +0 -0
- package/src/web/components/richText/index.jsx +5 -2
- package/src/web/components/richTextView/index.tsx +67 -0
- package/src/web/components/scrollView/{index.jsx → index.tsx} +18 -33
- package/src/web/components/slot/{index.jsx → index.tsx} +8 -9
- package/src/web/components/swiper/index.css +1 -1
- package/src/web/components/swiper/{index.jsx → index.tsx} +73 -78
- package/src/web/components/tabs/index.tsx +33 -0
- package/src/web/components/tabs/{tabs.h5.jsx → tabs.h5.tsx} +4 -33
- package/src/web/components/tabs/{tabs.pc.jsx → tabs.pc.tsx} +5 -39
- package/src/web/components/text/index.css +18 -0
- package/src/web/components/text/index.tsx +69 -0
- package/src/web/components/uploaderFileView/index.css +11 -0
- package/src/web/components/uploaderFileView/index.jsx +75 -0
- package/src/web/components/uploaderView/{index.jsx → index.tsx} +12 -15
- package/src/web/types.d.ts +20 -0
- package/src/web/utils/constant.js +2 -0
- package/src/web/utils/loading-fallback.tsx +2 -0
- package/src/web/utils/platform.js +77 -6
- package/src/web/utils/tcb.js +0 -8
- package/src/web/utils/useSetState.ts +14 -0
- package/src/web/utils/useSyncValue.ts +17 -0
- package/src/web/wedatheme/.git +1 -0
- package/src/web/wedatheme/.gitignore +5 -0
- package/src/web/wedatheme/.npmrc +1 -0
- package/src/web/wedatheme/package-lock.json +14335 -0
- package/src/configs/components/button.svg +0 -18
- package/src/web/components/drawer/index.jsx +0 -64
- package/src/web/components/form/enumSelect/hooks/index.js +0 -49
- package/src/web/components/form/form/index.jsx +0 -76
- package/src/web/components/link/test/__snapshots__/storybook.test.js.snap +0 -754
- package/src/web/components/richTextView/index.jsx +0 -89
- package/src/web/components/tabs/index.jsx +0 -10
- package/src/web/components/text/index.jsx +0 -71
- package/src/web/utils/useSyncValue.js +0 -14
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as PropTypes from 'prop-types';
|
|
3
2
|
import { Checkbox as TeaCheckbox, ConfigProvider } from 'tea-component';
|
|
4
3
|
|
|
5
4
|
import classNames from '../../../utils/classnames';
|
|
@@ -8,23 +7,24 @@ import isObjectEqual from '../../../utils/isObjectEqual';
|
|
|
8
7
|
import fromEntries from 'object.fromentries';
|
|
9
8
|
import { usePlatform } from '../../../utils/platform';
|
|
10
9
|
import { renderDecorator } from '../renderDecorator';
|
|
10
|
+
import { CommonFormPropsType } from '../types';
|
|
11
11
|
|
|
12
12
|
export default function Checkbox({
|
|
13
13
|
// 系统属性
|
|
14
14
|
id,
|
|
15
15
|
className,
|
|
16
16
|
style,
|
|
17
|
-
events,
|
|
17
|
+
events = {},
|
|
18
18
|
// 组件属性
|
|
19
|
-
name,
|
|
20
|
-
label,
|
|
19
|
+
name = 'formCheckbox',
|
|
20
|
+
label = '标题',
|
|
21
21
|
labelVisible = true,
|
|
22
|
-
range,
|
|
23
|
-
layout,
|
|
24
|
-
disabled,
|
|
25
|
-
requiredFlag,
|
|
22
|
+
range = [],
|
|
23
|
+
layout = 'horizontal',
|
|
24
|
+
disabled = false,
|
|
25
|
+
requiredFlag = false,
|
|
26
26
|
decorator
|
|
27
|
-
}) {
|
|
27
|
+
}: PropsType) {
|
|
28
28
|
const cls = classNames({
|
|
29
29
|
'weda-ui': true,
|
|
30
30
|
'weda-checkbox': true,
|
|
@@ -45,7 +45,7 @@ export default function Checkbox({
|
|
|
45
45
|
: range.filter(({checked}) => checked).map(({value}) => value)
|
|
46
46
|
);
|
|
47
47
|
// 两次range不同时, 需要刷新checkedItems
|
|
48
|
-
const prevRangeRef = React.useRef();
|
|
48
|
+
const prevRangeRef = React.useRef<object[]>();
|
|
49
49
|
React.useEffect(() => {
|
|
50
50
|
if (!isObjectEqual(prevRangeRef.current, range)) {
|
|
51
51
|
prevRangeRef.current = range;
|
|
@@ -64,15 +64,17 @@ export default function Checkbox({
|
|
|
64
64
|
e.stopPropagation();
|
|
65
65
|
const checked = !checkedItems[value];
|
|
66
66
|
const newMap = Object.assign({}, checkedItems, { [value]: checked });
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
if (!disabled) {
|
|
68
|
+
setCheckedItems(newMap);
|
|
69
|
+
events.change(
|
|
70
|
+
{
|
|
71
|
+
value: Object.entries(newMap)
|
|
72
|
+
.filter(([, checked]) => checked)
|
|
73
|
+
.map(([value]) => value),
|
|
74
|
+
},
|
|
75
|
+
{ originEvent: e }
|
|
76
|
+
);
|
|
77
|
+
}
|
|
76
78
|
};
|
|
77
79
|
return onChange;
|
|
78
80
|
};
|
|
@@ -164,32 +166,6 @@ export default function Checkbox({
|
|
|
164
166
|
);
|
|
165
167
|
}
|
|
166
168
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
className: PropTypes.string,
|
|
171
|
-
style: PropTypes.string,
|
|
172
|
-
events: PropTypes.objectOf(PropTypes.func),
|
|
173
|
-
// 组件属性
|
|
174
|
-
name: PropTypes.string,
|
|
175
|
-
label: PropTypes.string,
|
|
176
|
-
labelVisible: PropTypes.bool,
|
|
177
|
-
range: PropTypes.array,
|
|
178
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
179
|
-
disabled: PropTypes.bool,
|
|
180
|
-
requiredFlag: PropTypes.bool,
|
|
181
|
-
decorator: PropTypes.oneOfType([PropTypes.array, PropTypes.node])
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
Checkbox.defaultProps = {
|
|
185
|
-
// 系统属性
|
|
186
|
-
events: {},
|
|
187
|
-
// 组件属性
|
|
188
|
-
name: 'formCheckbox',
|
|
189
|
-
label: '标题',
|
|
190
|
-
labelVisible: true,
|
|
191
|
-
range: [],
|
|
192
|
-
layout: 'horizontal',
|
|
193
|
-
disabled: false,
|
|
194
|
-
requiredFlag: false,
|
|
195
|
-
};
|
|
169
|
+
export interface PropsType extends CommonFormPropsType {
|
|
170
|
+
range?: {label: string, value: any; [key: string]: any}[];
|
|
171
|
+
}
|
|
@@ -5,7 +5,6 @@ import SelectContainer from './SelectContainer';
|
|
|
5
5
|
|
|
6
6
|
import { normalProps } from './props/defaultProps';
|
|
7
7
|
import { propTypes } from './props/propsTypes';
|
|
8
|
-
import useOptions from './hooks';
|
|
9
8
|
|
|
10
9
|
const MultipleSelect = ({
|
|
11
10
|
// 系统属性
|
|
@@ -31,14 +30,10 @@ const MultipleSelect = ({
|
|
|
31
30
|
virtual,
|
|
32
31
|
searchable,
|
|
33
32
|
size,
|
|
33
|
+
options,
|
|
34
34
|
// 业务属性
|
|
35
|
-
enumType,
|
|
36
|
-
customEnum,
|
|
37
|
-
optionId,
|
|
38
35
|
isModelApp,
|
|
39
36
|
}) => {
|
|
40
|
-
const options = useOptions({ enumType, optionId, customEnum });
|
|
41
|
-
|
|
42
37
|
const onSelectChange = (values) => {
|
|
43
38
|
// @ts-ignore
|
|
44
39
|
events.change && events.change({ value: values });
|
|
@@ -5,19 +5,11 @@ import SelectContainer from './SelectContainer';
|
|
|
5
5
|
|
|
6
6
|
import { multipleProps } from './props/defaultProps';
|
|
7
7
|
import { propTypes } from './props/propsTypes';
|
|
8
|
-
import
|
|
8
|
+
import { useSyncValue } from '../../../utils/useSyncValue';
|
|
9
9
|
|
|
10
10
|
const { useState, useEffect } = React;
|
|
11
11
|
|
|
12
|
-
const useValue = (value) => {
|
|
13
|
-
const [selectedValue, setSelectedValue] = useState('');
|
|
14
12
|
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
setSelectedValue(value);
|
|
17
|
-
}, [value]);
|
|
18
|
-
|
|
19
|
-
return [selectedValue, setSelectedValue];
|
|
20
|
-
};
|
|
21
13
|
|
|
22
14
|
const NormalSelect = ({
|
|
23
15
|
// 系统属性
|
|
@@ -42,14 +34,11 @@ const NormalSelect = ({
|
|
|
42
34
|
virtual,
|
|
43
35
|
searchable,
|
|
44
36
|
size,
|
|
37
|
+
options,
|
|
45
38
|
// 业务属性
|
|
46
|
-
enumType,
|
|
47
|
-
customEnum,
|
|
48
|
-
optionId,
|
|
49
39
|
isModelApp,
|
|
50
40
|
}) => {
|
|
51
|
-
const
|
|
52
|
-
const [selectedValue, setSelectedValue] = useValue(value);
|
|
41
|
+
const [selectedValue, setSelectedValue] = useSyncValue(value);
|
|
53
42
|
|
|
54
43
|
const onSelectChange = (value) => {
|
|
55
44
|
// @ts-ignore
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import classNames from '../../../utils/classnames';
|
|
3
|
+
import './index.css';
|
|
4
|
+
import {ConfigProvider, Form as TeaForm} from 'tea-component';
|
|
5
|
+
import { usePlatform } from '../../../utils/platform';
|
|
6
|
+
import { CommonFormPropsType } from '../types';
|
|
7
|
+
|
|
8
|
+
export default function Form({
|
|
9
|
+
// 系统属性
|
|
10
|
+
className,
|
|
11
|
+
// 组件属性
|
|
12
|
+
// title,
|
|
13
|
+
// description,
|
|
14
|
+
// tips,
|
|
15
|
+
contentSlot,
|
|
16
|
+
// buttonSlot,
|
|
17
|
+
style,
|
|
18
|
+
id,
|
|
19
|
+
}) {
|
|
20
|
+
const platform = usePlatform();
|
|
21
|
+
const cls = classNames({
|
|
22
|
+
'weda-ui': true,
|
|
23
|
+
'weda-form': true,
|
|
24
|
+
'weui-form': platform === 'h5',
|
|
25
|
+
[className]: className,
|
|
26
|
+
});
|
|
27
|
+
if(platform === 'pc') {
|
|
28
|
+
return (
|
|
29
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
30
|
+
{/** @ts-expect-error tea form id */}
|
|
31
|
+
<TeaForm className={cls} style={style} id={id}>
|
|
32
|
+
{contentSlot}
|
|
33
|
+
</TeaForm>
|
|
34
|
+
</ConfigProvider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return (
|
|
38
|
+
<div className={cls} style={style} id={id}>
|
|
39
|
+
<div className="weui-cells__group weui-cells__group_form">
|
|
40
|
+
{contentSlot}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface PropsType extends CommonFormPropsType {
|
|
47
|
+
contentSlot?: any;
|
|
48
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as PropTypes from 'prop-types';
|
|
3
2
|
|
|
4
3
|
import classNames from '../../../utils/classnames';
|
|
5
4
|
import './index.css';
|
|
6
5
|
import { usePlatform } from '../../../utils/platform';
|
|
7
6
|
import { ConfigProvider, Form as TeaForm } from 'tea-component';
|
|
7
|
+
import { CommonFormPropsType } from '../types';
|
|
8
8
|
|
|
9
9
|
export default function FormCell({
|
|
10
10
|
className,
|
|
@@ -15,7 +15,7 @@ export default function FormCell({
|
|
|
15
15
|
multiCell,
|
|
16
16
|
requiredFlag,
|
|
17
17
|
size
|
|
18
|
-
}) {
|
|
18
|
+
}: PropsType) {
|
|
19
19
|
const platform = usePlatform();
|
|
20
20
|
const isFlex = layout !== 'vertical';
|
|
21
21
|
|
|
@@ -78,14 +78,7 @@ export default function FormCell({
|
|
|
78
78
|
);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
labelVisible: PropTypes.bool,
|
|
86
|
-
layout: PropTypes.string,
|
|
87
|
-
children: PropTypes.any,
|
|
88
|
-
multiCell: PropTypes.bool,
|
|
89
|
-
requiredFlag: PropTypes.bool,
|
|
90
|
-
size: PropTypes.string
|
|
91
|
-
};
|
|
81
|
+
export interface PropsType extends CommonFormPropsType {
|
|
82
|
+
multiCell?: boolean;
|
|
83
|
+
size?: string;
|
|
84
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* ios safari 特别是小屏幕 iphone SE 之流
|
|
2
|
+
weui自带cell的padding会把input压倒很小,
|
|
3
|
+
容易点不到,需要特殊处理
|
|
4
|
+
START
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
把weui-cell 的padding还回到input
|
|
9
|
+
*/
|
|
10
|
+
.weda-ui.weda-input input.weui-input {
|
|
11
|
+
padding: 28px 16px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.weda-ui.weda-input .weui-cell > label {
|
|
15
|
+
padding: 16px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.weda-ui.weda-input .weui-cell {
|
|
19
|
+
padding: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.weda-ui.weda-input .weui-btn_input-clear {
|
|
23
|
+
padding-right: 16px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* END
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
背景颜色设置问题
|
|
32
|
+
START
|
|
33
|
+
*/
|
|
34
|
+
.weda-ui .wedatea2td-input {
|
|
35
|
+
background: inherit;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* END
|
|
39
|
+
*/
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
2
|
import classNames from '../../../utils/classnames';
|
|
5
3
|
import { usePlatform } from '../../../utils/platform';
|
|
6
|
-
import { Input as TeaInput } from 'tea-component';
|
|
4
|
+
import { Input as TeaInput, ConfigProvider } from 'tea-component';
|
|
7
5
|
import { renderDecorator } from '../renderDecorator';
|
|
8
6
|
import { useSyncValue } from '../../../utils/useSyncValue';
|
|
7
|
+
import './index.css';
|
|
8
|
+
import { CommonFormPropsType } from '../types';
|
|
9
|
+
|
|
9
10
|
export default function Input({
|
|
10
|
-
// 系统属性
|
|
11
11
|
id,
|
|
12
12
|
className,
|
|
13
13
|
style,
|
|
14
|
-
events,
|
|
14
|
+
events = {},
|
|
15
15
|
// 组件属性
|
|
16
|
-
label,
|
|
17
|
-
labelVisible,
|
|
18
|
-
name,
|
|
19
|
-
defaultValue,
|
|
20
|
-
password,
|
|
21
|
-
placeholder,
|
|
22
|
-
type,
|
|
23
|
-
maxLength,
|
|
24
|
-
disabled,
|
|
25
|
-
focus: autoFocus,
|
|
26
|
-
layout,
|
|
27
|
-
requiredFlag,
|
|
28
|
-
size,
|
|
16
|
+
label = '标题',
|
|
17
|
+
labelVisible = true,
|
|
18
|
+
name = 'formInput',
|
|
19
|
+
defaultValue = '',
|
|
20
|
+
password = false,
|
|
21
|
+
placeholder = '请输入',
|
|
22
|
+
type = 'text',
|
|
23
|
+
maxLength = 140,
|
|
24
|
+
disabled = false,
|
|
25
|
+
focus: autoFocus = false,
|
|
26
|
+
layout = 'horizontal',
|
|
27
|
+
requiredFlag = false,
|
|
28
|
+
size = 'l',
|
|
29
|
+
clearable = true,
|
|
29
30
|
decorator,
|
|
30
|
-
|
|
31
|
-
}) {
|
|
31
|
+
}: PropsType) {
|
|
32
32
|
const platform = usePlatform();
|
|
33
33
|
const cls = classNames({
|
|
34
34
|
'weda-ui': true,
|
|
@@ -80,7 +80,6 @@ export default function Input({
|
|
|
80
80
|
const onBlur = function (e) {
|
|
81
81
|
events.blur({ value: e.target.value }, { originEvent: e });
|
|
82
82
|
};
|
|
83
|
-
|
|
84
83
|
const fieldEl = platform === 'h5' ? <div className={subCls}>
|
|
85
84
|
<div className="weui-cell__bd weui-flex">
|
|
86
85
|
<input
|
|
@@ -105,7 +104,8 @@ const fieldEl = platform === 'h5' ? <div className={subCls}>
|
|
|
105
104
|
</button>
|
|
106
105
|
}
|
|
107
106
|
</div>
|
|
108
|
-
</div> : <
|
|
107
|
+
</div> : <ConfigProvider classPrefix="wedatea2td">
|
|
108
|
+
<TeaInput
|
|
109
109
|
size={size}
|
|
110
110
|
type={inputType}
|
|
111
111
|
placeholder={placeholder}
|
|
@@ -117,7 +117,7 @@ const fieldEl = platform === 'h5' ? <div className={subCls}>
|
|
|
117
117
|
onFocus={onFocus}
|
|
118
118
|
onBlur={onBlur}
|
|
119
119
|
onKeyDown={onKeyDown}
|
|
120
|
-
|
|
120
|
+
/></ConfigProvider>;
|
|
121
121
|
return renderDecorator(fieldEl, decorator)({
|
|
122
122
|
id,
|
|
123
123
|
className: cls,
|
|
@@ -128,53 +128,19 @@ return renderDecorator(fieldEl, decorator)({
|
|
|
128
128
|
requiredFlag,
|
|
129
129
|
size
|
|
130
130
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
131
|
}
|
|
134
132
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
defaultValue: PropTypes.string,
|
|
146
|
-
password: PropTypes.bool,
|
|
147
|
-
placeholder: PropTypes.string,
|
|
148
|
-
type: PropTypes.oneOf(['text', 'number', 'idcard', 'digit']),
|
|
149
|
-
maxLength: PropTypes.number,
|
|
150
|
-
disabled: PropTypes.bool,
|
|
151
|
-
focus: PropTypes.bool,
|
|
152
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
153
|
-
requiredFlag: PropTypes.bool,
|
|
154
|
-
size: PropTypes.oneOf(['s', 'm', 'l', 'full']),
|
|
155
|
-
decorator: PropTypes.oneOfType([PropTypes.array, PropTypes.node]),
|
|
156
|
-
clearable: PropTypes.bool
|
|
157
|
-
};
|
|
133
|
+
export interface PropsType extends CommonFormPropsType {
|
|
134
|
+
defaultValue?: string;
|
|
135
|
+
password?: boolean;
|
|
136
|
+
placeholder?: string;
|
|
137
|
+
type?: "text" | "number" | "idcard" | "digit";
|
|
138
|
+
maxLength?: number;
|
|
139
|
+
focus?: boolean;
|
|
140
|
+
size?: "s" | "m" | "l" | "full";
|
|
141
|
+
clearable?: boolean;
|
|
142
|
+
}
|
|
158
143
|
|
|
159
|
-
Input.defaultProps = {
|
|
160
|
-
// 系统属性
|
|
161
|
-
events: {},
|
|
162
|
-
// 组件属性
|
|
163
|
-
label: '标题',
|
|
164
|
-
labelVisible: true,
|
|
165
|
-
name: 'formInput',
|
|
166
|
-
defaultValue: '',
|
|
167
|
-
password: false,
|
|
168
|
-
placeholder: '请输入',
|
|
169
|
-
type: 'text',
|
|
170
|
-
maxLength: 140,
|
|
171
|
-
disabled: false,
|
|
172
|
-
focus: false,
|
|
173
|
-
layout: 'horizontal',
|
|
174
|
-
requiredFlag: false,
|
|
175
|
-
size: 'l',
|
|
176
|
-
clearable: true
|
|
177
|
-
};
|
|
178
144
|
|
|
179
145
|
function getInputType(type, password) {
|
|
180
146
|
if (password) {
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as PropTypes from 'prop-types';
|
|
3
2
|
import {ConfigProvider, Radio as TeaRadio} from 'tea-component';
|
|
4
3
|
|
|
5
4
|
import {usePlatform} from '../../../utils/platform';
|
|
6
5
|
import classNames from '../../../utils/classnames';
|
|
7
6
|
import getLocalCounter from '../../../utils/getLocalCounter';
|
|
8
7
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
9
|
-
import FormCell from '../formcell';
|
|
10
8
|
|
|
11
9
|
import './index.css';
|
|
12
10
|
import { renderDecorator } from '../renderDecorator';
|
|
11
|
+
import { CommonFormPropsType } from '../types';
|
|
12
|
+
|
|
13
13
|
export default function Radio({
|
|
14
14
|
// 系统属性
|
|
15
15
|
id,
|
|
16
16
|
className,
|
|
17
17
|
style,
|
|
18
|
-
events,
|
|
18
|
+
events = {},
|
|
19
19
|
// 组件属性
|
|
20
|
-
label,
|
|
21
|
-
labelVisible,
|
|
22
|
-
name,
|
|
23
|
-
range,
|
|
24
|
-
layout,
|
|
25
|
-
disabled,
|
|
26
|
-
requiredFlag,
|
|
20
|
+
label = '标题',
|
|
21
|
+
labelVisible = true,
|
|
22
|
+
name = 'formRadio',
|
|
23
|
+
range = [],
|
|
24
|
+
layout = 'horizontal',
|
|
25
|
+
disabled = false,
|
|
26
|
+
requiredFlag = false,
|
|
27
27
|
decorator
|
|
28
|
-
}) {
|
|
28
|
+
}: PropsType) {
|
|
29
29
|
const platform = usePlatform();
|
|
30
30
|
const isH5 = platform === 'h5';
|
|
31
31
|
const cls = classNames({
|
|
@@ -44,7 +44,7 @@ export default function Radio({
|
|
|
44
44
|
range.find((item) => item.checked)?.value
|
|
45
45
|
);
|
|
46
46
|
// 两次range不同时, 需要刷新checkedItemValue
|
|
47
|
-
const prevRangeRef = React.useRef();
|
|
47
|
+
const prevRangeRef = React.useRef<PropsType['range']>();
|
|
48
48
|
React.useEffect(() => {
|
|
49
49
|
if (!isObjectEqual(prevRangeRef.current, range)) {
|
|
50
50
|
prevRangeRef.current = range;
|
|
@@ -59,8 +59,10 @@ export default function Radio({
|
|
|
59
59
|
const getChangeHandler = function (value) {
|
|
60
60
|
const onChange = function (e) {
|
|
61
61
|
e.stopPropagation();
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
if (!disabled) {
|
|
63
|
+
setCheckedItemValue(value);
|
|
64
|
+
events.change({ value }, { originEvent: e });
|
|
65
|
+
}
|
|
64
66
|
};
|
|
65
67
|
return onChange;
|
|
66
68
|
};
|
|
@@ -128,32 +130,7 @@ export default function Radio({
|
|
|
128
130
|
});
|
|
129
131
|
}
|
|
130
132
|
|
|
131
|
-
|
|
132
|
-
// 系统属性
|
|
133
|
-
id: PropTypes.string,
|
|
134
|
-
className: PropTypes.string,
|
|
135
|
-
style: PropTypes.string,
|
|
136
|
-
events: PropTypes.objectOf(PropTypes.func),
|
|
137
|
-
// 组件属性
|
|
138
|
-
label: PropTypes.string,
|
|
139
|
-
labelVisible: PropTypes.bool,
|
|
140
|
-
name: PropTypes.string,
|
|
141
|
-
range: PropTypes.array,
|
|
142
|
-
layout: PropTypes.string,
|
|
143
|
-
disabled: PropTypes.bool,
|
|
144
|
-
requiredFlag: PropTypes.bool,
|
|
145
|
-
decorator: PropTypes.oneOfType([PropTypes.array, PropTypes.node])
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
Radio.defaultProps = {
|
|
149
|
-
// 系统属性
|
|
150
|
-
events: {},
|
|
133
|
+
export interface PropsType extends CommonFormPropsType {
|
|
151
134
|
// 组件属性
|
|
152
|
-
label:
|
|
153
|
-
|
|
154
|
-
name: 'formRadio',
|
|
155
|
-
range: [],
|
|
156
|
-
layout: 'horizontal',
|
|
157
|
-
disabled: false,
|
|
158
|
-
requiredFlag: false,
|
|
159
|
-
};
|
|
135
|
+
range?: ({label: string} & Record<string, any>)[];
|
|
136
|
+
}
|
|
@@ -3,11 +3,9 @@ import FormCell from "./formcell";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
|
-
* @param {React.ReactNode} filedNode
|
|
7
|
-
* @param {React.FC|[React.FC, any]} DecoratorComponent
|
|
8
6
|
* @returns {(props: any) => JSX.Element}
|
|
9
7
|
*/
|
|
10
|
-
export function renderDecorator(filedNode, DecoratorComponent = FormCell) {
|
|
8
|
+
export function renderDecorator<D=any>(filedNode: React.ReactNode, DecoratorComponent: React.FC<D> = FormCell) {
|
|
11
9
|
if(!DecoratorComponent) {
|
|
12
10
|
return function WedaFormField() {
|
|
13
11
|
return (
|