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.
ygdc/assets/js/components/dialog.js

27 lines
909 B

2 months ago
import { ref, computed } from "vue";
import { getId } from "../handlers.js";
import { handleActive, ArrowVerticalKeyHandler, ArrowHorizontalKeyHandler, NumberKeyHandler } from "../handlers.js";
const html = (v) => { return v[0] };
export default {
props: ['active', 'title', 'text', 'buttons', "withshortkey", "stack"],
setup(props, { emit }) {
const handlers = [ArrowHorizontalKeyHandler];
if (props.withshortkey) {
handlers.push(NumberKeyHandler);
2 months ago
console.log(handlers);
2 months ago
}
handleActive(props, handlers);
const elements = computed(() => props.buttons.map((i) => { i.onClick = () => emit('resolve', i.result ); return i; }) );
return { elements }
},
template: html`
<div class="dialog overlay" v-if="active">
<h2>{{ title }}</h2>
<p>{{ text }}</p>
<d-list :elements="elements" type="horizontal" :withshortkey="withshortkey"></d-list>
</div>
`
}