UNPKG

@ozen-ui/kit

Version:

React component library

33 lines (32 loc) 2.57 kB
import { __assign, __rest } from "tslib"; import './Dialog.css'; import React, { forwardRef } from 'react'; import { CrossIcon } from '@ozen-ui/icons'; import { useDeprecatedComponent } from '../../hooks/useDeprecated'; import { useThemeProps } from '../../hooks/useThemeProps'; import { cn } from '../../utils/classname'; import { IconButton } from '../IconButtonNext'; import { Modal } from '../Modal'; import { DIALOG_DEFAULT_HIDE_CLOSE_BUTTON, DIALOG_DEFAULT_SIZE, DIALOG_DEFAULT_VARIANT, } from './constants'; import { iconButtonSizeMapper } from './utils'; export var cnDialog = cn('Dialog'); /** * @deprecated Компонент устарел. Для замены используйте компонент DialogNext */ export var Dialog = forwardRef(function (inProps, ref) { useDeprecatedComponent('Dialog'); var props = useThemeProps({ props: inProps, name: 'Dialog', }); var _a = props.variant, variant = _a === void 0 ? DIALOG_DEFAULT_VARIANT : _a, _b = props.size, size = _b === void 0 ? DIALOG_DEFAULT_SIZE : _b, _c = props.hideCloseButton, hideCloseButton = _c === void 0 ? DIALOG_DEFAULT_HIDE_CLOSE_BUTTON : _c, open = props.open, onClose = props.onClose, children = props.children, className = props.className, windowProps = props.windowProps, closeButtonProps = props.closeButtonProps, transitionProps = props.transitionProps, other = __rest(props, ["variant", "size", "hideCloseButton", "open", "onClose", "children", "className", "windowProps", "closeButtonProps", "transitionProps"]); var _d = closeButtonProps || {}, closeButtonClassName = _d.className, closeButtonRestProps = __rest(_d, ["className"]); return (React.createElement(Modal, __assign({}, other, { open: open, onClose: onClose, windowProps: __assign({ role: 'dialog', radius: size === 's' ? 'l' : 'xl', shadow: 'l' }, windowProps), className: cnDialog({ variant: variant, size: size, hasCloseButton: !hideCloseButton }, [ className, ]), transitionProps: __assign(__assign({}, (variant === 'fullsize' && { classNames: cnDialog({ animation: 'fullsize' }), })), transitionProps), ref: ref }), !hideCloseButton && (React.createElement(IconButton, __assign({ size: iconButtonSizeMapper[size], variant: "ghost", name: "close" }, closeButtonRestProps, { className: cnDialog('CloseButton', [closeButtonClassName]), onClick: onClose, icon: CrossIcon, compressed: true }))), React.createElement("div", { className: cnDialog('InnerContainer') }, children))); }); Dialog.displayName = 'Dialog';