UNPKG

@bokeh/bokehjs

Version:

Interactive, novel data visualization

49 lines 1.55 kB
import { DOMElement, DOMElementView } from "./dom_element"; import { Action } from "./action"; import { PlaceholderView } from "./placeholder"; import { build_views, remove_views, traverse_views } from "../../core/build_views"; export class TemplateView extends DOMElementView { static __name__ = "TemplateView"; _action_views = new Map(); get actions() { return this.model.actions; } get action_views() { return this.actions.map((model) => this._action_views.get(model)).filter((view) => view != null); } async _update_actions() { await build_views(this._action_views, this.actions); } *children() { yield* super.children(); yield* this.action_views; } async lazy_initialize() { await super.lazy_initialize(); await this._update_actions(); } remove() { remove_views(this._action_views); super.remove(); } update(source, i, vars, formatters) { traverse_views([this], (view) => { if (view instanceof PlaceholderView) { view.update(source, i, vars, formatters); } }); for (const action of this.action_views) { action.update(source, i, vars); } } } export class Template extends DOMElement { static __name__ = "Template"; static { this.prototype.default_view = TemplateView; this.define(({ List, Ref }) => ({ actions: [List(Ref(Action)), []], })); } } //# sourceMappingURL=template.js.map