You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB

2 months ago
import { nextTick, reactive, ref, computed, onMounted, onUnmounted } from "vue";
import { handleActive, ArrowVerticalKeyHandler, ArrowHorizontalKeyHandler, NumberKeyHandler } from "../handlers.js";
const html = (v) => { return v[0] };
const mappings = {
"player": ["d-playerElem", (p) => {return {"player": p} }],
"scorer": ["d-scorerElem", (p) => {return {"scorer": p} }],
"plain": ["d-plainElem", (p) => {return {"text": p} }],
}
2 months ago
export default {
props: ['options', 'type', 'title', 'stack', 'active', 'input'],
2 months ago
setup(props, context) {
handleActive(props, [ArrowVerticalKeyHandler, NumberKeyHandler]);
2 months ago
const children = computed(() => {
2 months ago
return props.options.map((o) => {
2 months ago
return {
component: props.type ? mappings[props.type][0] : "d-plainElem",
props: props.type ? mappings[props.type][1](o) : {"text": o},
2 months ago
onClick: () => {
2 months ago
context.emit('resolve', o);
2 months ago
}
}
})
});
return { children }
},
template: html`
<div class="playerselect">
2 months ago
<d-list :title="title" :withshortkey="true" :elements="children"/>
2 months ago
</div>
`
}