@ozen-ui/kit
Version:
React component library
24 lines (23 loc) • 1.61 kB
JavaScript
import { __assign, __rest } from "tslib";
import React from 'react';
import { useThemeProps } from '../../../../hooks/useThemeProps';
import { cn, polymorphicComponentWithRef } from '../../../../utils';
import { IconButton } from '../../../IconButtonNext';
import { cnSelect } from '../../classNames';
import { useSelectContext } from '../../SelectContext';
import { SELECT_ICON_BUTTON_DEFAULT_TAG, SELECT_ICON_BUTTON_DEFAULT_TAB_INDEX, SELECT_ICON_BUTTON_DISPLAY_NAME, } from './constants';
export var cnSelectIconButton = cn('SelectIconButton');
export var SelectIconButton = polymorphicComponentWithRef(function (inProps, ref) {
var props = useThemeProps({
props: inProps,
name: 'SelectIconButton',
});
var icon = props.icon, onClick = props.onClick, className = props.className, _a = props.as, as = _a === void 0 ? SELECT_ICON_BUTTON_DEFAULT_TAG : _a, _b = props.tabIndex, tabIndex = _b === void 0 ? SELECT_ICON_BUTTON_DEFAULT_TAB_INDEX : _b, other = __rest(props, ["icon", "onClick", "className", "as", "tabIndex"]);
var size = useSelectContext().size;
return (React.createElement(IconButton, __assign({}, other, { ref: ref, as: as, tabIndex: tabIndex, size: size, variant: "function", icon: icon, color: "tertiary", onClick: function (event) {
event.preventDefault();
event.stopPropagation();
onClick === null || onClick === void 0 ? void 0 : onClick(event);
}, compressed: true, className: cnSelectIconButton('', [cnSelect('Suffix'), className]) })));
});
SelectIconButton.displayName = SELECT_ICON_BUTTON_DISPLAY_NAME;