@hkyhy/marsun-components-core 0.1.2 → 0.1.5
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/README.md +11 -7
- package/dist/components/AgentHub/AgentHubAccessGuard.d.ts +11 -0
- package/dist/components/AgentHub/AgentHubIndexRedirect.d.ts +8 -0
- package/dist/components/AgentHub/Chat/Action/CreateButton.d.ts +6 -0
- package/dist/components/AgentHub/Chat/Action/ManageActionButtons.d.ts +6 -0
- package/dist/components/AgentHub/Chat/Action/SessionActionButtons.d.ts +8 -0
- package/dist/components/AgentHub/Chat/Action/handlers.d.ts +11 -0
- package/dist/components/AgentHub/Chat/Action/index.d.ts +7 -0
- package/dist/components/AgentHub/Chat/Detail/ChatInput/index.d.ts +11 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/index.d.ts +6 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/index.d.ts +7 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/index.d.ts +12 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/index.d.ts +9 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/index.d.ts +7 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/index.d.ts +33 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/index.d.ts +13 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/index.d.ts +14 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/index.d.ts +13 -0
- package/dist/components/AgentHub/Chat/Detail/index.d.ts +12 -0
- package/dist/components/AgentHub/Chat/Form/Form.d.ts +16 -0
- package/dist/components/AgentHub/Chat/Form/index.d.ts +2 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/index.d.ts +11 -0
- package/dist/components/AgentHub/Chat/List/FilterBar.d.ts +7 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/index.d.ts +15 -0
- package/dist/components/AgentHub/Chat/List/index.d.ts +6 -0
- package/dist/components/AgentHub/Chat/Modal/FormModal.d.ts +12 -0
- package/dist/components/AgentHub/Chat/Modal/index.d.ts +2 -0
- package/dist/components/AgentHub/Chat/constants/index.d.ts +1 -0
- package/dist/components/AgentHub/Chat/constants/types.d.ts +2 -0
- package/dist/components/AgentHub/Chat/hooks/index.d.ts +5 -0
- package/dist/components/AgentHub/Chat/hooks/useAutoScrollToBottom.d.ts +21 -0
- package/dist/components/AgentHub/Chat/hooks/useChat.d.ts +19 -0
- package/dist/components/AgentHub/Chat/hooks/useChatSessions.d.ts +20 -0
- package/dist/components/AgentHub/Chat/hooks/useSSECompletion.d.ts +13 -0
- package/dist/components/AgentHub/Chat/hooks/useTypewriter.d.ts +16 -0
- package/dist/components/AgentHub/Chat/index.d.ts +7 -0
- package/dist/components/AgentHub/Chat/utils/citationContent.d.ts +37 -0
- package/dist/components/AgentHub/Chat/utils/index.d.ts +5 -0
- package/dist/components/AgentHub/Chat/utils/messageContent.d.ts +18 -0
- package/dist/components/AgentHub/Chat/utils/sanitizeMermaidChart.d.ts +7 -0
- package/dist/components/AgentHub/Chat/utils/sessionMessages.d.ts +21 -0
- package/dist/components/AgentHub/Chat/utils/smoothScroll.d.ts +14 -0
- package/dist/components/AgentHub/ChatSessionAccessGuard.d.ts +8 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/CreateButton.d.ts +6 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/ManageActionButtons.d.ts +6 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/handlers.d.ts +5 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/index.d.ts +5 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/index.d.ts +16 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/index.d.ts +6 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/index.d.ts +4 -0
- package/dist/components/AgentHub/KnowledgeBase/Form/Form.d.ts +13 -0
- package/dist/components/AgentHub/KnowledgeBase/Form/index.d.ts +2 -0
- package/dist/components/AgentHub/KnowledgeBase/List/FilterBar.d.ts +7 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/index.d.ts +11 -0
- package/dist/components/AgentHub/KnowledgeBase/List/index.d.ts +4 -0
- package/dist/components/AgentHub/KnowledgeBase/Modal/FormModal.d.ts +11 -0
- package/dist/components/AgentHub/KnowledgeBase/Modal/index.d.ts +2 -0
- package/dist/components/AgentHub/KnowledgeBase/constants/index.d.ts +1 -0
- package/dist/components/AgentHub/KnowledgeBase/constants/types.d.ts +16 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/index.d.ts +2 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKBDocuments.d.ts +10 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKnowledgeBase.d.ts +13 -0
- package/dist/components/AgentHub/KnowledgeBase/index.d.ts +7 -0
- package/dist/components/AgentHub/types.d.ts +83 -0
- package/dist/components/Auth/PermissionGuard.d.ts +19 -0
- package/dist/components/Auth/ProtectedRoute.d.ts +10 -0
- package/dist/components/Auth/hasPermission.d.ts +2 -0
- package/dist/components/Auth/index.d.ts +3 -0
- package/dist/components/Auth/types.d.ts +1 -0
- package/dist/components/Descriptions/CommonDescriptions.d.ts +23 -0
- package/dist/components/Descriptions/index.d.ts +2 -0
- package/dist/components/File/FileItem/index.d.ts +22 -0
- package/dist/components/File/FileLink/index.d.ts +8 -0
- package/dist/components/File/FilePreview/index.d.ts +11 -0
- package/dist/components/File/FilePreviewModal/index.d.ts +10 -0
- package/dist/components/File/fileDisplay.d.ts +11 -0
- package/dist/components/File/index.d.ts +10 -0
- package/dist/components/File/types.d.ts +20 -0
- package/dist/components/Filter/CommonFilter/index.d.ts +41 -0
- package/dist/components/Filter/FilterDateRange/index.d.ts +18 -0
- package/dist/components/Filter/FilterInput/index.d.ts +10 -0
- package/dist/components/Filter/FilterNumberRange/index.d.ts +12 -0
- package/dist/components/Filter/FilterPanel/index.d.ts +11 -0
- package/dist/components/Filter/FilterPopover/index.d.ts +24 -0
- package/dist/components/Filter/FilterSelect/index.d.ts +18 -0
- package/dist/components/Filter/FilterTreeSelect/index.d.ts +22 -0
- package/dist/components/Filter/FilterTrigger/index.d.ts +16 -0
- package/dist/components/Filter/index.d.ts +30 -0
- package/dist/components/Filter/types.d.ts +35 -0
- package/dist/components/Filter/useFilterState.d.ts +49 -0
- package/dist/components/Form/FetchSelect.d.ts +21 -0
- package/dist/components/Form/FetchTreeSelect.d.ts +22 -0
- package/dist/components/Form/PersonOptionRow/index.d.ts +9 -0
- package/dist/components/Form/StepForm.d.ts +42 -0
- package/dist/components/Form/index.d.ts +8 -0
- package/dist/components/Icons/index.d.ts +85 -0
- package/dist/components/Layout/PageHeaderLayout/index.d.ts +12 -0
- package/dist/components/Layout/index.d.ts +2 -0
- package/dist/components/Modal/StepModal/index.d.ts +25 -0
- package/dist/components/Modal/StepModalTypes.d.ts +40 -0
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Stat/StatCard/index.d.ts +22 -0
- package/dist/components/Stat/StatCardList.d.ts +26 -0
- package/dist/components/Stat/StatPendingBreakdown/index.d.ts +25 -0
- package/dist/components/Stat/index.d.ts +6 -0
- package/dist/components/Tag/FileTags.d.ts +6 -0
- package/dist/components/Tag/SemanticTag.d.ts +52 -0
- package/dist/components/Tag/Tags/index.d.ts +16 -0
- package/dist/components/Tag/index.d.ts +6 -0
- package/dist/components/TooltipInfo/TooltipInfo.d.ts +19 -0
- package/dist/components/TooltipInfo/index.d.ts +2 -0
- package/dist/components/Tour/AppTour/index.d.ts +19 -0
- package/dist/components/Tour/index.d.ts +2 -0
- package/dist/components/Upload/index.d.ts +66 -0
- package/dist/components/Upload/index.js +181 -0
- package/dist/components/Upload/index.js.map +1 -0
- package/dist/components/Upload/style.module.scss.js +19 -0
- package/dist/components/Upload/style.module.scss.js.map +1 -0
- package/dist/components/VirtualScrollbar/VirtualScrollbar/index.d.ts +14 -0
- package/dist/components/VirtualScrollbar/index.d.ts +3 -0
- package/dist/components/VirtualScrollbar/useVirtualScrollbar.d.ts +23 -0
- package/dist/components/index.d.ts +15 -0
- package/dist/hooks/useFetchData.d.ts +22 -0
- package/dist/index.d.ts +26 -28
- package/dist/index.js +166 -164
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/provider/MarsunCoreProvider.d.ts +20 -0
- package/dist/provider/context.d.ts +24 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/styles/global.css +1 -0
- package/dist/theme/constants.d.ts +12 -0
- package/dist/theme/theme.d.ts +11 -0
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/resolveMaybeFn.d.ts +11 -0
- package/package.json +9 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { UploadFile } from 'antd/es/upload/interface';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
/** 上传变体 */
|
|
4
|
+
export type UploadVariant = 'panel' | 'button';
|
|
5
|
+
export interface CommonUploadProps {
|
|
6
|
+
value?: UploadFile[];
|
|
7
|
+
onChange?: (value: UploadFile[]) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
/** 单文件大小限制(字节),默认 500MB */
|
|
10
|
+
fileSize?: number;
|
|
11
|
+
/** 最大上传数量 */
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
multiple?: boolean;
|
|
14
|
+
/** 目录上传模式(webkitdirectory),选中整个文件夹并保留 webkitRelativePath */
|
|
15
|
+
directory?: boolean;
|
|
16
|
+
size?: 'small' | 'middle' | 'large';
|
|
17
|
+
accept?: string;
|
|
18
|
+
/** panel = 拖拽面板(Dragger 样式),button = 按钮(默认) */
|
|
19
|
+
variant?: UploadVariant;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
renderTips?: () => React.ReactNode;
|
|
22
|
+
/** 是否展示已上传文件列表,默认 true(tips 下方) */
|
|
23
|
+
showFileList?: boolean;
|
|
24
|
+
onSave?: (fileList: UploadFile[]) => void;
|
|
25
|
+
ossUpload?: boolean;
|
|
26
|
+
onUpload?: (options: {
|
|
27
|
+
file: File;
|
|
28
|
+
onSuccess: (url?: string) => void;
|
|
29
|
+
onError: (err: Error) => void;
|
|
30
|
+
}) => Promise<void> | void;
|
|
31
|
+
getPermission?: (file: File) => boolean;
|
|
32
|
+
concurrentCount?: number;
|
|
33
|
+
}
|
|
34
|
+
export type CommonUploadRef = {
|
|
35
|
+
upload: () => void;
|
|
36
|
+
uploading: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* CommonUpload — 通用上传组件
|
|
40
|
+
*
|
|
41
|
+
* - 在 antd `<Form.Item>` 内使用时,通过 `value`/`onChange` 自动接入表单
|
|
42
|
+
* - 独立使用时,通过 `onSave` 获取文件列表
|
|
43
|
+
*
|
|
44
|
+
* ## 两种变体
|
|
45
|
+
*
|
|
46
|
+
* - **`variant="button"`(默认)** — 虚线边框按钮 + 底部提示文案 + 已传文件列表
|
|
47
|
+
* - **`variant="panel"`** — Dragger 拖拽面板 + 底部已传文件列表
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* // 在 Form.Item 中使用
|
|
52
|
+
* <Form.Item name="files" label="简历附件" rules={[{ required: true, message: '请上传文件' }]}>
|
|
53
|
+
* <CommonUpload accept=".pdf,.jpg,.png" maxLength={10} />
|
|
54
|
+
* </Form.Item>
|
|
55
|
+
*
|
|
56
|
+
* // 独立使用(Modal 内、非表单场景)
|
|
57
|
+
* <CommonUpload variant="panel" accept=".doc,.pdf" onSave={(list) => setFiles(list)} />
|
|
58
|
+
*
|
|
59
|
+
* // ref 手动触发上传
|
|
60
|
+
* const ref = useRef<CommonUploadRef>(null);
|
|
61
|
+
* <CommonUpload ref={ref} onUpload={...} />;
|
|
62
|
+
* ref.current?.upload();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare const CommonUpload: React.ForwardRefExoticComponent<CommonUploadProps & React.RefAttributes<CommonUploadRef>>;
|
|
66
|
+
export default CommonUpload;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { jsxs as h, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Inbox as V, Upload as W, File as X, Trash2 as Y } from "../Icons/index.js";
|
|
3
|
+
import { message as y, Upload as D, Button as H, Typography as K, Tag as Z } from "antd";
|
|
4
|
+
import f from "react";
|
|
5
|
+
import t from "./style.module.scss.js";
|
|
6
|
+
import a from "classnames";
|
|
7
|
+
const j = (r) => r < 1024 * 1024 ? `${(r / 1024).toFixed(0)}KB` : r < 1024 ** 3 ? `${(r / 1024 / 1024).toFixed(0)}M` : `${(r / 1024 ** 3).toFixed(1)}G`;
|
|
8
|
+
function S(r, i, o) {
|
|
9
|
+
const c = [];
|
|
10
|
+
if (r) {
|
|
11
|
+
const g = r.split(",").map((N) => N.trim().replace(/^\./, "")).filter(Boolean);
|
|
12
|
+
g.length && c.push(`支持扩展名${g.join(",")}`);
|
|
13
|
+
}
|
|
14
|
+
return i && c.push(`单个文件大小不超过${j(i)}`), o && c.push(`最多上传${o}个附件`), c.length ? /* @__PURE__ */ e(K.Text, { type: "secondary", className: a("upload-item", t["upload-item"]), children: c.join(",") }) : null;
|
|
15
|
+
}
|
|
16
|
+
function ll(r) {
|
|
17
|
+
const i = r.lastIndexOf(".");
|
|
18
|
+
return i >= 0 ? r.slice(i + 1).toUpperCase() : "";
|
|
19
|
+
}
|
|
20
|
+
const G = ({ fileList: r, onRemove: i }) => r.length ? /* @__PURE__ */ e("div", { className: a("upload-link", t["upload-link"]), children: r.map((o) => /* @__PURE__ */ h(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: a(
|
|
24
|
+
a("upload-file-row", t["upload-file-row"]),
|
|
25
|
+
o.status === "error" && a("upload-file-row-error", t["upload-file-row-error"])
|
|
26
|
+
),
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ h("div", { className: a("upload-label", t["upload-label"]), children: [
|
|
29
|
+
/* @__PURE__ */ e(X, { className: a("upload-value", t["upload-value"]) }),
|
|
30
|
+
/* @__PURE__ */ e("span", { className: a("upload-meta", t["upload-meta"]), children: o.name }),
|
|
31
|
+
/* @__PURE__ */ e(Z, { color: "processing", className: a("upload-icon", t["upload-icon"]), children: ll(o.name) }),
|
|
32
|
+
o.size && /* @__PURE__ */ e(K.Text, { type: "secondary", className: a("upload-title", t["upload-title"]), children: j(o.size) })
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ e(
|
|
35
|
+
H,
|
|
36
|
+
{
|
|
37
|
+
type: "text",
|
|
38
|
+
danger: !0,
|
|
39
|
+
size: "small",
|
|
40
|
+
icon: /* @__PURE__ */ e(Y, {}),
|
|
41
|
+
onClick: () => i(o.uid),
|
|
42
|
+
className: a("upload-desc", t["upload-desc"])
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
o.uid
|
|
48
|
+
)) }) : null, el = f.forwardRef(
|
|
49
|
+
({
|
|
50
|
+
value: r,
|
|
51
|
+
onChange: i,
|
|
52
|
+
className: o,
|
|
53
|
+
variant: c,
|
|
54
|
+
size: g,
|
|
55
|
+
children: N,
|
|
56
|
+
renderTips: x,
|
|
57
|
+
showFileList: k = !0,
|
|
58
|
+
fileSize: R,
|
|
59
|
+
maxLength: M,
|
|
60
|
+
multiple: L,
|
|
61
|
+
directory: z,
|
|
62
|
+
accept: F,
|
|
63
|
+
onUpload: U,
|
|
64
|
+
onSave: u,
|
|
65
|
+
getPermission: w,
|
|
66
|
+
concurrentCount: P
|
|
67
|
+
}, _) => {
|
|
68
|
+
const [A, J] = f.useState([]), [C, I] = f.useState(!1), n = r ?? A, m = f.useCallback(
|
|
69
|
+
(l) => {
|
|
70
|
+
const s = typeof l == "function" ? l(n) : l;
|
|
71
|
+
i == null || i(s), J(s), u == null || u(s);
|
|
72
|
+
},
|
|
73
|
+
[n, i, u]
|
|
74
|
+
), b = R ?? 500 * 1024 * 1024, B = P ?? 3, O = f.useCallback(
|
|
75
|
+
(l) => w && !w(l) ? (y.error("无权限上传此文件"), !1) : l.size > b ? (y.error(`文件超出 ${j(b)} 限制`), !1) : !0,
|
|
76
|
+
[b, w]
|
|
77
|
+
), q = f.useCallback(async () => {
|
|
78
|
+
if (!(!U || !n.length)) {
|
|
79
|
+
I(!0);
|
|
80
|
+
try {
|
|
81
|
+
const l = [...n], s = [];
|
|
82
|
+
for (; l.length; ) {
|
|
83
|
+
const d = l.shift();
|
|
84
|
+
if (!(d != null && d.originFileObj)) continue;
|
|
85
|
+
const Q = d.originFileObj;
|
|
86
|
+
s.push(
|
|
87
|
+
new Promise((T) => {
|
|
88
|
+
U({
|
|
89
|
+
file: Q,
|
|
90
|
+
onSuccess: (v) => {
|
|
91
|
+
m(
|
|
92
|
+
($) => $.map(
|
|
93
|
+
(p) => p.uid === d.uid ? { ...p, status: "done", url: v ?? p.url } : p
|
|
94
|
+
)
|
|
95
|
+
), T();
|
|
96
|
+
},
|
|
97
|
+
onError: (v) => {
|
|
98
|
+
y.error(`${d.name} 上传失败`), m(
|
|
99
|
+
($) => $.map((p) => p.uid === d.uid ? { ...p, status: "error" } : p)
|
|
100
|
+
), T();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
})
|
|
104
|
+
), s.length >= B && await Promise.race(s);
|
|
105
|
+
}
|
|
106
|
+
await Promise.allSettled(s), u == null || u(n);
|
|
107
|
+
} finally {
|
|
108
|
+
I(!1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, [n, U, B, u, m]);
|
|
112
|
+
f.useImperativeHandle(_, () => ({ upload: q, uploading: C }), [
|
|
113
|
+
q,
|
|
114
|
+
C
|
|
115
|
+
]);
|
|
116
|
+
const E = (x == null ? void 0 : x()) ?? S(F, R, M);
|
|
117
|
+
return c === "panel" ? /* @__PURE__ */ h("div", { className: o, children: [
|
|
118
|
+
/* @__PURE__ */ h(
|
|
119
|
+
D.Dragger,
|
|
120
|
+
{
|
|
121
|
+
fileList: n,
|
|
122
|
+
beforeUpload: O,
|
|
123
|
+
onChange: (l) => m(l.fileList),
|
|
124
|
+
multiple: L,
|
|
125
|
+
directory: z,
|
|
126
|
+
accept: F,
|
|
127
|
+
showUploadList: !1,
|
|
128
|
+
customRequest: ({ onSuccess: l }) => l == null ? void 0 : l({}),
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ e("p", { className: a("upload-drag-icon", t["upload-drag-icon"]), children: /* @__PURE__ */ e(V, {}) }),
|
|
131
|
+
/* @__PURE__ */ e("p", { className: "ant-upload-text", children: "点击或拖拽文件到此区域上传" }),
|
|
132
|
+
/* @__PURE__ */ e("p", { children: E })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
k && /* @__PURE__ */ e(
|
|
137
|
+
G,
|
|
138
|
+
{
|
|
139
|
+
fileList: n,
|
|
140
|
+
onRemove: (l) => m((s) => s.filter((d) => d.uid !== l))
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] }) : /* @__PURE__ */ h("div", { className: o, children: [
|
|
144
|
+
/* @__PURE__ */ e(
|
|
145
|
+
D,
|
|
146
|
+
{
|
|
147
|
+
fileList: n,
|
|
148
|
+
beforeUpload: O,
|
|
149
|
+
onChange: (l) => m(l.fileList),
|
|
150
|
+
multiple: L,
|
|
151
|
+
directory: z,
|
|
152
|
+
accept: F,
|
|
153
|
+
showUploadList: !1,
|
|
154
|
+
customRequest: ({ onSuccess: l }) => l == null ? void 0 : l({}),
|
|
155
|
+
children: N ?? /* @__PURE__ */ e(
|
|
156
|
+
H,
|
|
157
|
+
{
|
|
158
|
+
size: g,
|
|
159
|
+
icon: /* @__PURE__ */ e(W, {}),
|
|
160
|
+
className: a("upload-toolbar", t["upload-toolbar"]),
|
|
161
|
+
children: "点击上传"
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ e("div", { className: a("upload-list", t["upload-list"]), children: E }),
|
|
167
|
+
k && /* @__PURE__ */ e(
|
|
168
|
+
G,
|
|
169
|
+
{
|
|
170
|
+
fileList: n,
|
|
171
|
+
onRemove: (l) => m((s) => s.filter((d) => d.uid !== l))
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
] });
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
el.displayName = "CommonUpload";
|
|
178
|
+
export {
|
|
179
|
+
el as default
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Upload/index.tsx"],"sourcesContent":["import { Trash2, File, Inbox, Upload as UploadIcon } from '@/components/Icons';\nimport { Button, message, Tag, Typography, Upload } from 'antd';\nimport type { UploadFile } from 'antd/es/upload/interface';\nimport React from 'react';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\n/* ---------- types ---------- */\n\n/** 上传变体 */\nexport type UploadVariant = 'panel' | 'button';\n\nexport interface CommonUploadProps {\n /* ---- antd Form.Item 兼容属性 ---- */\n value?: UploadFile[];\n onChange?: (value: UploadFile[]) => void;\n\n /* ---- 容器/样式 ---- */\n className?: string;\n\n /* ---- 上传配置 ---- */\n /** 单文件大小限制(字节),默认 500MB */\n fileSize?: number;\n /** 最大上传数量 */\n maxLength?: number;\n multiple?: boolean;\n /** 目录上传模式(webkitdirectory),选中整个文件夹并保留 webkitRelativePath */\n directory?: boolean;\n size?: 'small' | 'middle' | 'large';\n accept?: string;\n\n /* ---- UI 变体 ---- */\n /** panel = 拖拽面板(Dragger 样式),button = 按钮(默认) */\n variant?: UploadVariant;\n children?: React.ReactNode;\n renderTips?: () => React.ReactNode;\n\n /* ---- 文件列表展示 ---- */\n /** 是否展示已上传文件列表,默认 true(tips 下方) */\n showFileList?: boolean;\n\n /* ---- 回调 ---- */\n onSave?: (fileList: UploadFile[]) => void;\n ossUpload?: boolean;\n onUpload?: (options: {\n file: File;\n onSuccess: (url?: string) => void;\n onError: (err: Error) => void;\n }) => Promise<void> | void;\n getPermission?: (file: File) => boolean;\n concurrentCount?: number;\n}\n\nexport type CommonUploadRef = {\n upload: () => void;\n uploading: boolean;\n};\n\n/* ---------- utils ---------- */\n\nconst formatSize = (bytes: number): string => {\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(0)}KB`;\n if (bytes < 1024 ** 3) return `${(bytes / 1024 / 1024).toFixed(0)}M`;\n return `${(bytes / 1024 ** 3).toFixed(1)}G`;\n};\n\nfunction buildTips(accept?: string, fileSize?: number, maxLength?: number): React.ReactNode {\n const parts: string[] = [];\n if (accept) {\n const exts = accept\n .split(',')\n .map((s) => s.trim().replace(/^\\./, ''))\n .filter(Boolean);\n if (exts.length) parts.push(`支持扩展名${exts.join(',')}`);\n }\n if (fileSize) parts.push(`单个文件大小不超过${formatSize(fileSize)}`);\n if (maxLength) parts.push(`最多上传${maxLength}个附件`);\n return parts.length ? (\n <Typography.Text type=\"secondary\" className={classNames('upload-item', styles['upload-item'])}>\n {parts.join(',')}\n </Typography.Text>\n ) : null;\n}\n\nfunction getExt(filename: string): string {\n const idx = filename.lastIndexOf('.');\n return idx >= 0 ? filename.slice(idx + 1).toUpperCase() : '';\n}\n\n/* ---------- 子组件:已上传文件列表 ---------- */\n\ninterface UploadedFilesProps {\n fileList: UploadFile[];\n onRemove: (uid: string) => void;\n}\n\nconst UploadedFiles: React.FC<UploadedFilesProps> = ({ fileList, onRemove }) => {\n if (!fileList.length) return null;\n\n return (\n <div className={classNames('upload-link', styles['upload-link'])}>\n {fileList.map((file) => (\n <div\n key={file.uid}\n className={classNames(\n classNames('upload-file-row', styles['upload-file-row']),\n file.status === 'error' && classNames('upload-file-row-error', styles['upload-file-row-error']),\n )}\n >\n <div className={classNames('upload-label', styles['upload-label'])}>\n <File className={classNames('upload-value', styles['upload-value'])} />\n <span className={classNames('upload-meta', styles['upload-meta'])}>{file.name}</span>\n <Tag color=\"processing\" className={classNames('upload-icon', styles['upload-icon'])}>\n {getExt(file.name)}\n </Tag>\n {file.size && (\n <Typography.Text type=\"secondary\" className={classNames('upload-title', styles['upload-title'])}>\n {formatSize(file.size)}\n </Typography.Text>\n )}\n </div>\n <Button\n type=\"text\"\n danger\n size=\"small\"\n icon={<Trash2 />}\n onClick={() => onRemove(file.uid)}\n className={classNames('upload-desc', styles['upload-desc'])}\n />\n </div>\n ))}\n </div>\n );\n};\n\n/* ---------- 主组件 ---------- */\n\n/**\n * CommonUpload — 通用上传组件\n *\n * - 在 antd `<Form.Item>` 内使用时,通过 `value`/`onChange` 自动接入表单\n * - 独立使用时,通过 `onSave` 获取文件列表\n *\n * ## 两种变体\n *\n * - **`variant=\"button\"`(默认)** — 虚线边框按钮 + 底部提示文案 + 已传文件列表\n * - **`variant=\"panel\"`** — Dragger 拖拽面板 + 底部已传文件列表\n *\n * @example\n * ```tsx\n * // 在 Form.Item 中使用\n * <Form.Item name=\"files\" label=\"简历附件\" rules={[{ required: true, message: '请上传文件' }]}>\n * <CommonUpload accept=\".pdf,.jpg,.png\" maxLength={10} />\n * </Form.Item>\n *\n * // 独立使用(Modal 内、非表单场景)\n * <CommonUpload variant=\"panel\" accept=\".doc,.pdf\" onSave={(list) => setFiles(list)} />\n *\n * // ref 手动触发上传\n * const ref = useRef<CommonUploadRef>(null);\n * <CommonUpload ref={ref} onUpload={...} />;\n * ref.current?.upload();\n * ```\n */\nconst CommonUpload = React.forwardRef<CommonUploadRef, CommonUploadProps>(\n (\n {\n value,\n onChange,\n className,\n variant,\n size,\n children,\n renderTips,\n showFileList = true,\n fileSize,\n maxLength,\n multiple,\n directory,\n accept,\n onUpload,\n onSave,\n getPermission,\n concurrentCount,\n },\n ref,\n ) => {\n const [innerFileList, setInnerFileList] = React.useState<UploadFile[]>([]);\n const [uploading, setUploading] = React.useState(false);\n\n // 受控模式:value 优先;非受控:内部状态\n const fileList = value ?? innerFileList;\n const setFileList = React.useCallback(\n (next: UploadFile[] | ((prev: UploadFile[]) => UploadFile[])) => {\n const resolved = typeof next === 'function' ? next(fileList) : next;\n onChange?.(resolved);\n setInnerFileList(resolved);\n onSave?.(resolved);\n },\n [fileList, onChange, onSave],\n );\n\n const effectiveFileSize = fileSize ?? 500 * 1024 * 1024;\n const concurrent = concurrentCount ?? 3;\n\n const beforeUploadFn = React.useCallback(\n (file: File): boolean => {\n if (getPermission && !getPermission(file)) {\n message.error('无权限上传此文件');\n return false;\n }\n if (file.size > effectiveFileSize) {\n message.error(`文件超出 ${formatSize(effectiveFileSize)} 限制`);\n return false;\n }\n return true;\n },\n [effectiveFileSize, getPermission],\n );\n\n const triggerUpload = React.useCallback(async () => {\n if (!onUpload || !fileList.length) return;\n setUploading(true);\n try {\n const pending = [...fileList];\n const pool: Promise<void>[] = [];\n while (pending.length) {\n const item = pending.shift();\n if (!item?.originFileObj) continue;\n const rawFile = item.originFileObj;\n pool.push(\n new Promise<void>((resolve) => {\n onUpload({\n file: rawFile,\n onSuccess: (url?) => {\n setFileList((prev) =>\n prev.map((f) =>\n f.uid === item.uid ? { ...f, status: 'done' as const, url: url ?? f.url } : f,\n ),\n );\n resolve();\n },\n onError: (_err: Error) => {\n message.error(`${item.name} 上传失败`);\n setFileList((prev) =>\n prev.map((f) => (f.uid === item.uid ? { ...f, status: 'error' as const } : f)),\n );\n resolve();\n },\n });\n }),\n );\n if (pool.length >= concurrent) await Promise.race(pool);\n }\n await Promise.allSettled(pool);\n onSave?.(fileList);\n } finally {\n setUploading(false);\n }\n }, [fileList, onUpload, concurrent, onSave, setFileList]);\n\n React.useImperativeHandle(ref, () => ({ upload: triggerUpload, uploading }), [\n triggerUpload,\n uploading,\n ]);\n\n const tips = renderTips?.() ?? buildTips(accept, fileSize, maxLength);\n\n if (variant === 'panel') {\n return (\n <div className={className}>\n <Upload.Dragger\n fileList={fileList}\n beforeUpload={beforeUploadFn}\n onChange={(info) => setFileList(info.fileList)}\n multiple={multiple}\n directory={directory}\n accept={accept}\n showUploadList={false}\n customRequest={({ onSuccess }) => onSuccess?.({})}\n >\n <p className={classNames('upload-drag-icon', styles['upload-drag-icon'])}>\n <Inbox />\n </p>\n <p className=\"ant-upload-text\">点击或拖拽文件到此区域上传</p>\n <p>{tips}</p>\n </Upload.Dragger>\n {showFileList && (\n <UploadedFiles\n fileList={fileList}\n onRemove={(uid) => setFileList((prev) => prev.filter((f) => f.uid !== uid))}\n />\n )}\n </div>\n );\n }\n\n // button mode (default)\n return (\n <div className={className}>\n <Upload\n fileList={fileList}\n beforeUpload={beforeUploadFn}\n onChange={(info) => setFileList(info.fileList)}\n multiple={multiple}\n directory={directory}\n accept={accept}\n showUploadList={false}\n customRequest={({ onSuccess }) => onSuccess?.({})}\n >\n {children ?? (\n <Button\n size={size}\n icon={<UploadIcon />}\n className={classNames('upload-toolbar', styles['upload-toolbar'])}\n >\n 点击上传\n </Button>\n )}\n </Upload>\n <div className={classNames('upload-list', styles['upload-list'])}>{tips}</div>\n {showFileList && (\n <UploadedFiles\n fileList={fileList}\n onRemove={(uid) => setFileList((prev) => prev.filter((f) => f.uid !== uid))}\n />\n )}\n </div>\n );\n },\n);\n\nCommonUpload.displayName = 'CommonUpload';\n\nexport default CommonUpload;\n"],"names":["formatSize","bytes","buildTips","accept","fileSize","maxLength","parts","exts","s","jsx","Typography","classNames","styles","getExt","filename","idx","UploadedFiles","fileList","onRemove","file","jsxs","File","Tag","Button","Trash2","CommonUpload","React","value","onChange","className","variant","size","children","renderTips","showFileList","multiple","directory","onUpload","onSave","getPermission","concurrentCount","ref","innerFileList","setInnerFileList","uploading","setUploading","setFileList","next","resolved","effectiveFileSize","concurrent","beforeUploadFn","message","triggerUpload","pending","pool","item","rawFile","resolve","url","prev","f","_err","tips","Upload","info","onSuccess","Inbox","uid","UploadIcon"],"mappings":";;;;;;AA4DA,MAAMA,IAAa,CAACC,MACdA,IAAQ,OAAO,OAAa,IAAIA,IAAQ,MAAM,QAAQ,CAAC,CAAC,OACxDA,IAAQ,QAAQ,IAAU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A,QAAA;AAAA,UACC,UAAAC;AAAA,UACA,UAAU,CAACmD,MAAQtB,EAAY,CAACc,MAASA,EAAK,OAAO,CAACC,MAAMA,EAAE,QAAQO,CAAG,CAAC;AAAA,QAAA;AAAA,MAAA;AAAA,IAC5E,GAEJ;AAAA,EAEJ;AACF;AAEA3C,GAAa,cAAc;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const o = {
|
|
2
|
+
"upload-item": "_upload-item_xoraq_67",
|
|
3
|
+
"upload-link": "_upload-link_xoraq_73",
|
|
4
|
+
"upload-label": "_upload-label_xoraq_77",
|
|
5
|
+
"upload-value": "_upload-value_xoraq_84",
|
|
6
|
+
"upload-meta": "_upload-meta_xoraq_89",
|
|
7
|
+
"upload-icon": "_upload-icon_xoraq_95",
|
|
8
|
+
"upload-title": "_upload-title_xoraq_100",
|
|
9
|
+
"upload-desc": "_upload-desc_xoraq_106",
|
|
10
|
+
"upload-toolbar": "_upload-toolbar_xoraq_115",
|
|
11
|
+
"upload-list": "_upload-list_xoraq_125",
|
|
12
|
+
"upload-file-row": "_upload-file-row_xoraq_129",
|
|
13
|
+
"upload-file-row-error": "_upload-file-row-error_xoraq_140",
|
|
14
|
+
"upload-drag-icon": "_upload-drag-icon_xoraq_145"
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
o as default
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=style.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ScrollDirection } from '../useVirtualScrollbar';
|
|
3
|
+
export interface VirtualScrollbarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** 滚动方向,默认 vertical */
|
|
6
|
+
direction?: ScrollDirection;
|
|
7
|
+
/** 滚动/悬停后自动隐藏 thumb,默认 true */
|
|
8
|
+
autoHide?: boolean;
|
|
9
|
+
/** 外层容器 className */
|
|
10
|
+
wrapperClassName?: string;
|
|
11
|
+
}
|
|
12
|
+
/** 覆盖式虚拟滚动条:隐藏原生滚动条,thumb 悬浮不占布局宽度 */
|
|
13
|
+
declare const VirtualScrollbar: React.ForwardRefExoticComponent<VirtualScrollbarProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default VirtualScrollbar;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export type ScrollDirection = 'vertical' | 'horizontal' | 'both';
|
|
3
|
+
export interface ThumbMetrics {
|
|
4
|
+
vertical: {
|
|
5
|
+
size: number;
|
|
6
|
+
offset: number;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
};
|
|
9
|
+
horizontal: {
|
|
10
|
+
size: number;
|
|
11
|
+
offset: number;
|
|
12
|
+
visible: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare function useVirtualScrollbar(viewportRef: RefObject<HTMLDivElement | null>, direction?: ScrollDirection, autoHide?: boolean): {
|
|
16
|
+
metrics: ThumbMetrics;
|
|
17
|
+
active: boolean;
|
|
18
|
+
handleScroll: () => void;
|
|
19
|
+
handleMouseEnter: () => void;
|
|
20
|
+
handleMouseLeave: () => void;
|
|
21
|
+
startDrag: (axis: "vertical" | "horizontal", event: React.MouseEvent) => void;
|
|
22
|
+
handleTrackClick: (axis: "vertical" | "horizontal", event: React.MouseEvent<HTMLDivElement>) => void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './Auth';
|
|
2
|
+
export * from './Descriptions';
|
|
3
|
+
export * from './File';
|
|
4
|
+
export * from './Filter';
|
|
5
|
+
export * from './Form';
|
|
6
|
+
export * from './Layout';
|
|
7
|
+
export * from './Modal';
|
|
8
|
+
export * from './Stat';
|
|
9
|
+
export * from './Tag';
|
|
10
|
+
export * from './TooltipInfo';
|
|
11
|
+
export * from './Tour';
|
|
12
|
+
export { default as CommonUpload } from './Upload';
|
|
13
|
+
export type { CommonUploadProps, CommonUploadRef, UploadVariant } from './Upload';
|
|
14
|
+
export * from './VirtualScrollbar';
|
|
15
|
+
export * from './Icons';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type FetchDataOptions<T> = {
|
|
2
|
+
/** props 模式数据(优先于 fetch) */
|
|
3
|
+
data?: T;
|
|
4
|
+
fetchUrl?: string;
|
|
5
|
+
fetchOptions?: RequestInit;
|
|
6
|
+
transformData?: (raw: unknown) => T;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** 默认 30s */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Provider 注入的 baseUrl */
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
/** Provider 注入的默认 headers */
|
|
13
|
+
defaultHeaders?: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
export type FetchDataResult<T> = {
|
|
16
|
+
data: T | undefined;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
error: Error | null;
|
|
19
|
+
reload: () => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function fetchWithTimeout(url: string, options?: RequestInit, timeoutMs?: number): Promise<unknown>;
|
|
22
|
+
export declare function useFetchData<T>(options: FetchDataOptions<T>): FetchDataResult<T>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export { }
|
|
1
|
+
export { MarsunCoreProvider, useMarsunAuth, useMarsunCore, useMarsunFetch } from './provider';
|
|
2
|
+
export type { MarsunCoreProviderProps, MarsunAuthContext, MarsunFetchContext } from './provider';
|
|
3
|
+
export { generateTheme, applyThemeToCssVariables, DEFAULT_PRIMARY_COLOR, PALETTE } from './theme';
|
|
4
|
+
export { useFetchData, fetchWithTimeout } from './hooks/useFetchData';
|
|
5
|
+
export type { FetchDataOptions, FetchDataResult } from './hooks/useFetchData';
|
|
6
|
+
export { resolveMaybeFn, resolveVisible, type MaybeFn, type Visibility, } from './utils/resolveMaybeFn';
|
|
7
|
+
export { formatFileSize } from './utils/format';
|
|
8
|
+
export * from './components/Auth';
|
|
9
|
+
export * from './components/Descriptions';
|
|
10
|
+
export * from './components/File';
|
|
11
|
+
export * from './components/Filter';
|
|
12
|
+
export * from './components/Form';
|
|
13
|
+
export * from './components/Layout';
|
|
14
|
+
export * from './components/Modal';
|
|
15
|
+
export * from './components/Stat';
|
|
16
|
+
export * from './components/Tag';
|
|
17
|
+
export * from './components/TooltipInfo';
|
|
18
|
+
export * from './components/Tour';
|
|
19
|
+
export { default as CommonUpload } from './components/Upload';
|
|
20
|
+
export type { CommonUploadProps, CommonUploadRef, UploadVariant } from './components/Upload';
|
|
21
|
+
export * from './components/VirtualScrollbar';
|
|
22
|
+
export * from './components/Icons';
|
|
23
|
+
export { default as AgentHubAccessGuard } from './components/AgentHub/AgentHubAccessGuard';
|
|
24
|
+
export { default as AgentHubIndexRedirect } from './components/AgentHub/AgentHubIndexRedirect';
|
|
25
|
+
export { default as AgentHubSessionAccessGuard } from './components/AgentHub/ChatSessionAccessGuard';
|
|
26
|
+
export type * from './components/AgentHub/types';
|