Skip to content

Commit

Permalink
vue-selectのimportがうまくいかない
Browse files Browse the repository at this point in the history
  • Loading branch information
reiroop committed Mar 26, 2024
1 parent b2e511f commit 7801174
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"vue": "^3.3.4",
"vue-multiselect": "^3.0.0-beta.3",
"vue-router": "^4.1.5",
"vue-select": "^4.0.0-beta.6",
"vue-slider-component": "^4.0.0-beta.9",
"zod": "^3.22.4"
},
Expand Down
32 changes: 17 additions & 15 deletions src/components/UI/FormSelectorFilterable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
<label v-if="label" :for="id" :class="$style.label">
{{ label }}
</label>
<vue-multiselect
<v-select
:id="id"
v-model="selectedOption"
:options="options"
track-by="key"
label="key"
:class="$style.inputContainer"
@select="updateModelValue"
></vue-multiselect>
:class="$style.multiselect"
@option:selected="updateModelValue"
>
<template #option="p">
<div :class="$style.option">{{ p.option.key }}</div>
</template>
</v-select>
</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { randomString } from '/@/lib/basic/randomString'
import VueMultiselect from 'vue-multiselect'

Check warning on line 24 in src/components/UI/FormSelectorFilterable.vue

View workflow job for this annotation

GitHub Actions / run lint

'VueMultiselect' is defined but never used
import vSelect from 'vue-select'

Check failure on line 25 in src/components/UI/FormSelectorFilterable.vue

View workflow job for this annotation

GitHub Actions / run type-check

Could not find a declaration file for module 'vue-select'. '/home/runner/work/traQ_S-UI/traQ_S-UI/node_modules/vue-select/dist/vue-select.umd.js' implicitly has an 'any' type.
import 'vue-select/dist/vue-select.css'
type Option = { key: string; value: string | null }
const props = withDefaults(
Expand All @@ -40,7 +45,9 @@ const emit = defineEmits<{
(e: 'update:modelValue', _val: string | null): void
}>()
const selectedOption = ref<Option | null>(null)
const selectedOption = ref<Option | null>(
props.options.find(o => o.value === props.modelValue) ?? null
)
const updateModelValue = (selectedOption: Option) => {
emit('update:modelValue', selectedOption?.value ?? null)
}
Expand All @@ -53,25 +60,20 @@ const id = randomString()
margin-bottom: 4px;
display: block;
}
.inputContainer {
.multiselect {
@include color-ui-primary;
@include background-secondary;
@include size-body1;
height: 30px;
border-radius: 4px;
&[data-on-secondary] {
@include background-primary;
}
border: solid 2px transparent;
&:focus-within {
border-color: $theme-accent-focus-default;
}
}
.select {
margin: 0 8px;
.option {
@include color-ui-primary;
@include background-secondary;
width: 100%;
color: inherit;
background: inherit;
}
</style>

0 comments on commit 7801174

Please sign in to comment.