"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var TextField_1 = require("office-ui-fabric-react/lib/TextField");
var DetailsList_1 = require("office-ui-fabric-react/lib/DetailsList");
var Utilities_1 = require("office-ui-fabric-react/lib/Utilities");
var Tooltip_1 = require("office-ui-fabric-react/lib/Tooltip");
var ScrollablePane_1 = require("office-ui-fabric-react/lib/ScrollablePane");
var Sticky_1 = require("office-ui-fabric-react/lib/Sticky");
var MarqueeSelection_1 = require("office-ui-fabric-react/lib/MarqueeSelection");
var _items = [];
var _columns = [
    {
        key: 'column1',
        name: 'Name',
        fieldName: 'name',
        minWidth: 100,
        maxWidth: 200,
        isResizable: true,
        ariaLabel: 'Operations for name'
    },
    {
        key: 'column2',
        name: 'Value',
        fieldName: 'value',
        minWidth: 100,
        maxWidth: 200,
        isResizable: true,
        ariaLabel: 'Operations for value'
    }
];
var ScrollablePaneDetailsListExample = /** @class */ (function (_super) {
    tslib_1.__extends(ScrollablePaneDetailsListExample, _super);
    function ScrollablePaneDetailsListExample(props) {
        var _this = _super.call(this, props) || this;
        _this._scrollablePane = Utilities_1.createRef();
        _this._onScroll = function (e) {
            if (_this._scrollablePane.current) {
                _this._scrollablePane.current.forceLayoutUpdate();
            }
        };
        // Populate with items for demos.
        if (_items.length === 0) {
            for (var i = 0; i < 200; i++) {
                _items.push({
                    key: i,
                    name: 'Item ' + i,
                    value: i
                });
            }
        }
        _this._selection = new DetailsList_1.Selection({
            onSelectionChanged: function () { return _this.setState({ selectionDetails: _this._getSelectionDetails() }); }
        });
        _this.state = {
            items: _items,
            selectionDetails: _this._getSelectionDetails()
        };
        return _this;
    }
    ScrollablePaneDetailsListExample.prototype.render = function () {
        var _this = this;
        var _a = this.state, items = _a.items, selectionDetails = _a.selectionDetails;
        return (React.createElement("div", { style: {
                height: '10000px',
                position: 'relative',
                maxHeight: 'inherit'
            } },
            React.createElement(ScrollablePane_1.ScrollablePane, { componentRef: this._scrollablePane },
                React.createElement(Sticky_1.Sticky, { stickyPosition: Sticky_1.StickyPositionType.Header }, selectionDetails),
                React.createElement(TextField_1.TextField, { label: "Filter by name:", 
                    // tslint:disable-next-line:jsx-no-lambda
                    onChanged: function (text) {
                        return _this.setState({ items: text ? _items.filter(function (i) { return i.name.toLowerCase().indexOf(text) > -1; }) : _items });
                    } }),
                React.createElement(Sticky_1.Sticky, { stickyPosition: Sticky_1.StickyPositionType.Header },
                    React.createElement("h1", { style: { margin: '0px' } }, "Item List")),
                React.createElement(MarqueeSelection_1.MarqueeSelection, { selection: this._selection },
                    React.createElement(DetailsList_1.DetailsList, { items: items, columns: _columns, setKey: "set", layoutMode: DetailsList_1.DetailsListLayoutMode.fixedColumns, onScroll: this._onScroll, onRenderDetailsHeader: 
                        // tslint:disable-next-line:jsx-no-lambda
                        function (detailsHeaderProps, defaultRender) { return (React.createElement(Sticky_1.Sticky, { stickyPosition: Sticky_1.StickyPositionType.Header }, defaultRender(tslib_1.__assign({}, detailsHeaderProps, { onRenderColumnHeaderTooltip: function (tooltipHostProps) { return (React.createElement(Tooltip_1.TooltipHost, tslib_1.__assign({}, tooltipHostProps))); } })))); }, selection: this._selection, selectionPreservedOnEmptyClick: true, ariaLabelForSelectionColumn: "Toggle selection", ariaLabelForSelectAllCheckbox: "Toggle selection for all items", 
                        // tslint:disable-next-line:jsx-no-lambda
                        onItemInvoked: function (item) { return alert("Item invoked: " + item.name); } })))));
    };
    ScrollablePaneDetailsListExample.prototype._getSelectionDetails = function () {
        var selectionCount = this._selection.getSelectedCount();
        switch (selectionCount) {
            case 0:
                return 'No items selected';
            case 1:
                return '1 item selected: ' + this._selection.getSelection()[0].name;
            default:
                return selectionCount + " items selected";
        }
    };
    return ScrollablePaneDetailsListExample;
}(React.Component));
exports.ScrollablePaneDetailsListExample = ScrollablePaneDetailsListExample;
//# sourceMappingURL=ScrollablePane.DetailsList.Example.js.map