-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathTableHeaderAction.vue
More file actions
65 lines (62 loc) · 1.61 KB
/
TableHeaderAction.vue
File metadata and controls
65 lines (62 loc) · 1.61 KB
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
<script setup lang="ts">
import ArrowUp from "../global/icons/ArrowUp.vue";
import ArrowDown from "../global/icons/ArrowDown.vue";
defineProps<{
column: {
id: string;
label: string;
};
schemaId: string;
tableId: string;
settings: {
orderby: {
column: string;
direction: "ASC" | "DESC";
};
};
}>();
const mgAriaSortMappings: Record<string, string> = {
ASC: "ascending",
DESC: "descending",
};
const emit = defineEmits<{
(e: "sort-requested", columnId: string): void;
}>();
</script>
<template>
<div class="flex justify-start items-center gap-1">
<button
:id="`table-emx2-${schemaId}-${tableId}-${column.label}-sort-btn`"
type="button"
@click.prevent
class="overflow-ellipsis whitespace-nowrap max-w-56 overflow-hidden inline-block text-left text-table-column-header font-normal align-middle"
:ariaSort="
settings.orderby.column === column.id
? mgAriaSortMappings[settings.orderby.direction]
: 'none'
"
>
<span
@click="emit('sort-requested', column.id)"
class="hover:cursor-pointer"
>{{ column.label }}</span
>
</button>
<ArrowUp
v-if="
column.id === settings.orderby.column &&
settings.orderby.direction === 'ASC'
"
aria-hidden="true"
class="h-4 w-4 text-table-column-header font-normal"
/>
<ArrowDown
v-if="
column.id === settings.orderby.column &&
settings.orderby.direction === 'DESC'
"
aria-hidden="true"
class="h-4 w-4 text-table-column-header font-normal"
/>
</div>
</template>