Added a readonly setting to Input.

This commit is contained in:
jtuu 2019-11-21 22:16:04 +02:00
parent 02e9690187
commit 8d4b149fba

View File

@ -6,7 +6,7 @@ import { is_any_property, Property } from "../observable/property/Property";
import "./Input.css"; import "./Input.css";
import { WidgetProperty } from "../observable/property/WidgetProperty"; import { WidgetProperty } from "../observable/property/WidgetProperty";
export type InputOptions = LabelledControlOptions; export type InputOptions = { readonly?: boolean } & LabelledControlOptions;
export abstract class Input<T> extends LabelledControl { export abstract class Input<T> extends LabelledControl {
readonly element: HTMLElement; readonly element: HTMLElement;
@ -39,6 +39,12 @@ export abstract class Input<T> extends LabelledControl {
this._value.set_val(this.get_value(), { silent: false }); this._value.set_val(this.get_value(), { silent: false });
}; };
if (options) {
if (options.readonly) {
this.set_attr("readOnly", true);
}
}
this.element.append(this.input_element); this.element.append(this.input_element);
} }