"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.TextWidthHelper = void 0;var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));

var _Emotion = require("../../lib/theming/Emotion");

var _getDOMRect = require("../../lib/dom/getDOMRect");
var _TokenView = require("../Token/TokenView");

var _Token = require("../Token/Token.styles");

// a thin character to preserve some space
// for the caret visibillity in the input
var THIN_SPACE = "\u2009";











/**
 * Херпер позволяет вычислить размеры блока с текстом
 * для последующего выставления размеров input
 */var
TextWidthHelper = exports.TextWidthHelper = /*#__PURE__*/function (_React$Component) {function TextWidthHelper() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;_this.
    element = null;_this.


































    elementRef = function (node) {return _this.element = node;};return _this;}(0, _inheritsLoose2.default)(TextWidthHelper, _React$Component);var _proto = TextWidthHelper.prototype;_proto.getSizeClassName = function getSizeClassName(size) {switch (size) {case 'large':return _Token.styles.helperContainerLarge(this.props.theme);case 'medium':return _Token.styles.helperContainerMedium(this.props.theme);case 'small':default:return _Token.styles.helperContainerSmall(this.props.theme);}};_proto.render = function render() {return /*#__PURE__*/_react.default.createElement(_TokenView.TokenView, { size: this.props.size, className: (0, _Emotion.cx)(_Token.styles.helperContainer(), this.getSizeClassName(this.props.size)) }, /*#__PURE__*/_react.default.createElement("div", { className: _Token.styles.helperText(), ref: this.elementRef }, this.props.text || THIN_SPACE));};_proto.getTextWidth = function getTextWidth() {return (0, _getDOMRect.getDOMRect)(this.element).width;};_proto.getTextHeight = function getTextHeight() {return (0, _getDOMRect.getDOMRect)(this.element).height;};return TextWidthHelper;}(_react.default.Component);