@redseed/redseed-ui-vue3 8.16.0 → 8.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { useId } from 'vue'
|
|
2
3
|
import { Card, CardHeader } from '../Card'
|
|
3
4
|
import Tr from './Tr.vue'
|
|
4
5
|
import Th from './Th.vue'
|
|
5
6
|
import Td from './Td.vue'
|
|
6
7
|
|
|
8
|
+
const titleId = useId()
|
|
9
|
+
|
|
7
10
|
const props = defineProps({
|
|
8
11
|
columns: {
|
|
9
12
|
type: Array,
|
|
@@ -51,7 +54,7 @@ const props = defineProps({
|
|
|
51
54
|
<slot name="avatar"></slot>
|
|
52
55
|
</template>
|
|
53
56
|
|
|
54
|
-
<slot name="title"></slot>
|
|
57
|
+
<span :id="titleId"><slot name="title"></slot></span>
|
|
55
58
|
|
|
56
59
|
<template #badge v-if="$slots.badge">
|
|
57
60
|
<slot name="badge"></slot>
|
|
@@ -82,7 +85,10 @@ const props = defineProps({
|
|
|
82
85
|
]"
|
|
83
86
|
>
|
|
84
87
|
<div class="rsui-table__container">
|
|
85
|
-
<table
|
|
88
|
+
<table
|
|
89
|
+
:aria-labelledby="showHeader && $slots.title ? titleId : undefined"
|
|
90
|
+
>
|
|
91
|
+
<caption v-if="!showHeader && $slots.title"><slot name="title"></slot></caption>
|
|
86
92
|
<thead v-if="columns">
|
|
87
93
|
<Tr>
|
|
88
94
|
<Th v-for="column in columns"
|
|
@@ -4,6 +4,11 @@ import Icon from '../Icon/Icon.vue'
|
|
|
4
4
|
import { ArrowUpIcon, ChevronUpDownIcon } from '@heroicons/vue/24/outline'
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
|
+
scope: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: 'col',
|
|
10
|
+
validator: value => ['col', 'row', 'colgroup', 'rowgroup'].includes(value),
|
|
11
|
+
},
|
|
7
12
|
alignment: {
|
|
8
13
|
type: String,
|
|
9
14
|
default: 'left',
|
|
@@ -35,6 +40,13 @@ watch(() => props.sort, () => {
|
|
|
35
40
|
isDesc.value = props.sort === 'desc'
|
|
36
41
|
})
|
|
37
42
|
|
|
43
|
+
const ariaSort = computed(() => {
|
|
44
|
+
if (!sortable.value) return undefined
|
|
45
|
+
if (isAsc.value) return 'ascending'
|
|
46
|
+
if (isDesc.value) return 'descending'
|
|
47
|
+
return 'none'
|
|
48
|
+
})
|
|
49
|
+
|
|
38
50
|
const emit = defineEmits(['sort'])
|
|
39
51
|
|
|
40
52
|
function handleSort() {
|
|
@@ -68,13 +80,19 @@ function handleSort() {
|
|
|
68
80
|
'rsui-th--sortable': sortable,
|
|
69
81
|
},
|
|
70
82
|
]"
|
|
83
|
+
:scope="scope"
|
|
84
|
+
:aria-sort="ariaSort"
|
|
85
|
+
:tabindex="sortable ? 0 : undefined"
|
|
71
86
|
@click="handleSort"
|
|
87
|
+
@keydown.enter.prevent="handleSort"
|
|
88
|
+
@keydown.space.prevent="handleSort"
|
|
72
89
|
>
|
|
73
90
|
<div class="rsui-th__content">
|
|
74
91
|
<slot></slot>
|
|
75
92
|
|
|
76
93
|
<div v-if="sortable"
|
|
77
94
|
class="rsui-th__sort"
|
|
95
|
+
aria-hidden="true"
|
|
78
96
|
>
|
|
79
97
|
<Icon v-if="!isAsc && !isDesc"
|
|
80
98
|
class="rsui-th__sort-icon"
|
|
@@ -21,7 +21,11 @@ function handleClick() {
|
|
|
21
21
|
'rsui-tr',
|
|
22
22
|
{ 'rsui-tr--clickable': clickable },
|
|
23
23
|
]"
|
|
24
|
+
:role="clickable ? 'button' : undefined"
|
|
25
|
+
:tabindex="clickable ? 0 : undefined"
|
|
24
26
|
@click="handleClick"
|
|
27
|
+
@keydown.enter.prevent="handleClick"
|
|
28
|
+
@keydown.space.prevent="handleClick"
|
|
25
29
|
>
|
|
26
30
|
<slot></slot>
|
|
27
31
|
</tr>
|