"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const core_1 = require("../react_monad/core");
class List extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.state = { ps: "creating" };
    }
    componentWillReceiveProps(new_props) {
        this.setState(Object.assign({}, this.state, { ps: new_props.items.map((item, index) => new_props.renderer(index)(item).comp(new_props.context)(callback => new_value => new_props.cont(callback)(new_value))).toList() }));
    }
    componentWillMount() {
        this.setState(Object.assign({}, this.state, { ps: this.props.items.map((item, index) => this.props.renderer(index)(item).comp(this.props.context)(callback => new_value => this.props.cont(callback)(new_value))).toList() }));
    }
    render() {
        return React.createElement("div", { className: `monadic-list ${this.props.className || ""}` },
            " ",
            this.state.ps != "creating" ? this.state.ps : [],
            " ");
    }
}
exports.list = function (items, key, className, dbg) {
    return renderer => core_1.make_C(context => cont => React.createElement(List, { kind: "list",
        items: items, renderer: renderer,
        cont: cont, context: context, key: key, className: className, debug_info: dbg }));
};
//# sourceMappingURL=list.js.map