UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

41 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = require("react"); class InferredElement { constructor(type, props, children) { this.type = type; this.props = props; this.children = children; } getElement(props = {}) { if (!this.type || !this.type.component) { return; } return this.children ? (0, react_1.createElement)(this.type.component, { ...this.props, ...props }, this.children.length > 0 ? this.children.map((child, index) => child.getElement({ key: index })) : this.children.getElement()) : (0, react_1.createElement)(this.type.component, { ...this.props, ...props }); } getProps() { return this.props; } isDefined() { return !!this.type; } getRepresentation() { if (!this.type) { return ''; } if (this.type.representation) { return this.type.representation(this.props, this.children); } if (this.type.component) { return `<${this.type.component.displayName || this.type.component.name} source="${this.props.source}" />`; } return ''; } } exports.default = InferredElement; module.exports = exports.default; //# sourceMappingURL=InferredElement.js.map