@pnt-team/pnt-component-frontend 0.0.89 → 0.0.91
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/lib/cjs/components/PntBusinessSelect/index.js +13 -32
- package/lib/cjs/components/PntGeneralLayout/index.js +1 -9
- package/lib/cjs/components/PntImage/index.d.ts +87 -0
- package/lib/cjs/components/PntImage/index.js +137 -0
- package/lib/{esm/components/PntImagePreview → cjs/components/PntImage}/index.scss +14 -7
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +3 -3
- package/lib/esm/components/PntBusinessSelect/index.js +8 -34
- package/lib/esm/components/PntImage/index.d.ts +87 -0
- package/lib/esm/components/PntImage/index.js +181 -0
- package/lib/{cjs/components/PntImagePreview → esm/components/PntImage}/index.scss +14 -7
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/umd/pnt-component-frontend.min.css +1 -1
- package/lib/umd/pnt-component-frontend.min.js +1 -1
- package/package.json +1 -1
- package/lib/cjs/components/PntImagePreview/index.d.ts +0 -75
- package/lib/cjs/components/PntImagePreview/index.js +0 -98
- package/lib/esm/components/PntImagePreview/index.d.ts +0 -75
- package/lib/esm/components/PntImagePreview/index.js +0 -120
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import './index.scss';
|
|
3
|
-
interface PntImagePreviewProps {
|
|
4
|
-
/**
|
|
5
|
-
* 当前图片组件 URL
|
|
6
|
-
* @description 图片的完整 URL 地址,用于显示已上传的图片
|
|
7
|
-
*/
|
|
8
|
-
iconUrl: string | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* 上传加载状态
|
|
11
|
-
* @description 当为 true 时显示上传加载状态,阻止其他操作
|
|
12
|
-
*/
|
|
13
|
-
loading: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* 默认图片
|
|
16
|
-
* @description 支持传入默认封面图片,不传入则使用默认的 uploadImg 作为默认图片
|
|
17
|
-
*/
|
|
18
|
-
defaultImg?: string;
|
|
19
|
-
/**
|
|
20
|
-
* 自定义扩展参数
|
|
21
|
-
* @description 用于传递额外的配置选项,如样式等
|
|
22
|
-
*/
|
|
23
|
-
params?: {
|
|
24
|
-
/** 自定义样式 */
|
|
25
|
-
style?: React.CSSProperties;
|
|
26
|
-
/** 其他可扩展配置 */
|
|
27
|
-
[key: string]: any;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* 删除回调函数
|
|
31
|
-
* @description 当点击删除图标时触发的回调函数
|
|
32
|
-
* @param e - 事件对象
|
|
33
|
-
*/
|
|
34
|
-
onRemove?: (e: any) => void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 上传图片查看器组件
|
|
38
|
-
* @description 用于展示上传的图片,支持预览、删除功能和上传状态显示
|
|
39
|
-
* @param {PntImagePreviewProps} props - 组件属性
|
|
40
|
-
* @param {string | undefined} props.iconUrl - 当前图片组件 URL
|
|
41
|
-
* @param {boolean} props.loading - 上传加载状态
|
|
42
|
-
* @param {string} [props.defaultImg] - 默认图片
|
|
43
|
-
* @param {object} [props.params] - 自定义扩展参数
|
|
44
|
-
* @param {function} [props.onRemove] - 删除回调函数
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```tsx
|
|
48
|
-
* // 基础用法
|
|
49
|
-
* <UploadImageViewer
|
|
50
|
-
* iconUrl={imageUrl}
|
|
51
|
-
* loading={uploading}
|
|
52
|
-
* onRemove={handleRemove}
|
|
53
|
-
* />
|
|
54
|
-
*
|
|
55
|
-
* // 带默认图片
|
|
56
|
-
* <UploadImageViewer
|
|
57
|
-
* iconUrl={imageUrl}
|
|
58
|
-
* loading={false}
|
|
59
|
-
* defaultImg="/path/to/default.png"
|
|
60
|
-
* onRemove={handleRemove}
|
|
61
|
-
* />
|
|
62
|
-
*
|
|
63
|
-
* // 自定义样式
|
|
64
|
-
* <UploadImageViewer
|
|
65
|
-
* iconUrl={imageUrl}
|
|
66
|
-
* loading={uploading}
|
|
67
|
-
* params={{ style: { width: '200px', height: '200px' } }}
|
|
68
|
-
* onRemove={handleRemove}
|
|
69
|
-
* />
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @returns {ReactElement} 上传图片查看器组件
|
|
73
|
-
*/
|
|
74
|
-
declare const PntImagePreview: FC<PntImagePreviewProps>;
|
|
75
|
-
export default PntImagePreview;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import uploadImg from "../../assets/images/uploadImg.png";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { BrowseIcon, DeleteIcon, LoadingIcon } from 'tdesign-icons-react';
|
|
4
|
-
import { Image, ImageViewer } from 'tdesign-react';
|
|
5
|
-
import "./index.scss";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
-
/**
|
|
10
|
-
* 上传图片查看器组件
|
|
11
|
-
* @description 用于展示上传的图片,支持预览、删除功能和上传状态显示
|
|
12
|
-
* @param {PntImagePreviewProps} props - 组件属性
|
|
13
|
-
* @param {string | undefined} props.iconUrl - 当前图片组件 URL
|
|
14
|
-
* @param {boolean} props.loading - 上传加载状态
|
|
15
|
-
* @param {string} [props.defaultImg] - 默认图片
|
|
16
|
-
* @param {object} [props.params] - 自定义扩展参数
|
|
17
|
-
* @param {function} [props.onRemove] - 删除回调函数
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* // 基础用法
|
|
22
|
-
* <UploadImageViewer
|
|
23
|
-
* iconUrl={imageUrl}
|
|
24
|
-
* loading={uploading}
|
|
25
|
-
* onRemove={handleRemove}
|
|
26
|
-
* />
|
|
27
|
-
*
|
|
28
|
-
* // 带默认图片
|
|
29
|
-
* <UploadImageViewer
|
|
30
|
-
* iconUrl={imageUrl}
|
|
31
|
-
* loading={false}
|
|
32
|
-
* defaultImg="/path/to/default.png"
|
|
33
|
-
* onRemove={handleRemove}
|
|
34
|
-
* />
|
|
35
|
-
*
|
|
36
|
-
* // 自定义样式
|
|
37
|
-
* <UploadImageViewer
|
|
38
|
-
* iconUrl={imageUrl}
|
|
39
|
-
* loading={uploading}
|
|
40
|
-
* params={{ style: { width: '200px', height: '200px' } }}
|
|
41
|
-
* onRemove={handleRemove}
|
|
42
|
-
* />
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @returns {ReactElement} 上传图片查看器组件
|
|
46
|
-
*/
|
|
47
|
-
const PntImagePreview = ({
|
|
48
|
-
iconUrl,
|
|
49
|
-
loading,
|
|
50
|
-
defaultImg,
|
|
51
|
-
params,
|
|
52
|
-
onRemove
|
|
53
|
-
}) => {
|
|
54
|
-
const src = iconUrl?.length ? iconUrl : defaultImg || uploadImg;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 加载中组件
|
|
58
|
-
* @param isImageLoading - 是否为图片加载状态
|
|
59
|
-
* @description 统一使用一种loading效果,避免两种加载风格
|
|
60
|
-
* @returns 加载状态的 JSX 元素
|
|
61
|
-
*/
|
|
62
|
-
const LoadingContent = isImageLoading => /*#__PURE__*/_jsx("div", {
|
|
63
|
-
className: isImageLoading ? 'pnt-image-preview-progress' : 'pnt-image-preview-upload-progress',
|
|
64
|
-
style: params?.style,
|
|
65
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
66
|
-
className: "pnt-image-preview-loading",
|
|
67
|
-
children: [/*#__PURE__*/_jsx(LoadingIcon, {
|
|
68
|
-
size: "18px",
|
|
69
|
-
name: 'loading'
|
|
70
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
71
|
-
children: "\u4E0A\u4F20\u4E2D"
|
|
72
|
-
})]
|
|
73
|
-
})
|
|
74
|
-
});
|
|
75
|
-
return /*#__PURE__*/_jsx("div", {
|
|
76
|
-
className: "pnt-image-preview-wrapper",
|
|
77
|
-
onClick: e => {
|
|
78
|
-
if (iconUrl?.length || loading) {
|
|
79
|
-
e.stopPropagation(); // 图片已上传 或 加载中 阻止上传行为
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
children: loading ? LoadingContent(false) : /*#__PURE__*/_jsx(ImageViewer, {
|
|
83
|
-
images: [src],
|
|
84
|
-
closeOnOverlay: true,
|
|
85
|
-
trigger: ({
|
|
86
|
-
open
|
|
87
|
-
}) => {
|
|
88
|
-
const mask = /*#__PURE__*/_jsxs("div", {
|
|
89
|
-
className: "pnt-image-preview-mask",
|
|
90
|
-
children: [/*#__PURE__*/_jsx("span", {
|
|
91
|
-
children: /*#__PURE__*/_jsx(BrowseIcon, {
|
|
92
|
-
onClick: open,
|
|
93
|
-
size: "16px",
|
|
94
|
-
name: 'browse'
|
|
95
|
-
})
|
|
96
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
97
|
-
className: "pnt-image-preview-divider"
|
|
98
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
99
|
-
children: /*#__PURE__*/_jsx(DeleteIcon, {
|
|
100
|
-
onClick: onRemove,
|
|
101
|
-
size: "16px",
|
|
102
|
-
name: 'delete'
|
|
103
|
-
})
|
|
104
|
-
})]
|
|
105
|
-
});
|
|
106
|
-
return /*#__PURE__*/_jsx(Image, {
|
|
107
|
-
alt: '',
|
|
108
|
-
src: src,
|
|
109
|
-
loading: LoadingContent(true),
|
|
110
|
-
overlayContent: iconUrl ? mask : /*#__PURE__*/_jsx(_Fragment, {}),
|
|
111
|
-
overlayTrigger: "hover",
|
|
112
|
-
fit: "contain",
|
|
113
|
-
className: "pnt-image-preview",
|
|
114
|
-
style: params?.style
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
})
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
export default PntImagePreview;
|