2024-10-12 04:55:51 +08:00
|
|
|
import {onSelect} from '../services/dom.ts';
|
2023-04-19 05:20:02 +08:00
|
|
|
import {Component} from './component';
|
2020-06-27 20:29:00 +08:00
|
|
|
|
2022-11-16 00:04:46 +08:00
|
|
|
export class OptionalInput extends Component {
|
2023-04-19 05:20:02 +08:00
|
|
|
|
2020-06-27 20:29:00 +08:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-19 05:20:02 +08:00
|
|
|
}
|