UNPKG

@ozen-ui/kit

Version:

React component library

20 lines (19 loc) 1.57 kB
import { __assign, __rest } from "tslib"; import React from 'react'; import { CrossIcon } from '@ozen-ui/icons'; import { cn } from '../../../../utils/classname'; import { polymorphicComponentWithRef } from '../../../../utils/polymorphicComponentWithRef'; import { IconButton } from '../../../IconButtonNext'; import { useDialogContext } from '../../DialogContext'; import { DIALOG_CLOSE_BUTTON_DEFAULT_TAG, DIALOG_CLOSE_BUTTON_DEFAULT_VARIANT, DIALOG_CLOSE_BUTTON_DEFAULT_NAME, } from './constants'; export var cnDialogCloseButton = cn('DialogNextCloseButton'); export var DialogCloseButton = polymorphicComponentWithRef(function (_a, ref) { var _b = _a.as, as = _b === void 0 ? DIALOG_CLOSE_BUTTON_DEFAULT_TAG : _b, className = _a.className, onClickProp = _a.onClick, _c = _a.icon, icon = _c === void 0 ? CrossIcon : _c, _d = _a.variant, variant = _d === void 0 ? DIALOG_CLOSE_BUTTON_DEFAULT_VARIANT : _d, _e = _a.name, name = _e === void 0 ? DIALOG_CLOSE_BUTTON_DEFAULT_NAME : _e, other = __rest(_a, ["as", "className", "onClick", "icon", "variant", "name"]); var _f = useDialogContext(), onClose = _f.onClose, size = _f.size; var onClick = function (event) { onClickProp === null || onClickProp === void 0 ? void 0 : onClickProp(event); onClose(); }; return (React.createElement(IconButton, __assign({ variant: variant, name: name, as: as, size: size, ref: ref, className: cnDialogCloseButton('', [className]), onClick: onClick, icon: icon, compressed: true }, other))); }); DialogCloseButton.displayName = 'DialogCloseButton';