2021-05-22 15:29:06 -05:00
|
|
|
<template>
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
<div class="field">
|
2022-01-24 22:23:30 -06:00
|
|
|
<span class="field-title" v-if="titleComponent"><component :is="titleComponent" /></span>
|
2022-01-13 22:25:47 -06:00
|
|
|
<VueNextSelect
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
:options="options"
|
2022-01-13 22:25:47 -06:00
|
|
|
v-model="value"
|
2022-02-27 13:49:34 -06:00
|
|
|
@update:model-value="onUpdate"
|
|
|
|
:min="1"
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
label-by="label"
|
|
|
|
:placeholder="placeholder"
|
|
|
|
:close-on-select="closeOnSelect"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-05-22 15:29:06 -05:00
|
|
|
</template>
|
|
|
|
|
2022-01-13 22:25:47 -06:00
|
|
|
<script setup lang="ts">
|
2022-03-03 21:39:48 -06:00
|
|
|
import "components/common/fields.css";
|
2022-06-26 19:17:22 -05:00
|
|
|
import type { CoercableComponent } from "features/feature";
|
2024-10-20 05:47:59 -05:00
|
|
|
import { computeOptionalComponent } from "util/vue";
|
|
|
|
import { ref, toRef, unref, watch } from "vue";
|
2022-01-13 22:25:47 -06:00
|
|
|
import VueNextSelect from "vue-next-select";
|
|
|
|
import "vue-next-select/dist/index.css";
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
|
2022-01-13 22:25:47 -06:00
|
|
|
export type SelectOption = { label: string; value: unknown };
|
|
|
|
|
2022-02-27 13:49:34 -06:00
|
|
|
const props = defineProps<{
|
2022-01-24 22:25:34 -06:00
|
|
|
title?: CoercableComponent;
|
|
|
|
modelValue?: unknown;
|
|
|
|
options: SelectOption[];
|
|
|
|
placeholder?: string;
|
|
|
|
closeOnSelect?: boolean;
|
|
|
|
}>();
|
2022-01-13 22:25:47 -06:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(e: "update:modelValue", value: unknown): void;
|
|
|
|
}>();
|
|
|
|
|
2022-02-27 13:49:34 -06:00
|
|
|
const titleComponent = computeOptionalComponent(toRef(props, "title"), "span");
|
2022-01-13 22:25:47 -06:00
|
|
|
|
2022-05-10 23:37:43 -05:00
|
|
|
const value = ref<SelectOption | null>(
|
|
|
|
props.options.find(option => option.value === props.modelValue) ?? null
|
2022-02-27 13:49:34 -06:00
|
|
|
);
|
|
|
|
watch(toRef(props, "modelValue"), modelValue => {
|
2024-10-20 05:47:59 -05:00
|
|
|
if (unref(value) !== modelValue) {
|
2022-05-10 23:37:43 -05:00
|
|
|
value.value = props.options.find(option => option.value === modelValue) ?? null;
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
}
|
|
|
|
});
|
2022-02-27 13:49:34 -06:00
|
|
|
|
|
|
|
function onUpdate(value: SelectOption) {
|
|
|
|
emit("update:modelValue", value.value);
|
|
|
|
}
|
2021-05-22 15:29:06 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-select {
|
2021-05-22 15:29:06 -05:00
|
|
|
width: 50%;
|
2021-09-04 16:51:41 -05:00
|
|
|
border-radius: var(--border-radius);
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.field-buttons .vue-select {
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
width: unset;
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-select,
|
|
|
|
.vue-dropdown {
|
2021-09-04 16:51:41 -05:00
|
|
|
border-color: var(--outline);
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-dropdown {
|
2021-09-04 16:51:41 -05:00
|
|
|
background: var(--raised-background);
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-dropdown-item {
|
2022-04-23 22:34:13 -05:00
|
|
|
color: var(--foreground);
|
2021-09-04 16:51:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
.vue-dropdown-item,
|
|
|
|
.vue-dropdown-item * {
|
|
|
|
transition-duration: 0s;
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-dropdown-item.highlighted {
|
2021-09-04 16:51:41 -05:00
|
|
|
background-color: var(--highlighted);
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
2021-06-20 23:29:55 -05:00
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-dropdown-item.selected,
|
|
|
|
.vue-dropdown-item.highlighted.selected {
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
background-color: var(--bought);
|
2021-06-20 23:29:55 -05:00
|
|
|
}
|
2021-09-04 16:51:41 -05:00
|
|
|
|
2023-02-15 21:58:06 -06:00
|
|
|
.vue-input input {
|
|
|
|
font-size: inherit;
|
|
|
|
}
|
|
|
|
|
2021-09-04 16:51:41 -05:00
|
|
|
.vue-input input::placeholder {
|
|
|
|
color: var(--link);
|
|
|
|
}
|
2021-05-22 15:29:06 -05:00
|
|
|
</style>
|