UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

51 lines 3.75 kB
define(["require", "exports", "tslib", "react", "office-ui-fabric-react/lib/Checkbox", "office-ui-fabric-react/lib/Persona", "office-ui-fabric-react/lib/Utilities"], function (require, exports, tslib_1, React, Checkbox_1, Persona_1, Utilities_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var CheckboxImplementationExamples = /** @class */ (function (_super) { tslib_1.__extends(CheckboxImplementationExamples, _super); function CheckboxImplementationExamples(props) { var _this = _super.call(this, props) || this; _this.state = { isChecked: false }; _this._onCheckboxChange = _this._onCheckboxChange.bind(_this); return _this; } CheckboxImplementationExamples.prototype.render = function () { var isChecked = this.state.isChecked; var styles = { root: { marginTop: '10px' } }; return (React.createElement("div", null, React.createElement(Checkbox_1.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: styles, ariaDescribedBy: 'descriptionID' }), React.createElement("label", { id: 'descriptionID', className: 'screenReaderOnly' }, "Uncontroller checkbox description"), React.createElement(Checkbox_1.Checkbox, { label: 'Uncontrolled checkbox with defaultChecked true', defaultChecked: true, onChange: this._onCheckboxChange, styles: styles }), React.createElement(Checkbox_1.Checkbox, { label: 'Disabled uncontrolled checkbox', disabled: true, styles: styles }), React.createElement(Checkbox_1.Checkbox, { label: 'Disabled uncontrolled checkbox with defaultChecked true', disabled: true, defaultChecked: true, onChange: this._onCheckboxChange, styles: styles }), React.createElement(Checkbox_1.Checkbox, { label: 'Controlled checkbox', checked: isChecked, onChange: this._onControlledCheckboxChange, styles: styles }), React.createElement(Checkbox_1.Checkbox, { label: 'Checkbox rendered with boxSide "end"', boxSide: 'end', styles: styles }), React.createElement(Checkbox_1.Checkbox, { label: 'Persona Checkbox', styles: styles, onRenderLabel: this._renderPersonaLabel }))); }; CheckboxImplementationExamples.prototype._onCheckboxChange = function (ev, isChecked) { console.log("The option has been changed to " + isChecked + "."); }; CheckboxImplementationExamples.prototype._onControlledCheckboxChange = function (ev, checked) { this.setState({ isChecked: checked }); }; CheckboxImplementationExamples.prototype._renderPersonaLabel = function (props) { var DEFAULT_IMAGE_URL = '/_layouts/15/userphoto.aspx?size=S&accountname='; return React.createElement(Persona_1.Persona, { primaryText: props.label, imageUrl: DEFAULT_IMAGE_URL, size: Persona_1.PersonaSize.size32 }); }; tslib_1.__decorate([ Utilities_1.autobind ], CheckboxImplementationExamples.prototype, "_onControlledCheckboxChange", null); return CheckboxImplementationExamples; }(React.Component)); exports.CheckboxImplementationExamples = CheckboxImplementationExamples; }); //# sourceMappingURL=Checkbox.ImplementationExamples.js.map