@zjlab-fe/data-hub-ui 0.21.6 → 0.22.0
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/dist/types/components/tip-tap/extensions/index.d.ts +1 -1
- package/es/assets/cardImg.png.js +3 -0
- package/es/assets/closeBtn.png.js +3 -0
- package/es/assets/icon-tag-header.png.js +3 -0
- package/es/assets/source.png.js +3 -0
- package/es/components/FileUploader/FileUploadModal.js +24 -0
- package/es/components/FileUploader/FileUploader.js +20 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploader.js +34 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderContextProvider.js +46 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderFileReceiver.css.js +36 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderFileReceiver.js +57 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderFileReceiverContainer.js +24 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderFileReceiverDesc.js +9 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderList.js +46 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderListItem.js +46 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderListItemFail.js +21 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderListItemPaused.js +20 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderListItemUploading.js +43 -0
- package/es/components/FileUploader/FileUploaderImpl/FileUploaderlListItemFinished.js +32 -0
- package/es/components/FileUploader/Locale/translations.js +52 -0
- package/es/components/FileUploader/Locale/useTranslate.js +16 -0
- package/es/components/FileUploader/UploadStoreProvider/UploadStoreProvider.js +31 -0
- package/es/components/FileUploader/UploadStoreProvider/uploadStoreReducer.js +62 -0
- package/es/components/FileUploader/UploadStoreProvider/useOnFileAllUploaded.js +31 -0
- package/es/components/FileUploader/UploadStoreProvider/useSaveUnfinishedUploads.js +42 -0
- package/es/components/FileUploader/UploadStoreProvider/useSetupMergingEvent.js +45 -0
- package/es/components/FileUploader/hooks/useCancelUpload.js +40 -0
- package/es/components/FileUploader/hooks/useCurrentFile.js +61 -0
- package/es/components/FileUploader/hooks/useCurrentFileOnUploading.js +52 -0
- package/es/components/FileUploader/hooks/useCurrentFileSetupAndBackUp.js +39 -0
- package/es/components/FileUploader/hooks/useFormatFiles.js +64 -0
- package/es/components/FileUploader/hooks/useFormatFilesFindDuplicates.js +75 -0
- package/es/components/FileUploader/hooks/useFormatFilesRemoveDuplicates.js +21 -0
- package/es/components/FileUploader/hooks/useHandleChunkCompletion.js +31 -0
- package/es/components/FileUploader/hooks/useOnMounted.js +24 -0
- package/es/components/FileUploader/hooks/useOnMountedResumeUnfinished.js +58 -0
- package/es/components/FileUploader/hooks/useRetryUpload.js +33 -0
- package/es/components/FileUploader/hooks/useUploadChunk.js +46 -0
- package/es/components/FileUploader/icons/CloseFilled.js +7 -0
- package/es/components/FileUploader/icons/UnkownFileIcon.js +7 -0
- package/es/components/FileUploader/icons/UploadIcon.js +7 -0
- package/es/components/FileUploader/index.css.js +532 -0
- package/es/components/FileUploader/index.js +23 -0
- package/es/components/FileUploader/types.js +13 -0
- package/es/components/FileUploader/utils/calcDisplaySize.js +20 -0
- package/es/components/FileUploader/utils/checkExpiryTime.js +15 -0
- package/es/components/FileUploader/utils/createFileToUpload.js +60 -0
- package/es/components/FileUploader/utils/fileDB/addFilesToIndexdb.js +14 -0
- package/es/components/FileUploader/utils/fileDB/deleteFileInStore.js +18 -0
- package/es/components/FileUploader/utils/fileDB/deleteObjectStore.js +25 -0
- package/es/components/FileUploader/utils/fileDB/index.js +77 -0
- package/es/components/FileUploader/utils/fileDB/openDBAndRetrieveData.js +90 -0
- package/es/components/FileUploader/utils/fileDB/retrieveExistingData.js +49 -0
- package/es/components/FileUploader/utils/modalConfig.css.js +20 -0
- package/es/components/FileUploader/utils/modalConfig.js +32 -0
- package/es/components/FileUploader/utils/retrieveAllFiles.js +70 -0
- package/es/components/FileUploader/utils/splitFileIntoChunk.js +15 -0
- package/es/components/SDK-modal/document-link.js +8 -0
- package/es/components/SDK-modal/index.js +25 -0
- package/es/components/SDK-modal/index.module.scss.js +49 -0
- package/es/components/SDK-modal/inner-modal.js +59 -0
- package/es/components/SDK-modal/locale/translations.js +17 -0
- package/es/components/apply-perm-modal/index.js +53 -0
- package/es/components/apply-perm-modal/index.module.scss.js +96 -0
- package/es/components/auth-tag/index.js +23 -0
- package/es/components/bench-card/index.js +20 -0
- package/es/components/bench-card/index.module.scss.js +48 -0
- package/es/components/confirm-again/index.js +15 -0
- package/es/components/confirm-again/index.scss.js +37 -0
- package/es/components/copy/index.js +41 -0
- package/es/components/copy/index.module.scss.js +15 -0
- package/es/components/corpus-card/index.js +88 -0
- package/es/components/corpus-card/index.module.scss.js +171 -0
- package/es/components/feature-card/classNames.js +72 -0
- package/es/components/feature-card/components.js +48 -0
- package/es/components/feature-card/context.js +13 -0
- package/es/components/feature-card/index.css.js +655 -0
- package/es/components/feature-card/index.js +48 -0
- package/es/components/file-preview/data-table/index.js +94 -0
- package/es/components/file-preview/data-table/index.module.scss.js +54 -0
- package/es/components/file-preview/excel-preview/index.js +132 -0
- package/es/components/file-preview/excel-preview/index.module.scss.js +11 -0
- package/es/components/file-preview/excel-preview/utils.js +46 -0
- package/es/components/file-preview/img-preview/index.js +18 -0
- package/es/components/file-preview/img-preview/index.module.scss.js +17 -0
- package/es/components/file-preview/index.js +124 -0
- package/es/components/file-preview/index.module.scss.js +32 -0
- package/es/components/file-preview/json-preview/index.js +166 -0
- package/es/components/file-preview/markdown-preview/index.js +53 -0
- package/es/components/file-preview/markdown-preview/index.module.scss.js +1055 -0
- package/es/components/file-preview/parquet-preview/index.js +54 -0
- package/es/components/file-preview/pdf-preview/index.js +215 -0
- package/es/components/file-preview/pdf-preview/index.module.scss.js +16 -0
- package/es/components/file-preview/table-preview/index.js +43 -0
- package/es/components/file-preview/table-preview/index.module.scss.js +11 -0
- package/es/components/file-preview/txt-preview/index.js +24 -0
- package/es/components/file-preview/util.js +94 -0
- package/es/components/file-uploader/components/circle-progress.css.js +39 -0
- package/es/components/file-uploader/components/circle-progress.js +12 -0
- package/es/components/file-uploader/components/hooks/use-drop-zone.js +74 -0
- package/es/components/file-uploader/components/hooks/use-file-validation.js +52 -0
- package/es/components/file-uploader/components/icons.js +19 -0
- package/es/components/file-uploader/components/theme.css.js +64 -0
- package/es/components/file-uploader/components/uploader-drop-zone.css.js +66 -0
- package/es/components/file-uploader/components/uploader-drop-zone.js +74 -0
- package/es/components/file-uploader/components/uploader-file-item.css.js +186 -0
- package/es/components/file-uploader/components/uploader-file-item.js +63 -0
- package/es/components/file-uploader/components/uploader-file-list.css.js +43 -0
- package/es/components/file-uploader/components/uploader-file-list.js +27 -0
- package/es/components/file-uploader/components/uploader.css.js +20 -0
- package/es/components/file-uploader/components/uploader.js +51 -0
- package/es/components/file-uploader/components/uploading-status.css.js +52 -0
- package/es/components/file-uploader/components/uploading-status.js +54 -0
- package/es/components/file-uploader/components/utils/directory-reader.js +65 -0
- package/es/components/file-uploader/constants.js +31 -0
- package/es/components/file-uploader/context/action-registry.js +69 -0
- package/es/components/file-uploader/context/file-state-store.js +83 -0
- package/es/components/file-uploader/context/handler-registry.js +119 -0
- package/es/components/file-uploader/context/upload-context.js +36 -0
- package/es/components/file-uploader/context/upload-provider.js +77 -0
- package/es/components/file-uploader/context/upload-reducer.js +21 -0
- package/es/components/file-uploader/context/use-upload-engine.js +440 -0
- package/es/components/file-uploader/engine/queue-callbacks.js +257 -0
- package/es/components/file-uploader/engine/queue-manager.js +195 -0
- package/es/components/file-uploader/engine/queue-uploader.js +25 -0
- package/es/components/file-uploader/hooks/use-upload.js +327 -0
- package/es/components/file-uploader/utils/chunk-handlers.js +66 -0
- package/es/components/file-uploader/utils/ensure-handlers.js +53 -0
- package/es/components/file-uploader/utils/error-handler.js +84 -0
- package/es/components/file-uploader/utils/upload-controllers.js +43 -0
- package/es/components/file-uploader/utils/upload-handler.js +68 -0
- package/es/components/file-uploader/utils/validate-handlers.js +16 -0
- package/es/components/floating-label-input/index.js +46 -0
- package/es/components/floating-label-input/index.module.scss.js +30 -0
- package/es/components/floating-layer/index.js +15 -0
- package/es/components/floating-layer/index.scss.js +31 -0
- package/es/components/header/index.js +10 -0
- package/es/components/header/index.module.scss.js +16 -0
- package/es/components/input-tag/index.js +65 -0
- package/es/components/menu/index.js +96 -0
- package/es/components/menu/index.module.scss.js +188 -0
- package/es/components/model-card/index.js +20 -0
- package/es/components/model-card/index.module.scss.js +116 -0
- package/es/components/notion-editor/code-block/index.js +18 -0
- package/es/components/notion-editor/code-block/languageDetector.js +134 -0
- package/es/components/notion-editor/code-block/languages.js +42 -0
- package/es/components/notion-editor/index.js +258 -0
- package/es/components/notion-editor/index.scss.js +421 -0
- package/es/components/notion-editor/parseMarkdown.js +184 -0
- package/es/components/operator-chain/components/AddButton.js +20 -0
- package/es/components/operator-chain/components/IOCard.js +8 -0
- package/es/components/operator-chain/components/SingleCard.js +12 -0
- package/es/components/operator-chain/components/VirtualDropdown.js +56 -0
- package/es/components/operator-chain/index.js +83 -0
- package/es/components/operator-chain/index.module.scss.js +232 -0
- package/es/components/permission-editor/index.js +9 -0
- package/es/components/permission-editor/permissionEditModal/index.js +37 -0
- package/es/components/permission-editor/permissionEditor/index.js +253 -0
- package/es/components/permission-editor/permissionEditor/index.module.scss.js +22 -0
- package/es/components/permission-editor/permissionViewPopover/index.js +9 -0
- package/es/components/popover-select/index.js +42 -0
- package/es/components/popover-select/index.module.scss.js +22 -0
- package/es/components/radio-card/index.js +24 -0
- package/es/components/radio-card/index.scss.js +58 -0
- package/es/components/section-heading/classNames.js +22 -0
- package/es/components/section-heading/components.js +27 -0
- package/es/components/section-heading/context.js +13 -0
- package/es/components/section-heading/index.css.js +648 -0
- package/es/components/section-heading/index.js +37 -0
- package/es/components/status-tag/index.js +31 -0
- package/es/components/tag-group-filter/dataSizeFilter.js +100 -0
- package/es/components/tag-group-filter/index.js +53 -0
- package/es/components/tag-group-filter/index.module.scss.js +134 -0
- package/es/components/tag-group-filter/tagFilter.js +19 -0
- package/es/components/tag-view/index.js +138 -0
- package/es/components/tag-view/index.module.scss.js +56 -0
- package/es/components/tag-view/useSize.js +41 -0
- package/es/components/tip-tap/bubble-menu.js +47 -0
- package/es/components/tip-tap/editor.js +34 -0
- package/es/components/tip-tap/extensions/index.js +133 -0
- package/es/components/tip-tap/extensions/markdown-paste.js +148 -0
- package/es/components/tip-tap/icons/index.js +29 -0
- package/es/components/tip-tap/reader.js +15 -0
- package/es/components/tip-tap/styles/editor.css.js +863 -0
- package/es/components/tip-tap/toolbar/components/color-picker.js +76 -0
- package/es/components/tip-tap/toolbar/components/heading-dropdown.js +44 -0
- package/es/components/tip-tap/toolbar/components/image-button.js +26 -0
- package/es/components/tip-tap/toolbar/components/link-button.js +107 -0
- package/es/components/tip-tap/toolbar/components/table-button.js +37 -0
- package/es/components/tip-tap/toolbar/components/toolbar-button.js +7 -0
- package/es/components/tip-tap/toolbar/index.js +39 -0
- package/es/components/uploadDrawer/UploadStoreProvider.js +61 -0
- package/es/components/uploadDrawer/fileUploadDrawer.js +66 -0
- package/es/components/uploadDrawer/fileUploadDrawerFileDragger.js +71 -0
- package/es/components/uploadDrawer/fileUploadDrawerList.js +54 -0
- package/es/components/uploadDrawer/fileUploadDrawerListProgressButton.js +54 -0
- package/es/components/uploadDrawer/hooks/useCancelUpload.js +37 -0
- package/es/components/uploadDrawer/hooks/useFilterFiles.js +107 -0
- package/es/components/uploadDrawer/hooks/useFinishUpload.js +33 -0
- package/es/components/uploadDrawer/hooks/useFormatFiles.js +54 -0
- package/es/components/uploadDrawer/hooks/useProgressButtonRef.js +22 -0
- package/es/components/uploadDrawer/hooks/useRemoveFilesInUploadQueue.js +21 -0
- package/es/components/uploadDrawer/hooks/useResumeUnfinishedUploads.js +52 -0
- package/es/components/uploadDrawer/hooks/useRetryUpload.js +35 -0
- package/es/components/uploadDrawer/hooks/useSaveUnfinishedUploads.js +42 -0
- package/es/components/uploadDrawer/hooks/useSetupUpload.js +80 -0
- package/es/components/uploadDrawer/hooks/useUploadFileToOSS.js +23 -0
- package/es/components/uploadDrawer/index.css.js +511 -0
- package/es/components/uploadDrawer/index.js +43 -0
- package/es/components/uploadDrawer/utils/calcDisplaySize.js +19 -0
- package/es/components/uploadDrawer/utils/constant.js +16 -0
- package/es/components/uploadDrawer/utils/createFileToUpload.js +51 -0
- package/es/components/uploadDrawer/utils/fileDB/deleteFileInStore.js +28 -0
- package/es/components/uploadDrawer/utils/fileDB/deleteObjectStore.js +28 -0
- package/es/components/uploadDrawer/utils/fileDB/handleAddFilesToDB.js +37 -0
- package/es/components/uploadDrawer/utils/fileDB/index.js +9 -0
- package/es/components/uploadDrawer/utils/fileDB/openDB.js +111 -0
- package/es/components/uploadDrawer/utils/retrieveAllFiles.js +110 -0
- package/es/components/uploadDrawer/utils/shouldCreateNewFile.js +13 -0
- package/es/components/uploadDrawer/utils/splitFileIntoChunk.js +15 -0
- package/es/index.js +42 -1
- package/es/lib/utils.js +8 -0
- package/lib/index.js +1 -1
- package/package.json +164 -154
- package/rollup.es.config.mjs +177 -0
- package/tsconfig.rollup.json +7 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import './index.css.js';
|
|
5
|
+
import { cn } from '../../lib/utils.js';
|
|
6
|
+
import { FeatureCardContext } from './context.js';
|
|
7
|
+
import { getRootSizeClasses, getAlignClass, getTitleSizeClasses, getDescriptionSizeClasses, getIconAlignClass, getIconRoundedClass, getIconSizeClasses } from './classNames.js';
|
|
8
|
+
import { Content, Description, Title, Body, Icon, Header } from './components.js';
|
|
9
|
+
|
|
10
|
+
const FeatureCardRoot = React.forwardRef(function FeatureCardRoot(props, ref) {
|
|
11
|
+
const { icon, cardTitle, description, titleAs = 'h3', align = 'left', size = 'lg', iconVariant = 'default', className, classNames, children } = props, rest = __rest(props, ["icon", "cardTitle", "description", "titleAs", "align", "size", "iconVariant", "className", "classNames", "children"]);
|
|
12
|
+
const SemanticClassNames = typeof classNames === 'function' ? classNames(props) : classNames;
|
|
13
|
+
const hasStructured = icon != null || cardTitle != null || description != null;
|
|
14
|
+
const alignClass = getAlignClass(align);
|
|
15
|
+
const iconAlignClass = getIconAlignClass(align);
|
|
16
|
+
const iconRoundedClass = getIconRoundedClass(iconVariant, size);
|
|
17
|
+
const iconSizeClasses = getIconSizeClasses(size);
|
|
18
|
+
const renderIcon = () => {
|
|
19
|
+
if (icon == null)
|
|
20
|
+
return null;
|
|
21
|
+
if (typeof icon === 'string') {
|
|
22
|
+
return (jsx("div", { className: cn('dhu-overflow-hidden dhu-bg-blue-500/10 dhu-text-blue-500', iconSizeClasses, iconRoundedClass, 'dhu-grid dhu-place-items-center', iconAlignClass, SemanticClassNames === null || SemanticClassNames === void 0 ? void 0 : SemanticClassNames.icon), children: jsx("img", { src: icon, className: "dhu-object-contain dhu-w-full dhu-h-full", alt: "" }) }));
|
|
23
|
+
}
|
|
24
|
+
return (jsx("div", { className: cn('dhu-overflow-hidden dhu-bg-blue-500/10 dhu-text-blue-500', iconSizeClasses, iconRoundedClass, 'dhu-grid dhu-place-items-center', iconAlignClass, SemanticClassNames === null || SemanticClassNames === void 0 ? void 0 : SemanticClassNames.icon), children: icon }));
|
|
25
|
+
};
|
|
26
|
+
const titleSizeClasses = getTitleSizeClasses(size);
|
|
27
|
+
const descriptionSizeClasses = getDescriptionSizeClasses(size);
|
|
28
|
+
const contextValue = {
|
|
29
|
+
size,
|
|
30
|
+
align,
|
|
31
|
+
iconVariant,
|
|
32
|
+
};
|
|
33
|
+
return (jsx(FeatureCardContext.Provider, { value: contextValue, children: jsxs("div", Object.assign({ ref: ref, className: cn('dhu-grid dhu-content-start dhu-border dhu-border-solid dhu-border-slate-100 dhu-bg-white', getRootSizeClasses(size), 'dhu-shadow-md hover:dhu-shadow-lg dhu-transition-shadow', alignClass, className, SemanticClassNames === null || SemanticClassNames === void 0 ? void 0 : SemanticClassNames.root) }, rest, { children: [children, !children && hasStructured && (jsxs(Fragment, { children: [renderIcon(), (cardTitle != null || description != null) && (jsxs("div", { className: cn('dh-feature-card__body', 'dhu-grid dhu-gap-1', SemanticClassNames === null || SemanticClassNames === void 0 ? void 0 : SemanticClassNames.body), children: [cardTitle != null &&
|
|
34
|
+
React.createElement(titleAs, {
|
|
35
|
+
className: cn('dhu-m-0 dhu-font-ali-75 dhu-font-semibold', titleSizeClasses, SemanticClassNames === null || SemanticClassNames === void 0 ? void 0 : SemanticClassNames.title),
|
|
36
|
+
}, cardTitle), description != null && (jsx("div", { className: cn('dhu-font-ali-55 dhu-font-normal dhu-text-gray-500', descriptionSizeClasses, 'dhu-line-clamp-3', SemanticClassNames === null || SemanticClassNames === void 0 ? void 0 : SemanticClassNames.description), children: description }))] }))] }))] })) }));
|
|
37
|
+
});
|
|
38
|
+
const FeatureCard = Object.assign(FeatureCardRoot, {
|
|
39
|
+
Root: FeatureCardRoot,
|
|
40
|
+
Header,
|
|
41
|
+
Icon,
|
|
42
|
+
Body,
|
|
43
|
+
Title,
|
|
44
|
+
Description,
|
|
45
|
+
Content,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export { FeatureCard, FeatureCard as default };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { Table } from 'antd';
|
|
4
|
+
import { InfoCircleOutlined } from '@ant-design/icons';
|
|
5
|
+
import i18next from 'i18next';
|
|
6
|
+
import { cell, textContent, pagination, table, downloadTip } from './index.module.scss.js';
|
|
7
|
+
|
|
8
|
+
function getScrollHeight(containerHeight) {
|
|
9
|
+
if (containerHeight) {
|
|
10
|
+
// 减去表格头部高度、分页器高度、横向滚动条高度
|
|
11
|
+
return containerHeight - 55 - 64 - 16;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return 55 * 10;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function getPageSize(containerHeight, maxLines = 2) {
|
|
18
|
+
if (containerHeight) {
|
|
19
|
+
const scrollHeight = getScrollHeight(containerHeight);
|
|
20
|
+
// console.log('+++ scrollHeight', scrollHeight);
|
|
21
|
+
// console.log('+++ pageSize', Math.floor(scrollHeight / (10 + 22 * maxLines)));
|
|
22
|
+
return Math.floor(scrollHeight / (10 + 22 * maxLines));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return 10;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const headerTextStyle = {
|
|
29
|
+
fontFamily: `-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`,
|
|
30
|
+
fontSize: '14px',
|
|
31
|
+
lineHeight: '22px',
|
|
32
|
+
letterSpacing: 0,
|
|
33
|
+
};
|
|
34
|
+
function getTextWidth(text, style = {}) {
|
|
35
|
+
// 创建隐藏元素
|
|
36
|
+
const span = document.createElement('span');
|
|
37
|
+
span.textContent = text;
|
|
38
|
+
// 应用样式(必须与目标文本一致)
|
|
39
|
+
Object.assign(span.style, Object.assign({ position: 'absolute', visibility: 'hidden', whiteSpace: 'nowrap' }, style));
|
|
40
|
+
// 插入文档(触发渲染)
|
|
41
|
+
document.body.appendChild(span);
|
|
42
|
+
// 获取宽度
|
|
43
|
+
const width = span.offsetWidth;
|
|
44
|
+
// 清理
|
|
45
|
+
document.body.removeChild(span);
|
|
46
|
+
return width;
|
|
47
|
+
}
|
|
48
|
+
function DataTable(props) {
|
|
49
|
+
const { maxLines = 5, containerWidth = window.innerWidth - 24 } = props;
|
|
50
|
+
const headerTextWidth = useRef([]);
|
|
51
|
+
const locale = i18next.resolvedLanguage || localStorage.getItem('i18nextLng') || 'zh';
|
|
52
|
+
if (headerTextWidth.current.length === 0) {
|
|
53
|
+
props.head.forEach((item) => {
|
|
54
|
+
headerTextWidth.current.push(getTextWidth(item));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const columns = props.head.map((item, index) => {
|
|
58
|
+
return {
|
|
59
|
+
title: (jsx("div", { title: item, style: headerTextStyle, children: item })),
|
|
60
|
+
dataIndex: item,
|
|
61
|
+
key: index,
|
|
62
|
+
render: (text) => {
|
|
63
|
+
const str = typeof text === 'object' ? JSON.stringify(text) : text;
|
|
64
|
+
return (jsx("div", { className: cell, style: {
|
|
65
|
+
height: 22 * maxLines,
|
|
66
|
+
maxWidth: containerWidth,
|
|
67
|
+
minWidth: headerTextWidth.current[index],
|
|
68
|
+
}, children: jsx("div", { className: textContent, style: {
|
|
69
|
+
WebkitLineClamp: maxLines,
|
|
70
|
+
}, onMouseLeave: (e) => {
|
|
71
|
+
e.currentTarget.scrollTop = 0;
|
|
72
|
+
}, children: str }) }));
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
const pagination$1 = {
|
|
77
|
+
className: pagination,
|
|
78
|
+
// position: ['bottomCenter'],
|
|
79
|
+
pageSize: getPageSize(props.containerHeight, maxLines),
|
|
80
|
+
showSizeChanger: false,
|
|
81
|
+
onChange: props.onPageChange,
|
|
82
|
+
showTotal: () => {
|
|
83
|
+
if (props.total && props.total > props.data.length) {
|
|
84
|
+
return (jsxs("div", { className: downloadTip, children: [jsx(InfoCircleOutlined, {}), ' ', locale === 'zh' ? '请下载查看完整内容' : 'Please download to view the full content'] }));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
return (jsx(Table, { tableLayout: "auto", className: table, columns: columns, dataSource: props.data, scroll: { x: 'max-content', y: getScrollHeight(props.containerHeight) }, pagination: pagination$1 }));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { DataTable as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var style = document.createElement('style');
|
|
2
|
+
style.textContent = `@charset "UTF-8";
|
|
3
|
+
.index-module__table___LFpqo td {
|
|
4
|
+
border-top: none !important;
|
|
5
|
+
border-left: none !important;
|
|
6
|
+
border-right: none !important;
|
|
7
|
+
}
|
|
8
|
+
.index-module__table___LFpqo th.ant-table-cell {
|
|
9
|
+
height: 55px;
|
|
10
|
+
padding: 5px 16px !important;
|
|
11
|
+
}
|
|
12
|
+
.index-module__table___LFpqo td.ant-table-cell {
|
|
13
|
+
padding: 5px 16px !important;
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
line-height: 22px;
|
|
16
|
+
letter-spacing: 0;
|
|
17
|
+
}
|
|
18
|
+
.index-module__table___LFpqo div {
|
|
19
|
+
scrollbar-width: thin;
|
|
20
|
+
scrollbar-color: #eaeaea transparent;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
}
|
|
23
|
+
.index-module__cell___MtAcf {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
justify-content: center; /* 垂直居中 */
|
|
27
|
+
}
|
|
28
|
+
.index-module__cell___MtAcf .index-module__textContent___yk5fQ {
|
|
29
|
+
/* 多行省略号 */
|
|
30
|
+
display: -webkit-box;
|
|
31
|
+
-webkit-box-orient: vertical;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
text-overflow: ellipsis;
|
|
34
|
+
word-break: break-all;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
}
|
|
37
|
+
.index-module__cell___MtAcf .index-module__textContent___yk5fQ:hover {
|
|
38
|
+
display: block;
|
|
39
|
+
overflow: auto;
|
|
40
|
+
}
|
|
41
|
+
.index-module__pagination___wbe3v {
|
|
42
|
+
position: relative;
|
|
43
|
+
}
|
|
44
|
+
.index-module__downloadTip___TI7NB {
|
|
45
|
+
position: absolute;
|
|
46
|
+
left: 16px;
|
|
47
|
+
color: #89909d;
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
}`;
|
|
50
|
+
document.head.appendChild(style);
|
|
51
|
+
|
|
52
|
+
var table = "index-module__table___LFpqo";var cell = "index-module__cell___MtAcf";var textContent = "index-module__textContent___yk5fQ";var pagination = "index-module__pagination___wbe3v";var downloadTip = "index-module__downloadTip___TI7NB";
|
|
53
|
+
|
|
54
|
+
export { cell, downloadTip, pagination, table, textContent };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useRef, useState, useEffect } from 'react';
|
|
4
|
+
import { appendAsset } from '../util.js';
|
|
5
|
+
import { stox } from './utils.js';
|
|
6
|
+
import { getFileExt } from '@zjlab-fe/util';
|
|
7
|
+
import DataTable from '../data-table/index.js';
|
|
8
|
+
import chardet from 'chardet';
|
|
9
|
+
import { wrap } from './index.module.scss.js';
|
|
10
|
+
|
|
11
|
+
function getEncoding(blob) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
try {
|
|
15
|
+
const reader = new FileReader();
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
reader.onload = function (e) {
|
|
18
|
+
// console.log('+++ e', e);
|
|
19
|
+
const newArrayBuffer = e.target.result; // 得到ArrayBuffer
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const result = chardet.detect(new Uint8Array(newArrayBuffer.slice(0, 1 * 1024)));
|
|
22
|
+
// console.log('+++ encoding', result);
|
|
23
|
+
resolve(result);
|
|
24
|
+
};
|
|
25
|
+
reader.readAsArrayBuffer(blob); // 开始读取
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
console.log('+++ getEncoding error', e);
|
|
29
|
+
resolve('UTF-8');
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function ExcelPreview(props) {
|
|
35
|
+
var _a;
|
|
36
|
+
const ref = useRef(null);
|
|
37
|
+
const ext = getFileExt(props.filePath);
|
|
38
|
+
const [csvData, setCsvData] = useState();
|
|
39
|
+
const [csvContainerHeight, setCsvContainerHeight] = useState();
|
|
40
|
+
const [csvContainerWidth, setCsvContainerWidth] = useState();
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
appendAsset([
|
|
43
|
+
'https://haina-datahub.zero2x.org/ossRoute/frontend/resources/npm/x-data-spreadsheet/1.1.9/dist/xspreadsheet.js',
|
|
44
|
+
'https://haina-datahub.zero2x.org/ossRoute/frontend/resources/npm/x-data-spreadsheet/1.1.9/dist/xspreadsheet.css',
|
|
45
|
+
'https://haina-datahub.zero2x.org/ossRoute/frontend/resources/npm/xlsx/0.18.5/dist/xlsx.full.min.js',
|
|
46
|
+
'https://haina-datahub.zero2x.org/ossRoute/frontend/resources/npm/papaparse/5.5.2/papaparse.min.js',
|
|
47
|
+
]).then(() => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
fetch(props.filePath)
|
|
49
|
+
.then((response) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (ext === 'csv') {
|
|
51
|
+
const blob = yield response.blob();
|
|
52
|
+
const file = new File([blob], 'test.csv', { type: blob.type });
|
|
53
|
+
getEncoding(blob).then((encoding) => {
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
window.Papa.parse(file, {
|
|
56
|
+
encoding,
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
complete: (result) => {
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
// console.log('+++ result', result);
|
|
61
|
+
const head = ((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a[0]) || [];
|
|
62
|
+
const data = [];
|
|
63
|
+
(_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.forEach((row, rowIndex) => {
|
|
64
|
+
if (rowIndex !== 0) {
|
|
65
|
+
const rowData = {
|
|
66
|
+
key: rowIndex.toString(),
|
|
67
|
+
};
|
|
68
|
+
head.forEach((cell, index) => {
|
|
69
|
+
rowData[cell] = row[index];
|
|
70
|
+
});
|
|
71
|
+
data.push(rowData);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// console.log('+++ head', head, data);
|
|
75
|
+
setCsvData({
|
|
76
|
+
head,
|
|
77
|
+
data,
|
|
78
|
+
});
|
|
79
|
+
setCsvContainerHeight(ref.current.clientHeight);
|
|
80
|
+
setCsvContainerWidth(ref.current.clientWidth);
|
|
81
|
+
(_c = props === null || props === void 0 ? void 0 : props.onSuccess) === null || _c === void 0 ? void 0 : _c.call(props);
|
|
82
|
+
},
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
error: (e) => {
|
|
85
|
+
var _a;
|
|
86
|
+
console.log(e);
|
|
87
|
+
(_a = props === null || props === void 0 ? void 0 : props.onError) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
response
|
|
95
|
+
.arrayBuffer()
|
|
96
|
+
.then(function (buffer) {
|
|
97
|
+
var _a;
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
const wb = window.XLSX.read(buffer);
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
101
|
+
const lastData = stox(wb);
|
|
102
|
+
// console.log('+++ loadData', lastData);
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
window
|
|
105
|
+
.x_spreadsheet(ref.current, {
|
|
106
|
+
mode: 'read',
|
|
107
|
+
showToolbar: false,
|
|
108
|
+
showContextmenu: false,
|
|
109
|
+
view: {
|
|
110
|
+
height: () => ref.current.clientHeight,
|
|
111
|
+
width: () => ref.current.clientWidth,
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
.loadData(lastData);
|
|
115
|
+
(_a = props === null || props === void 0 ? void 0 : props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
116
|
+
})
|
|
117
|
+
.catch((e) => {
|
|
118
|
+
throw e;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}))
|
|
122
|
+
.catch((e) => {
|
|
123
|
+
var _a;
|
|
124
|
+
console.log(e);
|
|
125
|
+
(_a = props === null || props === void 0 ? void 0 : props.onError) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
126
|
+
});
|
|
127
|
+
}));
|
|
128
|
+
}, []);
|
|
129
|
+
return (jsx("div", { ref: ref, className: wrap, children: ext === 'csv' && csvData ? (jsx(DataTable, { head: csvData.head, data: csvData.data, containerHeight: csvContainerHeight, containerWidth: csvContainerWidth, maxLines: (_a = props.tableConfig) === null || _a === void 0 ? void 0 : _a.maxLines })) : null }));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { ExcelPreview as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var style = document.createElement('style');
|
|
2
|
+
style.textContent = `.index-module__wrap___X1wOS {
|
|
3
|
+
height: 100%;
|
|
4
|
+
overflow-x: hidden;
|
|
5
|
+
overflow-y: auto;
|
|
6
|
+
}`;
|
|
7
|
+
document.head.appendChild(style);
|
|
8
|
+
|
|
9
|
+
var wrap = "index-module__wrap___X1wOS";
|
|
10
|
+
|
|
11
|
+
export { wrap };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
function stox(wb) {
|
|
3
|
+
const out = [];
|
|
4
|
+
wb.SheetNames.forEach(function (name) {
|
|
5
|
+
const o = { name: name, rows: {} };
|
|
6
|
+
const ws = wb.Sheets[name];
|
|
7
|
+
if (!ws || !ws['!ref'])
|
|
8
|
+
return;
|
|
9
|
+
const range = XLSX.utils.decode_range(ws['!ref']);
|
|
10
|
+
// sheet_to_json will lost empty row and col at begin as default
|
|
11
|
+
range.s = { r: 0, c: 0 };
|
|
12
|
+
const aoa = XLSX.utils.sheet_to_json(ws, {
|
|
13
|
+
raw: false,
|
|
14
|
+
header: 1,
|
|
15
|
+
range: range,
|
|
16
|
+
});
|
|
17
|
+
aoa.forEach(function (r, i) {
|
|
18
|
+
const cells = {};
|
|
19
|
+
r.forEach(function (c, j) {
|
|
20
|
+
cells[j] = { text: c || String(c) };
|
|
21
|
+
const cellRef = XLSX.utils.encode_cell({ r: i, c: j });
|
|
22
|
+
if (ws[cellRef] != null && ws[cellRef].f != null) {
|
|
23
|
+
cells[j].text = '=' + ws[cellRef].f;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
o.rows[i] = { cells: cells };
|
|
27
|
+
});
|
|
28
|
+
o.rows.len = aoa.length;
|
|
29
|
+
o.merges = [];
|
|
30
|
+
(ws['!merges'] || []).forEach(function (merge, i) {
|
|
31
|
+
//Needed to support merged cells with empty content
|
|
32
|
+
if (o.rows[merge.s.r] == null) {
|
|
33
|
+
o.rows[merge.s.r] = { cells: {} };
|
|
34
|
+
}
|
|
35
|
+
if (o.rows[merge.s.r].cells[merge.s.c] == null) {
|
|
36
|
+
o.rows[merge.s.r].cells[merge.s.c] = {};
|
|
37
|
+
}
|
|
38
|
+
o.rows[merge.s.r].cells[merge.s.c].merge = [merge.e.r - merge.s.r, merge.e.c - merge.s.c];
|
|
39
|
+
o.merges[i] = XLSX.utils.encode_range(merge);
|
|
40
|
+
});
|
|
41
|
+
out.push(o);
|
|
42
|
+
});
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { stox };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { wrap, img } from './index.module.scss.js';
|
|
3
|
+
|
|
4
|
+
function ImgPreview(props) {
|
|
5
|
+
// eslint-disable-next-line
|
|
6
|
+
const onError = (e) => {
|
|
7
|
+
var _a;
|
|
8
|
+
console.log('+++ img error');
|
|
9
|
+
(_a = props === null || props === void 0 ? void 0 : props.onError) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
10
|
+
};
|
|
11
|
+
const onLoad = () => {
|
|
12
|
+
var _a;
|
|
13
|
+
(_a = props === null || props === void 0 ? void 0 : props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
14
|
+
};
|
|
15
|
+
return (jsx("div", { className: wrap, children: jsx("img", { src: props.filePath, onError: onError, onLoad: onLoad, className: img }) }));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ImgPreview as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var style = document.createElement('style');
|
|
2
|
+
style.textContent = `.index-module__wrap___qyJ-P {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
height: 100%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.index-module__img___DXNGo {
|
|
10
|
+
max-width: 100%;
|
|
11
|
+
max-height: 100%;
|
|
12
|
+
}`;
|
|
13
|
+
document.head.appendChild(style);
|
|
14
|
+
|
|
15
|
+
var wrap = "index-module__wrap___qyJ-P";var img = "index-module__img___DXNGo";
|
|
16
|
+
|
|
17
|
+
export { img, wrap };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import PdfPreview from './pdf-preview/index.js';
|
|
3
|
+
import { getFileExt } from '@zjlab-fe/util';
|
|
4
|
+
import ExcelPreview from './excel-preview/index.js';
|
|
5
|
+
import ImgPreview from './img-preview/index.js';
|
|
6
|
+
import MDPreview from './markdown-preview/index.js';
|
|
7
|
+
import TxtPreview from './txt-preview/index.js';
|
|
8
|
+
import JsonPreview from './json-preview/index.js';
|
|
9
|
+
import ParquetPreview from './parquet-preview/index.js';
|
|
10
|
+
import TablePreview from './table-preview/index.js';
|
|
11
|
+
import { Spin, Modal } from 'antd';
|
|
12
|
+
import { useState, useEffect } from 'react';
|
|
13
|
+
import i18next from 'i18next';
|
|
14
|
+
import { wrap, spinWrap, modalWrap } from './index.module.scss.js';
|
|
15
|
+
|
|
16
|
+
function InnerFilePreview(props) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
const locale = i18next.resolvedLanguage || localStorage.getItem('i18nextLng') || 'zh';
|
|
19
|
+
const { filePath, tableConfig, jsonConfig } = props;
|
|
20
|
+
const [isError, setIsError] = useState(false);
|
|
21
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
22
|
+
// eslint-disable-next-line
|
|
23
|
+
const onError = (e) => {
|
|
24
|
+
var _a;
|
|
25
|
+
setIsLoading(false);
|
|
26
|
+
setIsError(true);
|
|
27
|
+
console.log(e);
|
|
28
|
+
(_a = props === null || props === void 0 ? void 0 : props.onError) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
29
|
+
};
|
|
30
|
+
const onSuccess = () => {
|
|
31
|
+
var _a;
|
|
32
|
+
setIsLoading(false);
|
|
33
|
+
(_a = props === null || props === void 0 ? void 0 : props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
34
|
+
};
|
|
35
|
+
let result = null;
|
|
36
|
+
if (isError) {
|
|
37
|
+
result = jsx("div", { className: wrap, children: locale === 'zh' ? '获取文件失败' : 'Failed to get file' });
|
|
38
|
+
}
|
|
39
|
+
else if (tableConfig) {
|
|
40
|
+
result = jsx(TablePreview, Object.assign({}, props, { onSuccess: onSuccess }));
|
|
41
|
+
}
|
|
42
|
+
else if (jsonConfig) {
|
|
43
|
+
result = jsx(JsonPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
|
|
44
|
+
}
|
|
45
|
+
else if (filePath) {
|
|
46
|
+
const ext = getFileExt(filePath).toLowerCase();
|
|
47
|
+
const spin = (jsx("div", { className: spinWrap, children: jsx(Spin, {}) }));
|
|
48
|
+
let innerPreview = null;
|
|
49
|
+
let canPreview = true;
|
|
50
|
+
switch (ext) {
|
|
51
|
+
case 'pdf': {
|
|
52
|
+
innerPreview = jsx(PdfPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case 'xlsx':
|
|
56
|
+
case 'csv': {
|
|
57
|
+
innerPreview = jsx(ExcelPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
case 'png':
|
|
61
|
+
case 'jpg':
|
|
62
|
+
case 'jpeg': {
|
|
63
|
+
innerPreview = jsx(ImgPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case 'mmd':
|
|
67
|
+
case 'md': {
|
|
68
|
+
innerPreview = jsx(MDPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case 'txt': {
|
|
72
|
+
innerPreview = jsx(TxtPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case 'parquet': {
|
|
76
|
+
innerPreview = jsx(ParquetPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case 'jsonl':
|
|
80
|
+
case 'json': {
|
|
81
|
+
innerPreview = jsx(JsonPreview, Object.assign({}, props, { onError: onError, onSuccess: onSuccess }));
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
default: {
|
|
85
|
+
canPreview = false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (canPreview) {
|
|
89
|
+
result = (jsxs(Fragment, { children: [isLoading && spin, innerPreview] }));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
result = (jsxs("div", { className: wrap, children: [locale === 'zh' ? '暂不支持' : 'Not supported', "\u00A0", ext, "\u00A0", locale === 'zh' ? '文件预览' : 'file preview'] }));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (props.openInModal) {
|
|
96
|
+
if (!((_a = props === null || props === void 0 ? void 0 : props.modalProps) === null || _a === void 0 ? void 0 : _a.show)) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return (jsx(Modal, { open: true, title: (_b = props === null || props === void 0 ? void 0 : props.modalProps) === null || _b === void 0 ? void 0 : _b.title, className: modalWrap, centered: true, width: "100%", onCancel: (_c = props === null || props === void 0 ? void 0 : props.modalProps) === null || _c === void 0 ? void 0 : _c.onCancel, footer: null, children: result }));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function FilePreview(props) {
|
|
106
|
+
const [key, setKey] = useState(0);
|
|
107
|
+
const [lastFilePath, setLastFilePath] = useState(props.filePath);
|
|
108
|
+
const [lastTableConfig, setLastTableConfig] = useState(props.tableConfig);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (lastFilePath !== props.filePath || lastTableConfig !== props.tableConfig) {
|
|
111
|
+
setLastFilePath(props.filePath);
|
|
112
|
+
setLastTableConfig(props.tableConfig);
|
|
113
|
+
setKey(key + 1);
|
|
114
|
+
}
|
|
115
|
+
}, [props.filePath, props.tableConfig]);
|
|
116
|
+
if (lastFilePath !== props.filePath || lastTableConfig !== props.tableConfig) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return jsx(InnerFilePreview, Object.assign({}, props), key);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export { FilePreview as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var style = document.createElement('style');
|
|
2
|
+
style.textContent = `.index-module__wrap___UpLkF {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
height: 100%;
|
|
7
|
+
overflow: auto;
|
|
8
|
+
padding-top: 16px;
|
|
9
|
+
padding-bottom: 16px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.index-module__spinWrap___qNaoa {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
padding-top: 16px;
|
|
17
|
+
padding-bottom: 16px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.index-module__modalWrap___CKrVC .ant-modal-body {
|
|
21
|
+
height: calc(100vh - 200px);
|
|
22
|
+
overflow-y: auto;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.index-module__modalWrap___CKrVC .ant-modal-content {
|
|
26
|
+
padding-top: 44px;
|
|
27
|
+
}`;
|
|
28
|
+
document.head.appendChild(style);
|
|
29
|
+
|
|
30
|
+
var wrap = "index-module__wrap___UpLkF";var spinWrap = "index-module__spinWrap___qNaoa";var modalWrap = "index-module__modalWrap___CKrVC";
|
|
31
|
+
|
|
32
|
+
export { modalWrap, spinWrap, wrap };
|