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); }
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); }
import React, { useMemo } from "react";
import classNames from "classnames";
import { Tooltip } from "antd";
import { isFunction } from "@pisell/utils";
import { getValueByKeys } from "../../../../../Table/fields/utils";
import "./index.less";
var prefix = "pisell-lowcode-";
var RenderFields = function RenderFields(props) {
  var fields = props.fields,
    columnsMap = props.columnsMap,
    showMode = props.showMode,
    record = props.record,
    isShowLabel = props.isShowLabel;
  var fieldContent = useMemo(function () {
    var fieldsList = fields.filter(function (item) {
      return columnsMap.has(item);
    }).map(function (field) {
      var column = columnsMap.get(field);
      var title = column.title;
      var value = isFunction(column.render) ? column.render(getValueByKeys(record, column.dataIndex), record) : getValueByKeys(record, column.dataIndex);
      var valueSpan = /*#__PURE__*/React.createElement("span", {
        className: "".concat(prefix, "gallery-render-fields-item-value")
      }, value);
      var valueDom = isShowLabel ? valueSpan : /*#__PURE__*/React.createElement(Tooltip, {
        title: title,
        destroyTooltipOnHide: true
      }, valueSpan);
      return /*#__PURE__*/React.createElement("div", {
        key: field,
        className: "".concat(prefix, "gallery-render-fields-item-wrap")
      }, isShowLabel && /*#__PURE__*/React.createElement("span", {
        className: "".concat(prefix, "gallery-render-fields-item-label")
      }, title), valueDom);
    });
    return fieldsList;
  }, [fields, columnsMap, record, isShowLabel]);
  return /*#__PURE__*/React.createElement("div", {
    className: classNames("".concat(prefix, "gallery-render-fields-wrap"), _defineProperty(_defineProperty({}, "".concat(prefix, "gallery-render-fields-wrap-inline"), showMode === "inline"), "".concat(prefix, "gallery-render-fields-wrap-block"), showMode === "block"))
  }, fieldContent);
};
export default RenderFields;