BookStack/resources/js/components/optional-input.js
Dan Brown 209fa04752
Some checks failed
lint-js / build (push) Has been cancelled
test-js / build (push) Has been cancelled
TS: Converted dom and keyboard nav services
2024-10-11 21:55:51 +01:00

29 lines
813 B
JavaScript

import {onSelect} from '../services/dom.ts';
import {Component} from './component';
export class OptionalInput extends Component {
setup() {
this.removeButton = this.$refs.remove;
this.showButton = this.$refs.show;
this.input = this.$refs.input;
this.setupListeners();
}
setupListeners() {
onSelect(this.removeButton, () => {
this.input.value = '';
this.input.classList.add('hidden');
this.removeButton.classList.add('hidden');
this.showButton.classList.remove('hidden');
});
onSelect(this.showButton, () => {
this.input.classList.remove('hidden');
this.removeButton.classList.remove('hidden');
this.showButton.classList.add('hidden');
});
}
}