11<template >
22 <aside
33 v-if =" !collapsed"
4- class =" w-72 shrink-0 border-l border-gray-default pl-4"
4+ class =" w-72 shrink-0 pl-4"
55 >
66 <div class =" flex items-center justify-between mb-3" >
77 <h3 class =" text-sm font-bold uppercase mb-0" >
2424 >{{ $t('Rechercher') }}</label >
2525 <input
2626 :id =" searchId"
27- v-model =" search"
27+ :value =" search"
2828 type =" search"
2929 class =" w-full border border-gray-default rounded px-2.5 py-1.5 text-sm"
3030 :placeholder =" $t('Rechercher')"
31+ @input =" $emit('update:search', ($event.target as HTMLInputElement).value)"
3132 >
3233 </div >
3334
3435 <div class =" space-y-4 overflow-y-auto max-h-[60vh]" >
3536 <div
36- v-for =" group in filteredGroups "
37+ v-for =" group in resources "
3738 :key =" group.type"
3839 >
3940 <div class =" text-xs text-gray-plain font-bold uppercase mb-1.5 border-b border-gray-default pb-1" >
8081</template >
8182
8283<script setup lang="ts">
83- import { computed , useId } from ' vue'
84+ import { useId } from ' vue'
8485import { ResourceIcon , getResourceLabel , type Resource , type ResourceType } from ' @datagouv/components-next'
8586import { RiArrowRightSLine , RiArrowLeftSLine } from ' @remixicon/vue'
8687
@@ -89,30 +90,18 @@ export interface ResourceGroup {
8990 items: Resource []
9091}
9192
92- const props = defineProps <{
93+ defineProps <{
9394 resources: ResourceGroup []
9495 selectedResourceId: string | null
9596 collapsed: boolean
97+ search: string
9698}>()
9799
98100defineEmits <{
99101 ' select' : [resource : Resource ]
100102 ' update:collapsed' : [value : boolean ]
103+ ' update:search' : [value : string ]
101104}>()
102105
103106const searchId = useId ()
104- const search = ref (' ' )
105-
106- const filteredGroups = computed (() => {
107- const q = search .value .toLowerCase ().trim ()
108- if (! q ) return props .resources .filter (g => g .items .length > 0 )
109- return props .resources
110- .map (group => ({
111- ... group ,
112- items: group .items .filter (r =>
113- (r .title || ' ' ).toLowerCase ().includes (q ),
114- ),
115- }))
116- .filter (g => g .items .length > 0 )
117- })
118107 </script >
0 commit comments