office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
72 lines (71 loc) • 5.94 kB
JavaScript
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
define(["require", "exports", 'react', '../../../../index', './CalloutExample.scss'], function (require, exports, React, index_1) {
"use strict";
var DIRECTION_OPTIONS = [
{ key: index_1.DirectionalHint[index_1.DirectionalHint.topLeftEdge], text: 'Top Left Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.topCenter], text: 'Top Center' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.topRightEdge], text: 'Top Right Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.topAutoEdge], text: 'Top Auto Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.bottomLeftEdge], text: 'Bottom Left Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.bottomCenter], text: 'Bottom Center' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.bottomRightEdge], text: 'Bottom Right Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.bottomAutoEdge], text: 'Bottom Auto Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.leftTopEdge], text: 'Left Top Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.leftCenter], text: 'Left Center' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.leftBottomEdge], text: 'Left Bottom Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.rightTopEdge], text: 'Right Top Edge' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.rightCenter], text: 'Right Center' },
{ key: index_1.DirectionalHint[index_1.DirectionalHint.rightBottomEdge], text: 'Right Bottom Edge' },
];
var CalloutDirectionalExample = (function (_super) {
__extends(CalloutDirectionalExample, _super);
function CalloutDirectionalExample() {
_super.call(this);
this._onDismiss = this._onDismiss.bind(this);
this._onShowMenuClicked = this._onShowMenuClicked.bind(this);
this._onShowBeakChange = this._onShowBeakChange.bind(this);
this._onDirectionalChanged = this._onDirectionalChanged.bind(this);
this._onChangeGapSizeClicked = this._onChangeGapSizeClicked.bind(this);
this.state = {
isCalloutVisible: false,
isBeakVisible: true,
directionalHint: index_1.DirectionalHint.bottomLeftEdge
};
}
CalloutDirectionalExample.prototype.render = function () {
var _this = this;
var _a = this.state, isCalloutVisible = _a.isCalloutVisible, isBeakVisible = _a.isBeakVisible, directionalHint = _a.directionalHint, gapSpace = _a.gapSpace;
// 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(index_1.Checkbox, {label: 'Show beak', checked: isBeakVisible, onChange: this._onShowBeakChange}), React.createElement(index_1.TextField, {ref: function (gapSize) { return _this._gapSize = gapSize; }, label: 'Gap Space', placeholder: 'Type in the gap space'}), React.createElement(index_1.Button, {onClick: this._onChangeGapSizeClicked}, "Submit"), React.createElement(index_1.Dropdown, {label: 'Directional hint', selectedKey: index_1.DirectionalHint[directionalHint], options: DIRECTION_OPTIONS, onChanged: this._onDirectionalChanged})), React.createElement("div", {className: 'ms-CalloutExample-buttonArea', ref: function (menuButton) { return _this._menuButtonElement = menuButton; }}, React.createElement(index_1.Button, {onClick: this._onShowMenuClicked}, isCalloutVisible ? 'Hide callout' : 'Show callout')), isCalloutVisible ? (React.createElement(index_1.Callout, {className: 'ms-CalloutExample-callout', gapSpace: gapSpace, targetElement: this._menuButtonElement, isBeakVisible: isBeakVisible, onDismiss: this._onDismiss, 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._onDismiss = 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
});
};
CalloutDirectionalExample.prototype._onDirectionalChanged = function (option) {
this.setState({
directionalHint: index_1.DirectionalHint[option.key]
});
};
CalloutDirectionalExample.prototype._onChangeGapSizeClicked = function () {
this.setState({
gapSpace: parseInt(this._gapSize.state.value, 10)
});
};
return CalloutDirectionalExample;
}(React.Component));
exports.CalloutDirectionalExample = CalloutDirectionalExample;
});