"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/* tslint:disable:no-unused-variable */
var React = require("react");
/* tslint:enable:no-unused-variable */
var Utilities_1 = require("office-ui-fabric-react/lib/Utilities");
var Checkbox_1 = require("office-ui-fabric-react/lib/Checkbox");
var MarqueeSelection_1 = require("office-ui-fabric-react/lib/MarqueeSelection");
require("./MarqueeSelection.Basic.Example.scss");
var exampleStylesImport = require("../../../common/_exampleStyles.scss");
var exampleStyles = exampleStylesImport;
var PHOTOS = Utilities_1.createArray(250, function (index) {
    var randomWidth = 50 + Math.floor(Math.random() * 150);
    return {
        key: index,
        url: "http://placehold.it/" + randomWidth + "x100",
        width: randomWidth,
        height: 100
    };
});
var MarqueeSelectionBasicExample = (function (_super) {
    tslib_1.__extends(MarqueeSelectionBasicExample, _super);
    function MarqueeSelectionBasicExample() {
        var _this = _super.call(this) || this;
        _this.state = {
            isMarqueeEnabled: true
        };
        _this._selection = new MarqueeSelection_1.Selection({
            onSelectionChanged: function () {
                if (_this._isMounted) {
                    _this.forceUpdate();
                }
            }
        });
        _this._selection.setItems(PHOTOS);
        return _this;
    }
    MarqueeSelectionBasicExample.prototype.componentDidMount = function () {
        this._isMounted = true;
    };
    MarqueeSelectionBasicExample.prototype.render = function () {
        var _this = this;
        return (React.createElement(MarqueeSelection_1.MarqueeSelection, { selection: this._selection, isEnabled: this.state.isMarqueeEnabled },
            React.createElement(Checkbox_1.Checkbox, { className: exampleStyles.exampleCheckbox, label: 'Is marquee enabled', defaultChecked: true, onChange: this._onChange }),
            React.createElement("p", null, "Drag a rectangle around the items below to select them:"),
            React.createElement("ul", { className: 'ms-MarqueeSelectionBasicExample-photoList' }, PHOTOS.map(function (photo, index) { return (React.createElement("div", { key: index, className: Utilities_1.css('ms-MarqueeSelectionBasicExample-photoCell', _this._selection.isIndexSelected(index) && 'is-selected'), "data-is-focusable": true, "data-selection-index": index, onClick: _this._log('clicked'), style: { width: photo.width, height: photo.height } }, index)); }))));
    };
    MarqueeSelectionBasicExample.prototype._log = function (text) {
        return function () {
            console.log(text);
        };
    };
    MarqueeSelectionBasicExample.prototype._onChange = function (ev, isMarqueeEnabled) {
        this.setState({ isMarqueeEnabled: isMarqueeEnabled });
    };
    tslib_1.__decorate([
        Utilities_1.autobind
    ], MarqueeSelectionBasicExample.prototype, "_onChange", null);
    return MarqueeSelectionBasicExample;
}(React.Component));
exports.MarqueeSelectionBasicExample = MarqueeSelectionBasicExample;
//# sourceMappingURL=MarqueeSelection.Basic.Example.js.map