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