office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
71 lines • 3.65 kB
JavaScript
define(["require", "exports", "tslib", "react", "../../../Utilities", "office-ui-fabric-react/lib/components/pickers/TagPicker/TagPicker", "office-ui-fabric-react/lib/Checkbox", "../../../common/_exampleStyles.scss"], function (require, exports, tslib_1, React, Utilities_1, TagPicker_1, Checkbox_1, exampleStylesImport) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var exampleStyles = exampleStylesImport;
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 = /** @class */ (function (_super) {
tslib_1.__extends(TagPickerBasicExample, _super);
function TagPickerBasicExample(props) {
var _this = _super.call(this, props) || this;
_this.state = {
isPickerDisabled: false
};
return _this;
}
TagPickerBasicExample.prototype.render = function () {
return (React.createElement("div", null,
React.createElement(Checkbox_1.Checkbox, { className: exampleStyles.exampleCheckbox, label: 'Disable Tag Picker', checked: this.state.isPickerDisabled, onChange: this._onDisabledButtonClick }),
React.createElement(TagPicker_1.TagPicker, { onResolveSuggestions: this._onFilterChanged, getTextFromItem: this._getTextFromItem, pickerSuggestionsProps: {
suggestionsHeaderText: 'Suggested Tags',
noResultsFoundText: 'No Color Tags Found'
}, itemLimit: 2, disabled: this.state.isPickerDisabled, inputProps: {
onBlur: function (ev) { return console.log('onBlur called'); },
onFocus: function (ev) { return console.log('onFocus called'); },
'aria-label': 'Tag Picker'
} })));
};
TagPickerBasicExample.prototype._getTextFromItem = function (item) {
return item.name;
};
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;
};
tslib_1.__decorate([
Utilities_1.autobind
], TagPickerBasicExample.prototype, "_onDisabledButtonClick", null);
tslib_1.__decorate([
Utilities_1.autobind
], TagPickerBasicExample.prototype, "_onFilterChanged", null);
return TagPickerBasicExample;
}(React.Component));
exports.TagPickerBasicExample = TagPickerBasicExample;
});
//# sourceMappingURL=TagPicker.Basic.Example.js.map