@saasmakers/ui 2.0.41 → 2.0.43
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.
|
@@ -181,6 +181,7 @@ defineExpose({
|
|
|
181
181
|
:id="id"
|
|
182
182
|
ref="input"
|
|
183
183
|
:autocomplete="autocomplete ? 'on' : 'off'"
|
|
184
|
+
v-bind="autofocus ? { 'data-autofocus': '' } : {}"
|
|
184
185
|
class="h-full w-full appearance-none items-center rounded-lg font-medium tracking-tight outline-none placeholder-gray-600 dark:placeholder-gray-400"
|
|
185
186
|
:class="{
|
|
186
187
|
'uppercase': uppercase,
|
|
@@ -75,8 +75,12 @@ export default function useDialog(
|
|
|
75
75
|
|
|
76
76
|
if (panelRef.value) {
|
|
77
77
|
const focusableElements = getFocusableElements(panelRef.value)
|
|
78
|
+
const autofocusTarget = panelRef.value.querySelector<HTMLElement>('[data-autofocus]')
|
|
78
79
|
|
|
79
|
-
if (
|
|
80
|
+
if (autofocusTarget) {
|
|
81
|
+
autofocusTarget.focus()
|
|
82
|
+
}
|
|
83
|
+
else if (focusableElements.length > 0) {
|
|
80
84
|
focusableElements[0].focus()
|
|
81
85
|
}
|
|
82
86
|
else {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Always-mounted hidden input used to open the mobile keyboard within the user
|
|
2
|
+
// gesture, before any async work (network create) breaks user activation.
|
|
3
|
+
// Kept at module scope so every consumer shares the same singleton input.
|
|
4
|
+
let warmupInput: HTMLInputElement | undefined
|
|
5
|
+
|
|
6
|
+
export default function useKeyboardWarmup() {
|
|
7
|
+
const { isDesktopBrowser } = useDevice()
|
|
8
|
+
|
|
9
|
+
function ensureWarmupInput() {
|
|
10
|
+
if (!import.meta.client || warmupInput) {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const input = document.createElement('input')
|
|
15
|
+
|
|
16
|
+
input.type = 'text'
|
|
17
|
+
input.tabIndex = -1
|
|
18
|
+
|
|
19
|
+
input.setAttribute('aria-hidden', 'true')
|
|
20
|
+
|
|
21
|
+
input.style.cssText = 'position:fixed;top:0;left:0;height:1px;width:1px;opacity:0;pointer-events:none;'
|
|
22
|
+
|
|
23
|
+
document.body.appendChild(input)
|
|
24
|
+
|
|
25
|
+
warmupInput = input
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Must run synchronously inside a user gesture. Focusing a real text input
|
|
29
|
+
// raises the on-screen keyboard; a later text-to-text focus move (to the
|
|
30
|
+
// profile name field) keeps it open without needing a fresh gesture.
|
|
31
|
+
function focusWarmupInput() {
|
|
32
|
+
if (isDesktopBrowser.value) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
ensureWarmupInput()
|
|
37
|
+
warmupInput?.focus()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
ensureWarmupInput,
|
|
42
|
+
focusWarmupInput,
|
|
43
|
+
}
|
|
44
|
+
}
|