@redseed/redseed-ui-vue3 8.34.0 → 8.35.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,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, ref } from 'vue'
|
|
2
|
+
import { computed, ref, useSlots } from 'vue'
|
|
3
3
|
import { useResponsiveWidth } from '../../helpers'
|
|
4
4
|
|
|
5
5
|
const props = defineProps({
|
|
@@ -59,10 +59,16 @@ const props = defineProps({
|
|
|
59
59
|
type: String,
|
|
60
60
|
default: undefined,
|
|
61
61
|
},
|
|
62
|
+
phComponent: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: 'Card',
|
|
65
|
+
},
|
|
62
66
|
})
|
|
63
67
|
|
|
64
68
|
const emit = defineEmits(['click'])
|
|
65
69
|
|
|
70
|
+
const slots = useSlots()
|
|
71
|
+
|
|
66
72
|
const cardElement = ref(null)
|
|
67
73
|
const { responsiveWidth } = useResponsiveWidth(cardElement)
|
|
68
74
|
|
|
@@ -91,6 +97,28 @@ const cardClass = computed(() => [
|
|
|
91
97
|
}
|
|
92
98
|
])
|
|
93
99
|
|
|
100
|
+
// PostHog autocapture reads the accessible name off the action layer. The
|
|
101
|
+
// ariaLabel prop covers the prop path, but cards commonly supply their label
|
|
102
|
+
// via the #aria-label slot (see ButtonCard / MetricCard), where the prop is
|
|
103
|
+
// undefined. Mirror the slot's text so slot-labelled cards still emit a named
|
|
104
|
+
// capture event instead of an unlabeled one.
|
|
105
|
+
function slotText(nodes) {
|
|
106
|
+
if (!Array.isArray(nodes)) return ''
|
|
107
|
+
return nodes
|
|
108
|
+
.map((node) => {
|
|
109
|
+
if (typeof node.children === 'string') return node.children
|
|
110
|
+
if (Array.isArray(node.children)) return slotText(node.children)
|
|
111
|
+
return ''
|
|
112
|
+
})
|
|
113
|
+
.join('')
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const captureLabel = computed(() => {
|
|
117
|
+
if (props.ariaLabel) return props.ariaLabel
|
|
118
|
+
if (slots['aria-label']) return slotText(slots['aria-label']()).trim() || undefined
|
|
119
|
+
return undefined
|
|
120
|
+
})
|
|
121
|
+
|
|
94
122
|
function onClick() {
|
|
95
123
|
if (props.disabled) return
|
|
96
124
|
|
|
@@ -127,6 +155,8 @@ function onClick() {
|
|
|
127
155
|
:title="$attrs.title"
|
|
128
156
|
:aria-label="!$slots['aria-label'] ? ariaLabel : undefined"
|
|
129
157
|
:aria-disabled="disabled ? true : undefined"
|
|
158
|
+
:data-ph-capture-attribute-component="phComponent"
|
|
159
|
+
:data-ph-capture-attribute-label="captureLabel"
|
|
130
160
|
@click="onClick"
|
|
131
161
|
@keydown.enter.prevent="!$event.repeat && onClick()"
|
|
132
162
|
@keydown.space.prevent="!$event.repeat && onClick()"
|
|
@@ -194,6 +194,9 @@ function showPreviousSlide() {
|
|
|
194
194
|
>
|
|
195
195
|
<button class="rsui-section-slider__action"
|
|
196
196
|
:disabled="disabledPrevButton"
|
|
197
|
+
aria-label="Previous"
|
|
198
|
+
data-ph-capture-attribute-component="SectionSliderAction"
|
|
199
|
+
data-ph-capture-attribute-label="Previous"
|
|
197
200
|
@click="showPreviousSlide"
|
|
198
201
|
>
|
|
199
202
|
<Icon :invert="featured">
|
|
@@ -203,6 +206,9 @@ function showPreviousSlide() {
|
|
|
203
206
|
|
|
204
207
|
<button class="rsui-section-slider__action"
|
|
205
208
|
:disabled="disabledNextButton"
|
|
209
|
+
aria-label="Next"
|
|
210
|
+
data-ph-capture-attribute-component="SectionSliderAction"
|
|
211
|
+
data-ph-capture-attribute-label="Next"
|
|
206
212
|
@click="showNextSlide"
|
|
207
213
|
>
|
|
208
214
|
<Icon :invert="featured">
|