@redseed/redseed-ui-vue3 8.16.0 → 8.18.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@redseed/redseed-ui-vue3",
3
- "version": "8.16.0",
3
+ "version": "8.18.0",
4
4
  "description": "RedSeed UI Vue 3 components",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/redseedtraining/redseed-ui",
@@ -17,7 +17,7 @@ const buttonGroupClass = computed(() => [
17
17
 
18
18
  </script>
19
19
  <template>
20
- <div :class="buttonGroupClass">
20
+ <div :class="buttonGroupClass" role="group">
21
21
  <slot></slot>
22
22
  </div>
23
23
  </template>
@@ -23,6 +23,8 @@ const buttonClass = computed(() => [
23
23
  <template>
24
24
  <button
25
25
  :class="buttonClass"
26
+ type="button"
27
+ :aria-pressed="selected"
26
28
  v-bind="$attrs"
27
29
  @click="$emit('click', $event)"
28
30
  >
@@ -16,12 +16,22 @@ const props = defineProps({
16
16
  }
17
17
  ]"
18
18
  clickable
19
- hoverable
19
+ :hoverable="!disabled"
20
20
  :disabled="disabled"
21
21
  >
22
+ <template v-if="$slots['aria-label']" #aria-label>
23
+ <slot name="aria-label"></slot>
24
+ </template>
25
+
22
26
  <div class="rsui-button-card__content">
23
27
  <div v-if="$slots.icon"
24
- class="rsui-button-card__icon"
28
+ :class="[
29
+ 'rsui-button-card__icon',
30
+ {
31
+ 'rsui-button-card__icon--disabled': disabled,
32
+ }
33
+ ]"
34
+ aria-hidden="true"
25
35
  >
26
36
  <slot name="icon"></slot>
27
37
  </div>
@@ -115,7 +115,21 @@ function onClick() {
115
115
  stroke-linecap="square"
116
116
  ></rect>
117
117
  </svg>
118
- <div v-if="clickable" class="rsui-card__action-layer" :title="$attrs.title" @click="onClick"></div>
118
+ <div
119
+ v-if="clickable"
120
+ class="rsui-card__action-layer"
121
+ role="button"
122
+ :tabindex="disabled ? undefined : 0"
123
+ :title="$attrs.title"
124
+ :aria-disabled="disabled ? true : undefined"
125
+ @click="onClick"
126
+ @keydown.enter.prevent="!$event.repeat && onClick()"
127
+ @keydown.space.prevent="!$event.repeat && onClick()"
128
+ >
129
+ <span v-if="$slots['aria-label']" class="rsui-card__action-layer-label">
130
+ <slot name="aria-label"></slot>
131
+ </span>
132
+ </div>
119
133
 
120
134
  <div v-if="$slots.image"
121
135
  class="rsui-card__image"
@@ -57,9 +57,13 @@ const linkLabelClass = computed(() => [
57
57
  <a
58
58
  :class="linkSlotClass"
59
59
  v-bind="$attrs"
60
- @click="$emit('click', $event)"
60
+ :aria-disabled="props.disabled || undefined"
61
+ :tabindex="props.disabled ? -1 : undefined"
62
+ @click="props.disabled ? $event.preventDefault() : $emit('click', $event)"
61
63
  >
62
- <slot name="icon"></slot>
64
+ <span v-if="$slots.icon" class="rsui-link-slot__icon" aria-hidden="true">
65
+ <slot name="icon"></slot>
66
+ </span>
63
67
 
64
68
  <span :class="linkLabelClass">
65
69
  <slot></slot>
@@ -44,7 +44,7 @@ const statusClass = computed(() => [
44
44
 
45
45
  <template>
46
46
  <li :class="componentClass">
47
- <div :class="statusClass">
47
+ <div :class="statusClass" aria-hidden="true">
48
48
 
49
49
  <slot name="active-icon"
50
50
  v-if="$slots['active-icon'] && isActive"
@@ -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>