import React, { CSSProperties } from 'react'; import PropTypes from 'prop-types'; import cls from 'classnames'; import { cssClasses } from '@douyinfe/semi-foundation/sideSheet/constants'; import Button from '../iconButton'; import { noop } from 'lodash'; import { IconClose } from '@douyinfe/semi-icons'; let uuid = 0; const prefixCls = cssClasses.PREFIX; export interface SideSheetContentProps { onClose?: (e: React.MouseEvent) => void; mask?: boolean; maskStyle?: CSSProperties; maskClosable?: boolean; title?: React.ReactNode; closable?: boolean; headerStyle?: CSSProperties; width: CSSProperties['width']; height: CSSProperties['height']; style: CSSProperties; bodyStyle?: CSSProperties; className: string; footer?: React.ReactNode; 'aria-label'?: string; } export default class SideSheetContent extends React.PureComponent { static propTypes = { onClose: PropTypes.func, }; static defaultProps = { onClose: noop, }; private sideSheetId: string; private timeoutId: number; componentDidMount() { this.sideSheetId = `sidesheet-${uuid++}`; } componentWillUnmount() { clearTimeout(this.timeoutId); } onMaskClick = (e: React.MouseEvent) => { if (e.target === e.currentTarget) { this.close(e); } }; close = (e: React.MouseEvent) => { const { onClose } = this.props; onClose && onClose(e); }; getMaskElement() { const { mask, maskStyle, maskClosable, } = this.props; if (mask) { return (
); } return null; } renderHeader() { const { title, closable, headerStyle, } = this.props; let header, closer; if (title) { header = (
{this.props.title}
); } if (closable) { closer = (