-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent.ts
More file actions
44 lines (36 loc) · 1.21 KB
/
component.ts
File metadata and controls
44 lines (36 loc) · 1.21 KB
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
40
41
42
43
44
import { ExternalElementNodePropsType } from 'omnia-component-framework';
import { getAttributeValue, getReadOnly, getValue } from '../../helpers';
class InputInteger extends HTMLInputElement {
private _renderProps?: ExternalElementNodePropsType;
constructor() {
super();
this.type = 'number';
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.valueAsNumber = getValue(renderProps.attributes);
this.readOnly = getReadOnly(renderProps.attributes);
this.max = getAttributeValue(renderProps.attributes, 'maximumValue', undefined);
this.min = getAttributeValue(renderProps.attributes, 'minimumValue', undefined);
}
onChange(event: Event) {
const value = (event?.target as HTMLInputElement)?.valueAsNumber;
this._renderProps?.onUpdateBindingArrayAndExecuteEvent(
[
{
key: 'value',
value: value,
},
],
{
name: 'OnChange',
parameters: [value],
},
);
}
}
export default InputInteger;