mui-component
Version:
some custom mui components
87 lines • 6.12 kB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _excluded = ["fileTypeIconSize", "showFileTypeIcon", "itemBarBoxProps", "fileInfoParser", "itemBarClassName", "fileNameWrap", "onFileDownload", "onFileDownloadStart", "previewIcon", "previewTooltip", "showPreview", "downloadIcon", "downloadTooltip", "showDownload", "FilePreviewRender", "previewModalProps", "urls", "fileListBoxProps", "fileListBoxClassName", "urlPrefix", "fallback", "triggerTooltip", "triggerText"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { Tooltip } from "@mui/material";
import { Modal } from "../../feedback";
import { AttachmentViewer } from "../AttachmentViewer";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export var AttachmentModalViewer = function AttachmentModalViewer(props) {
var fileTypeIconSize = props.fileTypeIconSize,
showFileTypeIcon = props.showFileTypeIcon,
itemBarBoxProps = props.itemBarBoxProps,
fileInfoParser = props.fileInfoParser,
itemBarClassName = props.itemBarClassName,
fileNameWrap = props.fileNameWrap,
onFileDownload = props.onFileDownload,
onFileDownloadStart = props.onFileDownloadStart,
previewIcon = props.previewIcon,
previewTooltip = props.previewTooltip,
showPreview = props.showPreview,
downloadIcon = props.downloadIcon,
downloadTooltip = props.downloadTooltip,
showDownload = props.showDownload,
FilePreviewRender = props.FilePreviewRender,
previewModalProps = props.previewModalProps,
urls = props.urls,
_props$fileListBoxPro = props.fileListBoxProps,
fileListBoxProps = _props$fileListBoxPro === void 0 ? {
mt: 0.5
} : _props$fileListBoxPro,
fileListBoxClassName = props.fileListBoxClassName,
urlPrefix = props.urlPrefix,
fallback = props.fallback,
triggerTooltip = props.triggerTooltip,
triggerText = props.triggerText,
restProps = _objectWithoutProperties(props, _excluded);
if (!urls || !(urls !== null && urls !== void 0 && urls.length)) return fallback || /*#__PURE__*/_jsx("span", {
children: "-"
});
return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
trigger: /*#__PURE__*/_jsx(Tooltip, {
arrow: true,
placement: "top",
title: triggerTooltip || "附件列表",
children: /*#__PURE__*/_jsxs("span", {
children: [triggerText || "附件", urls !== null && urls !== void 0 && urls.length ? " * ".concat(urls.length) : ""]
})
}),
fullWidth: true,
responsive: true,
title: "\u9644\u4EF6\u5217\u8868",
showConfirm: false,
cancelText: "\u5173\u95ED"
}, restProps), {}, {
children: /*#__PURE__*/_jsx(AttachmentViewer, {
urls: urlPrefix ? urls === null || urls === void 0 ? void 0 : urls.map(function (ele) {
return typeof ele === "string" ? "".concat(urlPrefix).concat(ele) : _objectSpread(_objectSpread({}, ele), {}, {
url: "".concat(urlPrefix).concat(ele.url)
});
}) : urls,
fileListBoxClassName: fileListBoxClassName,
fileListBoxProps: fileListBoxProps,
fileTypeIconSize: fileTypeIconSize,
showFileTypeIcon: showFileTypeIcon,
itemBarBoxProps: itemBarBoxProps,
itemBarClassName: itemBarClassName,
fileInfoParser: fileInfoParser,
fileNameWrap: fileNameWrap,
onFileDownload: onFileDownload,
onFileDownloadStart: onFileDownloadStart,
previewIcon: previewIcon,
previewTooltip: previewTooltip,
showPreview: showPreview,
downloadIcon: downloadIcon,
downloadTooltip: downloadTooltip,
showDownload: showDownload,
FilePreviewRender: FilePreviewRender,
previewModalProps: previewModalProps
})
}));
};