-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent.ts
More file actions
39 lines (33 loc) · 985 Bytes
/
component.ts
File metadata and controls
39 lines (33 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { ExternalElementNodePropsType } from 'omnia-component-framework';
import { getReadOnly, getValue } from '../../helpers';
class InputBoolean extends HTMLInputElement {
private _renderProps?: ExternalElementNodePropsType;
constructor() {
super();
this.type = 'checkbox';
this.onchange = this.onChange.bind(this);
}
setRenderProps(renderProps: ExternalElementNodePropsType) {
this.removeAttribute('style');
this.className = renderProps.className;
Object.assign(this.style, renderProps.style);
this._renderProps = renderProps;
this.checked = getValue(renderProps.attributes);
this.disabled = getReadOnly(renderProps.attributes);
}
onChange(e) {
this._renderProps?.onUpdateBindingArrayAndExecuteEvent(
[
{
key: 'value',
value: e.target.checked,
},
],
{
name: 'OnChange',
parameters: [e.target.checked],
},
);
}
}
export default InputBoolean;