This repository was archived by the owner on Jun 27, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 145
/
Copy pathTableFilter.vue
82 lines (76 loc) · 2.09 KB
/
TableFilter.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<template>
<ButtonWithDropdown
placement="bottom-end"
dusk="filters-dropdown"
:active="hasEnabledFilters"
>
<template #button>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
:class="{
'text-gray-400': !hasEnabledFilters,
'text-green-400': hasEnabledFilters,
}"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M3 3a1 1 0 011-1h12a1 1 0 011 1v3a1 1 0 01-.293.707L12 11.414V15a1 1 0 01-.293.707l-2 2A1 1 0 018 17v-5.586L3.293 6.707A1 1 0 013 6V3z"
clip-rule="evenodd"
/>
</svg>
</template>
<div
role="menu"
aria-orientation="horizontal"
aria-labelledby="filter-menu"
class="min-w-max"
>
<div
v-for="(filter, key) in filters"
:key="key"
class="rounded-md dark:bg-gray-700"
>
<h3 class="text-xs uppercase tracking-wide bg-gray-100 p-3 dark:text-gray-100 dark:bg-gray-700 dark:rounded-md">
{{ filter.label }}
</h3>
<div class="p-2">
<select
v-if="filter.type === 'select'"
:name="filter.key"
:value="filter.value"
class="block focus:ring-indigo-500 focus:border-indigo-500 w-full shadow-sm text-sm border-gray-300 rounded-md dark:bg-gray-600 dark:text-gray-100 dark:border-gray-500"
@change="onFilterChange(filter.key, $event.target.value)"
>
<option
v-for="(option, optionKey) in filter.options"
:key="optionKey"
:value="optionKey"
>
{{ option }}
</option>
</select>
</div>
</div>
</div>
</ButtonWithDropdown>
</template>
<script setup>
import ButtonWithDropdown from "./ButtonWithDropdown.vue";
defineProps({
hasEnabledFilters: {
type: Boolean,
required: true,
},
filters: {
type: Object,
required: true,
},
onFilterChange: {
type: Function,
required: true,
},
});
</script>