office-ui-fabric-react
Version: 
Reusable React components for building experiences for Office 365.
113 lines • 6.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
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 Checkbox_1 = require("office-ui-fabric-react/lib/Checkbox");
var Slider_1 = require("office-ui-fabric-react/lib/Slider");
var Utilities_1 = require("office-ui-fabric-react/lib/Utilities");
require("./CalloutExample.scss");
var exampleStylesImport = require("../../../common/_exampleStyles.scss");
var exampleStyles = exampleStylesImport;
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 CalloutDirectionalExample = /** @class */ (function (_super) {
    tslib_1.__extends(CalloutDirectionalExample, _super);
    function CalloutDirectionalExample(props) {
        var _this = _super.call(this, props) || this;
        _this.state = {
            isCalloutVisible: false,
            isBeakVisible: true,
            directionalHint: 4 /* bottomLeftEdge */
        };
        return _this;
    }
    CalloutDirectionalExample.prototype.render = function () {
        var _this = this;
        var _a = this.state, isCalloutVisible = _a.isCalloutVisible, isBeakVisible = _a.isBeakVisible, directionalHint = _a.directionalHint, gapSpace = _a.gapSpace, beakWidth = _a.beakWidth;
        //  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(Checkbox_1.Checkbox, { className: exampleStyles.exampleCheckbox, label: 'Show beak', checked: isBeakVisible, onChange: this._onShowBeakChange }),
                React.createElement(Slider_1.Slider, { max: 30, label: 'Gap Space', min: 0, defaultValue: 0, onChange: this._onGapSlider }),
                isBeakVisible &&
                    (React.createElement(Slider_1.Slider, { max: 50, label: 'Beak Width', min: 10, defaultValue: 16, onChange: this._onBeakWidthSlider })),
                React.createElement(Dropdown_1.Dropdown, { label: 'Directional hint', selectedKey: directionalHint, options: DIRECTION_OPTIONS, onChanged: this._onDirectionalChanged })),
            React.createElement("div", { className: 'ms-CalloutExample-buttonArea', ref: function (menuButton) { return _this._menuButtonElement = menuButton; } },
                React.createElement(Button_1.DefaultButton, { className: 'calloutExampleButton', onClick: this._onShowMenuClicked, text: isCalloutVisible ? 'Hide callout' : 'Show callout' })),
            isCalloutVisible ? (React.createElement(Callout_1.Callout, { className: 'ms-CalloutExample-callout', gapSpace: gapSpace, target: this._menuButtonElement, isBeakVisible: isBeakVisible, beakWidth: beakWidth, onDismiss: this._onCalloutDismiss, directionalHint: directionalHint },
                React.createElement("div", { className: 'ms-CalloutExample-header' },
                    React.createElement("p", { className: 'ms-CalloutExample-title' }, "All of your favorite people")),
                React.createElement("div", { className: 'ms-CalloutExample-inner' },
                    React.createElement("div", { className: 'ms-CalloutExample-content' },
                        React.createElement("p", { className: 'ms-CalloutExample-subText' }, "Message body is optional. If help documentation is available, consider adding a link to learn more at the bottom."))))) : (null)));
    };
    CalloutDirectionalExample.prototype._onCalloutDismiss = function () {
        this.setState({
            isCalloutVisible: false
        });
    };
    CalloutDirectionalExample.prototype._onShowMenuClicked = function () {
        this.setState({
            isCalloutVisible: !this.state.isCalloutVisible
        });
    };
    CalloutDirectionalExample.prototype._onShowBeakChange = function (ev, isVisible) {
        this.setState({
            isBeakVisible: isVisible,
            beakWidth: 10
        });
    };
    CalloutDirectionalExample.prototype._onDirectionalChanged = function (option) {
        this.setState({
            directionalHint: option.key
        });
    };
    CalloutDirectionalExample.prototype._onGapSlider = function (value) {
        this.setState({
            gapSpace: value
        });
    };
    CalloutDirectionalExample.prototype._onBeakWidthSlider = function (value) {
        this.setState({
            beakWidth: value
        });
    };
    tslib_1.__decorate([
        Utilities_1.autobind
    ], CalloutDirectionalExample.prototype, "_onCalloutDismiss", null);
    tslib_1.__decorate([
        Utilities_1.autobind
    ], CalloutDirectionalExample.prototype, "_onShowMenuClicked", null);
    tslib_1.__decorate([
        Utilities_1.autobind
    ], CalloutDirectionalExample.prototype, "_onShowBeakChange", null);
    tslib_1.__decorate([
        Utilities_1.autobind
    ], CalloutDirectionalExample.prototype, "_onDirectionalChanged", null);
    tslib_1.__decorate([
        Utilities_1.autobind
    ], CalloutDirectionalExample.prototype, "_onGapSlider", null);
    tslib_1.__decorate([
        Utilities_1.autobind
    ], CalloutDirectionalExample.prototype, "_onBeakWidthSlider", null);
    return CalloutDirectionalExample;
}(React.Component));
exports.CalloutDirectionalExample = CalloutDirectionalExample;
//# sourceMappingURL=Callout.Directional.Example.js.map