Exemplo n.º 1
0
    renderChild(value, prefix, componentChildren) {
        //value true is a shortcut to {children:true}.  This means content:true
        // would also return the children.
        let { Content, injected, contentWrapper, content, children, type = this.props.type || this.props.dataType, ...props } = value;

        if (content === true) {
            return componentChildren;
        }


        if (isString(content)) {
            let ContentWrapper = this.props.contentWrapper;
            return <ContentWrapper path={this.props.path} fieldAttrs={props}
                                   key={'content-' + prefix} type={type}
                                   content={content}/>
        }

        let newChildren;

        if (children) {
            if (children === true) {
                newChildren = componentChildren;
            } else {
                newChildren = Children.map(componentChildren, (child, i) => {
                    warning(typeof children != 'string',
                        "children property can not be a string");
                    return this.renderChild(children, `child-${prefix}-${i}`,
                        child);
                });
            }
        } else if (isArray(content)) {
            newChildren = content.map((c, key) => {
                let newC = this.asContentObject(c);
                return this.renderChild(newC, prefix + '-s-' + key,
                    componentChildren);
            }, this);
        } else if (content === false) {
            newChildren = null;
        } else {
            newChildren = children;

        }


        if (isDomType(type)) {
            if (isArray(newChildren)) {
                return createElement(type, allowed(props), ...newChildren);
            }
            return createElement(type, allowed(props), newChildren);
        }

        const Ctype = this.context.injector.inject(
            this.context.loader.loadType(type));
        return <Ctype path={this.props.path} content={content} {...props} >
            {children}
        </Ctype>
    }
Exemplo n.º 2
0
            return buttons.map(b => {
                onClick      = b.onClick || onClick;
                const btn    = isString(b) ? {
                    action: b,
                    label : b,
                    onClick
                } : extend({}, b, { onClick, template: buttonTemplate });
                let btnClass = this.props.buttonClass;
                if (btn.buttonClass) {
                    btnClass = `${btn.buttonClass} ${btnClass}`;
                }
                if (btn.primary) {
                    btn.buttonClass =
                        `${btnClass} ${this.props.primaryClass}`;
                } else {
                    btn.buttonClass =
                        `${btnClass} ${this.props.secondaryClass}`;

                }
                return btn;
            });
Exemplo n.º 3
0
        return Object.keys(buttons).map(function (b) {
            const v      = buttons[b];
            onClick      = v.onClick || onClick;
            const btn    = isString(v) ? {
                action: b,
                label : v,
                onClick
            } : { ...v, onClick, template: buttonTemplate };
            let btnClass = this.props.buttonClass;
            if (btn.buttonClass) {
                btnClass = `${btn.buttonClass} ${btnClass}`;
            }
            if (btn.primary) {
                btn.buttonClass = `${btnClass} ${this.props.primaryClass}`;
            } else {
                btn.buttonClass = `${btnClass} ${this.props.secondaryClass}`;

            }
            if (!btn.action) {
                btn.action = b;
            }
            return btn;
        }, this)