@cloudbase/weda-ui 3.1.1 → 3.1.4
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/dist/asset-manifest.json +17 -0
- package/dist/configs/components/carousel.json +2 -2
- package/dist/configs/components/form/checkbox.json +1 -0
- package/dist/configs/components/form/form.json +39 -15
- package/dist/configs/components/form/location.json +0 -32
- package/dist/configs/components/form/select.json +1 -0
- package/dist/index.html +88 -0
- package/dist/static/js/bundle.js +963 -0
- package/dist/static/js/bundle.js.map +1 -0
- package/dist/static/js/main.chunk.js +8841 -0
- package/dist/static/js/main.chunk.js.map +1 -0
- package/dist/static/js/vendors~main.chunk.js +247885 -0
- package/dist/static/js/vendors~main.chunk.js.map +1 -0
- package/dist/static/media/ef6fa527e24e354765d806b826b41391.fa67580a.svg +627 -0
- package/dist/web/components/chart/common/core/eChartBar.d.ts +36 -0
- package/dist/web/components/chart/common/core/eChartBar.js +3 -1
- package/dist/web/components/chart/common/core/eChartLine.d.ts +34 -0
- package/dist/web/components/chart/common/core/eChartLine.js +3 -1
- package/dist/web/components/chart/common/core/eChartPie.d.ts +22 -0
- package/dist/web/components/form/checkbox/index.js +1 -1
- package/dist/web/components/form/form/index.css +4 -0
- package/dist/web/components/form/form/index.d.ts +21 -2
- package/dist/web/components/form/form/index.js +90 -16
- package/dist/web/components/form/location/common/mapChoose.js +97 -35
- package/dist/web/components/form/location/common/propsConfig.d.ts +1 -4
- package/dist/web/components/form/location/common/propsConfig.js +0 -2
- package/dist/web/components/form/location/common/useLocationInfo.d.ts +2 -0
- package/dist/web/components/form/location/common/useLocationInfo.js +19 -3
- package/dist/web/components/form/location/components/LocationH5/index.css +1 -1
- package/dist/web/components/form/location/components/LocationH5/location.h5.js +30 -54
- package/dist/web/components/form/location/components/LocationPC/location.PC.js +16 -51
- package/dist/web/components/form/select/dropdown-select/ui.d.ts +15 -0
- package/dist/web/components/form/select/dropdown-select/ui.js +55 -0
- package/dist/web/components/form/select/h5.d.ts +1 -1
- package/dist/web/components/form/select/h5.js +54 -150
- package/dist/web/components/form/select/index.d.ts +1 -1
- package/dist/web/components/form/select/index.js +33 -94
- package/dist/web/components/form/select/use-options.d.ts +26 -0
- package/dist/web/components/form/select/use-options.js +103 -0
- package/dist/web/components/form/uploader/index.css +10 -3
- package/dist/web/components/form/uploader/uploader.h5.d.ts +1 -1
- package/dist/web/components/form/uploader/uploader.h5.js +18 -19
- package/dist/web/components/form/uploader/uploader.pc.js +6 -3
- package/dist/web/components/richText/index.js +20 -17
- package/dist/web/utils/isObjectEqual.d.ts +1 -1
- package/dist/web/utils/tcb.d.ts +5 -1
- package/dist/web/utils/tcb.js +26 -3
- package/package.json +41 -39
- package/CHANGELOG.md +0 -7
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as _moment from 'moment';
|
|
3
|
-
import { usePlatform
|
|
3
|
+
import { usePlatform } from '../../../utils/platform';
|
|
4
4
|
import SelectH5, { decodeIsoDatetime } from './h5';
|
|
5
5
|
import classNames from '../../../utils/classnames';
|
|
6
|
-
import {
|
|
6
|
+
import { DatePicker, TimePicker, Cascader, ConfigProvider, } from 'tea-component';
|
|
7
7
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
8
|
-
import { getRegionTree, getAreaCode } from './region';
|
|
9
8
|
import { renderDecorator } from '../renderDecorator';
|
|
10
9
|
import YearPicker from './year';
|
|
11
|
-
import { callDataSource, callWedaApi } from '../../../utils/tcb';
|
|
12
|
-
import destr from 'destr';
|
|
13
10
|
import { emptyObject } from '../../../utils/constant';
|
|
11
|
+
import { PureSelectPc } from './dropdown-select/ui';
|
|
12
|
+
import { useOptions } from './use-options';
|
|
13
|
+
import { getRegionTree, getAreaCode } from './region';
|
|
14
14
|
// @ts-ignore TODO: fix 与plugin构建阶段效果不同
|
|
15
15
|
export const moment = (typeof _moment === 'function' ? _moment : _moment.default);
|
|
16
16
|
export default function Select(props) {
|
|
@@ -70,89 +70,27 @@ function SelectPc({ where, dataSourceName, viewId, format, primaryField, enumNam
|
|
|
70
70
|
const [region, setRegion] = React.useState(defaultRegion || undefined);
|
|
71
71
|
const [mutiRegion, setMutiRegion] = React.useState(defaultMutiRegion != null ? defaultMutiRegion.split(',') : []);
|
|
72
72
|
const [selectedValue, setSelectedValue] = React.useState(defaultValue);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
React.useEffect(() => {
|
|
76
|
-
// 筛选参数
|
|
77
|
-
const whereEffected = [].concat(getWhereList(where));
|
|
78
|
-
if ((format === 'father-son' || format === 'related') &&
|
|
79
|
-
dataSourceName &&
|
|
80
|
-
viewId) {
|
|
81
|
-
fetchData({
|
|
82
|
-
dataSourceName: dataSourceName,
|
|
83
|
-
viewId: viewId,
|
|
84
|
-
methodName: 'wedaGetRecords',
|
|
85
|
-
params: whereEffected,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}, [where]);
|
|
89
|
-
// 获取数据列表中主列字段,将其作为选项
|
|
90
|
-
React.useEffect(() => {
|
|
91
|
-
var _a;
|
|
92
|
-
if (records && records.length !== 0 && primaryField) {
|
|
93
|
-
const option = records.map((item) => {
|
|
94
|
-
return {
|
|
95
|
-
label: item[primaryField] || item._id,
|
|
96
|
-
value: item._id,
|
|
97
|
-
};
|
|
98
|
-
});
|
|
99
|
-
setOption(option);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
setOption([{ label: '', value: '' }]);
|
|
103
|
-
setSelectedValue('');
|
|
104
|
-
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: '' });
|
|
105
|
-
}
|
|
106
|
-
}, [records]);
|
|
107
|
-
// 获取数据源列表
|
|
108
|
-
const fetchData = async (param) => {
|
|
109
|
-
let pageNo = 1;
|
|
110
|
-
const pageSize = 200;
|
|
111
|
-
let records = [];
|
|
112
|
-
let total = 99999;
|
|
113
|
-
for (let index = 0; index < Math.floor(total / pageSize) + 1; index++) {
|
|
114
|
-
const data = await callDataSource({
|
|
115
|
-
dataSourceName: param.dataSourceName,
|
|
116
|
-
viewId: param.viewId,
|
|
117
|
-
methodName: param.methodName,
|
|
118
|
-
params: {
|
|
119
|
-
pageNo: pageNo,
|
|
120
|
-
pageSize: pageSize,
|
|
121
|
-
where: param.params,
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
pageNo = pageNo + 1;
|
|
125
|
-
if (data === null || data === void 0 ? void 0 : data.records) {
|
|
126
|
-
total = (data === null || data === void 0 ? void 0 : data.total) || 0;
|
|
127
|
-
records = records.concat(data === null || data === void 0 ? void 0 : data.records);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (records) {
|
|
131
|
-
setRecords(records);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
React.useEffect(() => {
|
|
135
|
-
// 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
|
|
136
|
-
if (format === 'x-enum' && enumName) {
|
|
137
|
-
fetchEnumData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
|
|
138
|
-
}
|
|
139
|
-
}, [enumName]);
|
|
140
|
-
// 获取自定义选项集
|
|
141
|
-
const fetchEnumData = async (param) => {
|
|
142
|
-
var _a, _b, _c;
|
|
143
|
-
const data = await callWedaApi({
|
|
144
|
-
action: 'DescribeGeneralOptionsDetailList',
|
|
145
|
-
data: param,
|
|
146
|
-
});
|
|
147
|
-
const config = (_c = destr((_b = (_a = data === null || data === void 0 ? void 0 : data.Items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Config)) !== null && _c !== void 0 ? _c : [];
|
|
148
|
-
const enumOption = config.map((item) => {
|
|
149
|
-
return {
|
|
150
|
-
label: item.value,
|
|
151
|
-
value: item.key,
|
|
152
|
-
};
|
|
153
|
-
});
|
|
154
|
-
setOption(enumOption);
|
|
73
|
+
let params = {
|
|
74
|
+
controlledValue: range,
|
|
155
75
|
};
|
|
76
|
+
if (format === 'father-son' || format === 'related') {
|
|
77
|
+
params = {
|
|
78
|
+
format,
|
|
79
|
+
dataSourceName,
|
|
80
|
+
viewId,
|
|
81
|
+
where,
|
|
82
|
+
primaryField,
|
|
83
|
+
controlledValue: range,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
else if (format === 'x-enum') {
|
|
87
|
+
params = {
|
|
88
|
+
format,
|
|
89
|
+
enumName,
|
|
90
|
+
controlledValue: range,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const [options] = useOptions(params);
|
|
156
94
|
React.useEffect(() => {
|
|
157
95
|
var _a, _b, _c, _d, _e;
|
|
158
96
|
let hasChange = false;
|
|
@@ -179,6 +117,7 @@ function SelectPc({ where, dataSourceName, viewId, format, primaryField, enumNam
|
|
|
179
117
|
}
|
|
180
118
|
if (hasChange) {
|
|
181
119
|
prevDefaultRef.current = {
|
|
120
|
+
defaultValue,
|
|
182
121
|
defaultDate,
|
|
183
122
|
defaultTime,
|
|
184
123
|
defaultRegion,
|
|
@@ -186,7 +125,7 @@ function SelectPc({ where, dataSourceName, viewId, format, primaryField, enumNam
|
|
|
186
125
|
};
|
|
187
126
|
}
|
|
188
127
|
});
|
|
189
|
-
|
|
128
|
+
React.useEffect(() => {
|
|
190
129
|
if (mode == 'region' || mode == 'mutiRegion') {
|
|
191
130
|
if (regionData.length < 1) {
|
|
192
131
|
getAreaCode().then((value) => {
|
|
@@ -235,12 +174,12 @@ function SelectPc({ where, dataSourceName, viewId, format, primaryField, enumNam
|
|
|
235
174
|
const createDropdown = () => {
|
|
236
175
|
switch (mode) {
|
|
237
176
|
case 'selector':
|
|
238
|
-
return (React.createElement(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
177
|
+
return (React.createElement(PureSelectPc, { size: size, onChange: (value) => {
|
|
178
|
+
var _a;
|
|
179
|
+
onChange && onChange(value);
|
|
180
|
+
(_a = events === null || events === void 0 ? void 0 : events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value });
|
|
181
|
+
setSelectedValue(value);
|
|
182
|
+
}, value: selectedValue, placeholder: placeholder, options: options }));
|
|
244
183
|
case 'date': {
|
|
245
184
|
const now = moment();
|
|
246
185
|
const start = startDate
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare type OptionItem = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
declare type IRelationFetchOptions = {
|
|
6
|
+
format: 'father-son' | 'related';
|
|
7
|
+
viewId: string;
|
|
8
|
+
dataSourceName: string;
|
|
9
|
+
where: unknown;
|
|
10
|
+
primaryField: string;
|
|
11
|
+
controlledValue: OptionItem[];
|
|
12
|
+
};
|
|
13
|
+
declare type IEnumFetchOptions = {
|
|
14
|
+
format: 'x-enum';
|
|
15
|
+
enumName: string;
|
|
16
|
+
controlledValue: OptionItem[];
|
|
17
|
+
};
|
|
18
|
+
export declare type IUseoptionsParams = (IRelationFetchOptions | IEnumFetchOptions | {
|
|
19
|
+
format?: string;
|
|
20
|
+
controlledValue: OptionItem[];
|
|
21
|
+
}) & {
|
|
22
|
+
callWedaApi?: (params: any) => Promise<any> | any;
|
|
23
|
+
callDataSource?: (params: any) => Promise<any>;
|
|
24
|
+
};
|
|
25
|
+
export declare function useOptions(params: IUseoptionsParams): [options: OptionItem[]];
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useAsync, useDeepCompareEffect } from '@react-hookz/web';
|
|
2
|
+
import destr from 'destr';
|
|
3
|
+
import { useCallback, useEffect } from 'react';
|
|
4
|
+
import { getWhereList } from '../../../utils/platform';
|
|
5
|
+
import { callDataSource as tcbCallDataSource, callWedaApi as tcbCallWedaApi, } from '../../../utils/tcb';
|
|
6
|
+
import { useSyncValue } from '../../../utils/useSyncValue';
|
|
7
|
+
const formatNeedDataFetch = ['father-son', 'related', 'x-enum'];
|
|
8
|
+
export function useOptions(params) {
|
|
9
|
+
const { format, controlledValue, callDataSource = tcbCallDataSource, callWedaApi = tcbCallWedaApi, ...restOptions } = params;
|
|
10
|
+
// 获取自定义选项集
|
|
11
|
+
const fetchEnumData = useCallback(async (param) => {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const data = await callWedaApi({
|
|
14
|
+
action: 'DescribeGeneralOptionsDetailList',
|
|
15
|
+
data: param,
|
|
16
|
+
});
|
|
17
|
+
const config = (_c = destr((_b = (_a = data === null || data === void 0 ? void 0 : data.Items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Config)) !== null && _c !== void 0 ? _c : [];
|
|
18
|
+
const enumOption = config.map((item) => {
|
|
19
|
+
return {
|
|
20
|
+
label: item.value,
|
|
21
|
+
value: item.key,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return enumOption;
|
|
25
|
+
}, [callWedaApi]);
|
|
26
|
+
const fetchData = useCallback(async (param) => {
|
|
27
|
+
let pageNo = 1;
|
|
28
|
+
const pageSize = 200;
|
|
29
|
+
let records = [];
|
|
30
|
+
let total = 99999;
|
|
31
|
+
for (let index = 0; index < Math.floor(total / pageSize) + 1; index++) {
|
|
32
|
+
const data = await callDataSource({
|
|
33
|
+
dataSourceName: param.dataSourceName,
|
|
34
|
+
viewId: param.viewId,
|
|
35
|
+
methodName: param.methodName,
|
|
36
|
+
params: {
|
|
37
|
+
pageNo: pageNo,
|
|
38
|
+
pageSize: pageSize,
|
|
39
|
+
where: param.params,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
pageNo = pageNo + 1;
|
|
43
|
+
if (data === null || data === void 0 ? void 0 : data.records) {
|
|
44
|
+
total = (data === null || data === void 0 ? void 0 : data.total) || 0;
|
|
45
|
+
records = records.concat(data === null || data === void 0 ? void 0 : data.records);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return records;
|
|
49
|
+
}, [callDataSource]);
|
|
50
|
+
const [options, setOptions] = useSyncValue(controlledValue);
|
|
51
|
+
const [state, actions] = useAsync(async () => {
|
|
52
|
+
if (format === 'father-son' || format === 'related') {
|
|
53
|
+
const { dataSourceName, viewId, where, primaryField } = restOptions;
|
|
54
|
+
const whereEffected = [].concat(getWhereList(where));
|
|
55
|
+
const results = await fetchData({
|
|
56
|
+
dataSourceName,
|
|
57
|
+
viewId,
|
|
58
|
+
methodName: 'wedaGetRecords',
|
|
59
|
+
params: whereEffected,
|
|
60
|
+
});
|
|
61
|
+
if (primaryField) {
|
|
62
|
+
if (results && results.length !== 0) {
|
|
63
|
+
const option = results.map((item) => {
|
|
64
|
+
return {
|
|
65
|
+
label: item[primaryField] || item._id,
|
|
66
|
+
value: item._id,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
return option;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// 留一个空的weui才正常
|
|
73
|
+
return [{ label: '', value: '' }];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return results.map((opt) => ({
|
|
77
|
+
label: opt._id,
|
|
78
|
+
value: opt._id,
|
|
79
|
+
})); // 兜底 正常来说一定有primaryField
|
|
80
|
+
}
|
|
81
|
+
if (format === 'x-enum') {
|
|
82
|
+
// 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
|
|
83
|
+
const { enumName } = restOptions;
|
|
84
|
+
return fetchEnumData({
|
|
85
|
+
OptNameList: [enumName],
|
|
86
|
+
PageIndex: 1,
|
|
87
|
+
PageSize: 10,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}, []);
|
|
91
|
+
useDeepCompareEffect(() => {
|
|
92
|
+
if (formatNeedDataFetch.includes(format)) {
|
|
93
|
+
actions.execute();
|
|
94
|
+
}
|
|
95
|
+
// @ts-ignore not check
|
|
96
|
+
}, [format, restOptions.enumName, restOptions.where]);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (state.status === 'success') {
|
|
99
|
+
setOptions(state.result);
|
|
100
|
+
}
|
|
101
|
+
}, [state, state.status]);
|
|
102
|
+
return [options];
|
|
103
|
+
}
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
padding: 0;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
.weda-uploader-pc .weda-uploader-pc__header {
|
|
7
|
-
}
|
|
8
|
-
|
|
9
6
|
.weda-uploader-pc .weda-uploader-pc__title {
|
|
10
7
|
color: #000000;
|
|
11
8
|
line-height: 1.42857rem;
|
|
@@ -34,6 +31,7 @@
|
|
|
34
31
|
.weda-uploader-pc .weda-uploader-pc__input-box {
|
|
35
32
|
margin-bottom: 0.57143rem;
|
|
36
33
|
}
|
|
34
|
+
|
|
37
35
|
.weda-uploader-pc.cloudbase_standard .weda-uploader-pc__body {
|
|
38
36
|
margin-bottom: 0;
|
|
39
37
|
}
|
|
@@ -41,6 +39,7 @@
|
|
|
41
39
|
.weda-uploader-pc.cloudbase_standard .weda-uploader-pc__input-box {
|
|
42
40
|
margin-bottom: 0;
|
|
43
41
|
}
|
|
42
|
+
|
|
44
43
|
.weda-uploader-pc.cloudbase_standard .weda-uploader-pc__image-list {
|
|
45
44
|
margin-left: 0.57143rem;
|
|
46
45
|
}
|
|
@@ -56,6 +55,10 @@
|
|
|
56
55
|
cursor: zoom-in;
|
|
57
56
|
}
|
|
58
57
|
|
|
58
|
+
.weda-uploader-pc__input-box .wedatea2td-disabled {
|
|
59
|
+
cursor: not-allowed;
|
|
60
|
+
}
|
|
61
|
+
|
|
59
62
|
.weda-uploader-pc .weda-uploader-pc__action {
|
|
60
63
|
display: none;
|
|
61
64
|
position: absolute;
|
|
@@ -71,10 +74,12 @@
|
|
|
71
74
|
.weui-uploader.horizontal {
|
|
72
75
|
display: flex;
|
|
73
76
|
}
|
|
77
|
+
|
|
74
78
|
.weui-uploader.horizontal .weui-uploader__hd {
|
|
75
79
|
display: inline-block;
|
|
76
80
|
align-self: center;
|
|
77
81
|
}
|
|
82
|
+
|
|
78
83
|
.weda-uploader-pc.horizontal {
|
|
79
84
|
display: flex;
|
|
80
85
|
justify-content: space-between;
|
|
@@ -92,6 +97,7 @@
|
|
|
92
97
|
display: flex;
|
|
93
98
|
flex: 1;
|
|
94
99
|
}
|
|
100
|
+
|
|
95
101
|
.weui-uploader.vertical .weui-uploader__title {
|
|
96
102
|
flex: unset;
|
|
97
103
|
}
|
|
@@ -99,6 +105,7 @@
|
|
|
99
105
|
.weda-ui .weui-uploader.horizontal .weui-uploader__bd {
|
|
100
106
|
padding: 1.14286rem 0;
|
|
101
107
|
}
|
|
108
|
+
|
|
102
109
|
.weda-ui .weui-uploader.vertical .weui-uploader__bd {
|
|
103
110
|
padding: 1.14286rem;
|
|
104
111
|
}
|
|
@@ -3,7 +3,7 @@ import type { CommonFormPropsType } from '../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* H5端
|
|
5
5
|
*/
|
|
6
|
-
export declare function ImageUploaderH5({ title, maxUploadCount, maxSize, acceptTypes, className, id, events, layout, defaultValue, single, requiredFlag, onChange, style, }: H5UploaderProps): JSX.Element;
|
|
6
|
+
export declare function ImageUploaderH5({ title, maxUploadCount, maxSize, acceptTypes, className, id, events, layout, defaultValue, single, disabled, requiredFlag, onChange, style, }: H5UploaderProps): JSX.Element;
|
|
7
7
|
export interface SingleImageProps {
|
|
8
8
|
src: string;
|
|
9
9
|
deleteBySrc: (url: string) => void;
|
|
@@ -10,7 +10,7 @@ const uploadPath = 'weda-uploader';
|
|
|
10
10
|
/**
|
|
11
11
|
* H5端
|
|
12
12
|
*/
|
|
13
|
-
export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTypes, className, id, events, layout, defaultValue, single = false, requiredFlag = false, onChange, style, }) {
|
|
13
|
+
export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTypes, className, id, events, layout, defaultValue, single = false, disabled = false, requiredFlag = false, onChange, style, }) {
|
|
14
14
|
const cls = classNames({
|
|
15
15
|
'weda-ui': true,
|
|
16
16
|
'weui-cells': true,
|
|
@@ -123,24 +123,23 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
|
|
|
123
123
|
React.createElement("div", { className: "weui-uploader__file-content" },
|
|
124
124
|
progress,
|
|
125
125
|
"%")))),
|
|
126
|
-
showAdd && (React.createElement("div", { className: "weui-uploader__input-box" },
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} })))))));
|
|
126
|
+
showAdd && (React.createElement("div", { className: "weui-uploader__input-box" }, !disabled && (React.createElement("input", { id: "uploaderInput", className: "weui-uploader__input", type: "file", accept: accepts.join(','), multiple: true, onChange: (e) => {
|
|
127
|
+
const files = [...e.target.files];
|
|
128
|
+
if (files.some((f) => f.size > maxSize * 1024 * 1024)) {
|
|
129
|
+
weui.alert('请上传不超过10M的图片');
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
if (files.length > finalMaxImgCount) {
|
|
133
|
+
// 防止一下子选择过多文件
|
|
134
|
+
weui.alert(`最多只能上传${finalMaxImgCount}张图片,请重新选择`);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (fileIdList.length + files.length > finalMaxImgCount) {
|
|
138
|
+
weui.alert(`最多只能上传${finalMaxImgCount}张图片`);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
files.forEach((f) => uploadToTcb(f));
|
|
142
|
+
} }))))))));
|
|
144
143
|
}
|
|
145
144
|
function SingleImage({ src, deleteBySrc }) {
|
|
146
145
|
const [error, setError] = React.useState(false);
|
|
@@ -36,7 +36,7 @@ export function UploaderPC({ layout, className, id, style, title, tips, ...props
|
|
|
36
36
|
}
|
|
37
37
|
export function UploaderPCInner(props) {
|
|
38
38
|
const { tips = '', btnTitle = '上传图片', maxUploadCount = 9, maxSize = 10, value: defaultValue, // 需要兼容 cloud:和https: 协议,需要兼容 字符串和字符串数组
|
|
39
|
-
acceptTypes = IMAGE_TYPES, uploadPath = 'weda-uploader', events = emptyObject, single = false, onChange, } = props;
|
|
39
|
+
acceptTypes = IMAGE_TYPES, uploadPath = 'weda-uploader', events = emptyObject, single = false, disabled = false, onChange, } = props;
|
|
40
40
|
// 上传中
|
|
41
41
|
const [uploading, setUploading] = React.useState(false);
|
|
42
42
|
//上传进度
|
|
@@ -146,13 +146,16 @@ export function UploaderPCInner(props) {
|
|
|
146
146
|
"\u4E0A\u4F20",
|
|
147
147
|
progress,
|
|
148
148
|
"%..."))))),
|
|
149
|
-
React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, ((
|
|
149
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, disabled ? (React.createElement("li", { className: "_weda-fn-upload-result__item wedatea2td-disabled" },
|
|
150
|
+
React.createElement("div", { className: "_weda-fn-upload-result__status" },
|
|
151
|
+
React.createElement("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }),
|
|
152
|
+
React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" }, btnTitle)))) : (((!single && fileIDList.length < maxUploadCount) ||
|
|
150
153
|
(single && fileIDList.length < 1)) && ( // single 模式时,仅当数组为空时显示
|
|
151
154
|
React.createElement(Upload, { ...extraProps, beforeUpload: beforeHandle },
|
|
152
155
|
React.createElement("li", { className: "_weda-fn-upload-result__item _weda-fn-upload-result__item--upload" },
|
|
153
156
|
React.createElement("div", { className: "_weda-fn-upload-result__status" },
|
|
154
157
|
React.createElement("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }),
|
|
155
|
-
React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" }, btnTitle)))))))));
|
|
158
|
+
React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" }, btnTitle))))))))));
|
|
156
159
|
}
|
|
157
160
|
export const TcbImage = (props) => {
|
|
158
161
|
const { fileID, isZoom, ...rest } = props;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { useSetState } from '../../utils/useSetState';
|
|
3
3
|
import classNames from '../../utils/classnames';
|
|
4
4
|
import Editor, { convertEditorStateToHTML } from 'kedao';
|
|
@@ -56,24 +56,27 @@ label, labelVisible, value: initialValue, readOnly, layout, requiredFlag, onChan
|
|
|
56
56
|
const state = createStateFromContent(initialValue, {});
|
|
57
57
|
setEditorState(state);
|
|
58
58
|
}, []);
|
|
59
|
-
const extendControls =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{ type: 'IMAGE', url }
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
];
|
|
59
|
+
const extendControls = useMemo(() => {
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
key: 'richtext-uploader',
|
|
63
|
+
type: 'component',
|
|
64
|
+
component: (React.createElement(CustomUploader, { acceptTypes: acceptTypes, maxSize: maxSize, cloudPath: cloudPath, onChange: (url) => {
|
|
65
|
+
const state = ContentUtils.insertMedias(latestEditorState.current, [{ type: 'IMAGE', url }]);
|
|
66
|
+
setEditorState(state);
|
|
67
|
+
} })),
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}, [setEditorState, acceptTypes, maxSize, cloudPath, ContentUtils]);
|
|
71
71
|
// 修改img显示逻辑
|
|
72
72
|
const blockRenderFn = (contentBlock, { editor, editorState }) => {
|
|
73
|
+
var _a;
|
|
73
74
|
if (contentBlock.getType() === 'atomic') {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const entityKey = contentBlock.getEntityAt(0);
|
|
76
|
+
if (!entityKey) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const entity = (_a = editorState === null || editorState === void 0 ? void 0 : editorState.getCurrentContent()) === null || _a === void 0 ? void 0 : _a.getEntity(entityKey);
|
|
77
80
|
if (entity.getType() === 'IMAGE') {
|
|
78
81
|
return {
|
|
79
82
|
component: RichTextImg,
|
|
@@ -260,7 +263,7 @@ export const RichTextImg = ({ contentState, block }) => {
|
|
|
260
263
|
React.createElement("div", { className: "bf-media" },
|
|
261
264
|
React.createElement("div", { draggable: "true", className: "bf-image", style: { float: 'left' } },
|
|
262
265
|
React.createElement("div", { style: { position: 'relative', display: 'inline-block' } },
|
|
263
|
-
React.createElement("img", { src: src,
|
|
266
|
+
React.createElement("img", { src: src, style: { maxWidth: '100%', width }, onError: () => {
|
|
264
267
|
setSrc(defaultBase64);
|
|
265
268
|
setWidth('80px');
|
|
266
269
|
} }),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export function serde(a: any): any;
|
|
2
|
-
export default function _default(a: any, b: any, shouldSerde?: boolean):
|
|
2
|
+
export default function _default(a: any, b: any, shouldSerde?: boolean): any;
|
package/dist/web/utils/tcb.d.ts
CHANGED
|
@@ -11,7 +11,11 @@ export function getTempFileURL(data: any): Promise<any>;
|
|
|
11
11
|
/**
|
|
12
12
|
* 云函数获取数据
|
|
13
13
|
*/
|
|
14
|
-
export function callDataSource(param: any): Promise<any>;
|
|
14
|
+
export function callDataSource(param: any, throwError?: boolean): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* 云函数获取连接器数据
|
|
17
|
+
*/
|
|
18
|
+
export function callConnector(param: any, throwError?: boolean): Promise<any>;
|
|
15
19
|
/**
|
|
16
20
|
* 云API:获取用户自定义导航内容
|
|
17
21
|
* param
|
package/dist/web/utils/tcb.js
CHANGED
|
@@ -34,19 +34,42 @@ export async function getTempFileURL(data) {
|
|
|
34
34
|
/**
|
|
35
35
|
* 云函数获取数据
|
|
36
36
|
*/
|
|
37
|
-
export async function callDataSource(param) {
|
|
37
|
+
export async function callDataSource(param, throwError = false) {
|
|
38
38
|
var _a, _b, _c;
|
|
39
|
-
const {
|
|
39
|
+
const { dataSourceName, methodName, params } = param;
|
|
40
40
|
try {
|
|
41
41
|
const res = await ((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.cloud) === null || _b === void 0 ? void 0 : _b.callDataSource) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
42
|
+
dataSourceName,
|
|
43
|
+
methodName,
|
|
42
44
|
params,
|
|
45
|
+
}));
|
|
46
|
+
return res;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('callDataSource: ', error);
|
|
50
|
+
if (throwError)
|
|
51
|
+
throw error;
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 云函数获取连接器数据
|
|
57
|
+
*/
|
|
58
|
+
export async function callConnector(param, throwError = false) {
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
const { dataSourceName, methodName, params } = param;
|
|
61
|
+
try {
|
|
62
|
+
const res = await ((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.cloud) === null || _b === void 0 ? void 0 : _b.callConnector) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
43
63
|
dataSourceName,
|
|
44
64
|
methodName,
|
|
65
|
+
params,
|
|
45
66
|
}));
|
|
46
67
|
return res;
|
|
47
68
|
}
|
|
48
69
|
catch (error) {
|
|
49
|
-
console.error('
|
|
70
|
+
console.error('callConnector: ', error);
|
|
71
|
+
if (throwError)
|
|
72
|
+
throw error;
|
|
50
73
|
return {};
|
|
51
74
|
}
|
|
52
75
|
}
|