@microsoft/sp-dialog
Version:
SharePoint Framework support for displaying dialog boxes
60 lines • 3.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Dialog_1 = require("@fluentui/react/lib/Dialog");
var react_components_1 = require("@fluentui/react-components");
var React = tslib_1.__importStar(require("react"));
var ReactDom = tslib_1.__importStar(require("react-dom"));
var office_ui_fabric_react_bundle_1 = require("@ms/office-ui-fabric-react-bundle");
var BaseDialog_1 = tslib_1.__importDefault(require("./BaseDialog"));
var KillSwitches_1 = require("./common/KillSwitches");
var Dialog_module_scss_1 = tslib_1.__importDefault(require("./styles/Dialog.module.scss"));
/**
* The React wrapper to use Fabric React components to render the alert dialog
*/
var AlertDialogReact = /** @class */ (function (_super) {
tslib_1.__extends(AlertDialogReact, _super);
function AlertDialogReact() {
return _super !== null && _super.apply(this, arguments) || this;
}
AlertDialogReact.prototype.render = function () {
if (!(0, KillSwitches_1.isUsingV9ForSPDialogKSActivated)()) {
return (React.createElement(react_components_1.DialogBody, { className: Dialog_module_scss_1.default.dialogBody },
React.createElement(react_components_1.DialogTitle, { className: Dialog_module_scss_1.default.dialogTitle }, "Alert"),
React.createElement(react_components_1.DialogContent, { id: 'sp-dialog-content-message' }, this.props.message),
React.createElement(react_components_1.DialogActions, null,
React.createElement(react_components_1.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(Dialog_1.DialogContent, { title: 'Alert', subText: this.props.message, subTextId: 'sp-dialog-content-message' },
React.createElement(Dialog_1.DialogFooter, null,
React.createElement(office_ui_fabric_react_bundle_1.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) {
tslib_1.__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_1.default));
exports.default = AlertDialog;
//# sourceMappingURL=AlertDialog.js.map