@hkyhy/marsun-components-core 0.1.122 → 0.1.124
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 +1 -0
- package/dist/components/File/FileItem/index.js +65 -55
- package/dist/components/File/FileItem/index.js.map +1 -1
- package/dist/components/File/FilePreview/FilePreviewContent.js +114 -90
- package/dist/components/File/FilePreview/FilePreviewContent.js.map +1 -1
- package/dist/components/File/FilePreview/index.js +43 -33
- package/dist/components/File/FilePreview/index.js.map +1 -1
- package/dist/components/File/index.d.ts +1 -0
- package/dist/components/File/utils/authedFetch.d.ts +12 -0
- package/dist/components/File/utils/authedFetch.js +50 -0
- package/dist/components/File/utils/authedFetch.js.map +1 -0
- package/dist/components/Form/index.d.ts +1 -1
- package/dist/components/Form/kneFormInfo.d.ts +2 -0
- package/dist/components/Form/kneFormInfo.js +30 -27
- package/dist/components/Form/kneFormInfo.js.map +1 -1
- package/dist/components/FormInfo/fields.d.ts +2 -0
- package/dist/components/FormInfo/fields.js +22 -19
- package/dist/components/FormInfo/fields.js.map +1 -1
- package/dist/components/FormInfo/index.d.ts +1 -1
- package/dist/components/InfoPage/Content/index.d.ts +8 -1
- package/dist/components/InfoPage/Content/index.js +103 -57
- package/dist/components/InfoPage/Content/index.js.map +1 -1
- package/dist/components/InfoPage/Content/style.module.scss.js +10 -8
- package/dist/components/InfoPage/Content/style.module.scss.js.map +1 -1
- package/dist/components/InfoPage/index.d.ts +13 -1
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.d.ts +8 -1
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.js +148 -142
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.module.scss.js +5 -4
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionForm.module.scss.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionModal.d.ts +10 -2
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionModal.js +122 -116
- package/dist/components/Tools/ActionTracking/CreateAction/CreateActionModal.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/PersonRoleCascaderField.js +20 -31
- package/dist/components/Tools/ActionTracking/CreateAction/PersonRoleCascaderField.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/PersonRoleCascaderField.module.scss.js +1 -2
- package/dist/components/Tools/ActionTracking/CreateAction/PersonRoleCascaderField.module.scss.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/index.d.ts +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/submitHelpers.d.ts +5 -0
- package/dist/components/Tools/ActionTracking/CreateAction/submitHelpers.js +37 -18
- package/dist/components/Tools/ActionTracking/CreateAction/submitHelpers.js.map +1 -1
- package/dist/components/Tools/ActionTracking/CreateAction/types.d.ts +9 -0
- package/dist/components/Tools/ActionTracking/index.d.ts +1 -1
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.d.ts +14 -3
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.js +136 -95
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.js.map +1 -1
- package/dist/components/Tools/Inbox/InboxBell/index.d.ts +1 -1
- package/dist/components/Tools/Inbox/InboxBell/style.module.scss.js +18 -16
- package/dist/components/Tools/Inbox/InboxBell/style.module.scss.js.map +1 -1
- package/dist/components/Tools/Inbox/index.d.ts +2 -1
- package/dist/components/Tools/Inbox/requestInboxBadgeRefresh.d.ts +9 -0
- package/dist/components/Tools/Inbox/requestInboxBadgeRefresh.js +15 -0
- package/dist/components/Tools/Inbox/requestInboxBadgeRefresh.js.map +1 -0
- package/dist/components/Tools/index.d.ts +3 -2
- package/dist/file.js +24 -19
- package/dist/file.js.map +1 -1
- package/dist/form-info.js +46 -45
- package/dist/index.d.ts +1 -0
- package/dist/index.js +534 -524
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/styles/global.css +1 -1
- package/package.json +1 -1
|
@@ -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\nfunction mapPreviewError(err: unknown, kind: string): string {\n const raw = err instanceof Error ? err.message : String(err ?? '');\n if (kind === 'excel' && /anchors/i.test(raw)) {\n return '该 Excel 含图表/绘图等对象,当前预览引擎无法解析,请下载后用本地软件打开';\n }\n if (kind === 'word' && /ole|compound|docfile|not a valid/i.test(raw)) {\n return '旧版 Word(.doc)暂无法排版预览,请下载后用 Word 打开';\n }\n if (raw && !/^Cannot read properties/i.test(raw) && !/^undefined/i.test(raw)) {\n return raw;\n }\n return kind === 'excel'\n ? 'Excel 预览失败,请下载后查看'\n : kind === 'word'\n ? 'Word 预览失败,请下载后查看'\n : '预览加载失败';\n}\n\n/** exceljs/@js-preview 对部分含 drawing/chart 的 xlsx 会在 reconcile 时读 anchors 崩溃;去掉绘图部件后重试。 */\nasync function stripExcelDrawings(data: ArrayBuffer): Promise<ArrayBuffer | null> {\n try {\n const { default: JSZip } = await import('jszip');\n const zip = await JSZip.loadAsync(data);\n const names = Object.keys(zip.files);\n const drop = names.filter(\n (n) =>\n n.startsWith('xl/drawings/') ||\n n.startsWith('xl/charts/') ||\n n.startsWith('xl/diagrams/') ||\n /drawing[0-9]*\\.xml$/i.test(n),\n );\n if (drop.length === 0) return null;\n for (const n of drop) {\n zip.remove(n);\n }\n // 清理 worksheet 中的 drawing 引用,避免指向已删部件\n await Promise.all(\n names\n .filter((n) => /^xl\\/worksheets\\/[^/]+\\.xml$/i.test(n) && zip.file(n))\n .map(async (n) => {\n const file = zip.file(n);\n if (!file) return;\n const xml = await file.async('string');\n const cleaned = xml\n .replace(/<drawing[^>]*\\/>/gi, '')\n .replace(/<drawing[^>]*>[\\s\\S]*?<\\/drawing>/gi, '');\n if (cleaned !== xml) zip.file(n, cleaned);\n }),\n );\n return zip.generateAsync({ type: 'arraybuffer' });\n } catch {\n return null;\n }\n}\n\nasync function previewExcelBuffer(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n jsPreviewExcel: { init: (el: HTMLElement) => any },\n container: HTMLElement,\n data: ArrayBuffer,\n) {\n const instance = jsPreviewExcel.init(container);\n try {\n await instance.preview(data);\n return () => instance.destroy();\n } catch (err) {\n try {\n instance.destroy();\n } catch {\n // ignore\n }\n throw err;\n }\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\n try {\n return await previewExcelBuffer(jsPreviewExcel, container, data);\n } catch (firstErr) {\n const msg = firstErr instanceof Error ? firstErr.message : String(firstErr ?? '');\n if (!/anchors/i.test(msg)) {\n throw firstErr instanceof Error ? firstErr : new Error(mapPreviewError(firstErr, 'excel'));\n }\n const stripped = await stripExcelDrawings(data);\n if (!stripped) {\n throw firstErr instanceof Error ? firstErr : new Error(mapPreviewError(firstErr, 'excel'));\n }\n container.innerHTML = '';\n try {\n return await previewExcelBuffer(jsPreviewExcel, container, stripped);\n } catch (retryErr) {\n throw retryErr instanceof Error ? retryErr : new Error(mapPreviewError(retryErr, 'excel'));\n }\n }\n}\n\nfunction isZipBuffer(data: ArrayBuffer): boolean {\n const u = new Uint8Array(data);\n return u.length >= 2 && u[0] === 0x50 && u[1] === 0x4b; // PK\n}\n\nfunction isOleBuffer(data: ArrayBuffer): boolean {\n const u = new Uint8Array(data);\n return u.length >= 4 && u[0] === 0xd0 && u[1] === 0xcf && u[2] === 0x11 && u[3] === 0xe0;\n}\n\n/** 服务端把旧版 .doc 转成 HTML 后,预览响应不再是 OLE */\nfunction isLikelyHtmlBuffer(data: ArrayBuffer): boolean {\n const u = new Uint8Array(data.byteLength > 64 ? data.slice(0, 64) : data);\n let offset = 0;\n if (u.length >= 3 && u[0] === 0xef && u[1] === 0xbb && u[2] === 0xbf) offset = 3;\n const head = new TextDecoder('utf-8').decode(u.subarray(offset)).trimStart().toLowerCase();\n return (\n head.startsWith('<!doctype') ||\n head.startsWith('<html') ||\n head.startsWith('<pre') ||\n head.startsWith('<div') ||\n head.startsWith('<article')\n );\n}\n\nasync function renderWord(container: HTMLElement, data: ArrayBuffer) {\n // 误命名为 .doc 的真实 docx(ZIP)仍走 docx-preview\n if (isZipBuffer(data)) {\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 return;\n }\n\n // Assets 等对旧版 .doc 预览返回的 HTML\n if (isLikelyHtmlBuffer(data)) {\n container.innerHTML = new TextDecoder('utf-8').decode(data);\n return;\n }\n\n if (isOleBuffer(data)) {\n throw new Error('旧版 Word(.doc)暂无法排版预览,请下载后用 Word 打开');\n }\n\n throw new Error('无法识别的 Word 文件格式,请下载后查看');\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(mapPreviewError(err, kind));\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","mapPreviewError","err","kind","raw","stripExcelDrawings","data","JSZip","n","zip","names","drop","file","xml","cleaned","previewExcelBuffer","jsPreviewExcel","container","instance","renderExcel","height","_a","firstErr","msg","stripped","retryErr","isZipBuffer","u","isOleBuffer","isLikelyHtmlBuffer","offset","head","renderWord","renderAsync","blob","renderPpt","width","init","previewer","renderText","decoder","pre","styles","FilePreviewContent","previewUrl","unsupportedMessage","containerRef","useRef","cleanupRef","loading","setLoading","useState","error","setError","getPreviewKind","useEffect","cancelled","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,SAASC,EAAgBC,GAAcC,GAAsB;AAC3D,QAAMC,IAAMF,aAAe,QAAQA,EAAI,UAAU,OAAOA,KAAO,EAAE;AACjE,SAAIC,MAAS,WAAW,WAAW,KAAKC,CAAG,IAClC,6CAELD,MAAS,UAAU,oCAAoC,KAAKC,CAAG,IAC1D,uCAELA,KAAO,CAAC,2BAA2B,KAAKA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KAAKb,GAAY,UAAQ,IAAC,WAAWF,EAAO,oBAAoB,GAAG,GAC5E,IAIAvC,MAAS,gBACJ,gBAAAsD,EAACC,GAAA,EAAM,aAAab,EAAA,CAAoB,IAG7Cc,EAAiBxD,CAAI,IAErB,gBAAAsD;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWG,EAAWlB,EAAO,qBAAqB,GAAGA,EAAO,0BAA0B,CAAC;AAAA,MAEvF,UAAA,gBAAAe,EAACI,GAAA,EAAK,UAAUZ,GAAS,YAAY,EAAE,MAAMP,EAAO,0BAA0B,EAAA,GAC3E,UAAAU,sBACEM,GAAA,EAAM,aAAaN,GAAO,IAE3B,gBAAAK,EAAC,OAAA,EAAI,KAAKX,GAAc,WAAWJ,EAAO,2BAA2B,EAAA,CAAG,EAAA,CAE5E;AAAA,IAAA;AAAA,EAAA,IAKC,gBAAAe,EAACC,GAAA,EAAM,aAAab,EAAA,CAAoB,IAnDtC,gBAAAY,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 {\n fetchAuthedArrayBuffer,\n fetchAuthedObjectUrl,\n useFileAuthHeaderKey,\n useFileAuthHeaders,\n} from '../utils/authedFetch';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\ninterface FilePreviewContentProps {\n file: FileDisplayItem;\n previewUrl?: string;\n unsupportedMessage?: string;\n}\n\n/** 受护 URL → objectURL(img/iframe/video);公开 URL 原样返回 */\nfunction useAuthedObjectUrl(previewUrl?: string): {\n src: string | undefined;\n loading: boolean;\n error: string | null;\n} {\n const headers = useFileAuthHeaders();\n const authKey = useFileAuthHeaderKey();\n const [src, setSrc] = useState<string | undefined>(undefined);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!previewUrl) {\n setSrc(undefined);\n setError(null);\n setLoading(false);\n return undefined;\n }\n let cancelled = false;\n let revoke: (() => void) | undefined;\n setLoading(true);\n setError(null);\n void (async () => {\n try {\n const got = await fetchAuthedObjectUrl(previewUrl, headers);\n if (cancelled) {\n got.revoke();\n return;\n }\n revoke = got.revoke;\n setSrc(got.objectUrl);\n } catch (err) {\n if (!cancelled) {\n setSrc(undefined);\n setError(err instanceof Error ? err.message : '预览加载失败');\n }\n } finally {\n if (!cancelled) setLoading(false);\n }\n })();\n return () => {\n cancelled = true;\n revoke?.();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- headers 随 authKey 变\n }, [previewUrl, authKey]);\n\n return { src, loading, error };\n}\n\nfunction mapPreviewError(err: unknown, kind: string): string {\n const raw = err instanceof Error ? err.message : String(err ?? '');\n if (kind === 'excel' && /anchors/i.test(raw)) {\n return '该 Excel 含图表/绘图等对象,当前预览引擎无法解析,请下载后用本地软件打开';\n }\n if (kind === 'word' && /ole|compound|docfile|not a valid/i.test(raw)) {\n return '旧版 Word(.doc)暂无法排版预览,请下载后用 Word 打开';\n }\n if (raw && !/^Cannot read properties/i.test(raw) && !/^undefined/i.test(raw)) {\n return raw;\n }\n return kind === 'excel'\n ? 'Excel 预览失败,请下载后查看'\n : kind === 'word'\n ? 'Word 预览失败,请下载后查看'\n : '预览加载失败';\n}\n\n/** exceljs/@js-preview 对部分含 drawing/chart 的 xlsx 会在 reconcile 时读 anchors 崩溃;去掉绘图部件后重试。 */\nasync function stripExcelDrawings(data: ArrayBuffer): Promise<ArrayBuffer | null> {\n try {\n const { default: JSZip } = await import('jszip');\n const zip = await JSZip.loadAsync(data);\n const names = Object.keys(zip.files);\n const drop = names.filter(\n (n) =>\n n.startsWith('xl/drawings/') ||\n n.startsWith('xl/charts/') ||\n n.startsWith('xl/diagrams/') ||\n /drawing[0-9]*\\.xml$/i.test(n),\n );\n if (drop.length === 0) return null;\n for (const n of drop) {\n zip.remove(n);\n }\n // 清理 worksheet 中的 drawing 引用,避免指向已删部件\n await Promise.all(\n names\n .filter((n) => /^xl\\/worksheets\\/[^/]+\\.xml$/i.test(n) && zip.file(n))\n .map(async (n) => {\n const file = zip.file(n);\n if (!file) return;\n const xml = await file.async('string');\n const cleaned = xml\n .replace(/<drawing[^>]*\\/>/gi, '')\n .replace(/<drawing[^>]*>[\\s\\S]*?<\\/drawing>/gi, '');\n if (cleaned !== xml) zip.file(n, cleaned);\n }),\n );\n return zip.generateAsync({ type: 'arraybuffer' });\n } catch {\n return null;\n }\n}\n\nasync function previewExcelBuffer(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n jsPreviewExcel: { init: (el: HTMLElement) => any },\n container: HTMLElement,\n data: ArrayBuffer,\n) {\n const instance = jsPreviewExcel.init(container);\n try {\n await instance.preview(data);\n return () => instance.destroy();\n } catch (err) {\n try {\n instance.destroy();\n } catch {\n // ignore\n }\n throw err;\n }\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\n try {\n return await previewExcelBuffer(jsPreviewExcel, container, data);\n } catch (firstErr) {\n const msg = firstErr instanceof Error ? firstErr.message : String(firstErr ?? '');\n if (!/anchors/i.test(msg)) {\n throw firstErr instanceof Error ? firstErr : new Error(mapPreviewError(firstErr, 'excel'));\n }\n const stripped = await stripExcelDrawings(data);\n if (!stripped) {\n throw firstErr instanceof Error ? firstErr : new Error(mapPreviewError(firstErr, 'excel'));\n }\n container.innerHTML = '';\n try {\n return await previewExcelBuffer(jsPreviewExcel, container, stripped);\n } catch (retryErr) {\n throw retryErr instanceof Error ? retryErr : new Error(mapPreviewError(retryErr, 'excel'));\n }\n }\n}\n\nfunction isZipBuffer(data: ArrayBuffer): boolean {\n const u = new Uint8Array(data);\n return u.length >= 2 && u[0] === 0x50 && u[1] === 0x4b; // PK\n}\n\nfunction isOleBuffer(data: ArrayBuffer): boolean {\n const u = new Uint8Array(data);\n return u.length >= 4 && u[0] === 0xd0 && u[1] === 0xcf && u[2] === 0x11 && u[3] === 0xe0;\n}\n\n/** 服务端把旧版 .doc 转成 HTML 后,预览响应不再是 OLE */\nfunction isLikelyHtmlBuffer(data: ArrayBuffer): boolean {\n const u = new Uint8Array(data.byteLength > 64 ? data.slice(0, 64) : data);\n let offset = 0;\n if (u.length >= 3 && u[0] === 0xef && u[1] === 0xbb && u[2] === 0xbf) offset = 3;\n const head = new TextDecoder('utf-8').decode(u.subarray(offset)).trimStart().toLowerCase();\n return (\n head.startsWith('<!doctype') ||\n head.startsWith('<html') ||\n head.startsWith('<pre') ||\n head.startsWith('<div') ||\n head.startsWith('<article')\n );\n}\n\nasync function renderWord(container: HTMLElement, data: ArrayBuffer) {\n // 误命名为 .doc 的真实 docx(ZIP)仍走 docx-preview\n if (isZipBuffer(data)) {\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 return;\n }\n\n // Assets 等对旧版 .doc 预览返回的 HTML\n if (isLikelyHtmlBuffer(data)) {\n container.innerHTML = new TextDecoder('utf-8').decode(data);\n return;\n }\n\n if (isOleBuffer(data)) {\n throw new Error('旧版 Word(.doc)暂无法排版预览,请下载后用 Word 打开');\n }\n\n throw new Error('无法识别的 Word 文件格式,请下载后查看');\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 const authHeaders = useFileAuthHeaders();\n const authKey = useFileAuthHeaderKey();\n const media = useAuthedObjectUrl(\n kind === 'image' || kind === 'pdf' || kind === 'iframe' || kind === 'video' || kind === 'audio'\n ? previewUrl\n : undefined,\n );\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 fetchAuthedArrayBuffer(previewUrl, authHeaders);\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(mapPreviewError(err, kind));\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 // eslint-disable-next-line react-hooks/exhaustive-deps -- authHeaders 随 authKey\n }, [previewUrl, kind, file.id, file.name, authKey]);\n\n if (!previewUrl) {\n return <Empty description=\"无可预览地址\" />;\n }\n\n if (kind === 'image') {\n if (media.loading) {\n return (\n <div className={styles['file-preview-media-wrap']}>\n <Spin />\n </div>\n );\n }\n if (media.error || !media.src) {\n return <Empty description={media.error || '预览加载失败'} />;\n }\n return (\n <div className={styles['file-preview-media-wrap']}>\n <img src={media.src} alt={file.name} className={styles['file-preview-image']} />\n </div>\n );\n }\n\n if (kind === 'pdf' || kind === 'iframe') {\n if (media.loading) {\n return (\n <div className={styles['file-preview-media-wrap']}>\n <Spin />\n </div>\n );\n }\n if (media.error || !media.src) {\n return <Empty description={media.error || '预览加载失败'} />;\n }\n return <iframe src={media.src} title={file.name} className={styles['file-preview-iframe']} />;\n }\n\n if (kind === 'video') {\n if (media.loading) {\n return (\n <div className={styles['file-preview-media-wrap']}>\n <Spin />\n </div>\n );\n }\n if (media.error || !media.src) {\n return <Empty description={media.error || '预览加载失败'} />;\n }\n return (\n <div className={styles['file-preview-media-wrap']}>\n <video src={media.src} controls className={styles['file-preview-video']} />\n </div>\n );\n }\n\n if (kind === 'audio') {\n if (media.loading) {\n return (\n <div className={styles['file-preview-audio-wrap']}>\n <Spin />\n </div>\n );\n }\n if (media.error || !media.src) {\n return <Empty description={media.error || '预览加载失败'} />;\n }\n return (\n <div className={styles['file-preview-audio-wrap']}>\n <audio src={media.src} 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":["useAuthedObjectUrl","previewUrl","headers","useFileAuthHeaders","authKey","useFileAuthHeaderKey","src","setSrc","useState","loading","setLoading","error","setError","useEffect","cancelled","revoke","got","fetchAuthedObjectUrl","err","mapPreviewError","kind","raw","stripExcelDrawings","data","JSZip","zip","names","drop","file","xml","cleaned","previewExcelBuffer","jsPreviewExcel","container","instance","renderExcel","height","_a","firstErr","msg","stripped","retryErr","isZipBuffer","u","isOleBuffer","isLikelyHtmlBuffer","offset","head","renderWord","renderAsync","blob","renderPpt","width","init","previewer","renderText","decoder","pre","styles","FilePreviewContent","unsupportedMessage","containerRef","useRef","cleanupRef","getPreviewKind","authHeaders","media","fetchAuthedArrayBuffer","jsx","Spin","Empty","needsBlobPreview","classNames"],"mappings":";;;;;;;AAoBA,SAASA,EAAmBC,GAI1B;AACA,QAAMC,IAAUC,EAAA,GACVC,IAAUC,EAAA,GACV,CAACC,GAAKC,CAAM,IAAIC,EAA6B,MAAS,GACtD,CAACC,GAASC,CAAU,IAAIF,EAAS,EAAK,GACtC,CAACG,GAAOC,CAAQ,IAAIJ,EAAwB,IAAI;AAEtD,SAAAK,EAAU,MAAM;AACd,QAAI,CAACZ,GAAY;AACf,MAAAM,EAAO,MAAS,GAChBK,EAAS,IAAI,GACbF,EAAW,EAAK;AAChB;AAAA,IACF;AACA,QAAII,IAAY,IACZC;AACJ,WAAAL,EAAW,EAAI,GACfE,EAAS,IAAI,IACP,YAAY;AAChB,UAAI;AACF,cAAMI,IAAM,MAAMC,EAAqBhB,GAAYC,CAAO;AAC1D,YAAIY,GAAW;AACb,UAAAE,EAAI,OAAA;AACJ;AAAA,QACF;AACA,QAAAD,IAASC,EAAI,QACbT,EAAOS,EAAI,SAAS;AAAA,MACtB,SAASE,GAAK;AACZ,QAAKJ,MACHP,EAAO,MAAS,GAChBK,EAASM,aAAe,QAAQA,EAAI,UAAU,QAAQ;AAAA,MAE1D,UAAA;AACE,QAAKJ,KAAWJ,EAAW,EAAK;AAAA,MAClC;AAAA,IACF,GAAA,GACO,MAAM;AACX,MAAAI,IAAY,IACZC,KAAA,QAAAA;AAAA,IACF;AAAA,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C,UAAA,gBAAAU,EAAC,SAAA,EAAM,KAAKF,EAAM,KAAK,UAAQ,IAAC,WAAWR,EAAO,oBAAoB,GAAG,GAC3E,IAIAtC,MAAS,gBACJ,gBAAAgD,EAACE,GAAA,EAAM,aAAaV,EAAA,CAAoB,IAG7CW,EAAiBnD,CAAI,IAErB,gBAAAgD;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWI,EAAWd,EAAO,qBAAqB,GAAGA,EAAO,0BAA0B,CAAC;AAAA,MAEvF,UAAA,gBAAAU,EAACC,GAAA,EAAK,UAAU5D,GAAS,YAAY,EAAE,MAAMiD,EAAO,0BAA0B,EAAA,GAC3E,UAAA/C,sBACE2D,GAAA,EAAM,aAAa3D,GAAO,IAE3B,gBAAAyD,EAAC,OAAA,EAAI,KAAKP,GAAc,WAAWH,EAAO,2BAA2B,EAAA,CAAG,EAAA,CAE5E;AAAA,IAAA;AAAA,EAAA,IAKC,gBAAAU,EAACE,GAAA,EAAM,aAAaV,EAAA,CAAoB,IA3FtC,gBAAAQ,EAACE,GAAA,EAAM,aAAY,SAAA,CAAS;AA4FvC;"}
|
|
@@ -1,56 +1,66 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { formatFileSize as
|
|
3
|
-
import
|
|
4
|
-
import { Button as
|
|
5
|
-
import { normalizeFileDisplayItem as
|
|
6
|
-
import { getPreviewKind as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
1
|
+
import { jsxs as t, Fragment as U, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { formatFileSize as T } from "../../../utils/format.js";
|
|
3
|
+
import k from "../../Tag/SemanticTag.js";
|
|
4
|
+
import { Button as z, message as L } from "antd";
|
|
5
|
+
import { normalizeFileDisplayItem as j, getFileTypeName as C, getFileIcon as P } from "../fileDisplay.js";
|
|
6
|
+
import { getPreviewKind as R, getFileTypeTagColor as x } from "../previewKind.js";
|
|
7
|
+
import { useFileAuthHeaders as D, fetchWithMarsunAuth as E } from "../utils/authedFetch.js";
|
|
8
|
+
import A from "./FilePreviewContent.js";
|
|
9
|
+
import i from "./style.module.scss.js";
|
|
10
|
+
import m from "classnames";
|
|
11
|
+
import { CloudDownload as B } from "../../Icons/CloudDownload.js";
|
|
12
|
+
function H(l, n) {
|
|
12
13
|
return n ?? l.url ?? l.thumbnailUrl;
|
|
13
14
|
}
|
|
14
|
-
const
|
|
15
|
+
const V = ({
|
|
15
16
|
file: l,
|
|
16
17
|
url: n,
|
|
17
|
-
downloadUrl:
|
|
18
|
+
downloadUrl: f,
|
|
18
19
|
onDownload: a,
|
|
19
|
-
unsupportedMessage:
|
|
20
|
-
title:
|
|
21
|
-
extra:
|
|
20
|
+
unsupportedMessage: v = "暂不支持预览此文件类型",
|
|
21
|
+
title: w,
|
|
22
|
+
extra: h
|
|
22
23
|
}) => {
|
|
23
|
-
const e =
|
|
24
|
+
const e = j(l), d = H(e, n), s = f ?? d, u = !!(a || s), b = R(e), y = C(e.name, e.mimeType), F = D(), g = () => {
|
|
24
25
|
if (a) {
|
|
25
26
|
a(e);
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
s && (async () => {
|
|
30
|
+
try {
|
|
31
|
+
const o = await E(s, F);
|
|
32
|
+
if (!o.ok) throw new Error(`下载失败 (${o.status})`);
|
|
33
|
+
const N = await o.blob(), p = URL.createObjectURL(N), c = document.createElement("a");
|
|
34
|
+
c.href = p, c.download = e.name || "download", c.click(), URL.revokeObjectURL(p);
|
|
35
|
+
} catch (o) {
|
|
36
|
+
L.error(o instanceof Error ? o.message : "下载失败");
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
29
39
|
};
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
e.size != null && /* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ t("div", { className: m("file-preview", i["file-preview"]), children: [
|
|
41
|
+
/* @__PURE__ */ t("div", { className: m("file-preview-header", i["file-preview-header"]), children: [
|
|
42
|
+
w ?? /* @__PURE__ */ t(U, { children: [
|
|
43
|
+
/* @__PURE__ */ t("div", { className: i["file-preview-info"], children: [
|
|
44
|
+
/* @__PURE__ */ r("span", { className: i["file-preview-icon"], children: P(e.name, e.mimeType) }),
|
|
45
|
+
/* @__PURE__ */ r("span", { className: i["file-preview-name"], title: e.name, children: e.name }),
|
|
46
|
+
/* @__PURE__ */ r(k, { color: x(b), children: y }),
|
|
47
|
+
e.size != null && /* @__PURE__ */ r("span", { className: i["file-preview-size"], children: T(e.size) })
|
|
38
48
|
] }),
|
|
39
|
-
|
|
49
|
+
u && /* @__PURE__ */ r(z, { type: "link", icon: /* @__PURE__ */ r(B, {}), onClick: g, children: "下载" })
|
|
40
50
|
] }),
|
|
41
|
-
|
|
51
|
+
h
|
|
42
52
|
] }),
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
|
|
53
|
+
/* @__PURE__ */ r("div", { className: m("file-preview-body", i["file-preview-body"]), children: /* @__PURE__ */ r(
|
|
54
|
+
A,
|
|
45
55
|
{
|
|
46
56
|
file: e,
|
|
47
|
-
previewUrl:
|
|
48
|
-
unsupportedMessage:
|
|
57
|
+
previewUrl: d,
|
|
58
|
+
unsupportedMessage: v
|
|
49
59
|
}
|
|
50
60
|
) })
|
|
51
61
|
] });
|
|
52
62
|
};
|
|
53
63
|
export {
|
|
54
|
-
|
|
64
|
+
V as default
|
|
55
65
|
};
|
|
56
66
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/File/FilePreview/index.tsx"],"sourcesContent":["import { formatFileSize } from '@/utils/format';\nimport { CloudDownload } from '@/components/Icons';\nimport SemanticTag from '@/components/Tag/SemanticTag';\nimport { Button } from 'antd';\nimport React from 'react';\nimport { getFileIcon, getFileTypeName, normalizeFileDisplayItem } from '../fileDisplay';\nimport { getFileTypeTagColor, getPreviewKind } from '../previewKind';\nimport type { FileDisplayItem } from '../types';\nimport FilePreviewContent from './FilePreviewContent';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\nexport interface FilePreviewProps {\n file: FileDisplayItem;\n url?: string;\n downloadUrl?: string;\n onDownload?: (file: FileDisplayItem) => void;\n unsupportedMessage?: string;\n title?: React.ReactNode;\n extra?: React.ReactNode;\n}\n\nfunction resolvePreviewUrl(file: FileDisplayItem, url?: string): string | undefined {\n return url ?? file.url ?? file.thumbnailUrl;\n}\n\nconst FilePreview: React.FC<FilePreviewProps> = ({\n file,\n url,\n downloadUrl,\n onDownload,\n unsupportedMessage = '暂不支持预览此文件类型',\n title,\n extra,\n}) => {\n const resolvedFile = normalizeFileDisplayItem(file);\n const previewUrl = resolvePreviewUrl(resolvedFile, url);\n const resolvedDownloadUrl = downloadUrl ?? previewUrl;\n const canDownload = Boolean(onDownload || resolvedDownloadUrl);\n const previewKind = getPreviewKind(resolvedFile);\n const typeLabel = getFileTypeName(resolvedFile.name, resolvedFile.mimeType);\n\n const handleDownload = () => {\n if (onDownload) {\n onDownload(resolvedFile);\n return;\n }\n if (resolvedDownloadUrl) {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/File/FilePreview/index.tsx"],"sourcesContent":["import { formatFileSize } from '@/utils/format';\nimport { CloudDownload } from '@/components/Icons';\nimport SemanticTag from '@/components/Tag/SemanticTag';\nimport { Button, message } from 'antd';\nimport React from 'react';\nimport { getFileIcon, getFileTypeName, normalizeFileDisplayItem } from '../fileDisplay';\nimport { getFileTypeTagColor, getPreviewKind } from '../previewKind';\nimport type { FileDisplayItem } from '../types';\nimport { fetchWithMarsunAuth, useFileAuthHeaders } from '../utils/authedFetch';\nimport FilePreviewContent from './FilePreviewContent';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\nexport interface FilePreviewProps {\n file: FileDisplayItem;\n url?: string;\n downloadUrl?: string;\n onDownload?: (file: FileDisplayItem) => void;\n unsupportedMessage?: string;\n title?: React.ReactNode;\n extra?: React.ReactNode;\n}\n\nfunction resolvePreviewUrl(file: FileDisplayItem, url?: string): string | undefined {\n return url ?? file.url ?? file.thumbnailUrl;\n}\n\nconst FilePreview: React.FC<FilePreviewProps> = ({\n file,\n url,\n downloadUrl,\n onDownload,\n unsupportedMessage = '暂不支持预览此文件类型',\n title,\n extra,\n}) => {\n const resolvedFile = normalizeFileDisplayItem(file);\n const previewUrl = resolvePreviewUrl(resolvedFile, url);\n const resolvedDownloadUrl = downloadUrl ?? previewUrl;\n const canDownload = Boolean(onDownload || resolvedDownloadUrl);\n const previewKind = getPreviewKind(resolvedFile);\n const typeLabel = getFileTypeName(resolvedFile.name, resolvedFile.mimeType);\n const authHeaders = useFileAuthHeaders();\n\n const handleDownload = () => {\n if (onDownload) {\n onDownload(resolvedFile);\n return;\n }\n if (!resolvedDownloadUrl) return;\n void (async () => {\n try {\n const res = await fetchWithMarsunAuth(resolvedDownloadUrl, authHeaders);\n if (!res.ok) throw new Error(`下载失败 (${res.status})`);\n const blob = await res.blob();\n const blobUrl = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = blobUrl;\n a.download = resolvedFile.name || 'download';\n a.click();\n URL.revokeObjectURL(blobUrl);\n } catch (err) {\n message.error(err instanceof Error ? err.message : '下载失败');\n }\n })();\n };\n\n return (\n <div className={classNames('file-preview', styles['file-preview'])}>\n <div className={classNames('file-preview-header', styles['file-preview-header'])}>\n {title ?? (\n <>\n <div className={styles['file-preview-info']}>\n <span className={styles['file-preview-icon']}>\n {getFileIcon(resolvedFile.name, resolvedFile.mimeType)}\n </span>\n <span className={styles['file-preview-name']} title={resolvedFile.name}>\n {resolvedFile.name}\n </span>\n <SemanticTag color={getFileTypeTagColor(previewKind)}>{typeLabel}</SemanticTag>\n {resolvedFile.size != null && (\n <span className={styles['file-preview-size']}>\n {formatFileSize(resolvedFile.size)}\n </span>\n )}\n </div>\n {canDownload && (\n <Button type=\"link\" icon={<CloudDownload />} onClick={handleDownload}>\n 下载\n </Button>\n )}\n </>\n )}\n {extra}\n </div>\n <div className={classNames('file-preview-body', styles['file-preview-body'])}>\n <FilePreviewContent\n file={resolvedFile}\n previewUrl={previewUrl}\n unsupportedMessage={unsupportedMessage}\n />\n </div>\n </div>\n );\n};\n\nexport default FilePreview;\n"],"names":["resolvePreviewUrl","file","url","FilePreview","downloadUrl","onDownload","unsupportedMessage","title","extra","resolvedFile","normalizeFileDisplayItem","previewUrl","resolvedDownloadUrl","canDownload","previewKind","getPreviewKind","typeLabel","getFileTypeName","authHeaders","useFileAuthHeaders","handleDownload","res","fetchWithMarsunAuth","blob","blobUrl","a","err","message","jsxs","classNames","styles","Fragment","jsx","SemanticTag","getFileTypeTagColor","formatFileSize","Button","CloudDownload","FilePreviewContent"],"mappings":";;;;;;;;;;;AAuBA,SAASA,EAAkBC,GAAuBC,GAAkC;AAClF,SAAOA,KAAOD,EAAK,OAAOA,EAAK;AACjC;AAEA,MAAME,IAA0C,CAAC;AAAA,EAC/C,MAAAF;AAAA,EACA,KAAAC;AAAA,EACA,aAAAE;AAAA,EACA,YAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,OAAAC;AAAA,EACA,OAAAC;AACF,MAAM;AACJ,QAAMC,IAAeC,EAAyBT,CAAI,GAC5CU,IAAaX,EAAkBS,GAAcP,CAAG,GAChDU,IAAsBR,KAAeO,GACrCE,IAAc,GAAQR,KAAcO,IACpCE,IAAcC,EAAeN,CAAY,GACzCO,IAAYC,EAAgBR,EAAa,MAAMA,EAAa,QAAQ,GACpES,IAAcC,EAAA,GAEdC,IAAiB,MAAM;AAC3B,QAAIf,GAAY;AACd,MAAAA,EAAWI,CAAY;AACvB;AAAA,IACF;AACA,IAAKG,MACC,YAAY;AAChB,UAAI;AACF,cAAMS,IAAM,MAAMC,EAAo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AAAJ,EAACK,GAAA,CAAA,CAAc,GAAI,SAASjB,GAAgB,UAAA,KAAA,CAEtE;AAAA,MAAA,GAEJ;AAAA,MAEDZ;AAAA,IAAA,GACH;AAAA,IACA,gBAAAwB,EAAC,SAAI,WAAWH,EAAW,qBAAqBC,EAAO,mBAAmB,CAAC,GACzE,UAAA,gBAAAE;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,MAAM7B;AAAA,QACN,YAAAE;AAAA,QACA,oBAAAL;AAAA,MAAA;AAAA,IAAA,EACF,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -12,3 +12,4 @@ export { default as FilePreviewLink } from './FilePreviewLink';
|
|
|
12
12
|
export type { FilePreviewLinkProps } from './FilePreviewLink';
|
|
13
13
|
export { downloadFileItem, getFileDownloadAuthHeaders, getFileDownloadUrl } from './utils/download';
|
|
14
14
|
export type { FileDownloadAuthOptions, FileDownloadOptions } from './utils/download';
|
|
15
|
+
export { fetchAuthedArrayBuffer, fetchAuthedObjectUrl, fetchWithMarsunAuth, needsAuthFetch, } from './utils/authedFetch';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 相对 /api 等受护资源:须带 MarsunCoreProvider.fetch.headers(Bearer) */
|
|
2
|
+
export declare function needsAuthFetch(url: string, headers?: Record<string, string>): boolean;
|
|
3
|
+
export declare function fetchWithMarsunAuth(url: string, headers?: Record<string, string>): Promise<Response>;
|
|
4
|
+
export declare function fetchAuthedArrayBuffer(url: string, headers?: Record<string, string>): Promise<ArrayBuffer>;
|
|
5
|
+
export declare function fetchAuthedObjectUrl(url: string, headers?: Record<string, string>): Promise<{
|
|
6
|
+
objectUrl: string;
|
|
7
|
+
revoke: () => void;
|
|
8
|
+
}>;
|
|
9
|
+
/** File 预览组件内读取 Provider 注入的鉴权头 */
|
|
10
|
+
export declare function useFileAuthHeaders(): Record<string, string> | undefined;
|
|
11
|
+
/** effect 依赖用:仅 token 串,避免 headers 对象引用抖动 */
|
|
12
|
+
export declare function useFileAuthHeaderKey(): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useMarsunFetch as u } from "../../../provider/context.js";
|
|
2
|
+
function o(t, r) {
|
|
3
|
+
if (!t || !r || Object.keys(r).length === 0 || t.startsWith("blob:") || t.startsWith("data:")) return !1;
|
|
4
|
+
if (t.startsWith("/")) return !0;
|
|
5
|
+
try {
|
|
6
|
+
const e = new URL(t, typeof window < "u" ? window.location.origin : "http://local");
|
|
7
|
+
if (typeof window < "u" && e.origin === window.location.origin) return !0;
|
|
8
|
+
} catch {
|
|
9
|
+
return !1;
|
|
10
|
+
}
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
async function i(t, r) {
|
|
14
|
+
const e = {};
|
|
15
|
+
return o(t, r) && r && (e.headers = r), fetch(t, e);
|
|
16
|
+
}
|
|
17
|
+
async function f(t, r) {
|
|
18
|
+
const e = await i(t, r);
|
|
19
|
+
if (!e.ok) throw new Error(`预览加载失败 (${e.status})`);
|
|
20
|
+
return e.arrayBuffer();
|
|
21
|
+
}
|
|
22
|
+
async function h(t, r) {
|
|
23
|
+
if (!o(t, r))
|
|
24
|
+
return { objectUrl: t, revoke: () => {
|
|
25
|
+
} };
|
|
26
|
+
const e = await i(t, r);
|
|
27
|
+
if (!e.ok) throw new Error(`预览加载失败 (${e.status})`);
|
|
28
|
+
const a = await e.blob(), n = URL.createObjectURL(a);
|
|
29
|
+
return {
|
|
30
|
+
objectUrl: n,
|
|
31
|
+
revoke: () => URL.revokeObjectURL(n)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function c() {
|
|
35
|
+
const { headers: t } = u(), r = (t == null ? void 0 : t.Authorization) || (t == null ? void 0 : t.authorization);
|
|
36
|
+
return r ? { Authorization: r.startsWith("Bearer ") || r.startsWith("bearer ") ? r : `Bearer ${r}` } : void 0;
|
|
37
|
+
}
|
|
38
|
+
function w() {
|
|
39
|
+
var t;
|
|
40
|
+
return ((t = c()) == null ? void 0 : t.Authorization) || "";
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
f as fetchAuthedArrayBuffer,
|
|
44
|
+
h as fetchAuthedObjectUrl,
|
|
45
|
+
i as fetchWithMarsunAuth,
|
|
46
|
+
o as needsAuthFetch,
|
|
47
|
+
w as useFileAuthHeaderKey,
|
|
48
|
+
c as useFileAuthHeaders
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=authedFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authedFetch.js","sources":["../../../../src/components/File/utils/authedFetch.ts"],"sourcesContent":["import { useMarsunFetch } from '@/provider/context';\n\n/** 相对 /api 等受护资源:须带 MarsunCoreProvider.fetch.headers(Bearer) */\nexport function needsAuthFetch(url: string, headers?: Record<string, string>): boolean {\n if (!url || !headers || Object.keys(headers).length === 0) return false;\n if (url.startsWith('blob:') || url.startsWith('data:')) return false;\n // 同源相对路径或明确 /api\n if (url.startsWith('/')) return true;\n try {\n const u = new URL(url, typeof window !== 'undefined' ? window.location.origin : 'http://local');\n if (typeof window !== 'undefined' && u.origin === window.location.origin) return true;\n } catch {\n return false;\n }\n return false;\n}\n\nexport async function fetchWithMarsunAuth(\n url: string,\n headers?: Record<string, string>,\n): Promise<Response> {\n const init: RequestInit = {};\n if (needsAuthFetch(url, headers) && headers) {\n init.headers = headers;\n }\n return fetch(url, init);\n}\n\nexport async function fetchAuthedArrayBuffer(\n url: string,\n headers?: Record<string, string>,\n): Promise<ArrayBuffer> {\n const res = await fetchWithMarsunAuth(url, headers);\n if (!res.ok) throw new Error(`预览加载失败 (${res.status})`);\n return res.arrayBuffer();\n}\n\nexport async function fetchAuthedObjectUrl(\n url: string,\n headers?: Record<string, string>,\n): Promise<{ objectUrl: string; revoke: () => void }> {\n if (!needsAuthFetch(url, headers)) {\n return { objectUrl: url, revoke: () => undefined };\n }\n const res = await fetchWithMarsunAuth(url, headers);\n if (!res.ok) throw new Error(`预览加载失败 (${res.status})`);\n const blob = await res.blob();\n const objectUrl = URL.createObjectURL(blob);\n return {\n objectUrl,\n revoke: () => URL.revokeObjectURL(objectUrl),\n };\n}\n\n/** File 预览组件内读取 Provider 注入的鉴权头 */\nexport function useFileAuthHeaders(): Record<string, string> | undefined {\n const { headers } = useMarsunFetch();\n const raw = headers?.Authorization || headers?.authorization;\n if (!raw) return undefined;\n const Authorization =\n raw.startsWith('Bearer ') || raw.startsWith('bearer ') ? raw : `Bearer ${raw}`;\n return { Authorization };\n}\n\n/** effect 依赖用:仅 token 串,避免 headers 对象引用抖动 */\nexport function useFileAuthHeaderKey(): string {\n return useFileAuthHeaders()?.Authorization || '';\n}\n"],"names":["needsAuthFetch","url","headers","u","fetchWithMarsunAuth","init","fetchAuthedArrayBuffer","res","fetchAuthedObjectUrl","blob","objectUrl","useFileAuthHeaders","useMarsunFetch","raw","useFileAuthHeaderKey","_a"],"mappings":";AAGO,SAASA,EAAeC,GAAaC,GAA2C;AAErF,MADI,CAACD,KAAO,CAACC,KAAW,OAAO,KAAKA,CAAO,EAAE,WAAW,KACpDD,EAAI,WAAW,OAAO,KAAKA,EAAI,WAAW,OAAO,EAAG,QAAO;AAE/D,MAAIA,EAAI,WAAW,GAAG,EAAG,QAAO;AAChC,MAAI;AACF,UAAME,IAAI,IAAI,IAAIF,GAAK,OAAO,SAAW,MAAc,OAAO,SAAS,SAAS,cAAc;AAC9F,QAAI,OAAO,SAAW,OAAeE,EAAE,WAAW,OAAO,SAAS,OAAQ,QAAO;AAAA,EACnF,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,eAAsBC,EACpBH,GACAC,GACmB;AACnB,QAAMG,IAAoB,CAAA;AAC1B,SAAIL,EAAeC,GAAKC,CAAO,KAAKA,MAClCG,EAAK,UAAUH,IAEV,MAAMD,GAAKI,CAAI;AACxB;AAEA,eAAsBC,EACpBL,GACAC,GACsB;AACtB,QAAMK,IAAM,MAAMH,EAAoBH,GAAKC,CAAO;AAClD,MAAI,CAACK,EAAI,GAAI,OAAM,IAAI,MAAM,WAAWA,EAAI,MAAM,GAAG;AACrD,SAAOA,EAAI,YAAA;AACb;AAEA,eAAsBC,EACpBP,GACAC,GACoD;AACpD,MAAI,CAACF,EAAeC,GAAKC,CAAO;AAC9B,WAAO,EAAE,WAAWD,GAAK,QAAQ,MAAA;AAAA,MAAM;AAEzC,QAAMM,IAAM,MAAMH,EAAoBH,GAAKC,CAAO;AAClD,MAAI,CAACK,EAAI,GAAI,OAAM,IAAI,MAAM,WAAWA,EAAI,MAAM,GAAG;AACrD,QAAME,IAAO,MAAMF,EAAI,KAAA,GACjBG,IAAY,IAAI,gBAAgBD,CAAI;AAC1C,SAAO;AAAA,IACL,WAAAC;AAAA,IACA,QAAQ,MAAM,IAAI,gBAAgBA,CAAS;AAAA,EAAA;AAE/C;AAGO,SAASC,IAAyD;AACvE,QAAM,EAAE,SAAAT,EAAA,IAAYU,EAAA,GACdC,KAAMX,KAAA,gBAAAA,EAAS,mBAAiBA,KAAA,gBAAAA,EAAS;AAC/C,SAAKW,IAGE,EAAE,eADPA,EAAI,WAAW,SAAS,KAAKA,EAAI,WAAW,SAAS,IAAIA,IAAM,UAAUA,CAAG,GACrE,IAHC;AAIZ;AAGO,SAASC,IAA+B;;AAC7C,WAAOC,IAAAJ,EAAA,MAAA,gBAAAI,EAAsB,kBAAiB;AAChD;"}
|
|
@@ -18,7 +18,7 @@ export { SUPER_SELECT_EMPTY_TEXT, defaultSuperSelectEmpty } from './superSelectE
|
|
|
18
18
|
export { createPagedSuperSelectApi, pagedSuperSelectGetSearchProps, pagedSuperSelectPagination, PAGED_SUPER_SELECT_PAGE_SIZE, } from './createPagedSuperSelectApi';
|
|
19
19
|
export type { PagedSuperSelectOption, PagedSuperSelectQuery, PagedSuperSelectPage, CreatePagedSuperSelectApiOptions, } from './createPagedSuperSelectApi';
|
|
20
20
|
/** @kne/form-info — 业务从包根导入,勿直连 @kne/form-info */
|
|
21
|
-
export { FormInfo, Form, FormModal, FormSteps, FormStepsModal, List, TableList, MultiField, Input, TextArea, Select, TreeSelect, InputNumber, Switch, RadioGroup, SubmitButton, ResetButton, CancelButton, } from './kneFormInfo';
|
|
21
|
+
export { FormInfo, Form, FormModal, FormSteps, FormStepsModal, List, TableList, MultiField, Input, TextArea, Select, TreeSelect, InputNumber, Switch, RadioGroup, DatePicker, SubmitButton, ResetButton, CancelButton, } from './kneFormInfo';
|
|
22
22
|
export type { FormInfoProps, FormProps, FormModalProps, FormStepsProps, FormStepsModalProps, ListProps, TableListProps, MultiFieldProps, } from './kneFormInfo';
|
|
23
23
|
export { normalizeLabelTips, withNormalizedLabelTips } from './normalizeLabelTips';
|
|
24
24
|
/** @kne/react-form — 引擎 API;默认组件为 ReactForm(勿与 FormInfo 的 Form 混淆) */
|
|
@@ -49,6 +49,8 @@ export declare const TreeSelect: ComponentType<FieldProps>;
|
|
|
49
49
|
export declare const InputNumber: ComponentType<FieldProps>;
|
|
50
50
|
export declare const Switch: ComponentType<FieldProps>;
|
|
51
51
|
export declare const RadioGroup: ComponentType<FieldProps>;
|
|
52
|
+
/** 存量 kne 栈日期字段;新模块优先 `./form-info` DatePicker */
|
|
53
|
+
export declare const DatePicker: ComponentType<FieldProps>;
|
|
52
54
|
export declare const SubmitButton: ComponentType<ButtonProps>;
|
|
53
55
|
export declare const ResetButton: ComponentType<ButtonProps>;
|
|
54
56
|
export declare const CancelButton: ComponentType<ButtonProps>;
|
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import
|
|
3
|
-
import { CancelButton as u, ResetButton as l, SubmitButton as p, Select as S, Input as d, InputNumber as F, RadioGroup as
|
|
2
|
+
import e, { FormModal as s, Form as a, FormSteps as n, FormStepsModal as r, List as c, MultiField as i, TableList as m } from "@kne/form-info";
|
|
3
|
+
import { CancelButton as u, ResetButton as l, SubmitButton as p, Select as S, DatePicker as $, Input as d, InputNumber as F, RadioGroup as b, Switch as T, TextArea as B, TreeSelect as I } from "@kne/react-form-antd";
|
|
4
4
|
import { withNormalizedLabelTips as t } from "./normalizeLabelTips.js";
|
|
5
|
-
import { normalizeLabelTips as
|
|
6
|
-
const
|
|
5
|
+
import { normalizeLabelTips as Q } from "./normalizeLabelTips.js";
|
|
6
|
+
const x = e, P = a, h = s, N = n, k = r, A = c, C = m, D = i, o = d, M = t(o), G = Object.assign(M, {
|
|
7
7
|
Password: t(o.Password)
|
|
8
|
-
}),
|
|
9
|
-
|
|
10
|
-
),
|
|
8
|
+
}), z = t(
|
|
9
|
+
B
|
|
10
|
+
), g = t(
|
|
11
11
|
S
|
|
12
|
+
), j = t(
|
|
13
|
+
I
|
|
12
14
|
), y = t(
|
|
13
|
-
B
|
|
14
|
-
), K = t(
|
|
15
15
|
F
|
|
16
|
+
), K = t(
|
|
17
|
+
T
|
|
16
18
|
), O = t(
|
|
17
19
|
b
|
|
18
20
|
), W = t(
|
|
19
21
|
$
|
|
20
|
-
),
|
|
22
|
+
), q = p, v = l, E = u;
|
|
21
23
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
E as CancelButton,
|
|
25
|
+
W as DatePicker,
|
|
26
|
+
P as Form,
|
|
27
|
+
x as FormInfo,
|
|
25
28
|
h as FormModal,
|
|
26
29
|
N as FormSteps,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
k as FormStepsModal,
|
|
31
|
+
G as Input,
|
|
32
|
+
y as InputNumber,
|
|
33
|
+
A as List,
|
|
34
|
+
D as MultiField,
|
|
35
|
+
O as RadioGroup,
|
|
36
|
+
v as ResetButton,
|
|
37
|
+
g as Select,
|
|
38
|
+
q as SubmitButton,
|
|
39
|
+
K as Switch,
|
|
40
|
+
C as TableList,
|
|
41
|
+
z as TextArea,
|
|
42
|
+
j as TreeSelect,
|
|
43
|
+
Q as normalizeLabelTips,
|
|
41
44
|
t as withNormalizedLabelTips
|
|
42
45
|
};
|
|
43
46
|
//# sourceMappingURL=kneFormInfo.js.map
|
|
@@ -1 +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 *\n * 字段 `labelTips`:字符串由 {@link withNormalizedLabelTips} 统一包成 Info+TooltipInfo。\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 RadioGroup as KneRadioGroup,\n ResetButton as KneResetButton,\n Select as KneSelect,\n SubmitButton as KneSubmitButton,\n Switch as KneSwitch,\n TextArea as KneTextArea,\n TreeSelect as KneTreeSelect,\n} from '@kne/react-form-antd';\nimport type { ComponentType, FC, ReactNode } from 'react';\nimport { withNormalizedLabelTips } from './normalizeLabelTips';\n\ntype FieldProps = {\n name: string;\n label?: ReactNode;\n /** 字符串自动变 Info 悬停;也可传 ReactNode / (props)=>ReactNode 自定义 */\n labelTips?: ReactNode | ((props: FieldProps) => 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\ntype KneInputType = ComponentType<FieldProps> & { Password: ComponentType<FieldProps> };\nconst KneInputTyped = KneInput as unknown as KneInputType;\nconst InputWrapped = withNormalizedLabelTips(KneInputTyped);\nexport const Input = Object.assign(InputWrapped, {\n Password: withNormalizedLabelTips(KneInputTyped.Password),\n}) as KneInputType;\n\nexport const TextArea = withNormalizedLabelTips(\n KneTextArea as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const Select = withNormalizedLabelTips(\n KneSelect as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const TreeSelect = withNormalizedLabelTips(\n KneTreeSelect as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const InputNumber = withNormalizedLabelTips(\n KneInputNumber as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const Switch = withNormalizedLabelTips(\n KneSwitch as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const RadioGroup = withNormalizedLabelTips(\n KneRadioGroup as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\n\nexport const SubmitButton = KneSubmitButton as ComponentType<ButtonProps>;\nexport const ResetButton = KneResetButton as ComponentType<ButtonProps>;\nexport const CancelButton = KneCancelButton as ComponentType<ButtonProps>;\n\nexport { normalizeLabelTips, withNormalizedLabelTips } from './normalizeLabelTips';\n"],"names":["FormInfo","FormInfoBase","Form","KneForm","FormModal","KneFormModal","FormSteps","KneFormSteps","FormStepsModal","KneFormStepsModal","List","KneList","TableList","KneTableList","MultiField","KneMultiField","KneInputTyped","KneInput","InputWrapped","withNormalizedLabelTips","Input","TextArea","KneTextArea","Select","KneSelect","TreeSelect","KneTreeSelect","InputNumber","KneInputNumber","Switch","KneSwitch","RadioGroup","KneRadioGroup","SubmitButton","KneSubmitButton","ResetButton","KneResetButton","CancelButton","KneCancelButton"],"mappings":";;;;;
|
|
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 *\n * 字段 `labelTips`:字符串由 {@link withNormalizedLabelTips} 统一包成 Info+TooltipInfo。\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 DatePicker as KneDatePicker,\n Input as KneInput,\n InputNumber as KneInputNumber,\n RadioGroup as KneRadioGroup,\n ResetButton as KneResetButton,\n Select as KneSelect,\n SubmitButton as KneSubmitButton,\n Switch as KneSwitch,\n TextArea as KneTextArea,\n TreeSelect as KneTreeSelect,\n} from '@kne/react-form-antd';\nimport type { ComponentType, FC, ReactNode } from 'react';\nimport { withNormalizedLabelTips } from './normalizeLabelTips';\n\ntype FieldProps = {\n name: string;\n label?: ReactNode;\n /** 字符串自动变 Info 悬停;也可传 ReactNode / (props)=>ReactNode 自定义 */\n labelTips?: ReactNode | ((props: FieldProps) => 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\ntype KneInputType = ComponentType<FieldProps> & { Password: ComponentType<FieldProps> };\nconst KneInputTyped = KneInput as unknown as KneInputType;\nconst InputWrapped = withNormalizedLabelTips(KneInputTyped);\nexport const Input = Object.assign(InputWrapped, {\n Password: withNormalizedLabelTips(KneInputTyped.Password),\n}) as KneInputType;\n\nexport const TextArea = withNormalizedLabelTips(\n KneTextArea as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const Select = withNormalizedLabelTips(\n KneSelect as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const TreeSelect = withNormalizedLabelTips(\n KneTreeSelect as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const InputNumber = withNormalizedLabelTips(\n KneInputNumber as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const Switch = withNormalizedLabelTips(\n KneSwitch as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const RadioGroup = withNormalizedLabelTips(\n KneRadioGroup as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\n\n/** 存量 kne 栈日期字段;新模块优先 `./form-info` DatePicker */\nexport const DatePicker = withNormalizedLabelTips(\n KneDatePicker as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\n\nexport const SubmitButton = KneSubmitButton as ComponentType<ButtonProps>;\nexport const ResetButton = KneResetButton as ComponentType<ButtonProps>;\nexport const CancelButton = KneCancelButton as ComponentType<ButtonProps>;\n\nexport { normalizeLabelTips, withNormalizedLabelTips } from './normalizeLabelTips';\n"],"names":["FormInfo","FormInfoBase","Form","KneForm","FormModal","KneFormModal","FormSteps","KneFormSteps","FormStepsModal","KneFormStepsModal","List","KneList","TableList","KneTableList","MultiField","KneMultiField","KneInputTyped","KneInput","InputWrapped","withNormalizedLabelTips","Input","TextArea","KneTextArea","Select","KneSelect","TreeSelect","KneTreeSelect","InputNumber","KneInputNumber","Switch","KneSwitch","RadioGroup","KneRadioGroup","DatePicker","KneDatePicker","SubmitButton","KneSubmitButton","ResetButton","KneResetButton","CancelButton","KneCancelButton"],"mappings":";;;;;AA2EO,MAAMA,IAAWC,GACXC,IAAOC,GACPC,IAAYC,GACZC,IAAYC,GACZC,IAAiBC,GAEjBC,IAAOC,GAMPC,IAAYC,GAKZC,IAAaC,GAGpBC,IAAgBC,GAChBC,IAAeC,EAAwBH,CAAa,GAC7CI,IAAQ,OAAO,OAAOF,GAAc;AAAA,EAC/C,UAAUC,EAAwBH,EAAc,QAAQ;AAC1D,CAAC,GAEYK,IAAWF;AAAA,EACtBG;AACF,GACaC,IAASJ;AAAA,EACpBK;AACF,GACaC,IAAaN;AAAA,EACxBO;AACF,GACaC,IAAcR;AAAA,EACzBS;AACF,GACaC,IAASV;AAAA,EACpBW;AACF,GACaC,IAAaZ;AAAA,EACxBa;AACF,GAGaC,IAAad;AAAA,EACxBe;AACF,GAEaC,IAAeC,GACfC,IAAcC,GACdC,IAAeC;"}
|
|
@@ -36,6 +36,8 @@ export type { PagedSuperSelectOption, PagedSuperSelectQuery, PagedSuperSelectPag
|
|
|
36
36
|
export declare const InputNumber: ComponentType<FieldProps>;
|
|
37
37
|
export declare const Switch: ComponentType<FieldProps>;
|
|
38
38
|
export declare const RadioGroup: ComponentType<FieldProps>;
|
|
39
|
+
/** FormInfo 日期字段(antd DatePicker);禁止 Input type="date" */
|
|
40
|
+
export declare const DatePicker: ComponentType<FieldProps>;
|
|
39
41
|
export declare const SubmitButton: ComponentType<ButtonProps>;
|
|
40
42
|
export declare const ResetButton: ComponentType<ButtonProps>;
|
|
41
43
|
export declare const CancelButton: ComponentType<ButtonProps>;
|
|
@@ -1,39 +1,42 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { CancelButton as
|
|
2
|
+
import { CancelButton as a, ResetButton as s, SubmitButton as r, Input as c, TextArea as u, Select as i, TreeSelect as l, InputNumber as m, Switch as p, RadioGroup as S, DatePicker as b } from "@kne/react-form-antd";
|
|
3
3
|
import { withNormalizedLabelTips as t } from "../Form/normalizeLabelTips.js";
|
|
4
|
-
import { VariableMentionField as
|
|
5
|
-
const o =
|
|
4
|
+
import { VariableMentionField as $ } from "./VariableMentionInput/index.js";
|
|
5
|
+
const o = c;
|
|
6
6
|
function B(e) {
|
|
7
|
-
return e.enableVariableMention ? /* @__PURE__ */ n(
|
|
7
|
+
return e.enableVariableMention ? /* @__PURE__ */ n($, { ...e }) : /* @__PURE__ */ n(o, { ...e });
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const f = Object.assign(
|
|
10
10
|
t(B),
|
|
11
11
|
{
|
|
12
12
|
Password: t(o.Password)
|
|
13
13
|
}
|
|
14
|
-
), f = t(
|
|
15
|
-
c
|
|
16
14
|
), R = t(
|
|
17
|
-
|
|
15
|
+
u
|
|
18
16
|
), h = t(
|
|
19
|
-
|
|
17
|
+
i
|
|
20
18
|
), x = t(
|
|
19
|
+
l
|
|
20
|
+
), P = t(
|
|
21
21
|
m
|
|
22
22
|
), N = t(
|
|
23
23
|
p
|
|
24
|
-
),
|
|
24
|
+
), k = t(
|
|
25
25
|
S
|
|
26
|
-
),
|
|
26
|
+
), A = t(
|
|
27
|
+
b
|
|
28
|
+
), C = r, D = s, G = a;
|
|
27
29
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
G as CancelButton,
|
|
31
|
+
A as DatePicker,
|
|
32
|
+
f as Input,
|
|
33
|
+
P as InputNumber,
|
|
34
|
+
k as RadioGroup,
|
|
35
|
+
D as ResetButton,
|
|
36
|
+
h as Select,
|
|
34
37
|
C as SubmitButton,
|
|
35
38
|
N as Switch,
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
R as TextArea,
|
|
40
|
+
x as TreeSelect
|
|
38
41
|
};
|
|
39
42
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sources":["../../../src/components/FormInfo/fields.tsx"],"sourcesContent":["/**\n * FormInfo Input 扩展:enableVariableMention 时走 VariableMentionField(「插入变量」→ {{key}})。\n */\nimport {\n CancelButton as BaseCancelButton,\n Input as BaseInput,\n InputNumber as BaseInputNumber,\n RadioGroup as BaseRadioGroup,\n ResetButton as BaseResetButton,\n Select as BaseSelect,\n SubmitButton as BaseSubmitButton,\n Switch as BaseSwitch,\n TextArea as BaseTextArea,\n TreeSelect as BaseTreeSelect,\n} from '@kne/react-form-antd';\nimport { type ComponentType, type ReactNode } from 'react';\nimport { withNormalizedLabelTips } from '@/components/Form/normalizeLabelTips';\nimport { VariableMentionField } from './VariableMentionInput';\nimport type { VariableMentionItem } from '@/components/Editor/variableMention';\n\ntype FieldProps = {\n name: string;\n label?: ReactNode;\n labelTips?: ReactNode | ((props: FieldProps) => ReactNode);\n rule?: string;\n placeholder?: string;\n disabled?: boolean;\n block?: boolean;\n rows?: number;\n options?: unknown[];\n /** 开启「插入变量」;与 variables 联用 */\n enableVariableMention?: boolean;\n variables?: VariableMentionItem[];\n catalogError?: string;\n [key: string]: unknown;\n};\n\ntype ButtonProps = {\n children?: ReactNode;\n type?: string;\n loading?: boolean;\n [key: string]: unknown;\n};\n\ntype InputType = ComponentType<FieldProps> & { Password: ComponentType<FieldProps> };\n\nconst InputBase = BaseInput as unknown as InputType;\n\nfunction InputSwitch(props: FieldProps) {\n if (props.enableVariableMention) {\n return <VariableMentionField {...props} />;\n }\n return <InputBase {...props} />;\n}\n\nexport const Input = Object.assign(\n withNormalizedLabelTips(InputSwitch as ComponentType<FieldProps>),\n {\n Password: withNormalizedLabelTips(InputBase.Password),\n },\n) as InputType;\n\nexport const TextArea = withNormalizedLabelTips(\n BaseTextArea as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const Select = withNormalizedLabelTips(\n BaseSelect as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const TreeSelect = withNormalizedLabelTips(\n BaseTreeSelect as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\n\nexport {\n SuperSelect,\n SUPER_SELECT_ALL_VALUE,\n isSuperSelectAllValue,\n} from '@/components/Form/SuperSelect';\nexport type { SuperSelectProps, SuperSelectOption } from '@/components/Form/SuperSelect';\nexport {\n createPagedSuperSelectApi,\n pagedSuperSelectGetSearchProps,\n pagedSuperSelectPagination,\n PAGED_SUPER_SELECT_PAGE_SIZE,\n} from '@/components/Form/createPagedSuperSelectApi';\nexport type {\n PagedSuperSelectOption,\n PagedSuperSelectQuery,\n PagedSuperSelectPage,\n CreatePagedSuperSelectApiOptions,\n} from '@/components/Form/createPagedSuperSelectApi';\nexport const InputNumber = withNormalizedLabelTips(\n BaseInputNumber as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const Switch = withNormalizedLabelTips(\n BaseSwitch as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const RadioGroup = withNormalizedLabelTips(\n BaseRadioGroup as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\n\nexport const SubmitButton = BaseSubmitButton as ComponentType<ButtonProps>;\nexport const ResetButton = BaseResetButton as ComponentType<ButtonProps>;\nexport const CancelButton = BaseCancelButton as ComponentType<ButtonProps>;\n"],"names":["InputBase","BaseInput","InputSwitch","props","jsx","VariableMentionField","Input","withNormalizedLabelTips","TextArea","BaseTextArea","Select","BaseSelect","TreeSelect","BaseTreeSelect","InputNumber","BaseInputNumber","Switch","BaseSwitch","RadioGroup","BaseRadioGroup","SubmitButton","BaseSubmitButton","ResetButton","BaseResetButton","CancelButton","BaseCancelButton"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"fields.js","sources":["../../../src/components/FormInfo/fields.tsx"],"sourcesContent":["/**\n * FormInfo Input 扩展:enableVariableMention 时走 VariableMentionField(「插入变量」→ {{key}})。\n */\nimport {\n CancelButton as BaseCancelButton,\n DatePicker as BaseDatePicker,\n Input as BaseInput,\n InputNumber as BaseInputNumber,\n RadioGroup as BaseRadioGroup,\n ResetButton as BaseResetButton,\n Select as BaseSelect,\n SubmitButton as BaseSubmitButton,\n Switch as BaseSwitch,\n TextArea as BaseTextArea,\n TreeSelect as BaseTreeSelect,\n} from '@kne/react-form-antd';\nimport { type ComponentType, type ReactNode } from 'react';\nimport { withNormalizedLabelTips } from '@/components/Form/normalizeLabelTips';\nimport { VariableMentionField } from './VariableMentionInput';\nimport type { VariableMentionItem } from '@/components/Editor/variableMention';\n\ntype FieldProps = {\n name: string;\n label?: ReactNode;\n labelTips?: ReactNode | ((props: FieldProps) => ReactNode);\n rule?: string;\n placeholder?: string;\n disabled?: boolean;\n block?: boolean;\n rows?: number;\n options?: unknown[];\n /** 开启「插入变量」;与 variables 联用 */\n enableVariableMention?: boolean;\n variables?: VariableMentionItem[];\n catalogError?: string;\n [key: string]: unknown;\n};\n\ntype ButtonProps = {\n children?: ReactNode;\n type?: string;\n loading?: boolean;\n [key: string]: unknown;\n};\n\ntype InputType = ComponentType<FieldProps> & { Password: ComponentType<FieldProps> };\n\nconst InputBase = BaseInput as unknown as InputType;\n\nfunction InputSwitch(props: FieldProps) {\n if (props.enableVariableMention) {\n return <VariableMentionField {...props} />;\n }\n return <InputBase {...props} />;\n}\n\nexport const Input = Object.assign(\n withNormalizedLabelTips(InputSwitch as ComponentType<FieldProps>),\n {\n Password: withNormalizedLabelTips(InputBase.Password),\n },\n) as InputType;\n\nexport const TextArea = withNormalizedLabelTips(\n BaseTextArea as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const Select = withNormalizedLabelTips(\n BaseSelect as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const TreeSelect = withNormalizedLabelTips(\n BaseTreeSelect as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\n\nexport {\n SuperSelect,\n SUPER_SELECT_ALL_VALUE,\n isSuperSelectAllValue,\n} from '@/components/Form/SuperSelect';\nexport type { SuperSelectProps, SuperSelectOption } from '@/components/Form/SuperSelect';\nexport {\n createPagedSuperSelectApi,\n pagedSuperSelectGetSearchProps,\n pagedSuperSelectPagination,\n PAGED_SUPER_SELECT_PAGE_SIZE,\n} from '@/components/Form/createPagedSuperSelectApi';\nexport type {\n PagedSuperSelectOption,\n PagedSuperSelectQuery,\n PagedSuperSelectPage,\n CreatePagedSuperSelectApiOptions,\n} from '@/components/Form/createPagedSuperSelectApi';\nexport const InputNumber = withNormalizedLabelTips(\n BaseInputNumber as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const Switch = withNormalizedLabelTips(\n BaseSwitch as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\nexport const RadioGroup = withNormalizedLabelTips(\n BaseRadioGroup as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\n\n/** FormInfo 日期字段(antd DatePicker);禁止 Input type=\"date\" */\nexport const DatePicker = withNormalizedLabelTips(\n BaseDatePicker as ComponentType<FieldProps>,\n) as ComponentType<FieldProps>;\n\nexport const SubmitButton = BaseSubmitButton as ComponentType<ButtonProps>;\nexport const ResetButton = BaseResetButton as ComponentType<ButtonProps>;\nexport const CancelButton = BaseCancelButton as ComponentType<ButtonProps>;\n"],"names":["InputBase","BaseInput","InputSwitch","props","jsx","VariableMentionField","Input","withNormalizedLabelTips","TextArea","BaseTextArea","Select","BaseSelect","TreeSelect","BaseTreeSelect","InputNumber","BaseInputNumber","Switch","BaseSwitch","RadioGroup","BaseRadioGroup","DatePicker","BaseDatePicker","SubmitButton","BaseSubmitButton","ResetButton","BaseResetButton","CancelButton","BaseCancelButton"],"mappings":";;;;AA+CA,MAAMA,IAAYC;AAElB,SAASC,EAAYC,GAAmB;AACtC,SAAIA,EAAM,wBACD,gBAAAC,EAACC,GAAA,EAAsB,GAAGF,EAAA,CAAO,IAEnC,gBAAAC,EAACJ,GAAA,EAAW,GAAGG,EAAA,CAAO;AAC/B;AAEO,MAAMG,IAAQ,OAAO;AAAA,EAC1BC,EAAwBL,CAAwC;AAAA,EAChE;AAAA,IACE,UAAUK,EAAwBP,EAAU,QAAQ;AAAA,EAAA;AAExD,GAEaQ,IAAWD;AAAA,EACtBE;AACF,GACaC,IAASH;AAAA,EACpBI;AACF,GACaC,IAAaL;AAAA,EACxBM;AACF,GAoBaC,IAAcP;AAAA,EACzBQ;AACF,GACaC,IAAST;AAAA,EACpBU;AACF,GACaC,IAAaX;AAAA,EACxBY;AACF,GAGaC,IAAab;AAAA,EACxBc;AACF,GAEaC,IAAeC,GACfC,IAAcC,GACdC,IAAeC;"}
|
|
@@ -17,7 +17,7 @@ export { default as Steps, validateFieldsByName } from './Steps';
|
|
|
17
17
|
export { default as FormSteps } from './FormSteps';
|
|
18
18
|
export { default as FormStepsModal, useFormStepModal } from './FormStepsModal';
|
|
19
19
|
export { buildFormOverlayProps } from './buildFormOverlayProps';
|
|
20
|
-
export { Input, TextArea, Select, TreeSelect, InputNumber, Switch, RadioGroup, SubmitButton, ResetButton, CancelButton, SuperSelect, SUPER_SELECT_ALL_VALUE, isSuperSelectAllValue, createPagedSuperSelectApi, pagedSuperSelectGetSearchProps, pagedSuperSelectPagination, PAGED_SUPER_SELECT_PAGE_SIZE, } from './fields';
|
|
20
|
+
export { Input, TextArea, Select, TreeSelect, InputNumber, Switch, RadioGroup, DatePicker, SubmitButton, ResetButton, CancelButton, SuperSelect, SUPER_SELECT_ALL_VALUE, isSuperSelectAllValue, createPagedSuperSelectApi, pagedSuperSelectGetSearchProps, pagedSuperSelectPagination, PAGED_SUPER_SELECT_PAGE_SIZE, } from './fields';
|
|
21
21
|
export type { SuperSelectProps, SuperSelectOption, PagedSuperSelectOption, PagedSuperSelectQuery, PagedSuperSelectPage, CreatePagedSuperSelectApiOptions, } from './fields';
|
|
22
22
|
export { RichTextField } from './RichTextField';
|
|
23
23
|
export type { RichTextFieldProps } from './RichTextField';
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
export function buildStackFlexColumns(itemCount: any, minItemWidth?: number): {
|
|
3
|
+
width: number;
|
|
4
|
+
col: number;
|
|
5
|
+
}[];
|
|
2
6
|
export function Label({ className, children, setWidth }: {
|
|
3
7
|
className: any;
|
|
4
8
|
children: any;
|
|
5
9
|
setWidth: any;
|
|
6
10
|
}): React.JSX.Element;
|
|
7
11
|
export default Content;
|
|
8
|
-
declare function Content({ list, labelAlign, col, gutter, className, size, itemRender, }: {
|
|
12
|
+
declare function Content({ list, labelAlign, col, gutter, className, size, layout, columns: columnsProp, minItemWidth, itemRender, }: {
|
|
9
13
|
list?: never[] | undefined;
|
|
10
14
|
labelAlign?: string | undefined;
|
|
11
15
|
col?: number | undefined;
|
|
12
16
|
gutter?: number | undefined;
|
|
13
17
|
className: any;
|
|
14
18
|
size: any;
|
|
19
|
+
layout?: string | undefined;
|
|
20
|
+
columns: any;
|
|
21
|
+
minItemWidth?: number | undefined;
|
|
15
22
|
itemRender: any;
|
|
16
23
|
}): React.JSX.Element;
|