import * as tslib_1 from "tslib";
import * as React from 'react';
import { getRTL } from 'office-ui-fabric-react/lib/Utilities';
import { FocusZone, FocusZoneDirection } from 'office-ui-fabric-react/lib/FocusZone';
import { TextField } from 'office-ui-fabric-react/lib/TextField';
import { Image, ImageFit } from 'office-ui-fabric-react/lib/Image';
import { Icon } from 'office-ui-fabric-react/lib/Icon';
import { List } from 'office-ui-fabric-react/lib/List';
import * as styles from './List.Basic.Example.scss';
var ListBasicExample = /** @class */ (function (_super) {
    tslib_1.__extends(ListBasicExample, _super);
    function ListBasicExample(props) {
        var _this = _super.call(this, props) || this;
        _this._onFilterChanged = _this._onFilterChanged.bind(_this);
        _this.state = {
            filterText: '',
            items: props.items
        };
        return _this;
    }
    ListBasicExample.prototype.render = function () {
        var originalItems = this.props.items;
        var _a = this.state.items, items = _a === void 0 ? [] : _a;
        var resultCountText = items.length === originalItems.length ? '' : " (" + items.length + " of " + originalItems.length + " shown)";
        return (React.createElement(FocusZone, { direction: FocusZoneDirection.vertical },
            React.createElement(TextField, { label: 'Filter by name' + resultCountText, onBeforeChange: this._onFilterChanged }),
            React.createElement(List, { items: items, onRenderCell: this._onRenderCell })));
    };
    ListBasicExample.prototype._onFilterChanged = function (text) {
        var items = this.props.items;
        this.setState({
            filterText: text,
            items: text ? items.filter(function (item) { return item.name.toLowerCase().indexOf(text.toLowerCase()) >= 0; }) : items
        });
    };
    ListBasicExample.prototype._onRenderCell = function (item, index) {
        return (React.createElement("div", { className: styles.itemCell, "data-is-focusable": true },
            React.createElement(Image, { className: styles.itemImage, src: item.thumbnail, width: 50, height: 50, imageFit: ImageFit.cover }),
            React.createElement("div", { className: styles.itemContent },
                React.createElement("div", { className: styles.itemName }, item.name),
                React.createElement("div", { className: styles.itemIndex }, "Item " + index),
                React.createElement("div", null, item.description)),
            React.createElement(Icon, { className: styles.chevron, iconName: getRTL() ? 'ChevronLeft' : 'ChevronRight' })));
    };
    return ListBasicExample;
}(React.Component));
export { ListBasicExample };
//# sourceMappingURL=List.Basic.Example.js.map