-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathInputWidget.js
80 lines (68 loc) · 1.69 KB
/
InputWidget.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import _ from 'lodash';
import Element from '../Element';
export default class InputWidget extends Element {
static get defaultSettings() {
return {
type: 'input'
};
}
constructor(settings, component, instance, index) {
super(settings);
this.valueIndex = index || 0;
this.componentInstance = instance;
this.namespace = 'formio.widget';
this.component = component || {};
this.settings = _.merge({}, this.defaultSettings, settings || {});
}
attach(input) {
this._input = input;
return Promise.resolve();
}
get defaultSettings() {
return {};
}
set disabled(disabled) {
if (disabled) {
this._input.setAttribute('disabled', 'disabled');
}
else {
this._input.removeAttribute('disabled');
}
}
get input() {
return this._input;
}
getValue() {
return this._input.value;
}
getValueAsString(value) {
return value;
}
get validationValue() {
return this.dataValue;
}
addPrefix() {
return null;
}
addSuffix() {
return null;
}
setValue(value) {
this._input.value = value;
}
evalContext(additional) {
return super.evalContext(Object.assign({
component: this.component,
row: this.componentInstance.data,
rowIndex: this.componentInstance.rowIndex,
data: this.componentInstance.rootValue,
value: this.componentInstance.dataValue,
t: this.t.bind(this),
submission: (this.componentInstance.root ? this.componentInstance.root._submission : {
data: this.componentInstance.rootValue
}),
form: this.componentInstance.root ? this.componentInstance.root._form : {},
options: this.options,
}, additional));
}
}