1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { __assign, __decorate, __extends } from "tslib";
|
17 | import classNames from "classnames";
|
18 | import * as React from "react";
|
19 | import { polyfill } from "react-lifecycles-compat";
|
20 | import { AbstractPureComponent2, Classes } from "../../common";
|
21 | import * as Errors from "../../common/errors";
|
22 | import { DISPLAYNAME_PREFIX } from "../../common/props";
|
23 | import { uniqueId } from "../../common/utils";
|
24 | import { Button } from "../button/buttons";
|
25 | import { H4 } from "../html/html";
|
26 | import { Icon, IconSize } from "../icon/icon";
|
27 | import { Overlay } from "../overlay/overlay";
|
28 | var Dialog = (function (_super) {
|
29 | __extends(Dialog, _super);
|
30 | function Dialog(props) {
|
31 | var _this = _super.call(this, props) || this;
|
32 | var id = uniqueId("bp-dialog");
|
33 | _this.titleId = "title-" + id;
|
34 | return _this;
|
35 | }
|
36 | Dialog.prototype.render = function () {
|
37 | return (React.createElement(Overlay, __assign({}, this.props, { className: Classes.OVERLAY_SCROLL_CONTAINER, hasBackdrop: true }),
|
38 | React.createElement("div", { className: Classes.DIALOG_CONTAINER },
|
39 | React.createElement("div", { className: classNames(Classes.DIALOG, this.props.className), role: "dialog", "aria-labelledby": this.props["aria-labelledby"] || (this.props.title ? this.titleId : undefined), "aria-describedby": this.props["aria-describedby"], style: this.props.style },
|
40 | this.maybeRenderHeader(),
|
41 | this.props.children))));
|
42 | };
|
43 | Dialog.prototype.validateProps = function (props) {
|
44 | if (props.title == null) {
|
45 | if (props.icon != null) {
|
46 | console.warn(Errors.DIALOG_WARN_NO_HEADER_ICON);
|
47 | }
|
48 | if (props.isCloseButtonShown != null) {
|
49 | console.warn(Errors.DIALOG_WARN_NO_HEADER_CLOSE_BUTTON);
|
50 | }
|
51 | }
|
52 | };
|
53 | Dialog.prototype.maybeRenderCloseButton = function () {
|
54 |
|
55 |
|
56 | if (this.props.isCloseButtonShown !== false) {
|
57 | return (React.createElement(Button, { "aria-label": "Close", className: Classes.DIALOG_CLOSE_BUTTON, icon: React.createElement(Icon, { icon: "small-cross", size: IconSize.LARGE }), minimal: true, onClick: this.props.onClose }));
|
58 | }
|
59 | else {
|
60 | return undefined;
|
61 | }
|
62 | };
|
63 | Dialog.prototype.maybeRenderHeader = function () {
|
64 | var _a = this.props, icon = _a.icon, title = _a.title;
|
65 | if (title == null) {
|
66 | return undefined;
|
67 | }
|
68 | return (React.createElement("div", { className: Classes.DIALOG_HEADER },
|
69 | React.createElement(Icon, { icon: icon, size: IconSize.LARGE }),
|
70 | React.createElement(H4, { id: this.titleId }, title),
|
71 | this.maybeRenderCloseButton()));
|
72 | };
|
73 | Dialog.defaultProps = {
|
74 | canOutsideClickClose: true,
|
75 | isOpen: false,
|
76 | };
|
77 | Dialog.displayName = DISPLAYNAME_PREFIX + ".Dialog";
|
78 | Dialog = __decorate([
|
79 | polyfill
|
80 | ], Dialog);
|
81 | return Dialog;
|
82 | }(AbstractPureComponent2));
|
83 | export { Dialog };
|
84 |
|
\ | No newline at end of file |