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