@hkyhy/marsun-components-core 0.1.23 → 0.1.24

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.
@@ -3,3 +3,5 @@ export { hasCitationMarkers, normalizeAssistantMarkdown, normalizeDisplayText, p
3
3
  export type { ParsedAssistantContent } from './messageContent';
4
4
  export { sanitizeMermaidChart, stripProseFromMermaid } from './sanitizeMermaidChart';
5
5
  export { extractCitations, formatSessionTime, getSessionDisplayName, isWelcomeOnlyMessages, parseSessionMessages, toDisplayMessages, } from './sessionMessages';
6
+ export { animateScrollFromTopToBottom, animateScrollTo, getScrollBottom } from './smoothScroll';
7
+ export type { AnimateScrollOptions } from './smoothScroll';
@@ -0,0 +1,51 @@
1
+ const d = (t) => 1 - (1 - t) ** 5, T = (t, n, o = {}) => {
2
+ const { minDuration: i = 420, maxDuration: s = 880, msPerPixel: a = 0.32 } = o, r = Math.max(0, t.scrollHeight - t.clientHeight), c = Math.min(Math.max(0, n), r), l = t.scrollTop, m = c - l;
3
+ if (Math.abs(m) < 1)
4
+ return t.scrollTop = c, () => {
5
+ };
6
+ const f = Math.min(Math.max(Math.abs(m) * a, i), s), g = performance.now();
7
+ let e = 0, u = !1;
8
+ const h = (M) => {
9
+ if (u) return;
10
+ const p = Math.min((M - g) / f, 1);
11
+ t.scrollTop = l + m * d(p), p < 1 && (e = requestAnimationFrame(h));
12
+ };
13
+ return e = requestAnimationFrame(h), () => {
14
+ u = !0, cancelAnimationFrame(e);
15
+ };
16
+ }, x = (t) => Math.max(0, t.scrollHeight - t.clientHeight), F = (t, n = {}) => {
17
+ const o = [];
18
+ t.scrollTop = 0;
19
+ const i = () => {
20
+ o.push(
21
+ T(t, x(t), {
22
+ minDuration: 460,
23
+ maxDuration: 920,
24
+ msPerPixel: 0.34,
25
+ ...n
26
+ })
27
+ );
28
+ const a = window.setTimeout(() => {
29
+ const r = x(t);
30
+ r - t.scrollTop > 6 && o.push(
31
+ T(t, r, {
32
+ minDuration: 180,
33
+ maxDuration: 320,
34
+ msPerPixel: 0.2
35
+ })
36
+ );
37
+ }, 120);
38
+ o.push(() => window.clearTimeout(a));
39
+ }, s = requestAnimationFrame(() => {
40
+ requestAnimationFrame(i);
41
+ });
42
+ return () => {
43
+ cancelAnimationFrame(s), o.forEach((a) => a());
44
+ };
45
+ };
46
+ export {
47
+ F as animateScrollFromTopToBottom,
48
+ T as animateScrollTo,
49
+ x as getScrollBottom
50
+ };
51
+ //# sourceMappingURL=smoothScroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smoothScroll.js","sources":["../../../../../src/components/AgentHub/Chat/utils/smoothScroll.ts"],"sourcesContent":["export interface AnimateScrollOptions {\n minDuration?: number;\n maxDuration?: number;\n msPerPixel?: number;\n}\n\nconst easeOutQuint = (progress: number) => 1 - (1 - progress) ** 5;\n\n/**\n * Smoothly scroll an element with a custom ease-out curve (softer than native smooth).\n */\nexport const animateScrollTo = (\n element: HTMLElement,\n targetTop: number,\n options: AnimateScrollOptions = {},\n): (() => void) => {\n const { minDuration = 420, maxDuration = 880, msPerPixel = 0.32 } = options;\n\n const maxTop = Math.max(0, element.scrollHeight - element.clientHeight);\n const clampedTarget = Math.min(Math.max(0, targetTop), maxTop);\n const startTop = element.scrollTop;\n const distance = clampedTarget - startTop;\n\n if (Math.abs(distance) < 1) {\n element.scrollTop = clampedTarget;\n return () => {};\n }\n\n const duration = Math.min(Math.max(Math.abs(distance) * msPerPixel, minDuration), maxDuration);\n const startTime = performance.now();\n let rafId = 0;\n let cancelled = false;\n\n const step = (now: number) => {\n if (cancelled) return;\n\n const progress = Math.min((now - startTime) / duration, 1);\n element.scrollTop = startTop + distance * easeOutQuint(progress);\n\n if (progress < 1) {\n rafId = requestAnimationFrame(step);\n }\n };\n\n rafId = requestAnimationFrame(step);\n\n return () => {\n cancelled = true;\n cancelAnimationFrame(rafId);\n };\n};\n\nexport const getScrollBottom = (element: HTMLElement) =>\n Math.max(0, element.scrollHeight - element.clientHeight);\n\n/**\n * Session switch: reset to top, then ease to bottom; optional soft correction after layout shifts.\n */\nexport const animateScrollFromTopToBottom = (\n element: HTMLElement,\n options: AnimateScrollOptions = {},\n): (() => void) => {\n const cleanups: Array<() => void> = [];\n\n element.scrollTop = 0;\n\n const start = () => {\n cleanups.push(\n animateScrollTo(element, getScrollBottom(element), {\n minDuration: 460,\n maxDuration: 920,\n msPerPixel: 0.34,\n ...options,\n }),\n );\n\n const correctionTimer = window.setTimeout(() => {\n const bottom = getScrollBottom(element);\n const remaining = bottom - element.scrollTop;\n if (remaining > 6) {\n cleanups.push(\n animateScrollTo(element, bottom, {\n minDuration: 180,\n maxDuration: 320,\n msPerPixel: 0.2,\n }),\n );\n }\n }, 120);\n\n cleanups.push(() => window.clearTimeout(correctionTimer));\n };\n\n const raf = requestAnimationFrame(() => {\n requestAnimationFrame(start);\n });\n\n return () => {\n cancelAnimationFrame(raf);\n cleanups.forEach((cleanup) => cleanup());\n };\n};\n"],"names":["easeOutQuint","progress","animateScrollTo","element","targetTop","options","minDuration","maxDuration","msPerPixel","maxTop","clampedTarget","startTop","distance","duration","startTime","rafId","cancelled","step","now","getScrollBottom","animateScrollFromTopToBottom","cleanups","start","correctionTimer","bottom","raf","cleanup"],"mappings":"AAMA,MAAMA,IAAe,CAACC,MAAqB,KAAK,IAAIA,MAAa,GAKpDC,IAAkB,CAC7BC,GACAC,GACAC,IAAgC,CAAA,MACf;AACjB,QAAM,EAAE,aAAAC,IAAc,KAAK,aAAAC,IAAc,KAAK,YAAAC,IAAa,SAASH,GAE9DI,IAAS,KAAK,IAAI,GAAGN,EAAQ,eAAeA,EAAQ,YAAY,GAChEO,IAAgB,KAAK,IAAI,KAAK,IAAI,GAAGN,CAAS,GAAGK,CAAM,GACvDE,IAAWR,EAAQ,WACnBS,IAAWF,IAAgBC;AAEjC,MAAI,KAAK,IAAIC,CAAQ,IAAI;AACvB,WAAAT,EAAQ,YAAYO,GACb,MAAM;AAAA,IAAC;AAGhB,QA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0BAAsBH,CAAK;AAAA,EAC7B,CAAC;AAED,SAAO,MAAM;AACX,yBAAqBG,CAAG,GACxBJ,EAAS,QAAQ,CAACK,MAAYA,EAAA,CAAS;AAAA,EACzC;AACF;"}
@@ -23,7 +23,7 @@ async function B(r, e) {
23
23
  const t = s.init(r);
24
24
  return await t.preview(e), () => t.destroy();
25
25
  }
26
- async function C(r, e) {
26
+ async function M(r, e) {
27
27
  const { renderAsync: s } = await import("docx-preview"), a = new Blob([e]);
28
28
  await s(a, r, r, {
29
29
  inWrapper: !0,
@@ -32,11 +32,11 @@ async function C(r, e) {
32
32
  breakPages: !0
33
33
  });
34
34
  }
35
- async function M(r, e, s) {
35
+ async function T(r, e, s) {
36
36
  const { init: a } = await import("pptx-preview"), t = a(r, { width: s, height: Math.round(s * 0.5625), mode: "list" });
37
37
  return await t.preview(e), () => t.destroy();
38
38
  }
39
- function T(r, e) {
39
+ function W(r, e) {
40
40
  const s = new TextDecoder("utf-8"), a = document.createElement("pre");
41
41
  a.className = o["file-preview-text"], a.textContent = s.decode(e), r.appendChild(a);
42
42
  }
@@ -60,11 +60,11 @@ const D = ({
60
60
  if (i === "excel")
61
61
  t.current = await B(f, c);
62
62
  else if (i === "word")
63
- await C(f, c);
63
+ await M(f, c);
64
64
  else if (i === "ppt") {
65
65
  const y = f.clientWidth || 852;
66
- t.current = await M(f, c, y);
67
- } else i === "text" && T(f, c);
66
+ t.current = await T(f, c, y);
67
+ } else i === "text" && W(f, c);
68
68
  } catch (c) {
69
69
  l || w(c instanceof Error ? c.message : "预览加载失败");
70
70
  } finally {
@@ -75,14 +75,13 @@ const D = ({
75
75
  var c;
76
76
  l = !0, (c = t.current) == null || c.call(t), t.current = void 0, f.innerHTML = "";
77
77
  };
78
- }, [e, i, r.id, r.name]), e ? i === "image" ? /* @__PURE__ */ n("div", { className: o["file-preview-media-wrap"], children: /* @__PURE__ */ n("img", { src: e, alt: r.name, className: o["file-preview-image"] }) }) : i === "pdf" || i === "iframe" ? /* @__PURE__ */ n(
79
- "iframe",
78
+ }, [e, i, r.id, r.name]), e ? i === "image" ? /* @__PURE__ */ n("div", { className: o["file-preview-media-wrap"], children: /* @__PURE__ */ n("img", { src: e, alt: r.name, className: o["file-preview-image"] }) }) : i === "pdf" || i === "iframe" ? /* @__PURE__ */ n("iframe", { src: e, title: r.name, className: o["file-preview-iframe"] }) : i === "video" ? /* @__PURE__ */ n("div", { className: o["file-preview-media-wrap"], children: /* @__PURE__ */ n("video", { src: e, controls: !0, className: o["file-preview-video"] }) }) : i === "audio" ? /* @__PURE__ */ n("div", { className: o["file-preview-audio-wrap"], children: /* @__PURE__ */ n("audio", { src: e, controls: !0, className: o["file-preview-audio"] }) }) : i === "unsupported" ? /* @__PURE__ */ n(u, { description: s }) : P(i) ? /* @__PURE__ */ n(
79
+ "div",
80
80
  {
81
- src: e,
82
- title: r.name,
83
- className: o["file-preview-iframe"]
81
+ className: b(o["file-preview-office"], o["file-preview-office-wrap"]),
82
+ children: /* @__PURE__ */ n(x, { spinning: d, classNames: { root: o["file-preview-office-spin"] }, children: p ? /* @__PURE__ */ n(u, { description: p }) : /* @__PURE__ */ n("div", { ref: a, className: o["file-preview-office-inner"] }) })
84
83
  }
85
- ) : i === "video" ? /* @__PURE__ */ n("div", { className: o["file-preview-media-wrap"], children: /* @__PURE__ */ n("video", { src: e, controls: !0, className: o["file-preview-video"] }) }) : i === "audio" ? /* @__PURE__ */ n("div", { className: o["file-preview-audio-wrap"], children: /* @__PURE__ */ n("audio", { src: e, controls: !0, className: o["file-preview-audio"] }) }) : i === "unsupported" ? /* @__PURE__ */ n(u, { description: s }) : P(i) ? /* @__PURE__ */ n("div", { className: b(o["file-preview-office"], o["file-preview-office-wrap"]), children: /* @__PURE__ */ n(x, { spinning: d, wrapperClassName: o["file-preview-office-spin"], children: p ? /* @__PURE__ */ n(u, { description: p }) : /* @__PURE__ */ n("div", { ref: a, className: o["file-preview-office-inner"] }) }) }) : /* @__PURE__ */ n(u, { description: s }) : /* @__PURE__ */ n(u, { description: "无可预览地址" });
84
+ ) : /* @__PURE__ */ n(u, { description: s }) : /* @__PURE__ */ n(u, { description: "无可预览地址" });
86
85
  };
87
86
  export {
88
87
  D as default
@@ -1 +1 @@
1
- {"version":3,"file":"FilePreviewContent.js","sources":["../../../../src/components/File/FilePreview/FilePreviewContent.tsx"],"sourcesContent":["import { Empty, Spin } from 'antd';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { getPreviewKind, needsBlobPreview } from '../previewKind';\nimport type { FileDisplayItem } from '../types';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\ninterface FilePreviewContentProps {\n file: FileDisplayItem;\n previewUrl?: string;\n unsupportedMessage?: string;\n}\n\nasync function fetchPreviewBlob(url: string): Promise<ArrayBuffer> {\n const res = await fetch(url);\n if (!res.ok) throw new Error(`预览加载失败 (${res.status})`);\n return res.arrayBuffer();\n}\n\nasync function renderExcel(container: HTMLElement, data: ArrayBuffer) {\n const [{ default: jsPreviewExcel }] = await Promise.all([\n import('@js-preview/excel'),\n import('@js-preview/excel/lib/index.css'),\n ]);\n const height = Math.max(\n container.parentElement?.clientHeight ?? 0,\n Math.round(window.innerHeight * 0.65),\n 480,\n );\n container.style.height = `${height}px`;\n const instance = jsPreviewExcel.init(container);\n await instance.preview(data);\n return () => instance.destroy();\n}\n\nasync function renderWord(container: HTMLElement, data: ArrayBuffer) {\n const { renderAsync } = await import('docx-preview');\n const blob = new Blob([data]);\n await renderAsync(blob, container, container, {\n inWrapper: true,\n ignoreWidth: false,\n ignoreHeight: false,\n breakPages: true,\n });\n}\n\nasync function renderPpt(container: HTMLElement, data: ArrayBuffer, width: number) {\n const { init } = await import('pptx-preview');\n const previewer = init(container, { width, height: Math.round(width * 0.5625), mode: 'list' });\n await previewer.preview(data);\n return () => previewer.destroy();\n}\n\nfunction renderText(container: HTMLElement, data: ArrayBuffer) {\n const decoder = new TextDecoder('utf-8');\n const pre = document.createElement('pre');\n pre.className = styles['file-preview-text'] ?? '';\n pre.textContent = decoder.decode(data);\n container.appendChild(pre);\n}\n\nconst FilePreviewContent: React.FC<FilePreviewContentProps> = ({\n file,\n previewUrl,\n unsupportedMessage = '暂不支持预览此文件类型',\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const cleanupRef = useRef<(() => void) | void>(undefined);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const kind = getPreviewKind(file);\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container || !previewUrl) return undefined;\n\n let cancelled = false;\n cleanupRef.current?.();\n cleanupRef.current = undefined;\n container.innerHTML = '';\n setError(null);\n\n const run = async () => {\n if (kind === 'image') return;\n if (kind === 'pdf' || kind === 'iframe') return;\n if (kind === 'video' || kind === 'audio') return;\n if (kind === 'unsupported') return;\n\n setLoading(true);\n try {\n const data = await fetchPreviewBlob(previewUrl);\n if (cancelled) return;\n\n if (kind === 'excel') {\n cleanupRef.current = await renderExcel(container, data);\n } else if (kind === 'word') {\n await renderWord(container, data);\n } else if (kind === 'ppt') {\n const width = container.clientWidth || 852;\n cleanupRef.current = await renderPpt(container, data, width);\n } else if (kind === 'text') {\n renderText(container, data);\n }\n } catch (err) {\n if (!cancelled) {\n setError(err instanceof Error ? err.message : '预览加载失败');\n }\n } finally {\n if (!cancelled) setLoading(false);\n }\n };\n\n void run();\n\n return () => {\n cancelled = true;\n cleanupRef.current?.();\n cleanupRef.current = undefined;\n container.innerHTML = '';\n };\n }, [previewUrl, kind, file.id, file.name]);\n\n if (!previewUrl) {\n return <Empty description=\"无可预览地址\" />;\n }\n\n if (kind === 'image') {\n return (\n <div className={styles['file-preview-media-wrap']}>\n <img src={previewUrl} alt={file.name} className={styles['file-preview-image']} />\n </div>\n );\n }\n\n if (kind === 'pdf' || kind === 'iframe') {\n return (\n <iframe\n src={previewUrl}\n title={file.name}\n className={styles['file-preview-iframe']}\n />\n );\n }\n\n if (kind === 'video') {\n return (\n <div className={styles['file-preview-media-wrap']}>\n <video src={previewUrl} controls className={styles['file-preview-video']} />\n </div>\n );\n }\n\n if (kind === 'audio') {\n return (\n <div className={styles['file-preview-audio-wrap']}>\n <audio src={previewUrl} controls className={styles['file-preview-audio']} />\n </div>\n );\n }\n\n if (kind === 'unsupported') {\n return <Empty description={unsupportedMessage} />;\n }\n\n if (needsBlobPreview(kind)) {\n return (\n <div className={classNames(styles['file-preview-office'], styles['file-preview-office-wrap'])}>\n <Spin spinning={loading} wrapperClassName={styles['file-preview-office-spin']}>\n {error ? <Empty description={error} /> : <div ref={containerRef} className={styles['file-preview-office-inner']} />}\n </Spin>\n </div>\n );\n }\n\n return <Empty description={unsupportedMessage} />;\n};\n\nexport default FilePreviewContent;\n"],"names":["fetchPreviewBlob","url","res","renderExcel","container","data","jsPreviewExcel","height","_a","instance","renderWord","renderAsync","blob","renderPpt","width","init","previewer","renderText","decoder","pre","styles","FilePreviewContent","file","previewUrl","unsupportedMessage","containerRef","useRef","cleanupRef","loading","setLoading","useState","error","setError","kind","getPreviewKind","useEffect","cancelled","err","jsx","Empty","needsBlobPreview","classNames","Spin"],"mappings":";;;;;;AAaA,eAAeA,EAAiBC,GAAmC;AACjE,QAAMC,IAAM,MAAM,MAAMD,CAAG;AAC3B,MAAI,CAACC,EAAI,GAAI,OAAM,IAAI,MAAM,WAAWA,EAAI,MAAM,GAAG;AACrD,SAAOA,EAAI,YAAA;AACb;AAEA,eAAeC,EAAYC,GAAwBC,GAAmB;;AACpE,QAAM,CAAC,EAAE,SAASC,EAAA,CAAgB,IAAI,MAAM,QAAQ,IAAI;AAAA,IACtD,OAAO,mBAAmB;AAAA,IAC1B,OAAO,0DAAiC;AAAA,EAAA,CACzC,GACKC,IAAS,KAAK;AAAA,MAClBC,IAAAJ,EAAU,kBAAV,gBAAAI,EAAyB,iBAAgB;AAAA,IACzC,KAAK,MAAM,OAAO,cAAc,IAAI;AAAA,IACpC;AAAA,EAAA;AAEF,EAAAJ,EAAU,MAAM,SAAS,GAAGG,CAAM;AAClC,QAAME,IAAWH,E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gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKf;AAAA,MACL,OAAOD,EAAK;AAAA,MACZ,WAAWF,EAAO,qBAAqB;AAAA,IAAA;AAAA,EAAA,IAKzCa,MAAS,4BAER,OAAA,EAAI,WAAWb,EAAO,yBAAyB,GAC9C,UAAA,gBAAAkB,EAAC,SAAA,EAAM,KAAKf,GAAY,UAAQ,IAAC,WAAWH,EAAO,oBAAoB,GAAG,GAC5E,IAIAa,MAAS,4BAER,OAAA,EAAI,WAAWb,EAAO,yBAAyB,GAC9C,UAAA,gBAAAkB,EAAC,SAAA,EAAM,KAAKf,GAAY,UAAQ,IAAC,WAAWH,EAAO,oBAAoB,GAAG,GAC5E,IAIAa,MAAS,gBACJ,gBAAAK,EAACC,GAAA,EAAM,aAAaf,EAAA,CAAoB,IAG7CgB,EAAiBP,CAAI,IAErB,gBAAAK,EAAC,OAAA,EAAI,WAAWG,EAAWrB,EAAO,qBAAqB,GAAGA,EAAO,0BAA0B,CAAC,GAC1F,UAAA,gBAAAkB,EAACI,GAAA,EAAK,UAAUd,GAAS,kBAAkBR,EAAO,0BAA0B,GACzE,UAAAW,IAAQ,gBAAAO,EAACC,GAAA,EAAM,aAAaR,GAAO,IAAK,gBAAAO,EAAC,OAAA,EAAI,KAAKb,GAAc,WAAWL,EAAO,2BAA2B,EAAA,CAAG,GACnH,GACF,IAIG,gBAAAkB,EAACC,GAAA,EAAM,aAAaf,EAAA,CAAoB,IAnDtC,gBAAAc,EAACC,GAAA,EAAM,aAAY,SAAA,CAAS;AAoDvC;"}
1
+ {"version":3,"file":"FilePreviewContent.js","sources":["../../../../src/components/File/FilePreview/FilePreviewContent.tsx"],"sourcesContent":["import { Empty, Spin } from 'antd';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { getPreviewKind, needsBlobPreview } from '../previewKind';\nimport type { FileDisplayItem } from '../types';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\ninterface FilePreviewContentProps {\n file: FileDisplayItem;\n previewUrl?: string;\n unsupportedMessage?: string;\n}\n\nasync function fetchPreviewBlob(url: string): Promise<ArrayBuffer> {\n const res = await fetch(url);\n if (!res.ok) throw new Error(`预览加载失败 (${res.status})`);\n return res.arrayBuffer();\n}\n\nasync function renderExcel(container: HTMLElement, data: ArrayBuffer) {\n const [{ default: jsPreviewExcel }] = await Promise.all([\n import('@js-preview/excel'),\n import('@js-preview/excel/lib/index.css'),\n ]);\n const height = Math.max(\n container.parentElement?.clientHeight ?? 0,\n Math.round(window.innerHeight * 0.65),\n 480,\n );\n container.style.height = `${height}px`;\n const instance = jsPreviewExcel.init(container);\n await instance.preview(data);\n return () => instance.destroy();\n}\n\nasync function renderWord(container: HTMLElement, data: ArrayBuffer) {\n const { renderAsync } = await import('docx-preview');\n const blob = new Blob([data]);\n await renderAsync(blob, container, container, {\n inWrapper: true,\n ignoreWidth: false,\n ignoreHeight: false,\n breakPages: true,\n });\n}\n\nasync function renderPpt(container: HTMLElement, data: ArrayBuffer, width: number) {\n const { init } = await import('pptx-preview');\n const previewer = init(container, { width, height: Math.round(width * 0.5625), mode: 'list' });\n await previewer.preview(data);\n return () => previewer.destroy();\n}\n\nfunction renderText(container: HTMLElement, data: ArrayBuffer) {\n const decoder = new TextDecoder('utf-8');\n const pre = document.createElement('pre');\n pre.className = styles['file-preview-text'] ?? '';\n pre.textContent = decoder.decode(data);\n container.appendChild(pre);\n}\n\nconst FilePreviewContent: React.FC<FilePreviewContentProps> = ({\n file,\n previewUrl,\n unsupportedMessage = '暂不支持预览此文件类型',\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const cleanupRef = useRef<(() => void) | void>(undefined);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const kind = getPreviewKind(file);\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container || !previewUrl) return undefined;\n\n let cancelled = false;\n cleanupRef.current?.();\n cleanupRef.current = undefined;\n container.innerHTML = '';\n setError(null);\n\n const run = async () => {\n if (kind === 'image') return;\n if (kind === 'pdf' || kind === 'iframe') return;\n if (kind === 'video' || kind === 'audio') return;\n if (kind === 'unsupported') return;\n\n setLoading(true);\n try {\n const data = await fetchPreviewBlob(previewUrl);\n if (cancelled) return;\n\n if (kind === 'excel') {\n cleanupRef.current = await renderExcel(container, data);\n } else if (kind === 'word') {\n await renderWord(container, data);\n } else if (kind === 'ppt') {\n const width = container.clientWidth || 852;\n cleanupRef.current = await renderPpt(container, data, width);\n } else if (kind === 'text') {\n renderText(container, data);\n }\n } catch (err) {\n if (!cancelled) {\n setError(err instanceof Error ? err.message : '预览加载失败');\n }\n } finally {\n if (!cancelled) setLoading(false);\n }\n };\n\n void run();\n\n return () => {\n cancelled = true;\n cleanupRef.current?.();\n cleanupRef.current = undefined;\n container.innerHTML = '';\n };\n }, [previewUrl, kind, file.id, file.name]);\n\n if (!previewUrl) {\n return <Empty description=\"无可预览地址\" />;\n }\n\n if (kind === 'image') {\n return (\n <div className={styles['file-preview-media-wrap']}>\n <img src={previewUrl} alt={file.name} className={styles['file-preview-image']} />\n </div>\n );\n }\n\n if (kind === 'pdf' || kind === 'iframe') {\n return <iframe src={previewUrl} title={file.name} className={styles['file-preview-iframe']} />;\n }\n\n if (kind === 'video') {\n return (\n <div className={styles['file-preview-media-wrap']}>\n <video src={previewUrl} controls className={styles['file-preview-video']} />\n </div>\n );\n }\n\n if (kind === 'audio') {\n return (\n <div className={styles['file-preview-audio-wrap']}>\n <audio src={previewUrl} controls className={styles['file-preview-audio']} />\n </div>\n );\n }\n\n if (kind === 'unsupported') {\n return <Empty description={unsupportedMessage} />;\n }\n\n if (needsBlobPreview(kind)) {\n return (\n <div\n className={classNames(styles['file-preview-office'], styles['file-preview-office-wrap'])}\n >\n <Spin spinning={loading} classNames={{ root: styles['file-preview-office-spin'] }}>\n {error ? (\n <Empty description={error} />\n ) : (\n <div ref={containerRef} className={styles['file-preview-office-inner']} />\n )}\n </Spin>\n </div>\n );\n }\n\n return <Empty description={unsupportedMessage} />;\n};\n\nexport default FilePreviewContent;\n"],"names":["fetchPreviewBlob","url","res","renderExcel","container","data","jsPreviewExcel","height","_a","instance","renderWord","renderAsync","blob","renderPpt","width","init","previewer","renderText","decoder","pre","styles","FilePreviewContent","file","previewUrl","unsupportedMessage","containerRef","useRef","cleanupRef","loading","setLoading","useState","error","setError","kind","getPreviewKind","useEffect","cancelled","err","jsx","Empty","needsBlobPreview","classNames","Spin"],"mappings":";;;;;;AAaA,eAAeA,EAAiBC,GAAmC;AACjE,QAAMC,IAAM,MAAM,MAAMD,CAAG;AAC3B,MAAI,CAACC,EAAI,GAAI,OAAM,IAAI,MAAM,WAAWA,EAAI,MAAM,GAAG;AACrD,SAAOA,EAAI,YAAA;AACb;AAEA,eAAeC,EAAYC,GAAwBC,GAAmB;;AACpE,QAAM,CAAC,EAAE,SAASC,EAAA,CAAgB,IAAI,MAAM,QAAQ,IAAI;AAAA,IACtD,OAAO,mBAAmB;AAAA,IAC1B,OAAO,0DAAiC;AAAA,EAAA,CACzC,GACKC,IAAS,KAAK;AAAA,MAClBC,IAAAJ,EAAU,kBAAV,gBAAAI,EAAyB,iBAAgB;AAAA,IACzC,KAAK,MAAM,OAAO,cAAc,IAAI;AAAA,IACpC;AAAA,EAAA;AAEF,EAAAJ,EAAU,MAAM,SAAS,GAAGG,CAAM;AAClC,QAAME,IAAWH,EAAe,KAAKF,CAAS;AAC9C,eAAMK,EAAS,QAAQJ,CAAI,GACpB,MAAMI,EAAS,QAAA;AACxB;AAEA,eAAeC,EAAWN,GAAwBC,GAAmB;AACnE,QAAM,EAAE,aAAAM,EAAA,IAAgB,MAAM,OAAO,cAAc,GAC7CC,IAAO,IAAI,KAAK,CAACP,CAAI,CAAC;AAC5B,QAAMM,EAAYC,GAAMR,GAAWA,GAAW;AAAA,IAC5C,WAAW;AAAA,IACX,aAAa;AAAA,IACb,cAAc;AAAA,IACd,YAAY;AAAA,EAAA,CACb;AACH;AAEA,eAAeS,EAAUT,GAAwBC,GAAmBS,G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AG,GAC5E,IAIAa,MAAS,gBACJ,gBAAAK,EAACC,GAAA,EAAM,aAAaf,EAAA,CAAoB,IAG7CgB,EAAiBP,CAAI,IAErB,gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWG,EAAWrB,EAAO,qBAAqB,GAAGA,EAAO,0BAA0B,CAAC;AAAA,MAEvF,UAAA,gBAAAkB,EAACI,GAAA,EAAK,UAAUd,GAAS,YAAY,EAAE,MAAMR,EAAO,0BAA0B,EAAA,GAC3E,UAAAW,sBACEQ,GAAA,EAAM,aAAaR,GAAO,IAE3B,gBAAAO,EAAC,OAAA,EAAI,KAAKb,GAAc,WAAWL,EAAO,2BAA2B,EAAA,CAAG,EAAA,CAE5E;AAAA,IAAA;AAAA,EAAA,IAKC,gBAAAkB,EAACC,GAAA,EAAM,aAAaf,EAAA,CAAoB,IAnDtC,gBAAAc,EAACC,GAAA,EAAM,aAAY,SAAA,CAAS;AAoDvC;"}
@@ -6,3 +6,9 @@ export { default as FetchSelect } from './FetchSelect';
6
6
  export type { FetchSelectProps, SelectOptionItem } from './FetchSelect';
7
7
  export { default as PersonOptionRow } from './PersonOptionRow';
8
8
  export type { PersonOptionRowProps } from './PersonOptionRow';
9
+ /** @kne/form-info — 业务从包根导入,勿直连 @kne/form-info */
10
+ export { FormInfo, Form, FormModal, FormSteps, FormStepsModal, List, TableList, MultiField, Input, TextArea, Select, InputNumber, Switch, SubmitButton, ResetButton, CancelButton, } from './kneFormInfo';
11
+ export type { FormInfoProps, FormProps, FormModalProps, FormStepsProps, FormStepsModalProps, ListProps, TableListProps, MultiFieldProps, } from './kneFormInfo';
12
+ /** @kne/react-form — 引擎 API;默认组件为 ReactForm(勿与 FormInfo 的 Form 混淆) */
13
+ export { ReactForm, GroupList, useField, useFormApi, useFormContext, useGroup, useSubmit, useReset, RULES, preset, interceptors, compileErrMsg, computedFieldValueFromFormData, computedFormDataFormState, filterEmpty, findField, formUtils, isEmpty, isNotEmpty, matchFields, stateToError, stateToIsPass, } from './kneReactForm';
14
+ export type { GroupListRenderProps } from './kneReactForm';
@@ -0,0 +1,47 @@
1
+ import { FormModalProps, FormProps, FormStepsModalProps, FormStepsProps, ListProps, MultiFieldProps, TableListProps, FormInfoProps } from '@kne/form-info';
2
+ import { ComponentType, FC, ReactNode } from 'react';
3
+ type FieldProps = {
4
+ name: string;
5
+ label?: ReactNode;
6
+ rule?: string;
7
+ placeholder?: string;
8
+ disabled?: boolean;
9
+ block?: boolean;
10
+ rows?: number;
11
+ options?: unknown[];
12
+ [key: string]: unknown;
13
+ };
14
+ type ButtonProps = {
15
+ children?: ReactNode;
16
+ type?: string;
17
+ loading?: boolean;
18
+ [key: string]: unknown;
19
+ };
20
+ type ItemTitleCtx = {
21
+ index: number;
22
+ data?: Record<string, unknown>;
23
+ };
24
+ export type { FormInfoProps, FormProps, FormModalProps, FormStepsProps, FormStepsModalProps, ListProps, TableListProps, MultiFieldProps, };
25
+ export declare const FormInfo: FC<FormInfoProps>;
26
+ export declare const Form: FC<FormProps>;
27
+ export declare const FormModal: FC<FormModalProps & {
28
+ children?: ReactNode;
29
+ }>;
30
+ export declare const FormSteps: FC<FormStepsProps>;
31
+ export declare const FormStepsModal: FC<FormStepsModalProps>;
32
+ export declare const List: FC<Omit<ListProps, "itemTitle"> & {
33
+ maxLength?: number;
34
+ itemTitle?: (ctx: ItemTitleCtx) => string;
35
+ }>;
36
+ export declare const TableList: FC<Omit<TableListProps, "itemTitle"> & {
37
+ itemTitle?: (ctx: ItemTitleCtx) => string;
38
+ }>;
39
+ export declare const MultiField: FC<MultiFieldProps>;
40
+ export declare const Input: ComponentType<FieldProps>;
41
+ export declare const TextArea: ComponentType<FieldProps>;
42
+ export declare const Select: ComponentType<FieldProps>;
43
+ export declare const InputNumber: ComponentType<FieldProps>;
44
+ export declare const Switch: ComponentType<FieldProps>;
45
+ export declare const SubmitButton: ComponentType<ButtonProps>;
46
+ export declare const ResetButton: ComponentType<ButtonProps>;
47
+ export declare const CancelButton: ComponentType<ButtonProps>;
@@ -0,0 +1,23 @@
1
+ /* empty css */
2
+ import t, { Form as o, FormModal as s, FormSteps as e, FormStepsModal as n, List as a, MultiField as r, TableList as c } from "@kne/form-info";
3
+ import { CancelButton as m, Input as u, InputNumber as i, ResetButton as l, Select as F, SubmitButton as p, Switch as S, TextArea as $ } from "@kne/react-form-antd";
4
+ const M = t, I = o, L = s, T = e, f = n, x = a, h = c, w = r, A = u, C = $, N = F, R = i, g = S, j = p, k = l, q = m;
5
+ export {
6
+ q as CancelButton,
7
+ I as Form,
8
+ M as FormInfo,
9
+ L as FormModal,
10
+ T as FormSteps,
11
+ f as FormStepsModal,
12
+ A as Input,
13
+ R as InputNumber,
14
+ x as List,
15
+ w as MultiField,
16
+ k as ResetButton,
17
+ N as Select,
18
+ j as SubmitButton,
19
+ g as Switch,
20
+ h as TableList,
21
+ C as TextArea
22
+ };
23
+ //# sourceMappingURL=kneFormInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kneFormInfo.js","sources":["../../../src/components/Form/kneFormInfo.ts"],"sourcesContent":["/**\n * 经 core 再导出 @kne/form-info(业务唯一入口)。\n * 布局组件来自 @kne/form-info;字段组件须从 @kne/react-form-antd 具名导入\n * (form-info 的 `export *` 在 Vite 下经 namespace 读取时常为 undefined)。\n */\nimport '@kne/form-info/dist/index.css';\nimport FormInfoBase, {\n Form as KneForm,\n FormModal as KneFormModal,\n FormSteps as KneFormSteps,\n FormStepsModal as KneFormStepsModal,\n List as KneList,\n MultiField as KneMultiField,\n TableList as KneTableList,\n type FormModalProps,\n type FormProps,\n type FormStepsModalProps,\n type FormStepsProps,\n type ListProps,\n type MultiFieldProps,\n type TableListProps,\n type FormInfoProps,\n} from '@kne/form-info';\nimport {\n CancelButton as KneCancelButton,\n Input as KneInput,\n InputNumber as KneInputNumber,\n ResetButton as KneResetButton,\n Select as KneSelect,\n SubmitButton as KneSubmitButton,\n Switch as KneSwitch,\n TextArea as KneTextArea,\n} from '@kne/react-form-antd';\nimport type { ComponentType, FC, ReactNode } from 'react';\n\ntype FieldProps = {\n name: string;\n label?: ReactNode;\n rule?: string;\n placeholder?: string;\n disabled?: boolean;\n block?: boolean;\n rows?: number;\n options?: unknown[];\n [key: string]: unknown;\n};\n\ntype ButtonProps = {\n children?: ReactNode;\n type?: string;\n loading?: boolean;\n [key: string]: unknown;\n};\n\ntype ItemTitleCtx = { index: number; data?: Record<string, unknown> };\n\nexport type {\n FormInfoProps,\n FormProps,\n FormModalProps,\n FormStepsProps,\n FormStepsModalProps,\n ListProps,\n TableListProps,\n MultiFieldProps,\n};\n\nexport const FormInfo = FormInfoBase;\nexport const Form = KneForm;\nexport const FormModal = KneFormModal as FC<FormModalProps & { children?: ReactNode }>;\nexport const FormSteps = KneFormSteps as FC<FormStepsProps>;\nexport const FormStepsModal = KneFormStepsModal as FC<FormStepsModalProps>;\n\nexport const List = KneList as FC<\n Omit<ListProps, 'itemTitle'> & {\n maxLength?: number;\n itemTitle?: (ctx: ItemTitleCtx) => string;\n }\n>;\nexport const TableList = KneTableList as FC<\n Omit<TableListProps, 'itemTitle'> & {\n itemTitle?: (ctx: ItemTitleCtx) => string;\n }\n>;\nexport const MultiField = KneMultiField as FC<MultiFieldProps>;\n\nexport const Input = KneInput as ComponentType<FieldProps>;\nexport const TextArea = KneTextArea as ComponentType<FieldProps>;\nexport const Select = KneSelect as ComponentType<FieldProps>;\nexport const InputNumber = KneInputNumber as ComponentType<FieldProps>;\nexport const Switch = KneSwitch as ComponentType<FieldProps>;\nexport const SubmitButton = KneSubmitButton as ComponentType<ButtonProps>;\nexport const ResetButton = KneResetButton as ComponentType<ButtonProps>;\nexport const CancelButton = KneCancelButton as ComponentType<ButtonProps>;\n"],"names":["FormInfo","FormInfoBase","Form","KneForm","FormModal","KneFormModal","FormSteps","KneFormSteps","FormStepsModal","KneFormStepsModal","List","KneList","TableList","KneTableList","MultiField","KneMultiField","Input","KneInput","TextArea","KneTextArea","Select","KneSelect","InputNumber","KneInputNumber","Switch","KneSwitch","SubmitButton","KneSubmitButton","ResetButton","KneResetButton","CancelButton","KneCancelButton"],"mappings":";;;AAmEO,MAAMA,IAAWC,GACXC,IAAOC,GACPC,IAAYC,GACZC,IAAYC,GACZC,IAAiBC,GAEjBC,IAAOC,GAMPC,IAAYC,GAKZC,IAAaC,GAEbC,IAAQC,GACRC,IAAWC,GACXC,IAASC,GACTC,IAAcC,GACdC,IAASC,GACTC,IAAeC,GACfC,IAAcC,GACdC,IAAeC;"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 经 core 再导出 @kne/react-form 引擎 API。
3
+ * 默认组件命名为 ReactForm,避免与 form-info 的 Form 冲突。
4
+ * 业务禁止直连 @kne/react-form。
5
+ */
6
+ export { default as ReactForm } from '@kne/react-form';
7
+ export { GroupList, useField, useFormApi, useFormContext, useGroup, useSubmit, useReset, RULES, preset, interceptors, compileErrMsg, computedFieldValueFromFormData, computedFormDataFormState, filterEmpty, findField, formUtils, isEmpty, isNotEmpty, matchFields, stateToError, stateToIsPass, } from '@kne/react-form';
8
+ export type { GroupListRenderProps } from '@kne/react-form';
@@ -1,8 +1,8 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { Spin as o } from "antd";
3
- import a from "classnames";
4
- import e from "./style.module.scss.js";
5
- const n = ({ spinning: p, children: r, className: s }) => /* @__PURE__ */ m(o, { spinning: p, wrapperClassName: a(e["page-spin"], s), children: r });
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { Spin as p } from "antd";
3
+ import t from "classnames";
4
+ import a from "./style.module.scss.js";
5
+ const n = ({ spinning: o, children: s, className: m }) => /* @__PURE__ */ r(p, { spinning: o, classNames: { root: t(a["page-spin"], m) }, children: s });
6
6
  export {
7
7
  n as default
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Layout/PageSpin/index.tsx"],"sourcesContent":["import { Spin } from 'antd';\nimport classNames from 'classnames';\nimport type { ReactNode } from 'react';\nimport styles from './style.module.scss';\n\nexport type PageSpinProps = {\n spinning: boolean;\n children: ReactNode;\n className?: string;\n};\n\n/** 模块页 body 区整页 Spin:参与 flex 高度链,遮罩 Filter + 主工作区 */\nconst PageSpin: React.FC<PageSpinProps> = ({ spinning, children, className }) => (\n <Spin spinning={spinning} wrapperClassName={classNames(styles['page-spin'], className)}>\n {children}\n </Spin>\n);\n\nexport default PageSpin;\n"],"names":["PageSpin","spinning","children","className","jsx","Spin","classNames","styles"],"mappings":";;;;AAYA,MAAMA,IAAoC,CAAC,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,QAC/D,gBAAAC,EAACC,GAAA,EAAK,UAAAJ,GAAoB,kBAAkBK,EAAWC,EAAO,WAAW,GAAGJ,CAAS,GAClF,UAAAD,EAAA,CACH;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Layout/PageSpin/index.tsx"],"sourcesContent":["import { Spin } from 'antd';\nimport classNames from 'classnames';\nimport type { ReactNode } from 'react';\nimport styles from './style.module.scss';\n\nexport type PageSpinProps = {\n spinning: boolean;\n children: ReactNode;\n className?: string;\n};\n\n/** 模块页 body 区整页 Spin:参与 flex 高度链,遮罩 Filter + 主工作区 */\nconst PageSpin: React.FC<PageSpinProps> = ({ spinning, children, className }) => (\n <Spin spinning={spinning} classNames={{ root: classNames(styles['page-spin'], className) }}>\n {children}\n </Spin>\n);\n\nexport default PageSpin;\n"],"names":["PageSpin","spinning","children","className","Spin","classNames","styles"],"mappings":";;;;AAYA,MAAMA,IAAoC,CAAC,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,0BAC9DC,GAAA,EAAK,UAAAH,GAAoB,YAAY,EAAE,MAAMI,EAAWC,EAAO,WAAW,GAAGH,CAAS,EAAA,GACpF,UAAAD,EAAA,CACH;"}