<commit_before>import ViewManager from './../Core/ViewManager';
import Component from './../Core/Component';

class Placeholder extends Component {

    constructor(props) {
        super(props);
    }

    componentDidMount() {
        if (this.props.onDidUpdate) {
            this.props.onDidUpdate();
        }
    }

    componentDidUpdate() {
        if (this.props.onDidUpdate) {
            this.props.onDidUpdate();
        }
    }
}

Placeholder.defaultProps = {
    renderer() {
        let components = ViewManager.getContent(this.props.name);
        if (!_.isArray(components)) {
            components = [components];
        }
        const cmps = [];
        _.each(components, (item, index) => {
            if (!item) {
                return;
            }
            if (React.isValidElement(item)) {
                cmps.push(React.cloneElement(item, {key: index}));
            } else {
                const props = {key: index};
                if (!_.isFunction(item)) {
                    _.assign(props, item[1]);
                    item = item[0];
                }
                cmps.push(React.createElement(item, props));
            }
        });

        return (
            <webiny-placeholder>{cmps}</webiny-placeholder>
        );
    }
};

export default Placeholder;<commit_msg>- placeholder addition (props can now be passed)<commit_after>import ViewManager from './../Core/ViewManager';
import Component from './../Core/Component';

class Placeholder extends Component {

    constructor(props) {
        super(props);
    }

    componentDidMount() {
        if (this.props.onDidUpdate) {
            this.props.onDidUpdate();
        }
    }

    componentDidUpdate() {
        if (this.props.onDidUpdate) {
            this.props.onDidUpdate();
        }
    }
}

Placeholder.defaultProps = {
    renderer() {
        let components = ViewManager.getContent(this.props.name);
        if (!_.isArray(components)) {
            components = [components];
        }
        const cmps = [];
        const placeholderProps = _.omit(this.props, ['renderer', 'name', 'children']);
        _.each(components, (item, index) => {
            if (!item) {
                return;
            }
            const componentProps = _.merge({key: index}, placeholderProps);
            if (React.isValidElement(item)) {
                if (_.isString(item.type)) {
                    cmps.push(item);
                } else {
                    cmps.push(React.cloneElement(item, componentProps));
                }
            } else {
                if (!_.isFunction(item)) {
                    _.assign(componentProps, item[1]);
                    item = item[0];
                }
                console.log({item});
                cmps.push(React.createElement(item, componentProps));
            }
        });

        return (
            <webiny-placeholder>{cmps}</webiny-placeholder>
        );
    }
};

export default Placeholder;
{'fraction_non_alphanumeric': 0.13094440723375753, 'fraction_numerical': 0.0013395847287340924, 'mean_word_length': 1.55736301369863, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '660593', 'n_tokens_mistral': 804, 'n_tokens_neox': 786, 'n_words': 141}