@cloudbase/weda-ui 0.2.11 → 0.2.12
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 +247 -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 +104 -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/{NormalSelect.jsx → NormalSelect.tsx} +2 -9
- 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 +4 -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.jsx +562 -0
- package/src/web/components/form/uploaderFile/uploadFile.pc.jsx +487 -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 +35 -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} +66 -73
- 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/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/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,9 +1,9 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import * as PropTypes from 'prop-types';
|
|
3
2
|
|
|
4
3
|
import './index.css';
|
|
5
4
|
import classNames from '../../utils/classnames';
|
|
6
5
|
import { useSyncValue } from '../../utils/useSyncValue';
|
|
6
|
+
import {PropsType} from './index';
|
|
7
7
|
|
|
8
8
|
export default function TabsH5({
|
|
9
9
|
tabs,
|
|
@@ -12,7 +12,7 @@ export default function TabsH5({
|
|
|
12
12
|
className,
|
|
13
13
|
style,
|
|
14
14
|
...restProps
|
|
15
|
-
}) {
|
|
15
|
+
}: PropsType) {
|
|
16
16
|
const [currentIndex, setCurrentIndex] = useSyncValue(selectedIndex);
|
|
17
17
|
const stickyStyle = useMemo(() => {
|
|
18
18
|
const length = tabs.length;
|
|
@@ -23,7 +23,7 @@ export default function TabsH5({
|
|
|
23
23
|
}, [tabs, currentIndex]);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<div className={classNames("weda-tabs weda-ui", {
|
|
26
|
+
<div data-testid="tabs" className={classNames("weda-tabs weda-ui", {
|
|
27
27
|
[className]: className
|
|
28
28
|
})} style={style}>
|
|
29
29
|
<div className="weda-tabs__nav">
|
|
@@ -63,33 +63,4 @@ export default function TabsH5({
|
|
|
63
63
|
</div>
|
|
64
64
|
</div>
|
|
65
65
|
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
TabsH5.propTypes = {
|
|
70
|
-
tabs: PropTypes.array,
|
|
71
|
-
className: PropTypes.string,
|
|
72
|
-
style: PropTypes.object,
|
|
73
|
-
selectedIndex: PropTypes.number,
|
|
74
|
-
events: PropTypes.objectOf(PropTypes.func),
|
|
75
|
-
panel1: PropTypes.node,
|
|
76
|
-
panel2: PropTypes.node,
|
|
77
|
-
panel3: PropTypes.node,
|
|
78
|
-
panel4: PropTypes.node,
|
|
79
|
-
panel5: PropTypes.node,
|
|
80
|
-
panel6: PropTypes.node,
|
|
81
|
-
panel7: PropTypes.node,
|
|
82
|
-
panel8: PropTypes.node,
|
|
83
|
-
panel9: PropTypes.node,
|
|
84
|
-
panel10: PropTypes.node,
|
|
85
|
-
panel11: PropTypes.node,
|
|
86
|
-
panel12: PropTypes.node,
|
|
87
|
-
panel13: PropTypes.node,
|
|
88
|
-
panel14: PropTypes.node,
|
|
89
|
-
panel15: PropTypes.node,
|
|
90
|
-
panel16: PropTypes.node,
|
|
91
|
-
panel17: PropTypes.node,
|
|
92
|
-
panel18: PropTypes.node,
|
|
93
|
-
panel19: PropTypes.node,
|
|
94
|
-
panel20: PropTypes.node,
|
|
95
|
-
};
|
|
66
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as PropTypes from 'prop-types';
|
|
3
2
|
import { Tabs as TeaTabs, TabPanel, ConfigProvider } from 'tea-component';
|
|
4
3
|
import classNames from '../../utils/classnames';
|
|
5
4
|
import { useSyncValue } from '../../utils/useSyncValue';
|
|
5
|
+
import { PropsType } from './index';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
export default function TabsPc({
|
|
@@ -12,28 +12,23 @@ export default function TabsPc({
|
|
|
12
12
|
className,
|
|
13
13
|
style,
|
|
14
14
|
...restProps
|
|
15
|
-
}) {
|
|
15
|
+
}: PropsType) {
|
|
16
16
|
|
|
17
17
|
const [activeIndex, setActiveIndex] = useSyncValue(selectedIndex);
|
|
18
18
|
const _tabs = Array.isArray(tabs) && tabs.length && tabs.map((item, index) => {
|
|
19
19
|
return {
|
|
20
|
-
id: index,
|
|
20
|
+
id: index.toString(),
|
|
21
21
|
label: item.title
|
|
22
22
|
};
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// React.useEffect(() => {
|
|
28
|
-
// console.log('render');
|
|
29
|
-
// });
|
|
30
25
|
const onActive = (e) => {
|
|
31
26
|
setActiveIndex(e.id);
|
|
32
27
|
events && events.change(e);
|
|
33
28
|
};
|
|
34
29
|
return (
|
|
35
30
|
<ConfigProvider classPrefix="wedatea2td">
|
|
36
|
-
<TeaTabs style={style} tabs={_tabs} activeId={activeIndex} onActive={onActive} className={classNames(
|
|
31
|
+
<TeaTabs style={style} tabs={_tabs} activeId={String(activeIndex)} onActive={onActive} className={classNames(
|
|
37
32
|
"weda-tabs_pc",
|
|
38
33
|
{
|
|
39
34
|
[className]: className
|
|
@@ -44,7 +39,6 @@ export default function TabsPc({
|
|
|
44
39
|
<TabPanel
|
|
45
40
|
key={item.id}
|
|
46
41
|
id={item.id}
|
|
47
|
-
label={item.label}
|
|
48
42
|
>
|
|
49
43
|
{restProps[`panel${index + 1}`]}
|
|
50
44
|
</TabPanel>
|
|
@@ -53,32 +47,4 @@ export default function TabsPc({
|
|
|
53
47
|
</TeaTabs>
|
|
54
48
|
</ConfigProvider>
|
|
55
49
|
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
TabsPc.propTypes = {
|
|
59
|
-
tabs: PropTypes.array,
|
|
60
|
-
className: PropTypes.string,
|
|
61
|
-
selectedIndex: PropTypes.number,
|
|
62
|
-
style: PropTypes.object,
|
|
63
|
-
events: PropTypes.objectOf(PropTypes.func),
|
|
64
|
-
panel1: PropTypes.node,
|
|
65
|
-
panel2: PropTypes.node,
|
|
66
|
-
panel3: PropTypes.node,
|
|
67
|
-
panel4: PropTypes.node,
|
|
68
|
-
panel5: PropTypes.node,
|
|
69
|
-
panel6: PropTypes.node,
|
|
70
|
-
panel7: PropTypes.node,
|
|
71
|
-
panel8: PropTypes.node,
|
|
72
|
-
panel9: PropTypes.node,
|
|
73
|
-
panel10: PropTypes.node,
|
|
74
|
-
panel11: PropTypes.node,
|
|
75
|
-
panel12: PropTypes.node,
|
|
76
|
-
panel13: PropTypes.node,
|
|
77
|
-
panel14: PropTypes.node,
|
|
78
|
-
panel15: PropTypes.node,
|
|
79
|
-
panel16: PropTypes.node,
|
|
80
|
-
panel17: PropTypes.node,
|
|
81
|
-
panel18: PropTypes.node,
|
|
82
|
-
panel19: PropTypes.node,
|
|
83
|
-
panel20: PropTypes.node,
|
|
84
|
-
};
|
|
50
|
+
}
|
|
@@ -6,3 +6,21 @@
|
|
|
6
6
|
/* -webkit-line-clamp: 1;
|
|
7
7
|
white-space: pre-line; */
|
|
8
8
|
}
|
|
9
|
+
.weda-text.level_1 {
|
|
10
|
+
font-size: 64px !important;
|
|
11
|
+
}
|
|
12
|
+
.weda-text.level_2 {
|
|
13
|
+
font-size: 56px !important;
|
|
14
|
+
}
|
|
15
|
+
.weda-text.level_3 {
|
|
16
|
+
font-size: 48px !important;
|
|
17
|
+
}
|
|
18
|
+
.weda-text.level_4 {
|
|
19
|
+
font-size: 40px !important;
|
|
20
|
+
}
|
|
21
|
+
.weda-text.level_5 {
|
|
22
|
+
font-size: 32px !important;
|
|
23
|
+
}
|
|
24
|
+
.weda-text.level_6 {
|
|
25
|
+
font-size: 24px !important;
|
|
26
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import classNames from '../../utils/classnames';
|
|
3
|
+
import { CommonPropsType, unknownFunction } from '../../types';
|
|
4
|
+
import './index.css';
|
|
5
|
+
|
|
6
|
+
export interface PropsType extends CommonPropsType {
|
|
7
|
+
text: string,
|
|
8
|
+
level: string,
|
|
9
|
+
maxLines: number,
|
|
10
|
+
space: boolean,
|
|
11
|
+
userSelect: boolean,
|
|
12
|
+
textAlign: string,
|
|
13
|
+
textColor: string,
|
|
14
|
+
contenteditable: HTMLParagraphElement['contentEditable'],
|
|
15
|
+
onInput: unknownFunction,
|
|
16
|
+
onBlur: unknownFunction
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
export default function Text({
|
|
20
|
+
text = '文本内容',
|
|
21
|
+
maxLines = 2,
|
|
22
|
+
space = false,
|
|
23
|
+
userSelect = true,
|
|
24
|
+
textAlign = '',
|
|
25
|
+
textColor = '',
|
|
26
|
+
style = {},
|
|
27
|
+
className,
|
|
28
|
+
events,
|
|
29
|
+
id,
|
|
30
|
+
level = '0',
|
|
31
|
+
contenteditable,
|
|
32
|
+
onInput,
|
|
33
|
+
onBlur
|
|
34
|
+
}: PropsType) {
|
|
35
|
+
const textStyle: React.CSSProperties = {
|
|
36
|
+
WebkitLineClamp: maxLines,
|
|
37
|
+
whiteSpace: space ? 'pre-wrap' : 'pre-line',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (!userSelect) {
|
|
41
|
+
textStyle.userSelect = 'none';
|
|
42
|
+
}
|
|
43
|
+
const levelName = level === '0' ? '' : `level_${level}`;
|
|
44
|
+
|
|
45
|
+
// 添加文本颜色属性
|
|
46
|
+
let style2 = {};
|
|
47
|
+
if (textColor !== "") {
|
|
48
|
+
style2 = {color: textColor};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 添加对齐属性
|
|
52
|
+
if (textAlign !== "") {
|
|
53
|
+
style2 = {...style2, textAlign};
|
|
54
|
+
}
|
|
55
|
+
return (
|
|
56
|
+
<p
|
|
57
|
+
//@ts-expect-error contentEditable type def sucks
|
|
58
|
+
contentEditable={contenteditable}
|
|
59
|
+
onInput={onInput}
|
|
60
|
+
onBlur={onBlur}
|
|
61
|
+
style={{ ...style, ...textStyle, ...style2 }}
|
|
62
|
+
className={classNames('weda-text', 'weda-ui', className, levelName)}
|
|
63
|
+
id={id}
|
|
64
|
+
onClick={(e) => events.tap({}, { originEvent: e })}
|
|
65
|
+
>
|
|
66
|
+
{text}
|
|
67
|
+
</p>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { UploadFilePc } from '../form/uploaderFile/uploadFile.pc';
|
|
3
|
+
import {
|
|
4
|
+
filterStrList,
|
|
5
|
+
isCloudFileID,
|
|
6
|
+
downloadFile,
|
|
7
|
+
} from '../../utils/platform';
|
|
8
|
+
import { getTempFileURL } from '../../utils/tcb';
|
|
9
|
+
import './index.css';
|
|
10
|
+
|
|
11
|
+
const CLASS_PREFIX = 'weda-file-view-pc';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 上传文件回显
|
|
15
|
+
* single 表示单个文件回显
|
|
16
|
+
*/
|
|
17
|
+
export default function UploaderFileView({
|
|
18
|
+
value,
|
|
19
|
+
className,
|
|
20
|
+
single = true,
|
|
21
|
+
...rest
|
|
22
|
+
}) {
|
|
23
|
+
const fileIDList = filterStrList(value);
|
|
24
|
+
if(single){
|
|
25
|
+
return <FileView fileID={fileIDList[0]}/>
|
|
26
|
+
}else{
|
|
27
|
+
return (
|
|
28
|
+
<UploadFilePc
|
|
29
|
+
className={`${CLASS_PREFIX} ${className}`}
|
|
30
|
+
decorator={null}
|
|
31
|
+
{...rest}
|
|
32
|
+
value={fileIDList}
|
|
33
|
+
isEdit={false}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 单个文件回显
|
|
41
|
+
*/
|
|
42
|
+
const FileView = ({ fileID }) => {
|
|
43
|
+
const [src, setSrc] = React.useState('');
|
|
44
|
+
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
const fetchFileId = async (id) => {
|
|
47
|
+
if (isCloudFileID(id)) {
|
|
48
|
+
try {
|
|
49
|
+
const fileSrc = await getTempFileURL(id);
|
|
50
|
+
setSrc(fileSrc);
|
|
51
|
+
} catch (e) {}
|
|
52
|
+
} else {
|
|
53
|
+
setSrc(id);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
fetchFileId(fileID);
|
|
57
|
+
}, [fileID]);
|
|
58
|
+
|
|
59
|
+
const title = React.useMemo(() => {
|
|
60
|
+
if (isCloudFileID(fileID)) {
|
|
61
|
+
const uuidReg = /file-[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}-/;
|
|
62
|
+
const lastIndex = `${fileID}`.lastIndexOf('/');
|
|
63
|
+
const name = `${fileID}`.slice(lastIndex + 1);
|
|
64
|
+
const title = name.replace(uuidReg, '');
|
|
65
|
+
return title;
|
|
66
|
+
} else {
|
|
67
|
+
return fileID;
|
|
68
|
+
}
|
|
69
|
+
}, [fileID]);
|
|
70
|
+
return (
|
|
71
|
+
<a title={title} onClick={() => downloadFile(src)} className={`${CLASS_PREFIX}__single`}>
|
|
72
|
+
{title}
|
|
73
|
+
</a>
|
|
74
|
+
)
|
|
75
|
+
};
|
|
@@ -3,6 +3,7 @@ import * as PropTypes from 'prop-types';
|
|
|
3
3
|
import { TcbImage } from '../form/uploader/uploader.pc';
|
|
4
4
|
import classNames from '../../utils/classnames';
|
|
5
5
|
import './index.css';
|
|
6
|
+
import { CommonPropsType } from '../../types';
|
|
6
7
|
|
|
7
8
|
const CLASS_PREFIX = 'g-uploader-view';
|
|
8
9
|
|
|
@@ -20,8 +21,8 @@ export default function UploaderView({
|
|
|
20
21
|
isEmptyPlace = true,
|
|
21
22
|
className,
|
|
22
23
|
id,
|
|
23
|
-
style
|
|
24
|
-
}) {
|
|
24
|
+
style,
|
|
25
|
+
}: PropsType) {
|
|
25
26
|
const cls = classNames({
|
|
26
27
|
[CLASS_PREFIX]: true,
|
|
27
28
|
[className]: className,
|
|
@@ -80,16 +81,12 @@ export default function UploaderView({
|
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
srcList
|
|
85
|
-
alt
|
|
86
|
-
isZoom
|
|
87
|
-
gutter
|
|
88
|
-
height
|
|
89
|
-
width
|
|
90
|
-
isEmptyPlace
|
|
91
|
-
|
|
92
|
-
className: PropTypes.string, // 类,修改测试story,测试2
|
|
93
|
-
id: PropTypes.string,
|
|
94
|
-
style: PropTypes.object
|
|
95
|
-
};
|
|
84
|
+
export interface PropsType extends CommonPropsType {
|
|
85
|
+
srcList?: string[] | string;
|
|
86
|
+
alt?: string; // 替代文字
|
|
87
|
+
isZoom?: boolean; // 能否点击放大
|
|
88
|
+
gutter?: number; // 图片间距
|
|
89
|
+
height?: number; // 图片最大高度
|
|
90
|
+
width?: number; // 图片最大宽度
|
|
91
|
+
isEmptyPlace?: boolean; // 是否显示空值
|
|
92
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="resize-observer-browser" />
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export type unknownFunction = (...args: unknown[]) => unknown
|
|
5
|
+
export interface CommonPropsType {
|
|
6
|
+
style?: React.CSSProperties,
|
|
7
|
+
id?: string,
|
|
8
|
+
events?: Record<string, unknownFunction>;
|
|
9
|
+
className?: string,
|
|
10
|
+
children?: React.ReactNode | undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
var app: any
|
|
16
|
+
interface Window {
|
|
17
|
+
app: any;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -3,3 +3,5 @@ export const TitleType = {
|
|
|
3
3
|
TOP: 'top',
|
|
4
4
|
NONE: 'none',
|
|
5
5
|
};
|
|
6
|
+
|
|
7
|
+
export const LOAD_ERR_IMG_BASE64 = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNMjUuMzIgMTYuMzU5N0MyNi4wNzY0IDE2LjM1OTcgMjYuODI1NCAxNi41MDg3IDI3LjUyNDMgMTYuNzk4MUMyOC4yMjMxIDE3LjA4NzYgMjguODU4MSAxNy41MTE5IDI5LjM5MjkgMTguMDQ2OEMyOS45Mjc4IDE4LjU4MTYgMzAuMzUyMSAxOS4yMTY2IDMwLjY0MTYgMTkuOTE1NEMzMC45MzEgMjAuNjE0MyAzMS4wOCAyMS4zNjMzIDMxLjA4IDIyLjExOTdDMzEuMDggMjIuODc2MSAzMC45MzEgMjMuNjI1MSAzMC42NDE2IDI0LjMyMzlDMzAuMzUyMSAyNS4wMjI4IDI5LjkyNzggMjUuNjU3OCAyOS4zOTI5IDI2LjE5MjZDMjguODU4MSAyNi43Mjc1IDI4LjIyMzEgMjcuMTUxOCAyNy41MjQzIDI3LjQ0MTJDMjYuODI1NCAyNy43MzA3IDI2LjA3NjQgMjcuODc5NyAyNS4zMiAyNy44Nzk3QzIzLjc5MjQgMjcuODc5NyAyMi4zMjczIDI3LjI3MjggMjEuMjQ3MSAyNi4xOTI2QzIwLjE2NjkgMjUuMTEyNCAxOS41NiAyMy42NDczIDE5LjU2IDIyLjExOTdDMTkuNTYgMjAuNTkyIDIwLjE2NjkgMTkuMTI3IDIxLjI0NzEgMTguMDQ2OEMyMi4zMjczIDE2Ljk2NjUgMjMuNzkyNCAxNi4zNTk3IDI1LjMyIDE2LjM1OTdaTTI4IDMuNTU5NjlWMTQuODc2OEMyNy4xNzc3IDE0LjU4NjYgMjYuMTkyIDE0LjQzODggMjUuMzIgMTQuNDM5N0MyNC4wMzEgMTQuNDM5NyAyMi44MTU3IDE0Ljc1NzEgMjEuNzQ4OCAxNS4zMTg0TDIwLjc5NTIgMTMuMTU5N0wxNi4wMjU5IDIwLjAyNzVMOC40NDU3NiAxNi40NDFMMy41NiAyMy4zOTk3SDE3Ljc0NjJDMTcuOTg2NyAyNC44MjkgMTguNjI4MiAyNi4xNjA2IDE5LjU5NTggMjcuMjM5N0gxVjMuNTU5NjlIMjhaTTI1Ljk2IDI0LjAzOTdIMjQuNjhWMjUuMzE5N0gyNS45NlYyNC4wMzk3Wk0yNS45NiAxOC45MTk3SDI0LjY4VjIzLjM5OTdIMjUuOTZWMTguOTE5N1pNNi4xMiAxMC41OTk3QzYuMTIgMTEuOTk4MSA3LjE5OTA0IDEzLjEwODUgOC42MDc2OCAxMy4xNTg0QzEwLjAyMDggMTMuMjA3NyAxMS4yNCAxMi4wNDggMTEuMjQgMTAuNTk5N0MxMS4yNCA5LjI0NjA5IDEwLjA2NDMgOC4wODU3NyA4Ljc1MjMyIDguMDQwOTdDNy4yOTU2OCA3Ljk5MTY5IDYuMTIgOS4xNTEzNyA2LjEyIDEwLjU5OTdaIiBmaWxsPSIjQkNDNEQwIj48L3BhdGg+Cjwvc3ZnPgo=';
|
|
@@ -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
|
+
};
|
|
@@ -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/
|