UNPKG

@ozen-ui/kit

Version:

React component library

24 lines (23 loc) 2.02 kB
import { __assign, __rest } from "tslib"; import React, { forwardRef, useRef } from 'react'; import { useThemeProps } from '../../../../hooks/useThemeProps'; import { cn } from '../../../../utils/classname'; import { IconButton } from '../../../IconButtonNext'; import { useListCardItemAsInteractiveModule } from '../../hooks'; import { useListCardItemContext } from '../../ListCardItemContext'; import { ListCardItemTrailingItem } from '../ListCardItemTrailingItem'; import { LIST_CARD_ITEM_TRAILING_ICON_BUTTON_DEFAULT_COLOR, LIST_CARD_ITEM_TRAILING_ICON_BUTTON_DEFAULT_COMPRESSED, LIST_CARD_ITEM_SIZE_TO_TRAILING_ICON_BUTTON_SIZE, } from './constants'; export var cnListCardItemTrailingIconButton = cn('ListCardItemTrailingIconButton'); export var ListCardItemTrailingIconButton = forwardRef(function (inProps, ref) { var props = useThemeProps({ props: inProps, name: 'ListCardItemTrailingIconButton', }); var children = props.children, className = props.className, _a = props.compressed, compressed = _a === void 0 ? LIST_CARD_ITEM_TRAILING_ICON_BUTTON_DEFAULT_COMPRESSED : _a, _b = props.color, color = _b === void 0 ? LIST_CARD_ITEM_TRAILING_ICON_BUTTON_DEFAULT_COLOR : _b, caption = props.caption, disabled = props.disabled, dataTestid = props["data-testid"], other = __rest(props, ["children", "className", "compressed", "color", "caption", "disabled", 'data-testid']); var size = useListCardItemContext().size; var buttonRef = useRef(null); useListCardItemAsInteractiveModule(buttonRef, !disabled); return (React.createElement(ListCardItemTrailingItem, { ref: ref, className: cnListCardItemTrailingIconButton('', [className]), caption: caption, "data-testid": dataTestid }, React.createElement(IconButton, __assign({}, other, { ref: buttonRef, size: LIST_CARD_ITEM_SIZE_TO_TRAILING_ICON_BUTTON_SIZE[size], compressed: compressed, color: color, disabled: disabled }), children))); }); ListCardItemTrailingIconButton.displayName = 'ListCardItemTrailingIconButton';