1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.Drawer = exports.DrawerSize = void 0;
|
19 | var tslib_1 = require("tslib");
|
20 | var classnames_1 = tslib_1.__importDefault(require("classnames"));
|
21 | var React = tslib_1.__importStar(require("react"));
|
22 | var common_1 = require("../../common");
|
23 | var Errors = tslib_1.__importStar(require("../../common/errors"));
|
24 | var position_1 = require("../../common/position");
|
25 | var props_1 = require("../../common/props");
|
26 | var buttons_1 = require("../button/buttons");
|
27 | var html_1 = require("../html/html");
|
28 | var icon_1 = require("../icon/icon");
|
29 | var overlay_1 = require("../overlay/overlay");
|
30 | var DrawerSize;
|
31 | (function (DrawerSize) {
|
32 | DrawerSize["SMALL"] = "360px";
|
33 | DrawerSize["STANDARD"] = "50%";
|
34 | DrawerSize["LARGE"] = "90%";
|
35 | })(DrawerSize = exports.DrawerSize || (exports.DrawerSize = {}));
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | var Drawer = (function (_super) {
|
42 | tslib_1.__extends(Drawer, _super);
|
43 | function Drawer() {
|
44 | return _super !== null && _super.apply(this, arguments) || this;
|
45 | }
|
46 | Drawer.prototype.render = function () {
|
47 | var _a, _b;
|
48 | var _c;
|
49 | var _d = this.props, size = _d.size, style = _d.style, position = _d.position;
|
50 | var realPosition = (0, position_1.getPositionIgnoreAngles)(position);
|
51 | var classes = (0, classnames_1.default)(common_1.Classes.DRAWER, (_a = {},
|
52 | _a[(_c = common_1.Classes.positionClass(realPosition)) !== null && _c !== void 0 ? _c : ""] = true,
|
53 | _a), this.props.className);
|
54 | var styleProp = size == null
|
55 | ? style
|
56 | : tslib_1.__assign(tslib_1.__assign({}, style), (_b = {}, _b[(0, position_1.isPositionHorizontal)(realPosition) ? "height" : "width"] = size, _b));
|
57 | return (React.createElement(overlay_1.Overlay, tslib_1.__assign({}, this.props, { className: common_1.Classes.OVERLAY_CONTAINER }),
|
58 | React.createElement("div", { className: classes, style: styleProp },
|
59 | this.maybeRenderHeader(),
|
60 | this.props.children)));
|
61 | };
|
62 | Drawer.prototype.validateProps = function (props) {
|
63 | if (props.title == null) {
|
64 | if (props.icon != null) {
|
65 | console.warn(Errors.DIALOG_WARN_NO_HEADER_ICON);
|
66 | }
|
67 | if (props.isCloseButtonShown != null) {
|
68 | console.warn(Errors.DIALOG_WARN_NO_HEADER_CLOSE_BUTTON);
|
69 | }
|
70 | }
|
71 | if (props.position != null) {
|
72 | if (props.position !== (0, position_1.getPositionIgnoreAngles)(props.position)) {
|
73 | console.warn(Errors.DRAWER_ANGLE_POSITIONS_ARE_CASTED);
|
74 | }
|
75 | }
|
76 | };
|
77 | Drawer.prototype.maybeRenderCloseButton = function () {
|
78 |
|
79 |
|
80 | if (this.props.isCloseButtonShown !== false) {
|
81 | return (React.createElement(buttons_1.Button, { "aria-label": "Close", className: common_1.Classes.DIALOG_CLOSE_BUTTON, icon: React.createElement(icon_1.Icon, { icon: "small-cross", size: icon_1.IconSize.LARGE }), minimal: true, onClick: this.props.onClose }));
|
82 | }
|
83 | else {
|
84 | return null;
|
85 | }
|
86 | };
|
87 | Drawer.prototype.maybeRenderHeader = function () {
|
88 | var _a = this.props, icon = _a.icon, title = _a.title;
|
89 | if (title == null) {
|
90 | return null;
|
91 | }
|
92 | return (React.createElement("div", { className: common_1.Classes.DRAWER_HEADER },
|
93 | React.createElement(icon_1.Icon, { icon: icon, size: icon_1.IconSize.LARGE }),
|
94 | React.createElement(html_1.H4, null, title),
|
95 | this.maybeRenderCloseButton()));
|
96 | };
|
97 | Drawer.displayName = "".concat(props_1.DISPLAYNAME_PREFIX, ".Drawer");
|
98 | Drawer.defaultProps = {
|
99 | canOutsideClickClose: true,
|
100 | isOpen: false,
|
101 | position: "right",
|
102 | style: {},
|
103 | };
|
104 | return Drawer;
|
105 | }(common_1.AbstractPureComponent2));
|
106 | exports.Drawer = Drawer;
|
107 |
|
\ | No newline at end of file |