@pnt-team/pnt-component-frontend 0.0.88 → 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 +17 -9
- package/lib/cjs/components/PntGeneralLayout/index.d.ts +33 -1
- package/lib/cjs/components/PntGeneralLayout/index.js +16 -13
- package/lib/cjs/components/PntGeneralLayout/index.scss +121 -90
- 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 +27 -19
- package/lib/esm/components/PntGeneralLayout/index.d.ts +33 -1
- package/lib/esm/components/PntGeneralLayout/index.js +21 -6
- package/lib/esm/components/PntGeneralLayout/index.scss +121 -90
- 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
|
@@ -135,9 +135,7 @@ var PntBusinessSelect = (props) => {
|
|
|
135
135
|
const resTotal = ((_a = res.data.pagination) == null ? void 0 : _a.total) || 0;
|
|
136
136
|
let nextList;
|
|
137
137
|
if (append) {
|
|
138
|
-
const existed = new Set(
|
|
139
|
-
optionsRef.current.map((o) => o.game_id)
|
|
140
|
-
);
|
|
138
|
+
const existed = new Set(optionsRef.current.map((o) => o.game_id));
|
|
141
139
|
nextList = [
|
|
142
140
|
...optionsRef.current,
|
|
143
141
|
...newList.filter((o) => !existed.has(o.game_id))
|
|
@@ -151,6 +149,7 @@ var PntBusinessSelect = (props) => {
|
|
|
151
149
|
setOptions(nextList);
|
|
152
150
|
(_b = onLoadedRef.current) == null ? void 0 : _b.call(onLoadedRef, nextList);
|
|
153
151
|
}
|
|
152
|
+
} catch {
|
|
154
153
|
} finally {
|
|
155
154
|
if (append)
|
|
156
155
|
appendLoadingRef.current = false;
|
|
@@ -185,8 +184,8 @@ var PntBusinessSelect = (props) => {
|
|
|
185
184
|
return;
|
|
186
185
|
if (debounceRef.current)
|
|
187
186
|
clearTimeout(debounceRef.current);
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
keywordRef.current = "";
|
|
188
|
+
if (listMetaRef.current.keyword) {
|
|
190
189
|
fetchData("", 1, false);
|
|
191
190
|
}
|
|
192
191
|
},
|
|
@@ -366,11 +365,11 @@ var PntBusinessSelect = (props) => {
|
|
|
366
365
|
if (raw) {
|
|
367
366
|
return { ...raw, value: raw.game_id, label: getLabelText(raw) };
|
|
368
367
|
}
|
|
369
|
-
const fromCtx = ctxOptions.find(
|
|
370
|
-
(o) => String(o.value) === id
|
|
371
|
-
);
|
|
368
|
+
const fromCtx = ctxOptions.find((o) => String(o.value) === id);
|
|
372
369
|
if (fromCtx) {
|
|
373
|
-
const
|
|
370
|
+
const rest = { ...fromCtx };
|
|
371
|
+
delete rest.children;
|
|
372
|
+
delete rest.content;
|
|
374
373
|
return rest;
|
|
375
374
|
}
|
|
376
375
|
return { value: id, label: id };
|
|
@@ -382,6 +381,14 @@ var PntBusinessSelect = (props) => {
|
|
|
382
381
|
},
|
|
383
382
|
[onChange, multiple, getLabelText]
|
|
384
383
|
);
|
|
384
|
+
const handleClear = (0, import_react.useCallback)(() => {
|
|
385
|
+
keywordRef.current = "";
|
|
386
|
+
if (debounceRef.current)
|
|
387
|
+
clearTimeout(debounceRef.current);
|
|
388
|
+
if (listMetaRef.current.keyword) {
|
|
389
|
+
fetchData("", 1, false);
|
|
390
|
+
}
|
|
391
|
+
}, [fetchData]);
|
|
385
392
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
386
393
|
import_tdesign_react.Select,
|
|
387
394
|
{
|
|
@@ -390,6 +397,7 @@ var PntBusinessSelect = (props) => {
|
|
|
390
397
|
filterable,
|
|
391
398
|
filter: enableRemoteSearch ? void 0 : filterable ? localFilter : void 0,
|
|
392
399
|
onSearch: enableRemoteSearch ? handleSearch : void 0,
|
|
400
|
+
onClear: enableRemoteSearch ? handleClear : void 0,
|
|
393
401
|
loading: loading && options.length === 0,
|
|
394
402
|
multiple,
|
|
395
403
|
max,
|
|
@@ -19,6 +19,11 @@ interface PntGeneralLayoutProps {
|
|
|
19
19
|
* 返回按钮点击回调
|
|
20
20
|
*/
|
|
21
21
|
onBackButtonClick?: (() => void) | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* 是否显示头部底部分割线
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
headerBordered?: boolean;
|
|
22
27
|
/**
|
|
23
28
|
* 子头部内容
|
|
24
29
|
* @description 位于 Header 下方,常用于放置面包屑、Tab 等
|
|
@@ -41,6 +46,25 @@ interface PntGeneralLayoutProps {
|
|
|
41
46
|
* 内容区自定义样式
|
|
42
47
|
*/
|
|
43
48
|
bodyStyle?: React.CSSProperties;
|
|
49
|
+
/**
|
|
50
|
+
* 内容区内边距
|
|
51
|
+
* @description 数字按 px 处理;需要全出血内容时可传 '24px 0'
|
|
52
|
+
* @default 24
|
|
53
|
+
*/
|
|
54
|
+
bodyPadding?: number | string;
|
|
55
|
+
/**
|
|
56
|
+
* 内容区卡片圆角(px)
|
|
57
|
+
* @description 作用于 body 内 t-card / tea-card / 各业务 wrapper、block 容器
|
|
58
|
+
* @default 4
|
|
59
|
+
*/
|
|
60
|
+
cardRadius?: number;
|
|
61
|
+
/**
|
|
62
|
+
* 底部按钮样式模式
|
|
63
|
+
* @description fixed-统一下按钮尺寸(高 36px、最小宽 92px、加粗中号字);
|
|
64
|
+
* auto-不约束按钮尺寸,仅保留按钮间距
|
|
65
|
+
* @default 'fixed'
|
|
66
|
+
*/
|
|
67
|
+
footerButton?: 'fixed' | 'auto';
|
|
44
68
|
/**
|
|
45
69
|
* 底部内容
|
|
46
70
|
* @description 传入后将渲染 Layout Footer 区域,常用于放置操作按钮
|
|
@@ -50,7 +74,8 @@ interface PntGeneralLayoutProps {
|
|
|
50
74
|
/**
|
|
51
75
|
* 通用页面布局组件(L3 布局组件)
|
|
52
76
|
* @description 提供标准的「头部 + 子头部 + 内容区 + 底部」页面布局结构,
|
|
53
|
-
* 基于 TDesign Layout
|
|
77
|
+
* 基于 TDesign Layout(flex column)封装,内容区自动填满剩余高度,
|
|
78
|
+
* 适用于后台管理系统的列表页、详情页、表单页等场景。
|
|
54
79
|
*
|
|
55
80
|
* @example
|
|
56
81
|
* ```tsx
|
|
@@ -76,6 +101,13 @@ interface PntGeneralLayoutProps {
|
|
|
76
101
|
* >
|
|
77
102
|
* <Detail />
|
|
78
103
|
* </PntGeneralLayout>
|
|
104
|
+
*
|
|
105
|
+
* // 全出血内容区(无头部边线、内容无左右内边距、底部按钮不强制尺寸)
|
|
106
|
+
* <PntGeneralLayout
|
|
107
|
+
* headerBordered={false}
|
|
108
|
+
* bodyPadding="24px 0"
|
|
109
|
+
* footerButton="auto"
|
|
110
|
+
* />
|
|
79
111
|
* ```
|
|
80
112
|
*/
|
|
81
113
|
declare const PntGeneralLayout: FunctionComponent<PntGeneralLayoutProps>;
|
|
@@ -32,15 +32,29 @@ var PntGeneralLayout = (prop) => {
|
|
|
32
32
|
headerTitle,
|
|
33
33
|
showBackButton = false,
|
|
34
34
|
onBackButtonClick,
|
|
35
|
+
headerBordered = true,
|
|
35
36
|
subHeaderContent,
|
|
36
37
|
operation,
|
|
37
38
|
bodyRef,
|
|
38
39
|
children,
|
|
39
40
|
bodyStyle,
|
|
41
|
+
bodyPadding = 24,
|
|
42
|
+
cardRadius = 4,
|
|
43
|
+
footerButton = "fixed",
|
|
40
44
|
footer
|
|
41
45
|
} = prop;
|
|
42
46
|
const { Header, Footer } = import_tdesign_react.Layout;
|
|
43
|
-
|
|
47
|
+
const layoutClassName = [
|
|
48
|
+
"pnt-general-layout",
|
|
49
|
+
!headerBordered && "pnt-general-layout--borderless",
|
|
50
|
+
footerButton === "auto" && "pnt-general-layout--footer-auto",
|
|
51
|
+
className
|
|
52
|
+
].filter(Boolean).join(" ");
|
|
53
|
+
const cssVars = {
|
|
54
|
+
"--pnt-layout-body-padding": typeof bodyPadding === "number" ? `${bodyPadding}px` : bodyPadding,
|
|
55
|
+
"--pnt-layout-card-radius": `${cardRadius}px`
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tdesign_react.Layout, { className: layoutClassName, style: cssVars, children: [
|
|
44
58
|
headerTitle && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Header, { children: [
|
|
45
59
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "header-title", children: [
|
|
46
60
|
showBackButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -56,18 +70,7 @@ var PntGeneralLayout = (prop) => {
|
|
|
56
70
|
operation && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "header-operation", children: operation })
|
|
57
71
|
] }),
|
|
58
72
|
subHeaderContent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "general-layout-sub-header", children: subHeaderContent }),
|
|
59
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
-
"div",
|
|
61
|
-
{
|
|
62
|
-
className: "general-layout-body",
|
|
63
|
-
ref: bodyRef,
|
|
64
|
-
style: {
|
|
65
|
-
height: `calc(100%${headerTitle && " - 72px"}${footer && " - 72px"})`,
|
|
66
|
-
...bodyStyle
|
|
67
|
-
},
|
|
68
|
-
children
|
|
69
|
-
}
|
|
70
|
-
),
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "general-layout-body", ref: bodyRef, style: bodyStyle, children }),
|
|
71
74
|
footer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Footer, { children: footer })
|
|
72
75
|
] });
|
|
73
76
|
};
|
|
@@ -1,90 +1,121 @@
|
|
|
1
|
-
.pnt-general-layout {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
1
|
+
.pnt-general-layout {
|
|
2
|
+
// 可通过 props(bodyPadding / cardRadius)覆盖的布局变量
|
|
3
|
+
--pnt-layout-body-padding: 24px;
|
|
4
|
+
--pnt-layout-card-radius: 4px;
|
|
5
|
+
|
|
6
|
+
height: 100%;
|
|
7
|
+
background-color: rgba(0, 0, 0, 0);
|
|
8
|
+
|
|
9
|
+
.t-layout__header {
|
|
10
|
+
height: auto;
|
|
11
|
+
flex-shrink: 0;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: stretch;
|
|
15
|
+
border-bottom: 1px solid #f0f3f6;
|
|
16
|
+
|
|
17
|
+
.header-title {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
padding: 24px;
|
|
21
|
+
|
|
22
|
+
.goback-icon {
|
|
23
|
+
margin-right: 12px;
|
|
24
|
+
color: #3f8cff;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.title {
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
font-size: 20px;
|
|
31
|
+
line-height: 24px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 统一 flex 居中:高度由 header-title 的 padding 撑起(72px),
|
|
36
|
+
// 比固定 line-height: 72px 更稳,按钮高度变化也不会错位
|
|
37
|
+
.header-operation {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
padding-right: 24px;
|
|
41
|
+
|
|
42
|
+
.t-button + .t-button {
|
|
43
|
+
margin-left: 12px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 无头部分割线变体(headerBordered={false})
|
|
49
|
+
&--borderless {
|
|
50
|
+
.t-layout__header {
|
|
51
|
+
border-bottom: none;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.general-layout-sub-header {
|
|
56
|
+
flex-shrink: 0;
|
|
57
|
+
border-bottom: 1px solid #f0f3f6;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.general-layout-body {
|
|
61
|
+
// flex 自动填满 header/sub-header/footer 之外的剩余空间;
|
|
62
|
+
// min-height: 0 保证内容超长时由 body 自身滚动,而不是撑破布局
|
|
63
|
+
flex: 1 1 auto;
|
|
64
|
+
min-height: 0;
|
|
65
|
+
padding: var(--pnt-layout-body-padding);
|
|
66
|
+
overflow-y: auto;
|
|
67
|
+
background: #fafafa;
|
|
68
|
+
|
|
69
|
+
// 卡片/业务容器取各项目选择器超集,统一去阴影、间距与圆角
|
|
70
|
+
> div.tea-card,
|
|
71
|
+
> div.t-card,
|
|
72
|
+
> div.t-loading__parent > div.t-card,
|
|
73
|
+
> div[class*='-wrapper'],
|
|
74
|
+
> div[class*='-block'] {
|
|
75
|
+
box-shadow: none;
|
|
76
|
+
margin-bottom: 24px;
|
|
77
|
+
border-radius: var(--pnt-layout-card-radius);
|
|
78
|
+
|
|
79
|
+
.t-card__body {
|
|
80
|
+
border-radius: var(--pnt-layout-card-radius);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
> div:last-child,
|
|
85
|
+
> div:last-child.t-card,
|
|
86
|
+
> div:last-child.tea-card,
|
|
87
|
+
> div.t-loading__parent > div:last-child.t-card,
|
|
88
|
+
> div:last-child[class*='-wrapper'],
|
|
89
|
+
> div:last-child[class*='-block'] {
|
|
90
|
+
margin-bottom: 0;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.t-layout__footer {
|
|
95
|
+
flex-shrink: 0;
|
|
96
|
+
padding: 18px 24px;
|
|
97
|
+
background: #fff;
|
|
98
|
+
border-top: 1px solid #f0f3f6;
|
|
99
|
+
|
|
100
|
+
.t-button {
|
|
101
|
+
font-size: 14px;
|
|
102
|
+
min-width: 92px;
|
|
103
|
+
height: 36px;
|
|
104
|
+
font-weight: 600;
|
|
105
|
+
|
|
106
|
+
& + .t-button {
|
|
107
|
+
margin-left: 12px;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 底部按钮不约束尺寸变体(footerButton='auto'),仅保留按钮间距
|
|
113
|
+
&--footer-auto {
|
|
114
|
+
.t-layout__footer .t-button {
|
|
115
|
+
font-size: inherit;
|
|
116
|
+
min-width: 0;
|
|
117
|
+
height: auto;
|
|
118
|
+
font-weight: inherit;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
/**
|
|
4
|
+
* PntImage 文案集合
|
|
5
|
+
* @description 所有内部展示文案均可通过 texts prop 自定义,用于多语言场景
|
|
6
|
+
*/
|
|
7
|
+
export interface PntImageTexts {
|
|
8
|
+
/** 上传中占位文案(仅上传预览模式生效) */
|
|
9
|
+
uploading?: string;
|
|
10
|
+
/** 图片加载中占位文案(纯预览模式生效,透传给 tdesign Image loading) */
|
|
11
|
+
loading?: string;
|
|
12
|
+
/** 图片加载失败占位文案(纯预览模式生效,透传给 tdesign Image error) */
|
|
13
|
+
loadFailed?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PntImageProps {
|
|
16
|
+
/**
|
|
17
|
+
* 图片地址
|
|
18
|
+
* @description 图片的完整 URL 地址;为空则展示 defaultImg 或内置 uploadImg
|
|
19
|
+
*/
|
|
20
|
+
src: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* alt 文本
|
|
23
|
+
* @description 图片加载失败时的替代文本,纯预览模式必传以提升可访问性
|
|
24
|
+
*/
|
|
25
|
+
alt?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 默认图片
|
|
28
|
+
* @description src 为空时展示的占位图;不传则使用内置的 uploadImg
|
|
29
|
+
*/
|
|
30
|
+
defaultImg?: string;
|
|
31
|
+
/**
|
|
32
|
+
* 自定义样式
|
|
33
|
+
* @description 一般用于控制图片宽高
|
|
34
|
+
*/
|
|
35
|
+
style?: React.CSSProperties;
|
|
36
|
+
/**
|
|
37
|
+
* 上传中状态
|
|
38
|
+
* @description 当为 true 时显示上传中 loading 占位,阻止其他操作;仅在上传预览模式(传入 onRemove)生效
|
|
39
|
+
*/
|
|
40
|
+
loading?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 删除回调
|
|
43
|
+
* @description 传入即启用「上传预览模式」,mask 含预览 + 删除按钮;不传则为「纯预览模式」
|
|
44
|
+
* @param e - 事件对象
|
|
45
|
+
*/
|
|
46
|
+
onRemove?: (e: any) => void;
|
|
47
|
+
/**
|
|
48
|
+
* attach 容器
|
|
49
|
+
* @description 弹窗场景下需要透传给 tdesign ImageViewer 的 attach,避免预览浮层被父容器裁剪
|
|
50
|
+
*/
|
|
51
|
+
container?: HTMLElement | (() => HTMLElement);
|
|
52
|
+
/**
|
|
53
|
+
* 多语言文案
|
|
54
|
+
* @description 传入即覆盖默认中文文案;仅对应字段会覆盖,未传字段仍用默认值
|
|
55
|
+
*/
|
|
56
|
+
texts?: PntImageTexts;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* PntImage 业务图片组件
|
|
60
|
+
* @description 统一覆盖「上传图片预览」和「纯图片预览」两种业务场景,避免业务侧维护两套组件
|
|
61
|
+
*
|
|
62
|
+
* 模式判定:传入 `onRemove` 即为上传预览模式,否则为纯预览模式
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* // 上传预览模式
|
|
67
|
+
* <PntImage
|
|
68
|
+
* src={iconUrl}
|
|
69
|
+
* loading={loading}
|
|
70
|
+
* defaultImg={defaultImg}
|
|
71
|
+
* onRemove={handleRemove}
|
|
72
|
+
* style={{ width: 136, height: 136 }}
|
|
73
|
+
* />
|
|
74
|
+
*
|
|
75
|
+
* // 纯预览模式
|
|
76
|
+
* <PntImage
|
|
77
|
+
* src={url}
|
|
78
|
+
* alt="avatar"
|
|
79
|
+
* style={{ width: 60, height: 60 }}
|
|
80
|
+
* container={container}
|
|
81
|
+
* />
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @returns {ReactElement} 业务图片组件
|
|
85
|
+
*/
|
|
86
|
+
declare const PntImage: FC<PntImageProps>;
|
|
87
|
+
export default PntImage;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/PntImage/index.tsx
|
|
30
|
+
var PntImage_exports = {};
|
|
31
|
+
__export(PntImage_exports, {
|
|
32
|
+
default: () => PntImage_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(PntImage_exports);
|
|
35
|
+
var import_uploadImg = __toESM(require("../../assets/images/uploadImg.png"));
|
|
36
|
+
var import_tdesign_icons_react = require("tdesign-icons-react");
|
|
37
|
+
var import_tdesign_react = require("tdesign-react");
|
|
38
|
+
var import_index = require("./index.scss");
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
var DEFAULT_TEXTS = {
|
|
41
|
+
uploading: "上传中",
|
|
42
|
+
loading: "加载中",
|
|
43
|
+
loadFailed: "加载失败"
|
|
44
|
+
};
|
|
45
|
+
var PntImage = ({
|
|
46
|
+
src,
|
|
47
|
+
alt = "",
|
|
48
|
+
defaultImg,
|
|
49
|
+
style,
|
|
50
|
+
loading = false,
|
|
51
|
+
onRemove,
|
|
52
|
+
container,
|
|
53
|
+
texts
|
|
54
|
+
}) => {
|
|
55
|
+
const isUploadMode = typeof onRemove === "function";
|
|
56
|
+
const finalSrc = (src == null ? void 0 : src.length) ? src : defaultImg || import_uploadImg.default;
|
|
57
|
+
const attach = container ? typeof container === "function" ? container : () => container : void 0;
|
|
58
|
+
const finalTexts = { ...DEFAULT_TEXTS, ...texts };
|
|
59
|
+
const UploadLoadingContent = (isImageLoading) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: isImageLoading ? "pnt-image-progress" : "pnt-image-upload-progress",
|
|
63
|
+
style,
|
|
64
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pnt-image-loading", children: [
|
|
65
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tdesign_icons_react.LoadingIcon, { size: "18px", name: "loading" }),
|
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: finalTexts.uploading })
|
|
67
|
+
] })
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
const basicImageLoading = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
71
|
+
import_tdesign_react.Space,
|
|
72
|
+
{
|
|
73
|
+
direction: "vertical",
|
|
74
|
+
align: "center",
|
|
75
|
+
size: "small",
|
|
76
|
+
style: { color: "var(--td-text-color-disabled)" },
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tdesign_icons_react.ImageIcon, { size: 24 }),
|
|
79
|
+
finalTexts.loading
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
const basicImageError = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_tdesign_react.Space, { direction: "vertical", align: "center", size: "small", children: [
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tdesign_icons_react.ImageErrorIcon, { size: 24 }),
|
|
85
|
+
finalTexts.loadFailed
|
|
86
|
+
] });
|
|
87
|
+
const basicMask = (open) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
className: "pnt-image-mask pnt-image-mask--basic",
|
|
91
|
+
style: { background: "rgba(0,0,0,.1)", height: "100%" },
|
|
92
|
+
onClick: open
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
const uploadMask = (open) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pnt-image-mask pnt-image-mask--upload", children: [
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tdesign_icons_react.BrowseIcon, { onClick: open, size: "16px", name: "browse" }) }),
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pnt-image-divider" }),
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tdesign_icons_react.DeleteIcon, { onClick: onRemove, size: "16px", name: "delete" }) })
|
|
99
|
+
] });
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
+
"div",
|
|
102
|
+
{
|
|
103
|
+
className: "pnt-image-wrapper",
|
|
104
|
+
onClick: (e) => {
|
|
105
|
+
if (isUploadMode && ((src == null ? void 0 : src.length) || loading)) {
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
children: isUploadMode && loading ? UploadLoadingContent(false) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
|
+
import_tdesign_react.ImageViewer,
|
|
111
|
+
{
|
|
112
|
+
images: [finalSrc],
|
|
113
|
+
closeOnOverlay: true,
|
|
114
|
+
attach,
|
|
115
|
+
trigger: ({ open }) => {
|
|
116
|
+
const mask = isUploadMode ? uploadMask(open) : basicMask(open);
|
|
117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
+
import_tdesign_react.Image,
|
|
119
|
+
{
|
|
120
|
+
alt,
|
|
121
|
+
src: finalSrc,
|
|
122
|
+
loading: isUploadMode ? UploadLoadingContent(true) : basicImageLoading,
|
|
123
|
+
error: isUploadMode ? void 0 : basicImageError,
|
|
124
|
+
overlayContent: isUploadMode ? src ? mask : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}) : mask,
|
|
125
|
+
overlayTrigger: "hover",
|
|
126
|
+
fit: "contain",
|
|
127
|
+
className: "pnt-image",
|
|
128
|
+
style
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
var PntImage_default = PntImage;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
.pnt-image-
|
|
1
|
+
.pnt-image-wrapper {
|
|
2
2
|
position: relative;
|
|
3
3
|
|
|
4
|
-
.pnt-image-
|
|
5
|
-
.pnt-image-
|
|
4
|
+
.pnt-image-progress,
|
|
5
|
+
.pnt-image-upload-progress {
|
|
6
6
|
width: 136px;
|
|
7
7
|
height: 136px;
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: center;
|
|
10
10
|
justify-content: center;
|
|
11
11
|
|
|
12
|
-
.pnt-image-
|
|
12
|
+
.pnt-image-loading {
|
|
13
13
|
width: 100%;
|
|
14
14
|
height: 100%;
|
|
15
15
|
text-align: center;
|
|
@@ -33,18 +33,25 @@
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.pnt-image
|
|
36
|
+
.pnt-image {
|
|
37
37
|
width: 136px;
|
|
38
38
|
height: 136px;
|
|
39
39
|
|
|
40
|
-
.pnt-image-
|
|
40
|
+
.pnt-image-mask {
|
|
41
41
|
background: rgba(0, 0, 0, 60%);
|
|
42
42
|
color: #fff;
|
|
43
43
|
height: 100%;
|
|
44
44
|
display: flex;
|
|
45
45
|
align-items: center;
|
|
46
46
|
justify-content: center;
|
|
47
|
-
|
|
47
|
+
|
|
48
|
+
// 纯预览模式:半透明遮罩,鼠标手型
|
|
49
|
+
&--basic {
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 上传预览模式:分隔线
|
|
54
|
+
.pnt-image-divider {
|
|
48
55
|
margin: 0 var(--td-comp-margin-l);
|
|
49
56
|
border-left: 1px var(--td-text-color-anti) solid;
|
|
50
57
|
height: var(--td-comp-size-xxxs);
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { PntProvider, usePntConfig, type PntConfig, type commonEesType, } from './config';
|
|
2
|
-
export { default as
|
|
2
|
+
export { default as PntImage } from './components/PntImage';
|
|
3
3
|
export { default as PntBusinessSelect } from './components/PntBusinessSelect';
|
|
4
4
|
export { default as PntSecureBox } from './components/PntSecureBox';
|
|
5
5
|
export { default as PntGeneralLayout } from './components/PntGeneralLayout';
|