diff --git a/src/builder.js b/src/builder.js index e1ce5bd..5953e76 100644 --- a/src/builder.js +++ b/src/builder.js @@ -38,6 +38,64 @@ const builder = { } }, + /** + * Pure convenience, mostly to enable jdocs for builder.extensions + * @param {*} unrecognizedComponent + * @returns {Component} + */ + asComponent(unrecognizedComponent) { + if (unrecognizedComponent instanceof Component) { + console.log("Recognized as Component"); + return unrecognizedComponent; + + } else if (unrecognizedComponent instanceof Modifier) { + return unrecognizedComponent.toComponent() + } + console.log("NOT Recognized"); + + return unrecognizedComponent; + }, + + /** + * Pure convenience, mostly to enable jdocs for builder.extensions + * in this case if there is an actual difference as the element being + * a FlexContainerComponent + * @param {*} unrecognizedComponent + * @returns {FlexContainerComponent} + */ + asFlexContainerComponent(unrecognizedComponent) { + if (unrecognizedComponent instanceof FlexContainerComponent) { + console.log("Recognized as FlexContainerComponent"); + return unrecognizedComponent; + + } else if (unrecognizedComponent instanceof Modifier) { + return unrecognizedComponent.toComponent() + } + console.log("NOT Recognized"); + + return unrecognizedComponent; + }, + + /** + * Pure convenience, mostly to enable jdocs for builder.extensions + * in this case if there is an actual difference as the element being + * an InputComponent + * @param {*} unrecognizedComponent + * @returns {InputComponent} + */ + asInputComponent(unrecognizedComponent) { + if (unrecognizedComponent instanceof InputComponent) { + console.log("Recognized as InputComponent"); + return unrecognizedComponent; + + } else if (unrecognizedComponent instanceof Modifier) { + return unrecognizedComponent.toComponent() + } + console.log("NOT Recognized"); + + return unrecognizedComponent; + }, + /** * * @param {string} htmlText