UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

50 lines 3.26 kB
import * as tslib_1 from "tslib"; import * as React from 'react'; import { Checkbox } from 'office-ui-fabric-react/lib/Checkbox'; import { Persona, PersonaSize } from 'office-ui-fabric-react/lib/Persona'; var CheckboxImplementationExamples = /** @class */ (function (_super) { tslib_1.__extends(CheckboxImplementationExamples, _super); function CheckboxImplementationExamples(props) { var _this = _super.call(this, props) || this; _this._onControlledCheckboxChange = function (ev, checked) { _this.setState({ isChecked: checked }); }; _this.state = { isChecked: false }; _this._onCheckboxChange = _this._onCheckboxChange.bind(_this); return _this; } CheckboxImplementationExamples.prototype.render = function () { var isChecked = this.state.isChecked; var checkboxStyles = function () { return { root: { marginTop: '10px' } }; }; return (React.createElement("div", null, React.createElement(Checkbox, { label: 'Uncontrolled checkbox', onChange: this._onCheckboxChange, inputProps: { onFocus: function () { console.log('Uncontrolled checkbox is focused'); }, onBlur: function () { console.log('Uncontrolled checkbox is blured'); } }, styles: checkboxStyles, ariaDescribedBy: 'descriptionID' }), React.createElement("label", { id: 'descriptionID', className: 'screenReaderOnly' }, "Uncontroller checkbox description"), React.createElement(Checkbox, { label: 'Uncontrolled checkbox with defaultChecked true', defaultChecked: true, onChange: this._onCheckboxChange, styles: checkboxStyles }), React.createElement(Checkbox, { label: 'Disabled uncontrolled checkbox', disabled: true, styles: checkboxStyles }), React.createElement(Checkbox, { label: 'Disabled uncontrolled checkbox with defaultChecked true', disabled: true, defaultChecked: true, onChange: this._onCheckboxChange, styles: checkboxStyles }), React.createElement(Checkbox, { label: 'Controlled checkbox', checked: isChecked, onChange: this._onControlledCheckboxChange, styles: checkboxStyles }), React.createElement(Checkbox, { label: 'Checkbox rendered with boxSide "end"', boxSide: 'end', styles: checkboxStyles }), React.createElement(Checkbox, { label: 'Persona Checkbox', styles: checkboxStyles, onRenderLabel: this._renderPersonaLabel }))); }; CheckboxImplementationExamples.prototype._onCheckboxChange = function (ev, isChecked) { console.log("The option has been changed to " + isChecked + "."); }; CheckboxImplementationExamples.prototype._renderPersonaLabel = function (props) { var DEFAULT_IMAGE_URL = '/_layouts/15/userphoto.aspx?size=S&accountname='; return React.createElement(Persona, { text: props.label, imageUrl: DEFAULT_IMAGE_URL, size: PersonaSize.size32 }); }; return CheckboxImplementationExamples; }(React.Component)); export { CheckboxImplementationExamples }; //# sourceMappingURL=Checkbox.ImplementationExamples.js.map