import React, { forwardRef } from "react";
import { StyledChip, TextChip } from "./TextFieldChip.styles";
/**
 * Чип, отображающий выбранный элемент
 */ export const TextFieldChip = /*#__PURE__*/ forwardRef(({ id, text, disabled, readOnly, view, _forceChipManipulationWithReadonly, chipType, rootWrapper: Root, onClick, onClear, onKeyDown }, ref)=>{
    const onClearHandle = ()=>onClear(id);
    const onKeyDownHandle = (event)=>{
        onKeyDown?.(event, id);
    };
    const 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: `${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);
});
