import React from 'react';
import { Dialog } from '@alifd/next';
import { LayoutContext } from '../../utils/layout';
import { DialogProps } from '@alifd/next/types/dialog';

export default class ContextDialog extends React.Component<DialogProps> {
  static contextType = LayoutContext;

  render() {
    let { props } = this;
    if (this?.context?.tabId) {
      const { overlayProps = {} } = this.props;
      overlayProps.container = this.context.tabId;
      props = {
        ...props,
        overlayProps,
      };
    }

    return <Dialog {...props} />;
  }
}
