UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

59 lines (57 loc) 2.76 kB
define(["require", "exports", "tslib", "react", "office-ui-fabric-react/lib/components/pickers/TagPicker/TagPicker", "office-ui-fabric-react/lib/Checkbox"], function (require, exports, tslib_1, React, TagPicker_1, Checkbox_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _testTags = [ 'black', 'blue', 'brown', 'cyan', 'green', 'magenta', 'mauve', 'orange', 'pink', 'purple', 'red', 'rose', 'violet', 'white', 'yellow' ].map(function (item) { return ({ key: item, name: item }); }); var TagPickerBasicExample = (function (_super) { tslib_1.__extends(TagPickerBasicExample, _super); function TagPickerBasicExample() { var _this = _super.call(this) || this; _this.state = { isPickerDisabled: false }; return _this; } TagPickerBasicExample.prototype.render = function () { return (React.createElement("div", null, React.createElement(Checkbox_1.Checkbox, { label: 'Disable Tag Picker', checked: this.state.isPickerDisabled, onChange: this._onDisabledButtonClick.bind(this) }), React.createElement(TagPicker_1.TagPicker, { ref: 'tagPicker', onResolveSuggestions: this._onFilterChanged.bind(this), getTextFromItem: function (item) { return item.name; }, pickerSuggestionsProps: { suggestionsHeaderText: 'Suggested Tags', noResultsFoundText: 'No Color Tags Found' }, disabled: this.state.isPickerDisabled }))); }; TagPickerBasicExample.prototype._onDisabledButtonClick = function () { this.setState({ isPickerDisabled: !this.state.isPickerDisabled }); }; TagPickerBasicExample.prototype._onFilterChanged = function (filterText, tagList) { var _this = this; return filterText ? _testTags.filter(function (tag) { return tag.name.toLowerCase().indexOf(filterText.toLowerCase()) === 0; }).filter(function (item) { return !_this._listContainsDocument(item, tagList); }) : []; }; TagPickerBasicExample.prototype._listContainsDocument = function (tag, tagList) { if (!tagList || !tagList.length || tagList.length === 0) { return false; } return tagList.filter(function (compareTag) { return compareTag.key === tag.key; }).length > 0; }; return TagPickerBasicExample; }(React.Component)); exports.TagPickerBasicExample = TagPickerBasicExample; }); //# sourceMappingURL=TagPicker.Basic.Example.js.map