import { memo, useContext } from 'react';
import { WidgetContext } from '../../WidgetProvider/WidgetProvider';
import { BoardContext } from '../../BoardProvider/BoardProvider';
import { getWidgetBaseStyle } from '../../WidgetManager/utils/utils';
import { WidgetWrapper } from '../../WidgetComponents/WidgetWrapper';
import { FlexStyle, ZIndexStyle } from '../../WidgetComponents/constants';
import { EditMask } from '../../WidgetComponents/EditMask';
import { StyledWidgetToolBar } from '../../WidgetComponents/StyledWidgetToolBar';
import { Space } from 'antd';
import { LockIconFn } from '../../WidgetComponents/StatusIcon';
import { WidgetDropdownList } from '../../WidgetComponents/WidgetDropdownList';
import { ExportBtnWidgetCore } from './ExportBtnWidgetCore';

export const ExportBtnWidget: React.FC<{}> = memo(() => {
  const widget = useContext(WidgetContext);
  const { editing } = useContext(BoardContext);
  const { background, border, padding } = getWidgetBaseStyle(
    widget.config.customConfig.props,
  );
  return (
    <WidgetWrapper background={background} border={border} padding={padding}>
      <div style={ZIndexStyle}>
        <div style={FlexStyle}>
          <ExportBtnWidgetCore />
        </div>
      </div>
      {editing && <EditMask />}
      <StyledWidgetToolBar>
        <Space size={0}>
          <LockIconFn
            boardEditing={editing}
            wid={widget.id}
            lock={widget.config?.lock}
          />
          <WidgetDropdownList widget={widget} />
        </Space>
      </StyledWidgetToolBar>
    </WidgetWrapper>
  );
});
