@cloudbase/weda-ui 0.2.17 → 2.0.8
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/README.md +3 -0
- package/package.json +10 -5
- package/src/configs/components/button.json +0 -2
- package/src/configs/components/calendar.json +9 -3
- package/src/configs/components/carousel.json +18 -9
- package/src/configs/components/chart/bar.json +31 -12
- package/src/configs/components/chart/line.json +27 -10
- package/src/configs/components/chart/pie.json +22 -8
- package/src/configs/components/chart/statisticsCard.json +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +31 -11
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +123 -4
- package/src/configs/components/form/select.json +247 -13
- package/src/configs/components/graphicCard.json +90 -75
- package/src/configs/components/image.json +19 -8
- package/src/configs/components/link.json +25 -6
- package/src/configs/components/listView.json +83 -27
- package/src/configs/components/lottery.json +153 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +97 -79
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +6 -2
- package/src/configs/components/scrollVeiw.json +98 -34
- package/src/configs/components/swiper.json +22 -10
- package/src/configs/components/tabs.json +54 -9
- package/src/configs/components/text.json +43 -30
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +13 -0
- package/src/docs/common/format.tsx +112 -0
- package/src/docs/common/tableView.css +164 -0
- package/src/docs/common/tableView.tsx +273 -0
- package/src/docs/compsdocs/chart/Bar.mdx +159 -0
- package/src/docs/compsdocs/chart/Line.mdx +100 -0
- package/src/docs/compsdocs/chart/Pie.mdx +83 -0
- package/src/docs/compsdocs/chart/_category_.json +1 -0
- package/src/docs/compsdocs/chart/statisticsCard.mdx +51 -0
- package/src/docs/compsdocs/database/DataView.mdx +33 -0
- package/src/docs/compsdocs/database/ListView.mdx +33 -0
- package/src/docs/compsdocs/database/_category_.json +1 -0
- package/src/docs/compsdocs/form/Form.mdx +35 -0
- package/src/docs/compsdocs/form/FormCheckbox.mdx +35 -0
- package/src/docs/compsdocs/form/FormDate.mdx +30 -0
- package/src/docs/compsdocs/form/FormEmail.mdx +30 -0
- package/src/docs/compsdocs/form/FormImageUploader.mdx +31 -0
- package/src/docs/compsdocs/form/FormInput.mdx +30 -0
- package/src/docs/compsdocs/form/FormLocation.mdx +64 -0
- package/src/docs/compsdocs/form/FormPhone.mdx +30 -0
- package/src/docs/compsdocs/form/FormRadio.mdx +35 -0
- package/src/docs/compsdocs/form/FormRegion.mdx +30 -0
- package/src/docs/compsdocs/form/FormSelect.mdx +36 -0
- package/src/docs/compsdocs/form/FormSwitch.mdx +30 -0
- package/src/docs/compsdocs/form/FormTextarea.mdx +30 -0
- package/src/docs/compsdocs/form/FormTime.mdx +30 -0
- package/src/docs/compsdocs/form/FormUploadFile.mdx +30 -0
- package/src/docs/compsdocs/form/FormUrl.mdx +30 -0
- package/src/docs/compsdocs/form/_category_.json +1 -0
- package/src/docs/compsdocs/grid/Card.mdx +32 -0
- package/src/docs/compsdocs/grid/Container.mdx +42 -0
- package/src/docs/compsdocs/grid/Footer.mdx +31 -0
- package/src/docs/compsdocs/grid/GridLayout.mdx +32 -0
- package/src/docs/compsdocs/grid/Header.mdx +31 -0
- package/src/docs/compsdocs/grid/Layout.mdx +25 -0
- package/src/docs/compsdocs/grid/List.mdx +31 -0
- package/src/docs/compsdocs/grid/ScrollView.mdx +37 -0
- package/src/docs/compsdocs/grid/Swiper.mdx +58 -0
- package/src/docs/compsdocs/grid/_category_.json +1 -0
- package/src/docs/compsdocs/media/Icon.mdx +31 -0
- package/src/docs/compsdocs/media/Image.mdx +55 -0
- package/src/docs/compsdocs/media/_category_.json +1 -0
- package/src/docs/compsdocs/model/ModelCreate.mdx +20 -0
- package/src/docs/compsdocs/model/ModelDetail.mdx +20 -0
- package/src/docs/compsdocs/model/ModelTable.mdx +24 -0
- package/src/docs/compsdocs/model/ModelUpdate.mdx +21 -0
- package/src/docs/compsdocs/model/PageLayout.mdx +21 -0
- package/src/docs/compsdocs/model/_category_.json +1 -0
- package/src/docs/compsdocs/navmenu/Classification.mdx +38 -0
- package/src/docs/compsdocs/navmenu/NavBar.mdx +43 -0
- package/src/docs/compsdocs/navmenu/NavLayout.mdx +30 -0
- package/src/docs/compsdocs/navmenu/TabBar.mdx +43 -0
- package/src/docs/compsdocs/navmenu/TabBarItem.mdx +29 -0
- package/src/docs/compsdocs/navmenu/_category_.json +1 -0
- package/src/docs/compsdocs/senior/Lottery.mdx +48 -0
- package/src/docs/compsdocs/senior/Modal.mdx +58 -0
- package/src/docs/compsdocs/senior/SlotMachine.mdx +52 -0
- package/src/docs/compsdocs/senior/_category_.json +1 -0
- package/src/docs/compsdocs/show/Calendar.mdx +29 -0
- package/src/docs/compsdocs/show/Divider.mdx +31 -0
- package/src/docs/compsdocs/show/GraphicCard.mdx +30 -0
- package/src/docs/compsdocs/show/Item.mdx +32 -0
- package/src/docs/compsdocs/show/ItemList.mdx +47 -0
- package/src/docs/compsdocs/show/Media.mdx +25 -0
- package/src/docs/compsdocs/show/StatusTip.mdx +25 -0
- package/src/docs/compsdocs/show/Swiper.mdx +33 -0
- package/src/docs/compsdocs/show/Tabs.mdx +38 -0
- package/src/docs/compsdocs/show/_category_.json +1 -0
- package/src/docs/compsdocs/show/button.mdx +25 -0
- package/src/docs/compsdocs/text/Link.mdx +43 -0
- package/src/docs/compsdocs/text/RichTextView.mdx +36 -0
- package/src/docs/compsdocs/text/Text.mdx +31 -0
- package/src/docs/compsdocs/text/Title.mdx +32 -0
- package/src/docs/compsdocs/text/_category_.json +1 -0
- package/src/docs/compsdocs/wxOpen/Phone.mdx +60 -0
- package/src/docs/compsdocs/wxOpen/Share.mdx +46 -0
- package/src/docs/compsdocs/wxOpen/UserInfo.mdx +60 -0
- package/src/docs/compsdocs/wxOpen/_category_.json +4 -0
- package/src/index.js +2 -0
- package/src/mp/components/button/index.js +18 -2
- package/src/mp/components/button/index.wxml +7 -4
- package/src/mp/components/chart/bar/index.js +6 -2
- package/src/mp/components/chart/common/core/eChartBar.js +9 -8
- package/src/mp/components/chart/common/core/eChartBase.js +20 -16
- package/src/mp/components/chart/common/core/eChartLine.js +6 -5
- package/src/mp/components/chart/line/index.js +10 -6
- package/src/mp/components/chart/pie/index.js +6 -2
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- package/src/mp/components/dataView/index.json +1 -1
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/form/index.wxml +1 -2
- package/src/mp/components/form/formcell/index.wxml +1 -1
- package/src/mp/components/form/formcell/index.wxss +17 -0
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/input/index.wxss +15 -0
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/location/index.wxss +4 -6
- package/src/mp/components/form/radio/index.js +34 -1
- package/src/mp/components/form/select/index.js +351 -41
- package/src/mp/components/form/select/index.wxml +17 -2
- package/src/mp/components/form/select/index.wxss +4 -0
- package/src/mp/components/form/select/region/index.js +101 -0
- package/src/mp/components/form/textarea/index.js +1 -1
- package/src/mp/components/form/textarea/index.wxss +4 -0
- package/src/mp/components/form/uploader/index.js +39 -27
- package/src/mp/components/form/uploader/index.json +3 -2
- package/src/mp/components/form/uploader/index.wxml +11 -7
- package/src/mp/components/form/uploader/index.wxss +20 -2
- package/src/mp/components/form/uploader/weui-uploader.js +209 -0
- package/src/mp/components/form/uploader/weui-uploader.json +7 -0
- package/src/mp/components/form/uploader/weui-uploader.wxml +45 -0
- package/src/mp/components/form/uploader/weui-uploader.wxss +1 -0
- package/src/mp/components/form/uploaderFile/index.js +10 -6
- package/src/mp/components/form/uploaderFile/index.wxss +4 -4
- package/src/mp/components/image/index.wxss +3 -2
- package/src/mp/components/listView/index.js +38 -43
- package/src/mp/components/listView/index.wxml +1 -1
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/lottery/index.js +270 -0
- package/src/mp/components/{internals/listView → lottery}/index.json +0 -0
- package/src/mp/components/lottery/index.wxml +43 -0
- package/src/mp/components/lottery/index.wxss +317 -0
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/wxOpenApi/phone/index.json +4 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +7 -1
- package/src/mp/style/weda-ui.wxss +16 -0
- package/src/mp/utils/constant.js +15 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/lodash.js +2 -0
- package/src/mp/utils/platform.js +10 -0
- package/src/mp/utils/tcb.js +44 -0
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +10 -9
- package/src/web/components/calendar/index.jsx +1 -1
- package/src/web/components/carousel/index.tsx +8 -8
- package/src/web/components/chart/bar/index.tsx +40 -39
- package/src/web/components/chart/common/config/line.js +1 -1
- package/src/web/components/chart/common/core/eChartBar.js +7 -6
- package/src/web/components/chart/common/core/eChartBase.ts +20 -16
- package/src/web/components/chart/common/core/eChartLine.js +8 -6
- package/src/web/components/chart/line/index.tsx +40 -39
- package/src/web/components/chart/statisticsCard/index.tsx +29 -8
- package/src/web/components/form/checkbox/index.tsx +61 -23
- package/src/web/components/form/form/index.css +5 -1
- package/src/web/components/form/form/index.tsx +3 -1
- package/src/web/components/form/formcell/index.css +22 -1
- package/src/web/components/form/formcell/index.tsx +11 -6
- package/src/web/components/form/input/index.css +7 -12
- package/src/web/components/form/location/components/LocationH5/index.css +4 -7
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +1 -1
- package/src/web/components/form/radio/index.tsx +90 -53
- package/src/web/components/form/select/h5.tsx +370 -73
- package/src/web/components/form/select/index.css +15 -0
- package/src/web/components/form/select/index.tsx +392 -145
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +89 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/textarea/index.css +4 -0
- package/src/web/components/form/textarea/index.tsx +2 -2
- package/src/web/components/form/tips/index.css +4 -0
- package/src/web/components/form/tips/index.tsx +4 -3
- package/src/web/components/form/uploader/index.css +26 -2
- package/src/web/components/form/uploader/uploader.h5.tsx +89 -57
- package/src/web/components/form/uploader/uploader.pc.tsx +4 -4
- package/src/web/components/form/uploaderFile/index.css +2 -4
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +13 -7
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +13 -5
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.css +3 -3
- package/src/web/components/image/index.tsx +6 -7
- package/src/web/components/index.js +8 -0
- package/src/web/components/link/index.tsx +7 -4
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +12 -20
- package/src/web/components/lottery/index.css +327 -0
- package/src/web/components/lottery/index.tsx +567 -0
- package/src/web/components/lottery/lotteryUtil.ts +130 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navLayout/index.tsx +2 -2
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +230 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/picker/timePicker.tsx +2 -2
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/slot/index.tsx +1 -1
- package/src/web/components/tabs/index.tsx +2 -0
- package/src/web/components/tabs/tabs.h5.tsx +43 -33
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +12 -20
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/utils/{constant.js → constant.ts} +17 -2
- package/src/web/utils/lodash.ts +2 -0
- package/src/web/utils/platform.js +9 -0
- package/src/web/utils/tcb.js +26 -0
- package/src/web/weda-ui.css +7 -1
- package/src/mp/components/internals/listView/arrow-right-line.svg +0 -3
- package/src/mp/components/internals/listView/index.js +0 -286
- package/src/mp/components/internals/listView/index.wxml +0 -40
- package/src/mp/components/internals/listView/index.wxss +0 -150
- package/src/mp/components/internals/listView/more-line.svg +0 -3
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Checkbox as TeaCheckbox, ConfigProvider } from 'tea-component';
|
|
3
3
|
|
|
4
4
|
import classNames from '../../../utils/classnames';
|
|
@@ -8,6 +8,8 @@ import fromEntries from 'object.fromentries';
|
|
|
8
8
|
import { usePlatform } from '../../../utils/platform';
|
|
9
9
|
import { renderDecorator } from '../renderDecorator';
|
|
10
10
|
import { CommonFormPropsType } from '../types';
|
|
11
|
+
import { callWedaApi } from '../../../utils/tcb';
|
|
12
|
+
import destr from 'destr';
|
|
11
13
|
|
|
12
14
|
export default function Checkbox({
|
|
13
15
|
// 系统属性
|
|
@@ -19,6 +21,8 @@ export default function Checkbox({
|
|
|
19
21
|
name = 'formCheckbox',
|
|
20
22
|
label = '标题',
|
|
21
23
|
labelVisible = true,
|
|
24
|
+
format = '',
|
|
25
|
+
enumName = '',
|
|
22
26
|
range = [],
|
|
23
27
|
layout = 'horizontal',
|
|
24
28
|
disabled = false,
|
|
@@ -40,21 +44,53 @@ export default function Checkbox({
|
|
|
40
44
|
'weui-cell_disabled': isH5 && disabled,
|
|
41
45
|
});
|
|
42
46
|
|
|
47
|
+
const [option, setOption] = useState(range);
|
|
43
48
|
const [checkedItems, setCheckedItems] = React.useState(
|
|
44
|
-
platform === 'h5' ? fromEntries(
|
|
45
|
-
|
|
49
|
+
platform === 'h5' ? fromEntries(option.map(({ value, checked }) => [value, !!checked]))
|
|
50
|
+
: option.filter(({ checked }) => checked).map(({ value }) => value)
|
|
46
51
|
);
|
|
47
52
|
// 两次range不同时, 需要刷新checkedItems
|
|
48
53
|
const prevRangeRef = React.useRef<object[]>();
|
|
49
54
|
React.useEffect(() => {
|
|
50
|
-
if (!isObjectEqual(prevRangeRef.current,
|
|
51
|
-
prevRangeRef.current =
|
|
55
|
+
if (!isObjectEqual(prevRangeRef.current, option)) {
|
|
56
|
+
prevRangeRef.current = option;
|
|
52
57
|
setCheckedItems(
|
|
53
|
-
fromEntries(
|
|
58
|
+
fromEntries(option.map(({ value, checked }) => [value, !!checked]))
|
|
54
59
|
);
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
62
|
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
// 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
|
|
65
|
+
if (format === 'x-enum' && enumName) {
|
|
66
|
+
fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
|
|
67
|
+
}
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (format !== 'x-enum') {
|
|
72
|
+
setOption(range)
|
|
73
|
+
}
|
|
74
|
+
}, [range]);
|
|
75
|
+
|
|
76
|
+
const fetchData = async (param:
|
|
77
|
+
{ OptNameList?: object, PageIndex?: number, PageSize?: number }
|
|
78
|
+
) => {
|
|
79
|
+
let data = await callWedaApi({
|
|
80
|
+
action: 'DescribeGeneralOptionsDetailList',
|
|
81
|
+
data: param,
|
|
82
|
+
});
|
|
83
|
+
const config = destr(data?.Items?.[0]?.Config) ?? [];
|
|
84
|
+
const enumOption = config.map(item => {
|
|
85
|
+
return {
|
|
86
|
+
label: item.value,
|
|
87
|
+
value: item.key,
|
|
88
|
+
checked: false
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
setOption(enumOption);
|
|
92
|
+
};
|
|
93
|
+
|
|
58
94
|
/**
|
|
59
95
|
* 在ios h5端, label和input的绑定不生效
|
|
60
96
|
* 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
|
|
@@ -82,8 +118,8 @@ export default function Checkbox({
|
|
|
82
118
|
// 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
|
|
83
119
|
const hashcode = React.useMemo(() => getLocalCounter(), []);
|
|
84
120
|
let checkboxElement;
|
|
85
|
-
if(platform === 'h5') {
|
|
86
|
-
checkboxElement =
|
|
121
|
+
if (platform === 'h5') {
|
|
122
|
+
checkboxElement = option.map(({ label, value }, index) => {
|
|
87
123
|
const _id = `checkbox-${hashcode}-${index}`;
|
|
88
124
|
const _name = `checkbox-${hashcode}-${name}`;
|
|
89
125
|
return (
|
|
@@ -120,17 +156,17 @@ export default function Checkbox({
|
|
|
120
156
|
.map(([value]) => value)
|
|
121
157
|
}
|
|
122
158
|
onChange={value => {
|
|
123
|
-
const newMap =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
159
|
+
const newMap = option
|
|
160
|
+
.map((opt) => opt.value)
|
|
161
|
+
.reduce((acc, cur) => {
|
|
162
|
+
const idx = value.indexOf(cur);
|
|
163
|
+
if (idx < 0) {
|
|
164
|
+
acc[cur] = false;
|
|
165
|
+
} else {
|
|
166
|
+
acc[cur] = true;
|
|
167
|
+
}
|
|
168
|
+
return acc;
|
|
169
|
+
}, {});
|
|
134
170
|
setCheckedItems(newMap);
|
|
135
171
|
events.change(
|
|
136
172
|
{
|
|
@@ -141,7 +177,7 @@ export default function Checkbox({
|
|
|
141
177
|
);
|
|
142
178
|
}}
|
|
143
179
|
>
|
|
144
|
-
{
|
|
180
|
+
{option.map(({ value, label }, index) => {
|
|
145
181
|
const _id = `checkbox-${hashcode}-${index}`;
|
|
146
182
|
return (
|
|
147
183
|
<TeaCheckbox key={_id} name={value} id={_id}>
|
|
@@ -149,7 +185,7 @@ export default function Checkbox({
|
|
|
149
185
|
</TeaCheckbox>
|
|
150
186
|
);
|
|
151
187
|
})}
|
|
152
|
-
|
|
188
|
+
</TeaCheckbox.Group>
|
|
153
189
|
</ConfigProvider>
|
|
154
190
|
);
|
|
155
191
|
}
|
|
@@ -167,5 +203,7 @@ export default function Checkbox({
|
|
|
167
203
|
}
|
|
168
204
|
|
|
169
205
|
export interface PropsType extends CommonFormPropsType {
|
|
170
|
-
range?: {label: string, value: any;
|
|
171
|
-
|
|
206
|
+
range?: { label: string, value: any;[key: string]: any }[];
|
|
207
|
+
format?: string;
|
|
208
|
+
enumName?: string;
|
|
209
|
+
}
|
|
@@ -22,6 +22,8 @@ export default function Form({
|
|
|
22
22
|
'weda-ui': true,
|
|
23
23
|
'weda-form': true,
|
|
24
24
|
'weui-form': platform === 'h5',
|
|
25
|
+
'weda-form-pc': platform === 'pc',
|
|
26
|
+
'gsd-h5-react-form-pc': platform === 'pc',
|
|
25
27
|
[className]: className,
|
|
26
28
|
});
|
|
27
29
|
if(platform === 'pc') {
|
|
@@ -45,4 +47,4 @@ export default function Form({
|
|
|
45
47
|
|
|
46
48
|
export interface PropsType extends CommonFormPropsType {
|
|
47
49
|
contentSlot?: any;
|
|
48
|
-
}
|
|
50
|
+
}
|
|
@@ -4,7 +4,28 @@
|
|
|
4
4
|
font-family: SimSun;
|
|
5
5
|
font-size: 12px;
|
|
6
6
|
color: #f60;
|
|
7
|
+
align-self: flex-start;
|
|
7
8
|
}
|
|
9
|
+
|
|
10
|
+
.weda-ui .weui-cells__group_form .weui-cells {
|
|
11
|
+
margin: 0;
|
|
12
|
+
}
|
|
13
|
+
.weda-formcells.weui-flex .weda-formcells__label {
|
|
14
|
+
width: 130px;
|
|
15
|
+
}
|
|
16
|
+
.weui-cells__group_form .weui-cell {
|
|
17
|
+
padding: 16px 16px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.weda-formcells__content.weui-flex__item .weui-cell_form {
|
|
21
|
+
padding: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.weda-formcells__content.weui-flex__item .weui-cell_form {
|
|
25
|
+
padding-right: 16px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
8
29
|
/* formcell 在 form container 外部兼容 and 独立 layout 适配 */
|
|
9
30
|
|
|
10
31
|
.weda-formcells__pc.vertical .wedatea2td-form__controls,
|
|
@@ -68,4 +89,4 @@
|
|
|
68
89
|
/*formcell end*/
|
|
69
90
|
|
|
70
91
|
|
|
71
|
-
/* formcell 在 form container 外部兼容 */
|
|
92
|
+
/* formcell 在 form container 外部兼容 */
|
|
@@ -14,13 +14,13 @@ export default function FormCell({
|
|
|
14
14
|
children,
|
|
15
15
|
multiCell,
|
|
16
16
|
requiredFlag,
|
|
17
|
-
size
|
|
17
|
+
size,
|
|
18
18
|
}: PropsType) {
|
|
19
19
|
const platform = usePlatform();
|
|
20
20
|
const isFlex = layout !== 'vertical';
|
|
21
21
|
|
|
22
|
-
if(platform === 'pc') {
|
|
23
|
-
return (
|
|
22
|
+
if (platform === 'pc') {
|
|
23
|
+
return (
|
|
24
24
|
<ConfigProvider classPrefix="wedatea2td">
|
|
25
25
|
<TeaForm.Item
|
|
26
26
|
style={style}
|
|
@@ -31,9 +31,14 @@ export default function FormCell({
|
|
|
31
31
|
'weda-formcells__pc': !!label,
|
|
32
32
|
'weda-formcells__full-width': size === 'full',
|
|
33
33
|
[layout]: layout,
|
|
34
|
-
[className]: [className]
|
|
34
|
+
[className]: [className],
|
|
35
35
|
})}
|
|
36
|
-
label={
|
|
36
|
+
label={
|
|
37
|
+
<>
|
|
38
|
+
{label}
|
|
39
|
+
{requiredFlag && <span className="weda-formcells__flag">*</span>}
|
|
40
|
+
</>
|
|
41
|
+
}
|
|
37
42
|
>
|
|
38
43
|
{children}
|
|
39
44
|
</TeaForm.Item>
|
|
@@ -59,10 +64,10 @@ export default function FormCell({
|
|
|
59
64
|
'weui-cell': true,
|
|
60
65
|
})}
|
|
61
66
|
>
|
|
67
|
+
<label>{label}</label>
|
|
62
68
|
{requiredFlag ? (
|
|
63
69
|
<label className="weda-formcells__flag">*</label>
|
|
64
70
|
) : null}
|
|
65
|
-
<label>{label}</label>
|
|
66
71
|
</div>
|
|
67
72
|
) : null}
|
|
68
73
|
<div
|
|
@@ -7,22 +7,17 @@
|
|
|
7
7
|
/*
|
|
8
8
|
把weui-cell 的padding还回到input
|
|
9
9
|
*/
|
|
10
|
-
.weda-ui
|
|
11
|
-
padding: 28px
|
|
10
|
+
.weda-ui input.weui-input {
|
|
11
|
+
padding: 28px 0;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.weda-ui.weda-input .weui-
|
|
15
|
-
padding: 16px;
|
|
16
|
-
}
|
|
17
|
-
.weda-ui.weda-input .weda-formcells__label.weui-cell label {
|
|
18
|
-
padding: 0;
|
|
19
|
-
}
|
|
20
|
-
.weda-ui.weda-input .weui-cell {
|
|
14
|
+
.weda-ui.weda-input .weui-flex__item .weui-cell_form {
|
|
21
15
|
padding: 0;
|
|
16
|
+
padding-right: 16px;
|
|
22
17
|
}
|
|
23
18
|
|
|
24
|
-
.weda-ui.weda-input .weui-
|
|
25
|
-
|
|
19
|
+
.weda-ui.weda-input .weui-cell_form {
|
|
20
|
+
padding: 0 16px;
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
/**
|
|
@@ -38,4 +33,4 @@
|
|
|
38
33
|
}
|
|
39
34
|
/**
|
|
40
35
|
* END
|
|
41
|
-
*/
|
|
36
|
+
*/
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
.weda-ui_form-location {
|
|
2
|
-
padding: 1.14286rem 0;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
1
|
.form-location-warp {
|
|
6
2
|
display: flex;
|
|
7
3
|
white-space: nowrap;
|
|
@@ -10,7 +6,9 @@
|
|
|
10
6
|
.form-location-label {
|
|
11
7
|
display: flex;
|
|
12
8
|
align-items: center;
|
|
13
|
-
padding:
|
|
9
|
+
padding: 16px;
|
|
10
|
+
width: 130px;
|
|
11
|
+
|
|
14
12
|
}
|
|
15
13
|
.form-location-label > span {
|
|
16
14
|
margin-right: 0.28571rem;
|
|
@@ -19,8 +17,7 @@
|
|
|
19
17
|
color: #f60;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
.form-location-con {
|
|
23
|
-
padding-left: 1.14286rem;
|
|
20
|
+
.weda-ui .form-location-con {
|
|
24
21
|
display: flex;
|
|
25
22
|
align-items: center;
|
|
26
23
|
}
|
|
@@ -329,8 +329,8 @@ export default function LocationH5(props) {
|
|
|
329
329
|
<div className="form-location-warp">
|
|
330
330
|
{labelVisible && (
|
|
331
331
|
<div className="form-location-label">
|
|
332
|
-
{requiredFlag && <span>*</span>}
|
|
333
332
|
{label}
|
|
333
|
+
{requiredFlag && <span>*</span>}
|
|
334
334
|
</div>
|
|
335
335
|
)}
|
|
336
336
|
<div className="form-location-con">
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {ConfigProvider, Radio as TeaRadio} from 'tea-component';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { ConfigProvider, Radio as TeaRadio } from 'tea-component';
|
|
3
3
|
|
|
4
|
-
import {usePlatform} from '../../../utils/platform';
|
|
4
|
+
import { usePlatform } from '../../../utils/platform';
|
|
5
5
|
import classNames from '../../../utils/classnames';
|
|
6
6
|
import getLocalCounter from '../../../utils/getLocalCounter';
|
|
7
7
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
8
|
+
import { callWedaApi } from '../../../utils/tcb';
|
|
8
9
|
|
|
9
10
|
import './index.css';
|
|
10
11
|
import { renderDecorator } from '../renderDecorator';
|
|
11
12
|
import { CommonFormPropsType } from '../types';
|
|
13
|
+
import destr from 'destr';
|
|
12
14
|
|
|
13
15
|
export default function Radio({
|
|
14
16
|
// 系统属性
|
|
@@ -19,6 +21,8 @@ export default function Radio({
|
|
|
19
21
|
// 组件属性
|
|
20
22
|
label = '标题',
|
|
21
23
|
labelVisible = true,
|
|
24
|
+
format = '',
|
|
25
|
+
enumName = '',
|
|
22
26
|
name = 'formRadio',
|
|
23
27
|
range = [],
|
|
24
28
|
layout = 'horizontal',
|
|
@@ -39,19 +43,50 @@ export default function Radio({
|
|
|
39
43
|
'weui-check__label': isH5,
|
|
40
44
|
'weui-cell_disabled': isH5 && disabled,
|
|
41
45
|
});
|
|
42
|
-
|
|
46
|
+
const [option, setOption] = useState(range);
|
|
43
47
|
const [checkedItemValue, setCheckedItemValue] = React.useState(
|
|
44
|
-
|
|
48
|
+
option.find((item) => item.checked)?.value
|
|
45
49
|
);
|
|
46
50
|
// 两次range不同时, 需要刷新checkedItemValue
|
|
47
51
|
const prevRangeRef = React.useRef<PropsType['range']>();
|
|
48
52
|
React.useEffect(() => {
|
|
49
|
-
if (!isObjectEqual(prevRangeRef.current,
|
|
50
|
-
prevRangeRef.current =
|
|
51
|
-
setCheckedItemValue(
|
|
53
|
+
if (!isObjectEqual(prevRangeRef.current, option)) {
|
|
54
|
+
prevRangeRef.current = option;
|
|
55
|
+
setCheckedItemValue(option.find((item) => item.checked)?.value);
|
|
52
56
|
}
|
|
53
57
|
});
|
|
54
58
|
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
// 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
|
|
61
|
+
if (format === 'x-enum' && enumName) {
|
|
62
|
+
fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
|
|
63
|
+
}
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (format !== 'x-enum') {
|
|
68
|
+
setOption(range)
|
|
69
|
+
}
|
|
70
|
+
}, [range]);
|
|
71
|
+
|
|
72
|
+
const fetchData = async (param:
|
|
73
|
+
{ OptNameList?: object, PageIndex?: number, PageSize?: number }
|
|
74
|
+
) => {
|
|
75
|
+
let data = await callWedaApi({
|
|
76
|
+
action: 'DescribeGeneralOptionsDetailList',
|
|
77
|
+
data: param,
|
|
78
|
+
});
|
|
79
|
+
const config = destr(data?.Items?.[0]?.Config) ?? [];
|
|
80
|
+
const enumOption = config.map(item => {
|
|
81
|
+
return {
|
|
82
|
+
label: item.value,
|
|
83
|
+
value: item.key,
|
|
84
|
+
checked: false
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
setOption(enumOption);
|
|
88
|
+
};
|
|
89
|
+
|
|
55
90
|
/**
|
|
56
91
|
* 在ios h5端, label和input的绑定不生效
|
|
57
92
|
* 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
|
|
@@ -70,55 +105,55 @@ export default function Radio({
|
|
|
70
105
|
// 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
|
|
71
106
|
const hashcode = React.useMemo(() => getLocalCounter(), []);
|
|
72
107
|
let radioElement;
|
|
73
|
-
if(isH5) {
|
|
108
|
+
if (isH5) {
|
|
74
109
|
|
|
75
|
-
radioElement =
|
|
110
|
+
radioElement = option.map(({ label, value }, index) => {
|
|
76
111
|
const _id = `radio-${hashcode}-${index}`;
|
|
77
112
|
const _name = `radio-${hashcode}-${name}`;
|
|
78
113
|
return (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
<div
|
|
115
|
+
className={subCls}
|
|
116
|
+
key={_id}
|
|
117
|
+
onClickCapture={getChangeHandler(value)}
|
|
118
|
+
>
|
|
119
|
+
<div className="weui-cell__hd">
|
|
120
|
+
<input
|
|
121
|
+
type="radio"
|
|
122
|
+
className="weui-check"
|
|
123
|
+
value={value}
|
|
124
|
+
name={_name}
|
|
125
|
+
id={_id}
|
|
126
|
+
checked={checkedItemValue === value}
|
|
127
|
+
disabled={disabled}
|
|
128
|
+
onClick={(e) => e.stopPropagation()}
|
|
94
129
|
/>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
130
|
+
<i className="weui-icon-checked"></i>
|
|
131
|
+
</div>
|
|
132
|
+
<div className="weui-cell__bd">
|
|
133
|
+
<p>{label}</p>
|
|
134
|
+
</div>
|
|
99
135
|
</div>
|
|
100
|
-
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
</
|
|
120
|
-
|
|
121
|
-
}
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
// pc
|
|
140
|
+
radioElement = (<ConfigProvider classPrefix="wedatea2td">
|
|
141
|
+
<TeaRadio.Group
|
|
142
|
+
disabled={disabled}
|
|
143
|
+
value={checkedItemValue}
|
|
144
|
+
onChange={(value, { event }) => getChangeHandler(value)(event)}
|
|
145
|
+
>
|
|
146
|
+
{option.map(({ value, label }, index) => {
|
|
147
|
+
const _id = `radio-${hashcode}-${index}`;
|
|
148
|
+
return (
|
|
149
|
+
<TeaRadio key={_id} name={value} id={_id}>
|
|
150
|
+
{label}
|
|
151
|
+
</TeaRadio>
|
|
152
|
+
);
|
|
153
|
+
})}
|
|
154
|
+
</TeaRadio.Group>
|
|
155
|
+
</ConfigProvider>);
|
|
156
|
+
}
|
|
122
157
|
return renderDecorator(radioElement, decorator)({
|
|
123
158
|
id,
|
|
124
159
|
className: cls,
|
|
@@ -132,5 +167,7 @@ export default function Radio({
|
|
|
132
167
|
|
|
133
168
|
export interface PropsType extends CommonFormPropsType {
|
|
134
169
|
// 组件属性
|
|
135
|
-
range?: ({label: string} & Record<string, any>)[];
|
|
136
|
-
|
|
170
|
+
range?: ({ label: string } & Record<string, any>)[];
|
|
171
|
+
format?: string;
|
|
172
|
+
enumName?: string;
|
|
173
|
+
}
|