"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// tslint:disable:jsx-no-multiline-js
var React = require("react");
var react_redux_1 = require("react-redux");
var core_1 = require("@jsonforms/core");
var ObjectListItem_1 = require("./ObjectListItem");
/**
 * Expands the given root data array by expanding every element.
 * If the parent data containing the array is provided,
 * a suitable delete function for the expanded elements is created.
 *
 * As a difference to the ExpandArray component this component does not use containment
 * properties because it is only used for the root nodes of a tree.
 *
 * @param data the array to expand
 * @param schema the JsonSchema defining the property that the array belongs to
 * @param parentPath the instance path where data can be obtained from
 */
exports.ExpandRootArray = function (_a) {
    var rootData = _a.rootData, schema = _a.schema, path = _a.path, selection = _a.selection, handlers = _a.handlers, filterPredicate = _a.filterPredicate, labelProvider = _a.labelProvider, imageProvider = _a.imageProvider;
    var data = core_1.resolveData(rootData, path);
    if (data === undefined || data === null) {
        return 'No data';
    }
    return data.map(function (_element, index) {
        var composedPath = core_1.Paths.compose(path, index.toString());
        return (React.createElement(ObjectListItem_1.default, { key: composedPath, path: composedPath, schema: schema, selection: selection, handlers: handlers, isRoot: true, filterPredicate: filterPredicate, labelProvider: labelProvider, imageProvider: imageProvider }));
    });
};
// TODO: update selected element once selection has been changed
exports.ExpandRootArrayContainer = function (_a) {
    var path = _a.path, schema = _a.schema, rootData = _a.rootData, selection = _a.selection, uischema = _a.uischema, handlers = _a.handlers, filterPredicate = _a.filterPredicate, labelProvider = _a.labelProvider, imageProvider = _a.imageProvider;
    return (React.createElement(exports.ExpandRootArray, { schema: schema, path: path, rootData: rootData, selection: selection, handlers: handlers, uischema: uischema, filterPredicate: filterPredicate, labelProvider: labelProvider, imageProvider: imageProvider }));
};
var mapStateToProps = function (state) { return ({
    rootData: core_1.getData(state)
}); };
exports.default = react_redux_1.connect(mapStateToProps, null)(exports.ExpandRootArrayContainer);
//# sourceMappingURL=ExpandRootArray.js.map