import { IQuestion } from 'survey-core' ; import { SurveyPDF } from '../survey' ; import { DocController } from '../doc_controller' ; import { IFlatQuestion , FlatQuestion } from './flat_question' ; export type FlatConstructor = new ( survey , question , controller ) => IFlatQuestion ; export class FlatRepository { private questions : { [ index ] : FlatConstructor ; } = { } ; private static instance : FlatRepository = new FlatRepository ( ) ; public static getInstance ( ) { return FlatRepository . instance ; } public register ( modelType , rendererConstructor ) { this . questions [ modelType ] = rendererConstructor ; } public create ( survey , question , docController , type ? ) { const questionType = typeof type === 'undefined' ? question . getType ( ) : type ; const rendererConstructor = this . questions [ questionType ] || FlatQuestion ; return new rendererConstructor ( survey , question , docController ) ; } }