@ozen-ui/kit
Version:
React component library
20 lines (19 loc) • 1.44 kB
JavaScript
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 { useDrawerContext } from '../../DrawerContext';
import { DRAWER_CLOSE_BUTTON_DEFAULT_TAG } from './constants';
export var cnDrawerCloseButton = cn('DrawerNextCloseButton');
export var DrawerCloseButton = polymorphicComponentWithRef(function (_a, ref) {
var _b = _a.as, as = _b === void 0 ? DRAWER_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 ? 'ghost' : _d, _e = _a.name, name = _e === void 0 ? 'close' : _e, other = __rest(_a, ["as", "className", "onClick", "icon", "variant", "name"]);
var _f = useDrawerContext(), size = _f.size, onClose = _f.onClose;
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: cnDrawerCloseButton('', [className]), onClick: onClick, icon: icon, compressed: true }, other)));
});
DrawerCloseButton.displayName = 'DrawerCloseButton';