Skip to content

Commit

Permalink
Refactored CountSelect.
Browse files Browse the repository at this point in the history
  • Loading branch information
Utar94 committed Apr 18, 2024
1 parent 65dbde7 commit 7444889
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions frontend/src/components/shared/CountSelect.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
<script setup lang="ts">
import { TarSelect, parsingUtils, type SelectOption, type SelectSize } from "logitar-vue3-ui";
import { TarSelect, parsingUtils, type SelectOption } from "logitar-vue3-ui";
import { ref } from "vue";
import { useI18n } from "vue-i18n";
const { parseNumber } = parsingUtils;
const { t } = useI18n();
const props = withDefaults(
defineProps<{
ariaLabel?: string;
describedBy?: string;
disabled?: boolean | string;
floating?: boolean | string;
id?: string;
label?: string;
modelValue?: number;
multiple?: boolean | string;
name?: string;
options?: SelectOption[];
placeholder?: string;
required?: boolean | string;
size?: SelectSize;
}>(),
{
floating: true,
id: "count",
label: "count",
options: () => [{ text: "10" }, { text: "25" }, { text: "50" }, { text: "100" }],
},
);
defineProps<{
modelValue?: number;
}>();
const options = ref<SelectOption[]>([{ text: "10" }, { text: "25" }, { text: "50" }, { text: "100" }]);
defineEmits<{
(e: "update:model-value", value?: number): void;
Expand All @@ -36,10 +19,11 @@ defineEmits<{

<template>
<TarSelect
v-bind="props"
:aria-label="ariaLabel ? t(ariaLabel) : undefined"
:label="t(label)"
:placeholder="placeholder ? t(placeholder) : undefined"
floating
id="count"
:label="t('count')"
:model-value="modelValue"
:options="options"
@update:model-value="$emit('update:model-value', parseNumber($event))"
/>
</template>

0 comments on commit 7444889

Please sign in to comment.