File tree Expand file tree Collapse file tree
apps/modeling-commons-frontend/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change 220220 transform : translateX (30px );
221221}
222222
223+ .fade-in {
224+ animation : fadeIn 0.4s ease-out ;
225+ }
226+
227+ @keyframes fadeIn {
228+ from {
229+ opacity : 0 ;
230+ }
231+ to {
232+ opacity : 1 ;
233+ }
234+ }
235+
223236.border-dashed-stylized {
224237 background-image : url (" data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='8' ry='8' stroke='%238375E7FF' stroke-width='4' stroke-dasharray='8%2c8' stroke-dashoffset='0' stroke-linecap='butt'/%3e%3c/svg%3e" );
225238 border-radius : var (--radius-md );
Original file line number Diff line number Diff line change 11<template >
22 <USelectMenu
3+ ref="selectMenu"
34 v-model =" selected "
45 v-model :search-term =" searchTerm "
56 placeholder="NetLogo Version"
67 :items =" items "
78 icon="i-lucide-box"
89 :loading =" loading "
910 >
11+ <template v-if =" selected ?.value " #content-bottom >
12+ <div class =" px-2 py-1 border-t border-muted fade-in" >
13+ <UButton variant="link" color="error" size="xs" class="w-full" icon="i-lucide-x" @click .stop =" clearSelection " >
14+ <span class =" text-sm" >Clear selected version</span >
15+ </UButton >
16+ </div >
17+ </template >
1018 <template #empty >
1119 <UEmpty
1220 icon="i-lucide-box"
1927</template >
2028
2129<script lang="ts">
30+ import type { USelectMenu } from ' #components' ;
31+
2232export type NetLogoVersionItem = { label: string ; value: string };
2333export const toNetLogoVersionItem = (version : string ): NetLogoVersionItem => ({
2434 label: version ,
@@ -39,4 +49,12 @@ const selected = defineModel<NetLogoVersionItem | undefined>({
3949 default: undefined ,
4050});
4151const searchTerm = defineModel <string >(" search-term" , { type: String , default: " " });
52+
53+ const ref = useTemplateRef (" selectMenu" );
54+
55+ function clearSelection() {
56+ selected .value = undefined ;
57+ searchTerm .value = " " ;
58+ ref .value ?.triggerRef .click ();
59+ }
4260 </script >
Original file line number Diff line number Diff line change 77 :items =" userMenuItems "
88 virtualize
99 :loading =" loading "
10+ clear
1011 >
12+ <template v-if =" selectedUser ?.value " #content-bottom >
13+ <div class =" px-2 py-1 border-t border-muted fade-in" >
14+ <UButton variant="link" color="error" size="xs" class="w-full" icon="i-lucide-x" @click .stop =" clearSelection " >
15+ <span class =" text-sm" >Clear selected user</span >
16+ </UButton >
17+ </div >
18+ </template >
1119 <template #empty >
1220 <UEmpty
1321 icon="i-lucide-users"
@@ -67,13 +75,19 @@ const userMenuItems = computed<UserSelectMenuItem[]>(() => {
6775 }
6876 return [... props .users .map (toUserSelectMenuItem )];
6977});
70- const selectedUser = defineModel <UserSelectMenuItem >({
71- type: Object as () => UserSelectMenuItem ,
72- default: null ,
78+ const selectedUser = defineModel <UserSelectMenuItem | undefined >({
79+ type: Object as () => UserSelectMenuItem | undefined ,
80+ default: undefined ,
7381});
7482const searchTerm = defineModel <string >(" search-term" , { type: String , default: " " });
7583const selectMenu = useTemplateRef (" selectMenu" );
7684
85+ function clearSelection() {
86+ selectedUser .value = undefined ;
87+ searchTerm .value = " " ;
88+ selectMenu .value ?.triggerRef .click ();
89+ }
90+
7791onMounted (() => {
7892 useInfiniteScroll (
7993 // @ts-expect-error -- need to update @nuxt/ui for this to work
You can’t perform that action at this time.
0 commit comments