jiti-meet/react/features/base/dialog/components/web/Dialog.js

89 lines
2.0 KiB
JavaScript
Raw Normal View History

// @flow
2017-03-07 03:34:51 +00:00
import React from 'react';
2019-03-21 16:38:29 +00:00
import { connect } from '../../../redux';
2017-03-07 03:34:51 +00:00
2018-10-18 08:28:08 +00:00
import AbstractDialog from '../AbstractDialog';
import type { Props as AbstractDialogProps, State } from '../AbstractDialog';
import StatelessDialog from './StatelessDialog';
2017-03-07 03:34:51 +00:00
/**
* The type of the React {@code Component} props of {@link Dialog}.
2017-03-07 03:34:51 +00:00
*/
2019-03-19 15:42:25 +00:00
type Props = AbstractDialogProps & {
2017-11-13 15:54:04 +00:00
2017-03-07 03:34:51 +00:00
/**
2017-11-13 15:54:04 +00:00
* Whether the dialog is modal. This means clicking on the blanket will
* leave the dialog open. No cancel button.
2017-03-07 03:34:51 +00:00
*/
2017-11-13 15:54:04 +00:00
isModal: boolean,
2017-11-13 15:54:04 +00:00
/**
* Disables rendering of the submit button.
*/
submitDisabled: boolean,
2017-11-13 15:54:04 +00:00
/**
* Width of the dialog, can be:
* - 'small' (400px), 'medium' (600px), 'large' (800px),
* 'x-large' (968px)
* - integer value for pixel width
* - string value for percentage
*/
width: string
};
2017-03-07 03:34:51 +00:00
2017-11-13 15:54:04 +00:00
/**
* Web dialog that uses atlaskit modal-dialog to display dialogs.
*/
class Dialog extends AbstractDialog<Props, State> {
2017-03-07 03:34:51 +00:00
/**
* Initializes a new Dialog instance.
2017-03-07 03:34:51 +00:00
*
* @param {Object} props - The read-only properties with which the new
* instance is to be initialized.
2017-03-07 03:34:51 +00:00
*/
2019-03-19 15:42:25 +00:00
constructor(props: Props) {
super(props);
2017-03-07 03:34:51 +00:00
// Bind event handlers so they are only bound once per instance.
this._onCancel = this._onCancel.bind(this);
this._onSubmit = this._onSubmit.bind(this);
2017-03-07 03:34:51 +00:00
}
/**
* Implements React's {@link Component#render()}.
2017-03-07 03:34:51 +00:00
*
* @inheritdoc
2017-03-07 03:34:51 +00:00
* @returns {ReactElement}
*/
render() {
const props = {
...this.props,
2017-09-18 07:01:14 +00:00
onCancel: this._onCancel,
onSubmit: this._onSubmit
};
2017-03-07 03:34:51 +00:00
2019-03-19 15:42:25 +00:00
// $FlowExpectedError
delete props.dispatch;
2017-03-07 03:34:51 +00:00
return <StatelessDialog { ...props } />;
2017-03-07 03:34:51 +00:00
}
_onCancel: () => void;
2017-03-07 03:34:51 +00:00
/**
* Dispatches action to hide the dialog.
*
* @returns {void}
*/
_onCancel() {
2017-09-18 07:01:14 +00:00
this.props.isModal || super._onCancel();
2017-03-07 03:34:51 +00:00
}
_onSubmit: (?string) => void;
2017-03-07 03:34:51 +00:00
}
export default connect()(Dialog);