@saasmakers/ui 2.0.42 → 2.0.44
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.
|
@@ -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
|
+
}
|
|
@@ -19,6 +19,7 @@ export default function useToast() {
|
|
|
19
19
|
|
|
20
20
|
const createToast = (params: {
|
|
21
21
|
action?: BaseToastAction
|
|
22
|
+
durationMs?: number
|
|
22
23
|
emoji?: string
|
|
23
24
|
i18nParams?: Record<string, number | string>
|
|
24
25
|
message: string
|
|
@@ -56,7 +57,10 @@ export default function useToast() {
|
|
|
56
57
|
existingToast.action = params.action
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
scheduleDismiss(existingToast.id,
|
|
60
|
+
scheduleDismiss(existingToast.id, {
|
|
61
|
+
durationMs: params.durationMs,
|
|
62
|
+
hasAction: !!existingToast.action,
|
|
63
|
+
})
|
|
60
64
|
|
|
61
65
|
return
|
|
62
66
|
}
|
|
@@ -70,7 +74,10 @@ export default function useToast() {
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
toasts.value.push(toast)
|
|
73
|
-
scheduleDismiss(toast.id,
|
|
77
|
+
scheduleDismiss(toast.id, {
|
|
78
|
+
durationMs: params.durationMs,
|
|
79
|
+
hasAction: !!params.action,
|
|
80
|
+
})
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
return {
|
|
@@ -123,10 +130,24 @@ function getFingerprint(params: {
|
|
|
123
130
|
return parts.join(':')
|
|
124
131
|
}
|
|
125
132
|
|
|
126
|
-
function
|
|
133
|
+
function getDismissDuration(params: {
|
|
134
|
+
durationMs?: number
|
|
135
|
+
hasAction: boolean
|
|
136
|
+
}): number {
|
|
137
|
+
if (params.durationMs !== undefined) {
|
|
138
|
+
return params.durationMs
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return (params.hasAction ? 8 : 5) * 1000
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function scheduleDismiss(toastId: string, params: {
|
|
145
|
+
durationMs?: number
|
|
146
|
+
hasAction: boolean
|
|
147
|
+
}) {
|
|
127
148
|
clearDismissTimer(toastId)
|
|
128
149
|
|
|
129
|
-
const duration = (
|
|
150
|
+
const duration = getDismissDuration(params)
|
|
130
151
|
const timer = setTimeout(() => closeToast(toastId), duration)
|
|
131
152
|
|
|
132
153
|
dismissTimers.set(toastId, timer)
|
package/nuxt.config.ts
CHANGED
|
@@ -140,11 +140,6 @@ export default defineNuxtConfig({
|
|
|
140
140
|
},
|
|
141
141
|
|
|
142
142
|
unocss: {
|
|
143
|
-
nuxtLayers: true,
|
|
144
|
-
presets: uno.presets,
|
|
145
|
-
rules: uno.rules,
|
|
146
|
-
shortcuts: uno.shortcuts,
|
|
147
|
-
theme: uno.theme,
|
|
148
143
|
content: {
|
|
149
144
|
// Force consumers to scan layer classes even when resolved from node_modules,
|
|
150
145
|
// otherwise transition utilities used only here are purged during their prod build.
|
|
@@ -152,5 +147,10 @@ export default defineNuxtConfig({
|
|
|
152
147
|
path.join(currentDir, 'app/**/*.{vue,ts}'),
|
|
153
148
|
],
|
|
154
149
|
},
|
|
150
|
+
nuxtLayers: true,
|
|
151
|
+
presets: uno.presets,
|
|
152
|
+
rules: uno.rules,
|
|
153
|
+
shortcuts: uno.shortcuts,
|
|
154
|
+
theme: uno.theme,
|
|
155
155
|
},
|
|
156
156
|
})
|