Dominik Baranec
Dominik Baranec
NNuxt
Created by Dominik Baranec on 9/12/2024 in #❓・help
SelectMenu trailing Button NuxtUI
Hi, i try use trailing slot for my button, it is rendered but i can not clink on it ?
<script setup lang="ts">
import { useField } from "vee-validate";
import { IsSelectVariant } from "~/types/variants";
import type { CodebookDto } from "~~/apis/client-is/models";

const props = withDefaults(
defineProps<{
label: string;
name: string;
options: Array<any> | Array<CodebookDto> | undefined;
optionAttribute?: string;
valueAttribute?: string;
variant?: IsSelectVariant;
}>(),
{
variant: IsSelectVariant.default,
optionAttribute: "value",
valueAttribute: "id",
}
);

const emit = defineEmits(["update:modelValue"]);

const { value: modelValueProxy, errorMessage } = useField<string>(props.name);

const fieldProps = computed(() => ({
error: errorMessage.value,
}));
</script>

<template>
<UFormGroup
:label="props.label"
:name="props.name"
v-bind="fieldProps"
:hint="props.variant == IsSelectVariant.optional ? '(nepovinný údaj)' : ''"
>
<USelectMenu
v-model="modelValueProxy"
:options="props.options"
:optionAttribute="props.optionAttribute"
:valueAttribute="props.valueAttribute"
>
<template #empty>Zoznam je prázdny </template>
<template #trailing>
<UButton
v-show="modelValueProxy != null"
color="gray"
variant="link"
icon="i-heroicons-x-mark-20-solid"
:padded="false"
@click="console.log('clear')"
/>
</template>
</USelectMenu>
</UFormGroup>
</template>
<script setup lang="ts">
import { useField } from "vee-validate";
import { IsSelectVariant } from "~/types/variants";
import type { CodebookDto } from "~~/apis/client-is/models";

const props = withDefaults(
defineProps<{
label: string;
name: string;
options: Array<any> | Array<CodebookDto> | undefined;
optionAttribute?: string;
valueAttribute?: string;
variant?: IsSelectVariant;
}>(),
{
variant: IsSelectVariant.default,
optionAttribute: "value",
valueAttribute: "id",
}
);

const emit = defineEmits(["update:modelValue"]);

const { value: modelValueProxy, errorMessage } = useField<string>(props.name);

const fieldProps = computed(() => ({
error: errorMessage.value,
}));
</script>

<template>
<UFormGroup
:label="props.label"
:name="props.name"
v-bind="fieldProps"
:hint="props.variant == IsSelectVariant.optional ? '(nepovinný údaj)' : ''"
>
<USelectMenu
v-model="modelValueProxy"
:options="props.options"
:optionAttribute="props.optionAttribute"
:valueAttribute="props.valueAttribute"
>
<template #empty>Zoznam je prázdny </template>
<template #trailing>
<UButton
v-show="modelValueProxy != null"
color="gray"
variant="link"
icon="i-heroicons-x-mark-20-solid"
:padded="false"
@click="console.log('clear')"
/>
</template>
</USelectMenu>
</UFormGroup>
</template>
6 replies
NNuxt
Created by Dominik Baranec on 8/27/2024 in #❓・help
NuxtUI UInput file
<UInput type="file" size="sm" multiple icon="i-heroicons-folder" @change="(event) => onFileChange(event)" ></UInput> how can i change default text for Choose Files and No file choosen?
1 replies