import React, { forwardRef } from "react";
import { StyledChip, TextChip } from "./TextFieldChip.styles";
/**
 * Чип, отображающий выбранный элемент
 */ export var TextFieldChip = /*#__PURE__*/ forwardRef(function(param, ref) {
    var id = param.id, text = param.text, disabled = param.disabled, readOnly = param.readOnly, view = param.view, _forceChipManipulationWithReadonly = param._forceChipManipulationWithReadonly, chipType = param.chipType, Root = param.rootWrapper, onClick = param.onClick, onClear = param.onClear, onKeyDown = param.onKeyDown;
    var onClearHandle = function onClearHandle() {
        return onClear(id);
    };
    var onKeyDownHandle = function onKeyDownHandle(event) {
        onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, id);
    };
    var handleClick = function handleClick(e) {
        if (onClick) {
            onClick(e);
        }
        if (onClear) {
            onClear(id);
        }
    };
    return chipType === 'default' ? /*#__PURE__*/ React.createElement(Root, view ? {
        chipView: view
    } : {}, /*#__PURE__*/ React.createElement(StyledChip, {
        ref: ref,
        tabIndex: -1,
        disabled: disabled,
        readOnly: readOnly,
        onClick: onClick,
        onClear: onClearHandle,
        onClickClose: onClearHandle,
        onKeyDown: onKeyDownHandle,
        text: "".concat(text),
        view: view,
        // TODO: #1547
        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
        // @ts-ignore
        _forceChipManipulationWithReadonly: _forceChipManipulationWithReadonly
    })) : /*#__PURE__*/ React.createElement(TextChip, {
        ref: ref,
        tabIndex: -1,
        onClick: handleClick,
        onKeyDown: onKeyDownHandle
    }, text);
});
