@microsoft/sp-dialog
Version:
SharePoint Framework support for displaying dialog boxes
58 lines • 2.77 kB
JavaScript
import { __extends } from "tslib";
import { DialogContent as DialogContentV8, DialogFooter } from '@fluentui/react/lib/Dialog';
import { DialogBody, DialogContent, DialogActions, DialogTitle, Button } from '@fluentui/react-components';
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { PrimaryButton } from '@ms/office-ui-fabric-react-bundle';
import BaseDialog from './BaseDialog';
import { isUsingV9ForSPDialogKSActivated } from './common/KillSwitches';
import styles from './styles/Dialog.module.scss';
/**
* The React wrapper to use Fabric React components to render the alert dialog
*/
var AlertDialogReact = /** @class */ (function (_super) {
__extends(AlertDialogReact, _super);
function AlertDialogReact() {
return _super !== null && _super.apply(this, arguments) || this;
}
AlertDialogReact.prototype.render = function () {
if (!isUsingV9ForSPDialogKSActivated()) {
return (React.createElement(DialogBody, { className: styles.dialogBody },
React.createElement(DialogTitle, { className: styles.dialogTitle }, "Alert"),
React.createElement(DialogContent, { id: 'sp-dialog-content-message' }, this.props.message),
React.createElement(DialogActions, null,
React.createElement(Button, { appearance: 'primary', "data-automation-id": 'sp-alert-dialog-ok-button', onClick: this.props.close }, "OK"))));
}
// Return the content of the dialog
return (React.createElement(DialogContentV8, { title: 'Alert', subText: this.props.message, subTextId: 'sp-dialog-content-message' },
React.createElement(DialogFooter, null,
React.createElement(PrimaryButton, { "data-automation-id": 'sp-alert-dialog-ok-button', onClick: this.props.close, text: 'OK' }))));
};
return AlertDialogReact;
}(React.Component));
/**
* Internal implementation of a dialog to mimic browser's alert() behavior.
* Third-party can use this by calling the static method Dialog.alert()
*
* @internal
*/
var AlertDialog = /** @class */ (function (_super) {
__extends(AlertDialog, _super);
function AlertDialog(message) {
var _this = _super.call(this, { isBlocking: false }) || this;
_this._message = message;
return _this;
}
AlertDialog.prototype.render = function () {
ReactDom.render(React.createElement(AlertDialogReact, {
message: this._message,
close: this.close
}), this.domElement);
};
AlertDialog.prototype.onAfterClose = function () {
ReactDom.unmountComponentAtNode(this.domElement);
};
return AlertDialog;
}(BaseDialog));
export default AlertDialog;
//# sourceMappingURL=AlertDialog.js.map