@bokeh/bokehjs
Version:
Interactive, novel data visualization
42 lines • 1.32 kB
JavaScript
import { Widget, WidgetView } from "./widget";
import { div } from "../../core/dom";
import * as toggle_input_css from "../../styles/widgets/toggle_input.css";
export class ToggleInputView extends WidgetView {
static __name__ = "ToggleInputView";
label_el;
stylesheets() {
return [...super.stylesheets(), toggle_input_css.default];
}
connect_signals() {
super.connect_signals();
const { active, disabled, label } = this.model.properties;
this.on_change(active, () => this._update_active());
this.on_change(disabled, () => this._update_disabled());
this.on_change(label, () => this._update_label());
}
_toggle_active() {
if (!this.model.disabled) {
this.model.active = !this.model.active;
}
}
render() {
super.render();
this.label_el = div({ class: toggle_input_css.label }, this.model.label);
}
_update_label() {
this.label_el.textContent = this.model.label;
}
}
export class ToggleInput extends Widget {
static __name__ = "ToggleInput";
constructor(attrs) {
super(attrs);
}
static {
this.define(({ Bool, Str }) => ({
active: [Bool, false],
label: [Str, ""],
}));
}
}
//# sourceMappingURL=toggle_input.js.map