srcdev-nuxt-components 6.1.41 → 6.1.42
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.
|
@@ -49,11 +49,14 @@
|
|
|
49
49
|
* v-model="showToast"
|
|
50
50
|
* :config="{
|
|
51
51
|
* appearance: { theme: 'success', position: 'top', alignment: 'right' },
|
|
52
|
-
* behavior: { autoDismiss: true, duration: 3000 },
|
|
52
|
+
* behavior: { autoDismiss: true, duration: 3000, returnFocusTo: buttonRef },
|
|
53
53
|
* content: { text: 'Operation completed successfully!' }
|
|
54
54
|
* }"
|
|
55
55
|
* />
|
|
56
56
|
*
|
|
57
|
+
* The returnFocusTo property accepts an HTMLElement or ComponentPublicInstance
|
|
58
|
+
* and will focus that element when the toast is dismissed for better accessibility.
|
|
59
|
+
*
|
|
57
60
|
* Types exported for use in other components:
|
|
58
61
|
* - DisplayToastConfig
|
|
59
62
|
* - DisplayToastProps
|
|
@@ -88,6 +91,7 @@ export interface DisplayToastBehaviorConfig {
|
|
|
88
91
|
autoDismiss?: boolean
|
|
89
92
|
duration?: number
|
|
90
93
|
revealDuration?: number
|
|
94
|
+
returnFocusTo?: HTMLElement | ComponentPublicInstance | null
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
export interface DisplayToastContentConfig {
|
|
@@ -157,6 +161,7 @@ const fullWidth = computed(() => props.config?.appearance?.fullWidth ?? false)
|
|
|
157
161
|
const autoDismiss = computed(() => props.config?.behavior?.autoDismiss ?? true)
|
|
158
162
|
const duration = computed(() => props.config?.behavior?.duration ?? 5000)
|
|
159
163
|
const revealDuration = computed(() => props.config?.behavior?.revealDuration ?? 550)
|
|
164
|
+
const returnFocusTo = computed(() => props.config?.behavior?.returnFocusTo ?? null)
|
|
160
165
|
const toastDisplayText = computed(() => props.config?.content?.text ?? "")
|
|
161
166
|
const customIcon = computed(() => props.config?.content?.customIcon)
|
|
162
167
|
|
|
@@ -209,6 +214,23 @@ const displayDurationMs = computed(() => duration.value + "ms")
|
|
|
209
214
|
const setDismissToast = async () => {
|
|
210
215
|
transitionalState.value = false
|
|
211
216
|
await useSleep(revealDuration.value)
|
|
217
|
+
|
|
218
|
+
// Return focus to specified element if provided
|
|
219
|
+
if (returnFocusTo.value) {
|
|
220
|
+
// Handle both HTMLElement and ComponentPublicInstance
|
|
221
|
+
let focusTarget: HTMLElement | null = null
|
|
222
|
+
|
|
223
|
+
if (returnFocusTo.value instanceof HTMLElement) {
|
|
224
|
+
focusTarget = returnFocusTo.value
|
|
225
|
+
} else if (returnFocusTo.value && "$el" in returnFocusTo.value) {
|
|
226
|
+
focusTarget = returnFocusTo.value.$el as HTMLElement
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (focusTarget && typeof focusTarget.focus === "function") {
|
|
230
|
+
focusTarget.focus()
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
212
234
|
externalTriggerModel.value = false
|
|
213
235
|
privateDisplayToast.value = false
|
|
214
236
|
}
|
package/package.json
CHANGED