"use strict";

exports.__esModule = true;
exports.TagItemEditable = void 0;
var _react = _interopRequireWildcard(require("react"));
var _designSystem = require("@wix/design-system");
var _react2 = require("@wix/bex-core/react");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/Tags/ManageTags/ManageTagsModal/TagItemEditable.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const TagItemEditable = ({
  tagName,
  isLastTag,
  errorMessage,
  onApprove,
  onCancel,
  maxLength
}) => {
  const {
    translate: t
  } = (0, _react2.useWixPatternsContainer)();
  const [currentValueLength, setCurrentValueLength] = (0, _react.useState)((tagName == null ? void 0 : tagName.length) ?? 0);
  return /*#__PURE__*/_react.default.createElement(_designSystem.TableListItem, {
    options: [{
      value: /*#__PURE__*/_react.default.createElement(_designSystem.FormField, {
        dataHook: "manage-tags-modal-tag-form-field",
        status: errorMessage ? 'error' : undefined,
        statusMessage: errorMessage,
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 40,
          columnNumber: 13
        }
      }, /*#__PURE__*/_react.default.createElement(_designSystem.ListItemEditable, {
        dataHook: "manage-tags-modal-tag-editable",
        value: tagName ?? '',
        onEnterPressed: e => {
          onApprove(e.currentTarget.value);
        },
        onChange: e => setCurrentValueLength(e.target.value.length),
        onApprove: onApprove,
        onCancel: onCancel,
        placeholder: t('cairo.tags.manageTags.modal.list.input.placeholder'),
        cancelButtonTooltipContent: t('cairo.tags.manageTags.modal.list.input.cancel.CTA'),
        approveButtonTooltipContent: t('cairo.tags.manageTags.modal.list.input.save.CTA'),
        approveButtonDisabledOnEmpty: false,
        autoFocus: true,
        size: 'small',
        margins: 'none',
        suffix: /*#__PURE__*/_react.default.createElement(_designSystem.Input.Affix, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 68,
            columnNumber: 19
          }
        }, `${currentValueLength} / ${maxLength}`),
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 45,
          columnNumber: 15
        }
      }))
    }],
    verticalPadding: "tiny",
    showDivider: !isLastTag,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 36,
      columnNumber: 5
    }
  });
};
exports.TagItemEditable = TagItemEditable;
//# sourceMappingURL=TagItemEditable.js.map