script[setup]: select-dropdown (#18427)

* script[setup]: select-dropdown

* Align value type
This commit is contained in:
Rijk van Zanten
2023-05-03 10:53:11 -04:00
committed by GitHub
parent 6f0cdd9db8
commit 4514666408

View File

@@ -18,10 +18,9 @@
</v-select>
</template>
<script lang="ts">
import { useI18n } from 'vue-i18n';
import { defineComponent, PropType } from 'vue';
<script setup lang="ts">
import { i18n } from '@/lang';
import { useI18n } from 'vue-i18n';
type Option = {
text: string;
@@ -29,41 +28,22 @@ type Option = {
children?: Option[];
};
export default defineComponent({
props: {
disabled: {
type: Boolean,
default: false,
},
value: {
type: [String, Number],
default: null,
},
choices: {
type: Array as PropType<Option[]>,
default: null,
},
icon: {
type: String,
default: null,
},
allowNone: {
type: Boolean,
default: false,
},
placeholder: {
type: String,
default: () => i18n.global.t('select_an_item'),
},
allowOther: {
type: Boolean,
default: false,
},
},
emits: ['input'],
setup() {
const { t } = useI18n();
return { t };
},
});
withDefaults(
defineProps<{
value: string | number | null;
disabled?: boolean;
choices?: Option[];
icon?: string;
allowNone?: boolean;
placeholder?: string;
allowOther?: boolean;
}>(),
{
placeholder: () => i18n.global.t('select_an_item'),
}
);
defineEmits(['input']);
const { t } = useI18n();
</script>