import React from "react" ; import { ReactQuestionFactory , SurveyPage , ISurveyCreator , SurveyQuestionElementBase } from "survey-react-ui" ; import { QuestionEmbeddedSurveyModel } from "@survey/creator" ; export class SurveyElementEmbeddedSurvey extends SurveyQuestionElementBase { constructor ( props ) { super ( props ) ; } protected get embeddedSurvey ( ) : QuestionEmbeddedSurveyModel { return ( this . props . element || this . props . question ) as QuestionEmbeddedSurveyModel ; } protected get creator ( ) : ISurveyCreator { return this . props . creator ; } public render ( ) { if ( ! this . embeddedSurvey ) return null ; const survey = this . embeddedSurvey . embeddedSurvey ; if ( ! survey || ! survey . currentPage ) return null ; return < SurveyPage survey = { survey } page = { survey . currentPage } css = { survey . css } creator = { this . creator } / > ; } } ReactQuestionFactory . Instance . registerQuestion ( "embeddedsurvey" , ( props ) => { return React . createElement ( SurveyElementEmbeddedSurvey , props ) ; } ) ;