@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,5 @@
|
|
|
1
1
|
// 平台类方法,如 BOM、DOM、区分 h5 和 pc 端
|
|
2
|
-
import {
|
|
2
|
+
import { useMediaQuery } from '@react-hookz/web';
|
|
3
3
|
/**
|
|
4
4
|
* 当前环境是否为 H5 端
|
|
5
5
|
*/
|
|
@@ -19,14 +19,85 @@ export const isH5Platform = () => {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* 判断当前是否是 cloud
|
|
22
|
+
* 判断当前是否是 cloud 开头的文件协议
|
|
23
23
|
*/
|
|
24
24
|
export const isCloudFileID = (url) => {
|
|
25
25
|
return /^cloud:\/\/.*/.test(url);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* 判断当前是否是 http/https 开头的文件协议
|
|
30
|
+
*/
|
|
31
|
+
export const isHttpFileID = (url) => {
|
|
32
|
+
return /^http(s?):\/\/.*/.test(url);
|
|
33
|
+
};
|
|
34
|
+
|
|
28
35
|
export function usePlatform() {
|
|
29
|
-
const smallScreen =
|
|
30
|
-
const touchDevice =
|
|
31
|
-
return
|
|
32
|
-
}
|
|
36
|
+
const smallScreen = useMediaQuery('(max-width: 1024px)') ?? isH5Platform();
|
|
37
|
+
const touchDevice = useMediaQuery('(pointer:coarse)') ?? smallScreen;
|
|
38
|
+
return touchDevice || smallScreen ? 'h5' : 'pc';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 过滤非字符串,返回字符串数组
|
|
43
|
+
* 用于兼容单个组件和组件数组
|
|
44
|
+
*/
|
|
45
|
+
export const filterStrList = (value) => {
|
|
46
|
+
return [].concat(value).filter((d) => typeof d === 'string' && d !== '');
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 文件字节转换
|
|
51
|
+
*/
|
|
52
|
+
export const transSize = (size) => {
|
|
53
|
+
const b = parseInt(size) || 0;
|
|
54
|
+
const getBig = (d) => Math.ceil(d / 1024) || 0;
|
|
55
|
+
if (b < 1024) {
|
|
56
|
+
return `${size}B`;
|
|
57
|
+
}
|
|
58
|
+
const k = getBig(size);
|
|
59
|
+
if (k < 1024) {
|
|
60
|
+
return `${k}K`;
|
|
61
|
+
}
|
|
62
|
+
const m = getBig(k);
|
|
63
|
+
if (m < 1024) {
|
|
64
|
+
return `${m}M`;
|
|
65
|
+
}
|
|
66
|
+
const g = getBig(m);
|
|
67
|
+
return `${g}G`;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 链接转换为下载
|
|
72
|
+
*/
|
|
73
|
+
export const downloadFile = (url) => {
|
|
74
|
+
if (!url) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const urlObj = new URL(url);
|
|
78
|
+
urlObj.searchParams.append('response-content-disposition', 'attawchment');
|
|
79
|
+
const urls = urlObj.toString();
|
|
80
|
+
window.open(urls);
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
window.URL.revokeObjectURL(urls);
|
|
83
|
+
}, 0);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 文件名截取,保留后缀类型
|
|
88
|
+
*/
|
|
89
|
+
export const cutFileTitle = (str = '', count = 10) => {
|
|
90
|
+
let [title, type] = [str, ''];
|
|
91
|
+
const dotIndex = `${str}`.lastIndexOf('.');
|
|
92
|
+
if (dotIndex > -1) {
|
|
93
|
+
type = str.slice(dotIndex + 1);
|
|
94
|
+
title = str.slice(0, dotIndex);
|
|
95
|
+
}
|
|
96
|
+
if (title.length > count) {
|
|
97
|
+
title = `${title.slice(0, 7)}...${title.slice(-3)}`;
|
|
98
|
+
}
|
|
99
|
+
if (type) {
|
|
100
|
+
title = `${title}.${type}`;
|
|
101
|
+
}
|
|
102
|
+
return title;
|
|
103
|
+
};
|
package/src/web/utils/tcb.js
CHANGED
|
@@ -35,11 +35,3 @@ export async function getTempFileURL(data) {
|
|
|
35
35
|
return await window?.app?.cloud?.getTempFileURL(data);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
export async function getDescribeGeneralOptionsDetailList(params) {
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
const callWedaApi = window?.app?.cloud?.callWedaApi;
|
|
42
|
-
if (callWedaApi) {
|
|
43
|
-
return await callWedaApi(params);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useSetState = <T extends object>(
|
|
4
|
+
initialState: T = {} as T
|
|
5
|
+
): [T, (patch: Partial<T> | ((prevState: T) => Partial<T>)) => void] => {
|
|
6
|
+
const [state, set] = useState<T>(initialState);
|
|
7
|
+
const setState = useCallback((patch) => {
|
|
8
|
+
set((prevState) =>
|
|
9
|
+
Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch)
|
|
10
|
+
);
|
|
11
|
+
}, []);
|
|
12
|
+
|
|
13
|
+
return [state, setState];
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { usePrevious } from '@react-hookz/web';
|
|
3
|
+
|
|
4
|
+
type TComparotor<T = any> = (a: T, b: T) => boolean;
|
|
5
|
+
export function useSyncValue<T>(
|
|
6
|
+
defaultValue: T,
|
|
7
|
+
comparotor: TComparotor = Object.is
|
|
8
|
+
): [T, (value: T) => void] {
|
|
9
|
+
const [stateValue, setStateValue] = useState(defaultValue);
|
|
10
|
+
const prevValue = usePrevious(defaultValue);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!comparotor(prevValue, defaultValue)) {
|
|
13
|
+
setStateValue(defaultValue);
|
|
14
|
+
}
|
|
15
|
+
}, [defaultValue]);
|
|
16
|
+
return [stateValue, setStateValue];
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gitdir: ../../../.git/modules/src/web/wedatheme
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
registry=https://mirrors.tencent.com/npm/
|