function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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 _classNames;
  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"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "gallery-render-fields-wrap-inline"), showMode === "inline"), _defineProperty(_classNames, "".concat(prefix, "gallery-render-fields-wrap-block"), showMode === "block"), _classNames))
  }, fieldContent);
};
export default RenderFields;