"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var Utilities_1 = require("office-ui-fabric-react/lib-commonjs/Utilities");
var Checkbox_1 = require("office-ui-fabric-react/lib-commonjs/Checkbox");
var MarqueeSelection_1 = require("office-ui-fabric-react/lib-commonjs/MarqueeSelection");
var Styling_1 = require("office-ui-fabric-react/lib-commonjs/Styling");
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 theme = Styling_1.getTheme();
var styles = Styling_1.mergeStyleSets({
    photoList: {
        display: 'inline-block',
        border: '1px solid ' + theme.palette.neutralTertiary,
        margin: 0,
        padding: 10,
        overflow: 'hidden',
        userSelect: 'none',
    },
    photoCell: {
        position: 'relative',
        display: 'inline-block',
        margin: 2,
        boxSizing: 'border-box',
        background: theme.palette.neutralLighter,
        lineHeight: 100,
        verticalAlign: 'middle',
        textAlign: 'center',
        selectors: {
            '&.is-selected': {
                background: theme.palette.themeLighter,
                border: '1px solid ' + theme.palette.themePrimary,
            },
        },
    },
});
var checkboxStyles = { root: { margin: '10px 0' } };
var MarqueeSelectionBasicExample = /** @class */ (function (_super) {
    tslib_1.__extends(MarqueeSelectionBasicExample, _super);
    function MarqueeSelectionBasicExample(props) {
        var _this = _super.call(this, props) || this;
        _this._onChange = function (ev, isMarqueeEnabled) {
            _this.setState({ isMarqueeEnabled: isMarqueeEnabled });
        };
        _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, { styles: checkboxStyles, 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: styles.photoList }, PHOTOS.map(function (photo, index) { return (React.createElement("div", { key: index, className: Utilities_1.css(styles.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);
        };
    };
    return MarqueeSelectionBasicExample;
}(React.Component));
exports.MarqueeSelectionBasicExample = MarqueeSelectionBasicExample;
//# sourceMappingURL=MarqueeSelection.Basic.Example.js.map