UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

70 lines 4.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); require("./CalloutExample.scss"); var Button_1 = require("office-ui-fabric-react/lib/Button"); var Callout_1 = require("office-ui-fabric-react/lib/Callout"); var Dropdown_1 = require("office-ui-fabric-react/lib/Dropdown"); var DIRECTION_OPTIONS = [ { key: 0 /* topLeftEdge */, text: 'Top Left Edge' }, { key: 1 /* topCenter */, text: 'Top Center' }, { key: 2 /* topRightEdge */, text: 'Top Right Edge' }, { key: 3 /* topAutoEdge */, text: 'Top Auto Edge' }, { key: 4 /* bottomLeftEdge */, text: 'Bottom Left Edge' }, { key: 5 /* bottomCenter */, text: 'Bottom Center' }, { key: 6 /* bottomRightEdge */, text: 'Bottom Right Edge' }, { key: 7 /* bottomAutoEdge */, text: 'Bottom Auto Edge' }, { key: 8 /* leftTopEdge */, text: 'Left Top Edge' }, { key: 9 /* leftCenter */, text: 'Left Center' }, { key: 10 /* leftBottomEdge */, text: 'Left Bottom Edge' }, { key: 11 /* rightTopEdge */, text: 'Right Top Edge' }, { key: 12 /* rightCenter */, text: 'Right Center' }, { key: 13 /* rightBottomEdge */, text: 'Right Bottom Edge' } ]; var CalloutCoverExample = /** @class */ (function (_super) { tslib_1.__extends(CalloutCoverExample, _super); function CalloutCoverExample(props) { var _this = _super.call(this, props) || this; _this._onDismiss = _this._onDismiss.bind(_this); _this._onShowMenuClicked = _this._onShowMenuClicked.bind(_this); _this._onDirectionalChanged = _this._onDirectionalChanged.bind(_this); _this.state = { isCalloutVisible: false, directionalHint: 4 /* bottomLeftEdge */ }; return _this; } CalloutCoverExample.prototype.render = function () { var _this = this; var _a = this.state, isCalloutVisible = _a.isCalloutVisible, directionalHint = _a.directionalHint; // ms-Callout-smallbeak is used in this directional example to reflect all the positions. Large beak will disable some position to avoid beak over the callout edge. return (React.createElement("div", { className: "ms-CalloutExample" }, React.createElement("div", { className: "ms-CalloutExample-configArea" }, React.createElement(Dropdown_1.Dropdown, { label: "Directional hint", selectedKey: directionalHint, options: DIRECTION_OPTIONS, onChange: this._onDirectionalChanged })), React.createElement("div", { className: "ms-CalloutCoverExample-buttonArea", ref: function (menuButton) { return (_this._menuButtonElement = menuButton); } }, React.createElement(Button_1.DefaultButton, { text: isCalloutVisible ? 'Hide callout' : 'Show callout', onClick: this._onShowMenuClicked })), isCalloutVisible ? (React.createElement(Callout_1.Callout, { className: "ms-CalloutExample-callout", onDismiss: this._onDismiss, target: this._menuButtonElement, directionalHint: directionalHint, coverTarget: true, isBeakVisible: false, gapSpace: 0 }, React.createElement("div", { className: "ms-CalloutExample-header" }, React.createElement("p", { className: "ms-CalloutExample-title" }, "I'm covering the target!")), React.createElement("div", { className: "ms-CalloutExample-inner" }, React.createElement("div", { className: "ms-CalloutExample-content" }, React.createElement(Button_1.DefaultButton, { onClick: this._onShowMenuClicked, text: "Click to dismiss" }))))) : null)); }; CalloutCoverExample.prototype._onDismiss = function () { this.setState({ isCalloutVisible: false }); }; CalloutCoverExample.prototype._onShowMenuClicked = function () { this.setState({ isCalloutVisible: !this.state.isCalloutVisible }); }; CalloutCoverExample.prototype._onDirectionalChanged = function (event, option) { this.setState({ directionalHint: option.key }); }; return CalloutCoverExample; }(React.Component)); exports.CalloutCoverExample = CalloutCoverExample; //# sourceMappingURL=Callout.Cover.Example.js.map