import * as ko from "knockout" ; import { ImplementorBase } from "survey-knockout-ui" ; import { SurveyCreator } from "../../creator" ; import { Base } from "survey-core" ; import { QuestionToolbox } from "@survey/creator" ; const template = require ( "./toolbox.html" ) ; export class ToolboxViewModel extends Base { private _categoriesSubscription : ko . Computed ; public categories = ko . observableArray < any > ( ) ; public creator : SurveyCreator ; constructor ( creator ) { super ( ) ; this . creator = creator ; new ImplementorBase ( this . toolbox ) ; this . _categoriesSubscription = ko . computed ( ( ) => { const categories = ko . unwrap ( this . toolbox . categories ) ; categories . forEach ( ( category , categoryIndex ) => { new ImplementorBase ( category ) ; } ) ; this . categories ( categories ) ; } ) ; } public get toolbox ( ) : QuestionToolbox { return this . creator . toolbox ; } dispose ( ) { this . _categoriesSubscription . dispose ( ) ; } } ko . components . register ( "svc-toolbox" , { viewModel : { createViewModel : ( params , componentInfo ) => { const model = new ToolboxViewModel ( params . model ) ; return model ; } , } , template : template } ) ;