diff --git a/frontend/components/global/Select.vue b/frontend/components/global/Select.vue index 0b62161..6c943cb 100644 --- a/frontend/components/global/Select.vue +++ b/frontend/components/global/Select.vue @@ -2,45 +2,63 @@ // types type Props = { + variant?: "solid" | "outlined"; + disabled?: boolean; modelValue: string; + error?: boolean; options: string[]; - placeholder: string; + placeholder?: string; }; -type Emit = { +type Emits = { "update:modelValue": [value: string]; }; // props -const props = defineProps(); +const props = withDefaults(defineProps(), { + variant: "solid", + disabled: false, + placeholder: "وارد نشده", +}); -const { modelValue } = toRefs(props); +const { modelValue, variant, error } = toRefs(props); // emit -const emit = defineEmits(); +const emit = defineEmits(); -// state +// computed const selectedValue = computed({ - get: () => modelValue.value, + get: () => modelValue.value ?? undefined, set: (value: string) => emit("update:modelValue", value), }); +const classes = computed(() => { + return [ + "flex items-center text-black justify-between cursor-text transition-all border-[1.5px] gap-3 typo-label-md px-4 py-3.5 selection:bg-slate-100 rounded-100 flex-1 w-full outline-none", + { + "input-solid": variant.value === "solid", + "input-outlined": variant.value === "outlined", + "input-effects": !error.value, + [variant.value === "solid" + ? "input-solid-error" + : "input-outlined-error"]: error.value, + }, + ]; +}); + // watch