UNPKG

@ozen-ui/kit

Version:

React component library

24 lines (23 loc) 1.82 kB
import { __assign, __rest } from "tslib"; import React, { forwardRef, useRef } from 'react'; import { useThemeProps } from '../../../../hooks/useThemeProps'; import { cn } from '../../../../utils/classname'; import { Button } from '../../../ButtonNext'; import { useListCardItemAsInteractiveModule } from '../../hooks'; import { useListCardItemContext } from '../../ListCardItemContext'; import { ListCardItemTrailingItem } from '../ListCardItemTrailingItem'; import { LIST_CARD_ITEM_SIZE_TO_TRAILING_BUTTON_SIZE, LIST_CARD_ITEM_TRAILING_BUTTON_DEFAULT_VARIANT, } from './constants'; export var cnListCardItemTrailingButton = cn('ListCardItemTrailingButton'); export var ListCardItemTrailingButton = forwardRef(function (inProps, ref) { var props = useThemeProps({ props: inProps, name: 'ListCardItemTrailingButton', }); var children = props.children, className = props.className, _a = props.variant, variant = _a === void 0 ? LIST_CARD_ITEM_TRAILING_BUTTON_DEFAULT_VARIANT : _a, caption = props.caption, disabled = props.disabled, dataTestid = props["data-testid"], other = __rest(props, ["children", "className", "variant", "caption", "disabled", 'data-testid']); var size = useListCardItemContext().size; var buttonRef = useRef(null); useListCardItemAsInteractiveModule(buttonRef, !disabled); return (React.createElement(ListCardItemTrailingItem, { ref: ref, className: cnListCardItemTrailingButton('', [className]), caption: caption, "data-testid": dataTestid }, React.createElement(Button, __assign({}, other, { className: cnListCardItemTrailingButton('Button'), ref: buttonRef, size: LIST_CARD_ITEM_SIZE_TO_TRAILING_BUTTON_SIZE[size], variant: variant, disabled: disabled }), children))); }); ListCardItemTrailingButton.displayName = 'ListCardItemTrailingButton';