251 lines
8.6 KiB
JavaScript
251 lines
8.6 KiB
JavaScript
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
// file that has been converted to a CommonJS file using a Babel-
|
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
mod
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// src/BigImageModal/BigImageModal.tsx
|
|
var BigImageModal_exports = {};
|
|
__export(BigImageModal_exports, {
|
|
componentPrefix: () => componentPrefix,
|
|
default: () => BigImageModal_default
|
|
});
|
|
module.exports = __toCommonJS(BigImageModal_exports);
|
|
var import_react = __toESM(require("react"));
|
|
var import_meta = require("@zhst/meta");
|
|
var import_classnames = __toESM(require("classnames"));
|
|
var import_func = require("@zhst/func");
|
|
var import_index = require("./index.less");
|
|
var import_navigation = __toESM(require("./components/navigation"));
|
|
var import_CombineImage = __toESM(require("./components/CombineImage"));
|
|
var DescriptionsItem = import_meta.Descriptions.Item;
|
|
var componentPrefix = "zhst-image";
|
|
var initialStyle = {
|
|
fontSize: "12px"
|
|
};
|
|
var BigImageModal = (0, import_react.forwardRef)((props, ref) => {
|
|
var _a;
|
|
const {
|
|
// 配置
|
|
title = "-",
|
|
open,
|
|
children,
|
|
activeTab,
|
|
attributeList = [],
|
|
isRelated = false,
|
|
tabs = {},
|
|
footer = null,
|
|
showCarousel = true,
|
|
// 数据
|
|
dataSource = [],
|
|
// 总数据源,只允许有一份
|
|
imageData = [],
|
|
relatedData = [],
|
|
// 事件
|
|
onIndexChange,
|
|
onTabChange,
|
|
transformPropFunc
|
|
} = props;
|
|
const combineImageRef = (0, import_react.useRef)(null);
|
|
const bigImagePreviewRef = (0, import_react.useRef)(null);
|
|
const videoPlayerRef = (0, import_react.useRef)(null);
|
|
const modalRef = (0, import_react.useRef)(null);
|
|
const [tab, setTab] = (0, import_react.useState)(activeTab || (0, import_func.get)(tabsConfig, "data[0].key"));
|
|
const [activeKey, setActiveKey] = (0, import_react.useState)("related");
|
|
const [currentIndex, setCurrentIndex] = (0, import_react.useState)(0);
|
|
const tabsConfig = !(0, import_func.isEmpty)(tabs) ? tabs : {
|
|
data: [
|
|
{
|
|
label: "对比图模式",
|
|
key: "COMPATER",
|
|
children: /* @__PURE__ */ import_react.default.createElement(
|
|
import_CombineImage.default,
|
|
{
|
|
ref: combineImageRef,
|
|
data: dataSource[currentIndex] || {}
|
|
}
|
|
)
|
|
},
|
|
{
|
|
label: "场景图模式",
|
|
key: "NORMAL",
|
|
children: /* @__PURE__ */ import_react.default.createElement(
|
|
import_meta.BigImagePreview,
|
|
{
|
|
ref: bigImagePreviewRef,
|
|
height: "500px",
|
|
data: dataSource[currentIndex]
|
|
}
|
|
)
|
|
}
|
|
]
|
|
};
|
|
(0, import_react.useEffect)(() => {
|
|
(async () => {
|
|
let data = {};
|
|
})();
|
|
}, [currentIndex, dataSource, imageData, isRelated]);
|
|
(0, import_react.useImperativeHandle)(ref, () => ({
|
|
ref,
|
|
tab,
|
|
setTab,
|
|
modalRef,
|
|
activeKey,
|
|
setActiveKey,
|
|
videoPlayerRef,
|
|
combineImageRef,
|
|
bigImagePreviewRef
|
|
}));
|
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
import_meta.Modal,
|
|
{
|
|
destroyOnClose: true,
|
|
open,
|
|
ref: modalRef,
|
|
footer,
|
|
className: componentPrefix,
|
|
title,
|
|
...props
|
|
},
|
|
/* @__PURE__ */ import_react.default.createElement(
|
|
"div",
|
|
{
|
|
style: {
|
|
marginTop: "16px"
|
|
}
|
|
},
|
|
/* @__PURE__ */ import_react.default.createElement(
|
|
import_meta.ConfigProvider,
|
|
{
|
|
theme: {
|
|
token: {
|
|
colorTextSecondary: "rgba(0,0,0,0.45)"
|
|
},
|
|
components: {
|
|
Descriptions: {
|
|
titleMarginBottom: "20px",
|
|
viewBg: "#f6f6f6",
|
|
titleColor: "rgba(0,0,0,0.45)",
|
|
colorTextLabel: "rgba(0,0,0,0.45)",
|
|
contentColor: "rgba(0,0,0,0.88)"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
attributeList.map((descriptions) => {
|
|
var _a2;
|
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
import_meta.Descriptions,
|
|
{
|
|
key: descriptions.title,
|
|
title: /* @__PURE__ */ import_react.default.createElement("p", { style: { margin: "12px 0 0", fontSize: initialStyle.fontSize } }, descriptions.title),
|
|
column: 8,
|
|
style: { padding: "0 64px" }
|
|
},
|
|
(_a2 = descriptions == null ? void 0 : descriptions.children) == null ? void 0 : _a2.map((item) => /* @__PURE__ */ import_react.default.createElement(
|
|
DescriptionsItem,
|
|
{
|
|
key: item.key,
|
|
label: item.label,
|
|
span: 1,
|
|
contentStyle: { fontSize: initialStyle.fontSize },
|
|
labelStyle: { fontSize: initialStyle.fontSize }
|
|
},
|
|
item.children
|
|
))
|
|
);
|
|
})
|
|
),
|
|
/* @__PURE__ */ import_react.default.createElement(
|
|
"div",
|
|
{
|
|
className: (0, import_classnames.default)(`${componentPrefix}-view-container`)
|
|
},
|
|
/* @__PURE__ */ import_react.default.createElement(
|
|
import_meta.Tabs,
|
|
{
|
|
activeKey: tab,
|
|
centered: true,
|
|
destroyInactiveTabPane: true,
|
|
onChange: (v) => {
|
|
setTab((pre) => {
|
|
onTabChange == null ? void 0 : onTabChange(v, pre);
|
|
return v;
|
|
});
|
|
},
|
|
tabBarStyle: { fontSize: "18px", fontWeight: "bold" },
|
|
items: tabsConfig.data,
|
|
...tabsConfig
|
|
}
|
|
),
|
|
tab === "VIDEO" && /* @__PURE__ */ import_react.default.createElement(import_meta.VideoPlayer, { ref: videoPlayerRef, url: (_a = dataSource[currentIndex]) == null ? void 0 : _a.flvUrl }),
|
|
/* @__PURE__ */ import_react.default.createElement(
|
|
import_navigation.default,
|
|
{
|
|
className: (0, import_classnames.default)(
|
|
`${componentPrefix}-view-container__nav`,
|
|
currentIndex <= 0 && `${componentPrefix}-view-container__nav--disabled`,
|
|
`${componentPrefix}-view-container__nav--left`
|
|
),
|
|
show: isRelated ? imageData.length > 1 : dataSource.length > 1,
|
|
disabled: currentIndex <= 0,
|
|
prev: true,
|
|
onClick: () => {
|
|
setCurrentIndex((pre) => {
|
|
onIndexChange == null ? void 0 : onIndexChange(pre - 1, pre);
|
|
return pre - 1;
|
|
});
|
|
}
|
|
}
|
|
),
|
|
/* @__PURE__ */ import_react.default.createElement(
|
|
import_navigation.default,
|
|
{
|
|
className: (0, import_classnames.default)(
|
|
`${componentPrefix}-view-container__nav`,
|
|
(currentIndex >= imageData.length - 1 || currentIndex >= dataSource.length - 1) && `${componentPrefix}-view-container__nav--disabled`,
|
|
`${componentPrefix}-view-container__nav--right`
|
|
),
|
|
show: isRelated ? imageData.length > 1 : dataSource.length > 1,
|
|
disabled: currentIndex >= imageData.length - 1 || currentIndex >= dataSource.length - 1,
|
|
next: true,
|
|
onClick: async (e) => {
|
|
setCurrentIndex((pre) => {
|
|
onIndexChange == null ? void 0 : onIndexChange(pre + 1, pre);
|
|
return pre + 1;
|
|
});
|
|
}
|
|
}
|
|
)
|
|
)
|
|
)
|
|
);
|
|
});
|
|
var BigImageModal_default = BigImageModal;
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
componentPrefix
|
|
});
|