salix/front/core/lib/input.js

43 lines
789 B
JavaScript
Raw Normal View History

2017-11-16 13:30:17 +00:00
import Component from './component';
/**
* Component that host an input.
*/
export default class Input extends Component {
constructor($element, $scope) {
super($element, $scope);
this.input = this.element.querySelector('input');
}
2019-09-30 09:30:54 +00:00
set disabled(value) {
this.input.disabled = value == true;
this.mdlUpdate();
}
2019-09-30 09:30:54 +00:00
get disabled() {
return this.input.disabled;
}
2019-09-30 09:30:54 +00:00
2017-11-16 13:30:17 +00:00
select() {
this.input.select();
}
2019-09-30 09:30:54 +00:00
2017-11-16 13:30:17 +00:00
focus() {
this.input.focus();
}
2019-09-30 09:30:54 +00:00
mdlUpdate() {
if (this.mdlElement)
this.mdlElement.updateClasses_();
}
2017-11-16 13:30:17 +00:00
}
Input.$inject = ['$element', '$scope'];
2019-09-30 09:30:54 +00:00
2019-10-09 22:47:29 +00:00
export const $options = {
2019-09-30 09:30:54 +00:00
bindings: {
label: '@?',
disabled: '<?',
2019-10-09 22:47:29 +00:00
readonly: '<?'
2019-09-30 09:30:54 +00:00
}
};