"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactI18next = require("react-i18next");
var _InputWrap = require("./InputWrap");
var _uuid = require("../..\\utils\\uuid");
var _jsxRuntime = require("react/jsx-runtime");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
 * A ez way to handle input correctly
 * @param placeholder {string} 默认占位符
 * @param content {string} 默认值
 * @returns
 */
const Input = ({
  placeholder,
  content,
  label,
  value,
  extraContents,
  height: _height = 28.2,
  readOnly: _readOnly = false,
  center: _center = false,
  width: _width = 100,
  onChange,
  onKeyDown,
  onBlur,
  onClick
}) => {
  const {
    t
  } = (0, _reactI18next.useTranslation)();
  const _content = (0, _react.useRef)('');
  const handleChange = e => {
    _content.current = e.currentTarget.value;
    if (content) {
      content.current = e.currentTarget.value;
    }
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputWrap.InputWrap, {
    height: _height,
    center: _center,
    width: _width,
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: "inputContainer",
      children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "inputLabel",
        children: t(label)
      }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        className: "contentContainer",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
          placeholder: placeholder,
          onInput: handleChange,
          value: value,
          readOnly: _readOnly,
          className: "inputBox",
          onChange: onChange,
          onBlur: onBlur,
          onClick: onClick,
          onKeyDown: onKeyDown
        }), extraContents ? extraContents.map(el => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: "content",
          children: el
        }, (0, _uuid.uuid)())) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {})]
      })]
    })
  });
};
var _default = Input;
exports.default = _default;