UNPKG

@yandex/ui

Version:

Yandex UI components

26 lines (25 loc) 1.35 kB
import { __assign, __rest } from "tslib"; import React from 'react'; import { useComponentRegistry } from '@bem-react/di'; import { compose, composeU } from '@bem-react/core'; import { Icon as IconPresenter } from '../../Icon/Icon'; import { withTypeCross } from '../../Icon/_type/Icon_type_cross'; import { withTypeCrossWebsearch } from '../../Icon/_type/Icon_type_cross-websearch'; import { withGlyphXSign } from '../../Icon/_glyph/Icon_glyph_x-sign'; import { cnTextinput } from '../Textinput'; import './Textinput-Clear.css'; var Icon = compose(withGlyphXSign, composeU(withTypeCross, withTypeCrossWebsearch))(IconPresenter); var getIconType = function (theme, view) { if (view === 'default') { return { glyph: 'x-sign' }; } if (theme === 'websearch') { return { type: 'cross-websearch' }; } return { type: 'cross' }; }; export var TextinputClear = function (_a) { var visible = _a.visible, className = _a.className, theme = _a.theme, view = _a.view, props = __rest(_a, ["visible", "className", "theme", "view"]); var IconWrapper = useComponentRegistry(cnTextinput()).Icon; return (React.createElement(IconWrapper, __assign({}, props, { component: React.createElement(Icon, __assign({}, getIconType(theme, view), { className: cnTextinput('Clear', { visible: visible }, [className]) })) }))); };