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