import { getValueByKeys } from "../../../../../Table/fields/utils/index.js";
import React, { useMemo } from "react";
import { isFunction } from "@pisell/utils";
import { Tooltip } from "antd";
import classNames from "classnames";
import "./index.less";
//#region src/components/table/Gallery/components/GalleryItem/components/RenderFields/index.tsx
const prefix = "pisell-lowcode-";
const RenderFields = (props) => {
	const { fields, columnsMap, showMode, record, isShowLabel } = props;
	const fieldContent = useMemo(() => {
		return fields.filter((item) => columnsMap.has(item)).map((field) => {
			const column = columnsMap.get(field);
			const title = column.title;
			const value = isFunction(column.render) ? column.render(getValueByKeys(record, column.dataIndex), record) : getValueByKeys(record, column.dataIndex);
			const valueSpan = /* @__PURE__ */ React.createElement("span", { className: `${prefix}gallery-render-fields-item-value` }, value);
			const valueDom = isShowLabel ? valueSpan : /* @__PURE__ */ React.createElement(Tooltip, {
				title,
				destroyTooltipOnHide: true
			}, valueSpan);
			return /* @__PURE__ */ React.createElement("div", {
				key: field,
				className: `${prefix}gallery-render-fields-item-wrap`
			}, isShowLabel && /* @__PURE__ */ React.createElement("span", { className: `${prefix}gallery-render-fields-item-label` }, title), valueDom);
		});
	}, [
		fields,
		columnsMap,
		record,
		isShowLabel
	]);
	return /* @__PURE__ */ React.createElement("div", { className: classNames(`${prefix}gallery-render-fields-wrap`, {
		[`${prefix}gallery-render-fields-wrap-inline`]: showMode === "inline",
		[`${prefix}gallery-render-fields-wrap-block`]: showMode === "block"
	}) }, fieldContent);
};
//#endregion
export { RenderFields as default };
