@cloudbase/weda-ui 0.2.15 → 0.2.16
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/package.json +10 -7
- package/src/configs/components/calendar.json +75 -0
- package/src/configs/components/carousel.json +273 -0
- package/src/configs/components/chart/statisticsCard.json +331 -0
- package/src/configs/components/dataView.json +139 -0
- package/src/configs/components/form/location.json +152 -0
- package/src/configs/components/form/uploaderFile.json +2 -1
- package/src/configs/components/graphicCard.json +399 -0
- package/src/configs/components/link.json +2 -2
- package/src/configs/components/listView.json +230 -0
- package/src/configs/components/navLayout.json +350 -0
- package/src/configs/components/swiper.json +3 -3
- package/src/configs/index.js +16 -0
- package/src/mp/components/button/index.js +12 -13
- package/src/mp/components/button/index.wxml +1 -1
- package/src/mp/components/calendar/arrowright--line.svg +11 -0
- package/src/mp/components/calendar/index.js +238 -0
- package/src/mp/components/calendar/index.json +4 -0
- package/src/mp/components/calendar/index.wxml +37 -0
- package/src/mp/components/calendar/index.wxss +178 -0
- package/src/mp/components/carousel/index.js +88 -0
- package/src/mp/components/carousel/index.json +7 -0
- package/src/mp/components/carousel/index.wxml +6 -0
- package/src/mp/components/chart/statisticsCard/index.js +226 -0
- package/src/mp/components/chart/statisticsCard/index.json +4 -0
- package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
- package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
- package/src/mp/components/dataView/index.js +34 -0
- package/src/mp/components/dataView/index.json +7 -0
- package/src/mp/components/dataView/index.wxml +15 -0
- package/src/mp/components/dataView/index.wxss +0 -0
- package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
- package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
- package/src/mp/components/form/location/index.js +341 -0
- package/src/mp/components/form/location/index.json +6 -0
- package/src/mp/components/form/location/index.wxml +25 -0
- package/src/mp/components/form/location/index.wxss +91 -0
- package/src/mp/components/form/uploader/index.js +39 -35
- package/src/mp/components/form/uploaderFile/index.js +61 -14
- package/src/mp/components/graphicCard/chevron-right.svg +3 -0
- package/src/mp/components/graphicCard/index.js +205 -0
- package/src/mp/components/graphicCard/index.json +4 -0
- package/src/mp/components/graphicCard/index.wxml +29 -0
- package/src/mp/components/graphicCard/index.wxss +157 -0
- package/src/mp/components/image/index.js +0 -1
- package/src/mp/components/listView/arrow-right-line.svg +3 -0
- package/src/mp/components/listView/index.js +286 -0
- package/src/mp/components/listView/index.json +4 -0
- package/src/mp/components/listView/index.wxml +40 -0
- package/src/mp/components/listView/index.wxss +150 -0
- package/src/mp/components/listView/more-line.svg +3 -0
- package/src/mp/components/navLayout/index.js +123 -0
- package/src/mp/components/navLayout/index.json +7 -0
- package/src/mp/components/navLayout/index.wxml +25 -0
- package/src/mp/components/navLayout/index.wxss +1193 -0
- package/src/mp/components/swiper/index.wxml +2 -0
- package/src/mp/index.json +9 -1
- package/src/mp/utils/debounce.js +133 -0
- package/src/mp/utils/dr_square_point.js +25 -0
- package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
- package/src/mp/utils/spark-md5.js +776 -0
- package/src/mp/utils/tcb.js +18 -0
- package/src/web/components/calendar/index.css +382 -0
- package/src/web/components/calendar/index.jsx +312 -0
- package/src/web/components/calendar/util.js +90 -0
- package/src/web/components/carousel/index.css +119 -0
- package/src/web/components/carousel/index.tsx +417 -0
- package/src/web/components/chart/statisticsCard/index.css +62 -0
- package/src/web/components/chart/statisticsCard/index.tsx +286 -0
- package/src/web/components/chart/statisticsCard/interface.ts +14 -0
- package/src/web/components/dataView/index.tsx +20 -0
- package/src/web/components/dataView/interface.ts +6 -0
- package/src/web/components/form/location/common/mapChoose.css +178 -0
- package/src/web/components/form/location/common/mapChoose.jsx +343 -0
- package/src/web/components/form/location/common/mapView.jsx +190 -0
- package/src/web/components/form/location/common/propsConfig.js +54 -0
- package/src/web/components/form/location/common/selectModal.css +44 -0
- package/src/web/components/form/location/common/selectModal.jsx +82 -0
- package/src/web/components/form/location/common/useLocationInfo.js +100 -0
- package/src/web/components/form/location/components/LocationH5/index.css +243 -0
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
- package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
- package/src/web/components/form/location/components/LocationPC/index.css +44 -0
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
- package/src/web/components/form/location/constants.js +4 -0
- package/src/web/components/form/location/index.css +0 -0
- package/src/web/components/form/location/index.jsx +25 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +16 -10
- package/src/web/components/form/uploader/uploader.pc.tsx +15 -11
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +122 -107
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +22 -19
- package/src/web/components/graphicCard/index.css +163 -0
- package/src/web/components/graphicCard/index.tsx +309 -0
- package/src/web/components/image/image.tsx +0 -1
- package/src/web/components/index.js +12 -0
- package/src/web/components/listView/arrow-right-line.svg +3 -0
- package/src/web/components/listView/index.css +139 -0
- package/src/web/components/listView/index.tsx +354 -0
- package/src/web/components/listView/interface.ts +98 -0
- package/src/web/components/navLayout/index.css +332 -0
- package/src/web/components/navLayout/index.tsx +247 -0
- package/src/web/components/tabs/index.tsx +2 -2
- package/src/web/components/tabs/tabs.h5.tsx +7 -4
- package/src/web/components/uploaderFileView/index.css +9 -9
- package/src/web/components/uploaderFileView/index.jsx +32 -23
- package/src/web/types.d.ts +15 -14
- package/src/web/utils/debounce.js +98 -0
- package/src/web/utils/platform.js +31 -0
- package/src/web/utils/tcb.js +35 -0
- package/src/web/utils/tmap.js +4 -0
|
@@ -1,43 +1,52 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { UploadFilePc } from '../form/uploaderFile/uploadFile.pc';
|
|
3
|
+
import { UploadFileH5 } from '../form/uploaderFile/uploadFile.h5';
|
|
3
4
|
import {
|
|
4
5
|
filterStrList,
|
|
5
6
|
isCloudFileID,
|
|
6
7
|
downloadFile,
|
|
8
|
+
usePlatform,
|
|
9
|
+
transFileCloudidToName,
|
|
7
10
|
} from '../../utils/platform';
|
|
8
11
|
import { getTempFileURL } from '../../utils/tcb';
|
|
9
12
|
import './index.css';
|
|
10
13
|
|
|
11
|
-
const CLASS_PREFIX = 'weda-file-view
|
|
14
|
+
const CLASS_PREFIX = 'weda-uploader-file-view';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
15
|
-
* single 表示单个文件回显
|
|
17
|
+
* 上传文件回显,传showType强制展示某端样式,否则根据平台自动判断
|
|
16
18
|
*/
|
|
17
19
|
export default function UploaderFileView({
|
|
18
20
|
value,
|
|
19
21
|
className,
|
|
20
|
-
single = true,
|
|
22
|
+
single = true, // 展示为单行 a 标签
|
|
23
|
+
showType, // 展示端为 pc 还是 h5 样式
|
|
21
24
|
...rest
|
|
22
25
|
}) {
|
|
23
26
|
const fileIDList = filterStrList(value);
|
|
24
|
-
if(single){
|
|
25
|
-
return <FileView fileID={fileIDList[0]}/>;
|
|
26
|
-
}else{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
if (single) {
|
|
28
|
+
return <FileView fileID={fileIDList[0]} />;
|
|
29
|
+
} else {
|
|
30
|
+
const platform = usePlatform();
|
|
31
|
+
const showTypeMix = showType ? (showType === 'h5' ? 'h5' : 'pc') : platform;
|
|
32
|
+
const uploadFileProps = {
|
|
33
|
+
...rest,
|
|
34
|
+
className: `${CLASS_PREFIX} ${className}`,
|
|
35
|
+
decorator: null,
|
|
36
|
+
labelVisible: false,
|
|
37
|
+
value: fileIDList,
|
|
38
|
+
isEdit: false,
|
|
39
|
+
};
|
|
40
|
+
return showTypeMix === 'pc' ? (
|
|
41
|
+
<UploadFilePc {...uploadFileProps} />
|
|
42
|
+
) : (
|
|
43
|
+
<UploadFileH5 {...uploadFileProps} />
|
|
35
44
|
);
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
/**
|
|
40
|
-
*
|
|
49
|
+
* 单个文件回显,用在表格里面
|
|
41
50
|
*/
|
|
42
51
|
const FileView = ({ fileID }) => {
|
|
43
52
|
const [src, setSrc] = React.useState('');
|
|
@@ -58,18 +67,18 @@ const FileView = ({ fileID }) => {
|
|
|
58
67
|
|
|
59
68
|
const title = React.useMemo(() => {
|
|
60
69
|
if (isCloudFileID(fileID)) {
|
|
61
|
-
|
|
62
|
-
const lastIndex = `${fileID}`.lastIndexOf('/');
|
|
63
|
-
const name = `${fileID}`.slice(lastIndex + 1);
|
|
64
|
-
const title = name.replace(uuidReg, '');
|
|
65
|
-
return title;
|
|
70
|
+
return transFileCloudidToName(fileID);
|
|
66
71
|
} else {
|
|
67
72
|
return fileID;
|
|
68
73
|
}
|
|
69
74
|
}, [fileID]);
|
|
70
75
|
return (
|
|
71
|
-
|
|
76
|
+
<a
|
|
77
|
+
title={title}
|
|
78
|
+
onClick={() => downloadFile(src)}
|
|
79
|
+
className={`${CLASS_PREFIX}__single`}
|
|
80
|
+
>
|
|
72
81
|
{title}
|
|
73
|
-
|
|
82
|
+
</a>
|
|
74
83
|
);
|
|
75
84
|
};
|
package/src/web/types.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/// <reference types="resize-observer-browser" />
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { any } from 'prop-types';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
export type unknownFunction = (...args: unknown[]) => unknown;
|
|
5
6
|
export interface CommonPropsType {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
id?: string;
|
|
9
|
+
events?: Record<string, unknownFunction>;
|
|
10
|
+
className?: string;
|
|
11
|
+
children?: React.ReactNode | undefined;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
14
|
declare global {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
var app: any;
|
|
16
|
+
interface Window {
|
|
17
|
+
app: any;
|
|
18
|
+
qq: any;
|
|
19
|
+
TMap: any;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function isObject(value) {
|
|
2
|
+
const type = typeof value;
|
|
3
|
+
return value != null && (type === 'object' || type === 'function');
|
|
4
|
+
}
|
|
5
|
+
function debounce(func, wait, options) {
|
|
6
|
+
let lastArgs, lastThis, maxWait, result, timerId, lastCallTime;
|
|
7
|
+
let lastInvokeTime = 0;
|
|
8
|
+
let leading = false;
|
|
9
|
+
let maxing = false;
|
|
10
|
+
let trailing = true;
|
|
11
|
+
if (typeof func !== 'function') {
|
|
12
|
+
throw new TypeError('Expected a function');
|
|
13
|
+
}
|
|
14
|
+
wait = +wait || 0;
|
|
15
|
+
if (isObject(options)) {
|
|
16
|
+
leading = !!options.leading;
|
|
17
|
+
maxing = 'maxWait' in options;
|
|
18
|
+
maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait;
|
|
19
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
20
|
+
}
|
|
21
|
+
function invokeFunc(time) {
|
|
22
|
+
const args = lastArgs;
|
|
23
|
+
const thisArg = lastThis;
|
|
24
|
+
|
|
25
|
+
lastArgs = lastThis = undefined;
|
|
26
|
+
lastInvokeTime = time;
|
|
27
|
+
result = func.apply(thisArg, args);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function startTimer(pendingFunc, wait) {
|
|
31
|
+
return setTimeout(pendingFunc, wait);
|
|
32
|
+
}
|
|
33
|
+
function leadingEdge(time) {
|
|
34
|
+
lastInvokeTime = time;
|
|
35
|
+
timerId = startTimer(timerExpired, wait);
|
|
36
|
+
return leading ? invokeFunc(time) : result;
|
|
37
|
+
}
|
|
38
|
+
function remainingWait(time) {
|
|
39
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
40
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
41
|
+
const timeWaiting = wait - timeSinceLastCall;
|
|
42
|
+
|
|
43
|
+
return maxing
|
|
44
|
+
? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
45
|
+
: timeWaiting;
|
|
46
|
+
}
|
|
47
|
+
function shouldInvoke(time) {
|
|
48
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
49
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
50
|
+
return (
|
|
51
|
+
lastCallTime === undefined ||
|
|
52
|
+
timeSinceLastCall >= wait ||
|
|
53
|
+
timeSinceLastCall < 0 ||
|
|
54
|
+
(maxing && timeSinceLastInvoke >= maxWait)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function timerExpired() {
|
|
58
|
+
const time = Date.now();
|
|
59
|
+
if (shouldInvoke(time)) {
|
|
60
|
+
return trailingEdge(time);
|
|
61
|
+
}
|
|
62
|
+
timerId = startTimer(timerExpired, remainingWait(time));
|
|
63
|
+
}
|
|
64
|
+
function trailingEdge(time) {
|
|
65
|
+
timerId = undefined;
|
|
66
|
+
if (trailing && lastArgs) {
|
|
67
|
+
return invokeFunc(time);
|
|
68
|
+
}
|
|
69
|
+
lastArgs = lastThis = undefined;
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//debouncedFunc
|
|
74
|
+
function debounced(...args) {
|
|
75
|
+
const time = Date.now();
|
|
76
|
+
const isInvoking = shouldInvoke(time);
|
|
77
|
+
|
|
78
|
+
lastArgs = args;
|
|
79
|
+
lastThis = this;
|
|
80
|
+
lastCallTime = time;
|
|
81
|
+
|
|
82
|
+
if (isInvoking) {
|
|
83
|
+
if (timerId === undefined) {
|
|
84
|
+
return leadingEdge(lastCallTime);
|
|
85
|
+
}
|
|
86
|
+
if (maxing) {
|
|
87
|
+
timerId = startTimer(timerExpired, wait);
|
|
88
|
+
return invokeFunc(lastCallTime);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (timerId === undefined) {
|
|
92
|
+
timerId = startTimer(timerExpired, wait);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
return debounced;
|
|
97
|
+
}
|
|
98
|
+
export default debounce;
|
|
@@ -38,6 +38,21 @@ export function usePlatform() {
|
|
|
38
38
|
return touchDevice || smallScreen ? 'h5' : 'pc';
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* 在h5下,判断当前是否是移动浏览器
|
|
43
|
+
*/
|
|
44
|
+
export function inH5IsMobile() {
|
|
45
|
+
try {
|
|
46
|
+
// 区分h5是在编辑器还是移动浏览器
|
|
47
|
+
let is_mobile_ua = false;
|
|
48
|
+
const ua = navigator && navigator.userAgent;
|
|
49
|
+
is_mobile_ua = /Android|webOS|BlackBerry|iPhone|iPad|iPod|iOS/i.test(ua);
|
|
50
|
+
return is_mobile_ua;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.log('isMobile err', e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
/**
|
|
42
57
|
* 过滤非字符串,返回字符串数组
|
|
43
58
|
* 用于兼容单个组件和组件数组
|
|
@@ -101,3 +116,19 @@ export const cutFileTitle = (str = '', count = 10) => {
|
|
|
101
116
|
}
|
|
102
117
|
return title;
|
|
103
118
|
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 判断是否在 ide 中
|
|
122
|
+
*/
|
|
123
|
+
export const isInIde = () => !!window?.app?.cloud?.IS_WEDA_IDE;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* cloudid和文件名转换
|
|
127
|
+
*/
|
|
128
|
+
export const transFileCloudidToName = (fileID) => {
|
|
129
|
+
const uuidReg = /(file-)?[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}-/;
|
|
130
|
+
const lastIndex = `${fileID}`.lastIndexOf('/');
|
|
131
|
+
const name = `${fileID}`.slice(lastIndex + 1);
|
|
132
|
+
const title = name.replace(uuidReg, '');
|
|
133
|
+
return title;
|
|
134
|
+
};
|
package/src/web/utils/tcb.js
CHANGED
|
@@ -35,3 +35,38 @@ export async function getTempFileURL(data) {
|
|
|
35
35
|
return await window?.app?.cloud?.getTempFileURL(data);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 云函数获取数据
|
|
41
|
+
*/
|
|
42
|
+
export async function callDataSource(param) {
|
|
43
|
+
const { params, dataSourceName, methodName } = param;
|
|
44
|
+
try {
|
|
45
|
+
const res = await window?.app?.cloud?.callDataSource?.({
|
|
46
|
+
params,
|
|
47
|
+
dataSourceName,
|
|
48
|
+
methodName,
|
|
49
|
+
});
|
|
50
|
+
return res;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('错误', error);
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 调用微搭后端API服务
|
|
59
|
+
*/
|
|
60
|
+
export async function callWedaApi(param) {
|
|
61
|
+
const { data, action } = param;
|
|
62
|
+
try {
|
|
63
|
+
const res = await window?.app?.cloud?.callWedaApi?.({
|
|
64
|
+
action,
|
|
65
|
+
data,
|
|
66
|
+
});
|
|
67
|
+
return res;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('错误', error);
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
}
|