]> BookStack Code Mirror - bookstack/blob - resources/js/components/event-emit-select.js
cf0215850d07c6f4acb2c98c2899cf373e87dba0
[bookstack] / resources / js / components / event-emit-select.js
1 import {onSelect} from "../services/dom";
2
3 /**
4  * EventEmitSelect
5  * Component will simply emit an event when selected.
6  *
7  * Has one required option: "name".
8  * A name of "hello" will emit a component DOM event of
9  * "event-emit-select-name"
10  *
11  * All options will be set as the "detail" of the event with
12  * their values included.
13  *
14  * @extends {Component}
15  */
16 class EventEmitSelect {
17     setup() {
18         this.container = this.$el;
19         this.name = this.$opts.name;
20
21
22         onSelect(this.$el, () => {
23             this.$emit(this.name, this.$opts);
24         });
25     }
26
27 }
28
29 export default EventEmitSelect;