Bokeh: 2.3.0
Python: 3.7.10
OS: WSL
I’m trying to use my custom widget but I keep getting the following error:
A minimal working example to reproduce the issue:
from bokeh.models.widgets.markups import Markup
from bokeh.core.properties import String, Dict, AnyRef
from bokeh.util.compiler import TypeScript
from bokeh.io import curdoc
TS_CODE = """
import {Markup, MarkupView} from "models/widgets/markup"
import * as p from "core/properties"
export class CustomDivView extends MarkupView {
model: CustomDiv
render(): void {
super.render()
if (this.model.render_as_text)
this.markup_el.textContent = this.model.text
else
this.markup_el.innerHTML = this.model.text
}
}
export namespace CustomDiv {
export type Attrs = p.AttrsOf<Props>
export type Props = Markup.Props & {
render_as_text: p.Property<boolean>
custom_styles: p.Property<({[key: string]: any} | null)>
}
}
export interface CustomDiv extends CustomDiv.Attrs {}
export class CustomDiv extends Markup {
properties: CustomDiv.Props
__view_type__: CustomDivView
constructor(attrs?: Partial<CustomDiv.Attrs>) {
super(attrs)
}
static init_CustomDiv(): void {
this.prototype.default_view = CustomDivView
this.define<CustomDiv.Props>(({Boolean, Nullable, Dict, String}) => ({
render_as_text: [ Boolean, false ],
custom_styles: [ Nullable(Dict(String)), null ],
}))
}
}
"""
class CustomDiv(Markup):
''' Custom Div widget.
'''
__implementation__ = TypeScript(TS_CODE)
custom_styles = Dict(String, AnyRef, default=None, help=""""
Additional CSS rules.
""")
div = CustomDiv(
text="Hello world!",
custom_styles={"div.bk.bk-clearfix": {"font-size": "30px"}}
)
curdoc().add_root(div)
P.S
I was using Bokeh v2.2.3 up until now and it worked well.