UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

123 lines 6.55 kB
import * as tslib_1 from "tslib"; import * as React from 'react'; import { DefaultButton } from 'office-ui-fabric-react/lib/Button'; import { Checkbox } from 'office-ui-fabric-react/lib/Checkbox'; import { ContextualMenuItemType } from 'office-ui-fabric-react/lib/ContextualMenu'; import { Dropdown } from 'office-ui-fabric-react/lib/Dropdown'; import { autobind, getRTL } from 'office-ui-fabric-react/lib/Utilities'; import './ContextualMenuExample.scss'; import * as exampleStylesImport from '../../../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 ContextualMenuDirectionalExample = /** @class */ (function (_super) { tslib_1.__extends(ContextualMenuDirectionalExample, _super); function ContextualMenuDirectionalExample(props) { var _this = _super.call(this, props) || this; _this.state = { isBeakVisible: false, directionalHint: 4 /* bottomLeftEdge */, directionalHintForRTL: 4 /* bottomLeftEdge */, useDirectionalHintForRtl: false, gapSpace: 0, beakWidth: 20, edgeFixed: false }; return _this; } ContextualMenuDirectionalExample.prototype.render = function () { var _a = this.state, beakWidth = _a.beakWidth, directionalHint = _a.directionalHint, directionalHintForRTL = _a.directionalHintForRTL, edgeFixed = _a.edgeFixed, gapSpace = _a.gapSpace, isBeakVisible = _a.isBeakVisible, useDirectionalHintForRtl = _a.useDirectionalHintForRtl; return (React.createElement("div", { className: 'ms-ContextualMenuDirectionalExample' }, React.createElement("div", { className: 'ms-ContextualMenuDirectionalExample-configArea' }, React.createElement(Checkbox, { className: exampleStyles.exampleCheckbox, label: 'Show beak', checked: isBeakVisible, onChange: this._onShowBeakChange }), React.createElement(Dropdown, { label: 'Directional hint', selectedKey: directionalHint, options: DIRECTION_OPTIONS, onChanged: this._onDirectionalChanged }), getRTL() && React.createElement(Checkbox, { label: 'Use RTL directional hint', checked: useDirectionalHintForRtl, onChange: this._onUseRtlHintChange }), getRTL() && React.createElement(Dropdown, { label: 'Directional hint for RTL', selectedKey: directionalHintForRTL, options: DIRECTION_OPTIONS, onChanged: this._onDirectionalRtlChanged, disabled: !useDirectionalHintForRtl })), React.createElement("div", { className: 'ms-ContextualMenuDirectionalExample-buttonArea' }, React.createElement(DefaultButton, { text: 'Show context menu', menuProps: { isBeakVisible: isBeakVisible, directionalHint: directionalHint, directionalHintForRTL: useDirectionalHintForRtl ? directionalHintForRTL : undefined, gapSpace: gapSpace, beakWidth: beakWidth, directionalHintFixed: edgeFixed, items: [ { key: 'newItem', name: 'New' }, { key: 'divider_1', itemType: ContextualMenuItemType.Divider }, { key: 'rename', name: 'Rename' }, { key: 'edit', name: 'Edit' }, { key: 'properties', name: 'Properties' }, { key: 'disabled', name: 'Disabled item', disabled: true } ] } })))); }; ContextualMenuDirectionalExample.prototype._onShowBeakChange = function (ev, isVisible) { this.setState({ isBeakVisible: isVisible }); }; ContextualMenuDirectionalExample.prototype._onUseRtlHintChange = function (ev, isVisible) { this.setState({ useDirectionalHintForRtl: isVisible }); }; ContextualMenuDirectionalExample.prototype._onDirectionalChanged = function (option) { this.setState({ directionalHint: option.key }); }; ContextualMenuDirectionalExample.prototype._onDirectionalRtlChanged = function (option) { this.setState({ directionalHintForRTL: option.key }); }; tslib_1.__decorate([ autobind ], ContextualMenuDirectionalExample.prototype, "_onShowBeakChange", null); tslib_1.__decorate([ autobind ], ContextualMenuDirectionalExample.prototype, "_onUseRtlHintChange", null); tslib_1.__decorate([ autobind ], ContextualMenuDirectionalExample.prototype, "_onDirectionalChanged", null); tslib_1.__decorate([ autobind ], ContextualMenuDirectionalExample.prototype, "_onDirectionalRtlChanged", null); return ContextualMenuDirectionalExample; }(React.Component)); export { ContextualMenuDirectionalExample }; //# sourceMappingURL=ContextualMenu.Directional.Example.js.map