import { CSS_ABSOLUTE_POSITIONING } from "../CSS_ABSOLUTE_POSITIONING.js";
import View from "../View.js";

class EmptyView extends View {
    /**
     * @param {string[]} [classList]
     * @param {Element} [el]
     * @param {string} [tag]
     * @param {string} [tagNamespace]
     * @param {Object<string>} [css]
     * @param {Object<string>} [attr]
     * @extends {View}
     * @constructor
     */
    constructor({
                    classList = [],
                    el,
                    tag = 'div',
                    tagNamespace = undefined,
                    css,
                    attr
    } = {}) {

        super();

        if (el !== undefined) {
            this.el = el;
        } else if (tagNamespace !== undefined) {
            this.el = document.createElementNS(tagNamespace, tag);
        } else {
            this.el = document.createElement(tag);
        }

        this.addClasses(classList);

        if (css !== undefined) {
            this.css(css);
        }

        if (attr !== undefined) {
            this.attr(attr);
        }
    }

    /**
     *
     * @param {string[]} [classList]
     * @param {Object<string>} [css]
     * @param {Object} [attr]
     * @param {Element} [el]
     * @param {string} [tag]
     * @returns {EmptyView}
     */
    static absolute({
                        classList=[],
                        css,
                        attr,
                        el,
                        tag
    } = {}) {

        return new EmptyView({
            classList,
            css: {
                css,
                ...CSS_ABSOLUTE_POSITIONING
            },
            attr,
            el,
            tag
        });
    }

    /**
     *
     * @param {View[]} elements
     * @param {{classList:string[],tag:string,css:{}}} options
     * @return {EmptyView}
     */
    static group(elements, options = {}) {
        const v = new EmptyView(options);

        elements.forEach(v.addChild, v);

        return v;
    }

    static create() {
        return new EmptyView();
    }
}


export default EmptyView;
