office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
62 lines • 4.02 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { DefaultButton, CompoundButton } from 'office-ui-fabric-react/lib/Button';
import { keytipMap } from './KeytipSetup';
import { Toggle } from 'office-ui-fabric-react/lib/Toggle';
var KeytipsButtonExample = /** @class */ (function (_super) {
tslib_1.__extends(KeytipsButtonExample, _super);
function KeytipsButtonExample(props) {
var _this = _super.call(this, props) || this;
_this._toggleDisabled = function (checked) {
_this.setState({ btnDisabled: !checked });
};
_this.state = {
btnDisabled: false
};
return _this;
}
/* tslint:disable:jsx-ban-props jsx-no-lambda */
KeytipsButtonExample.prototype.render = function () {
return (React.createElement("div", null,
React.createElement("p", null, "Keytips on the same level starting with the same characters will get filtered out as you hit those keys"),
React.createElement(DefaultButton, { keytipProps: keytipMap.Button, text: 'Button', onClick: function () { console.log('Button'); } }),
React.createElement(CompoundButton, { keytipProps: keytipMap.CompoundButton, text: 'Compound Button', description: 'With a Keytip', onClick: function () { console.log('Compound Button'); } }),
React.createElement(DefaultButton, { keytipProps: keytipMap.ButtonWithMenu, text: 'Button with Menu', onClick: function () { console.log('Button with Menu'); }, menuProps: {
items: [
{
key: 'buttonMenuItem1',
name: 'Menu Item 1',
keytipProps: keytipMap.ButtonMenuItem1
},
{
key: 'buttonMenuItem2',
name: 'Menu Item 2',
keytipProps: keytipMap.ButtonMenuItem2
}
]
} }),
React.createElement(DefaultButton, { keytipProps: keytipMap.SplitButton, text: 'Split Button', split: true, onClick: function () { console.log('Split Button'); }, menuProps: {
items: [
{
key: 'splitButtonMenuButton1',
name: 'Split Button Menu Item 1',
keytipProps: keytipMap.SplitButtonMenuItem1
},
{
key: 'splitButtonMenuButton2',
name: 'Split Button Menu Item 2',
keytipProps: keytipMap.SplitButtonMenuItem2
}
]
} }),
React.createElement(DefaultButton, { text: 'I do not have a keytip' }),
React.createElement("p", null, "A keytip can have an 'offset' prop which will position the keytip starting from the top-left corner of the element"),
React.createElement(DefaultButton, { keytipProps: keytipMap.ButtonOffset, text: 'Button keytip offset 10x10', onClick: function () { console.log('Button'); } }),
React.createElement("p", null, "A keytip will become disabled when its corresponding component becomes disabled. A disabled keytip will be visible but cannot be triggered"),
React.createElement(Toggle, { onText: 'Enabled', offText: 'Disabled', defaultChecked: !this.state.btnDisabled, onChanged: this._toggleDisabled }),
React.createElement(DefaultButton, { keytipProps: keytipMap.DisabledButton, disabled: this.state.btnDisabled, text: (this.state.btnDisabled ? 'Disabled' : 'Enabled') + ' Button', onClick: function () { console.log('Disabled Button'); } })));
};
return KeytipsButtonExample;
}(React.Component));
export { KeytipsButtonExample };
//# sourceMappingURL=Keytips.Button.Example.js.map