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-07-04 23:53:02 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* EventEmitSelect
|
|
|
|
* Component will simply emit an event when selected.
|
|
|
|
*
|
|
|
|
* Has one required option: "name".
|
|
|
|
* A name of "hello" will emit a component DOM event of
|
|
|
|
* "event-emit-select-name"
|
|
|
|
*
|
|
|
|
* All options will be set as the "detail" of the event with
|
|
|
|
* their values included.
|
|
|
|
*/
|
2023-04-19 05:20:02 +08:00
|
|
|
export class EventEmitSelect extends Component {
|
|
|
|
|
2020-07-04 23:53:02 +08:00
|
|
|
setup() {
|
|
|
|
this.container = this.$el;
|
|
|
|
this.name = this.$opts.name;
|
|
|
|
|
|
|
|
onSelect(this.$el, () => {
|
|
|
|
this.$emit(this.name, this.$opts);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-19 05:20:02 +08:00
|
|
|
}
|