@bagelink/vue 1.22.1 → 1.22.3

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.
@@ -29,6 +29,7 @@
29
29
  import { ref, provide, onMounted, onUnmounted, computed, watch, useSlots, Comment, Text } from 'vue'
30
30
  import type { Slots } from 'vue'
31
31
  import { useEscapeKey } from '../../composables/useEscapeKey'
32
+ import { useKeyboardInset } from '../../composables/useKeyboardInset'
32
33
  import { usePointerSession } from '../../composables/usePointerSession'
33
34
  import { MOBILE_BREAKPOINT } from '../../utils/constants'
34
35
  import {
@@ -188,6 +189,8 @@ const toggleBottom = () => { regions.value.bottom.open = !regions.value.bottom.o
188
189
  const toggleMenu = toggleStart
189
190
 
190
191
  useEscapeKey(() => { isOpen.value = false }, () => isMobile.value && isOpen.value)
192
+ // Publishes `--bgl-keyboard-inset` for sticky footers / chat composers on iOS.
193
+ useKeyboardInset()
191
194
 
192
195
  function closeOnMobile() {
193
196
  if (isMobile.value) { isOpen.value = false }
@@ -9,6 +9,7 @@ export { useBoundedRectDrag } from './useBoundedRectDrag'
9
9
  export type { BoundedRectDragOptions, DragRect } from './useBoundedRectDrag'
10
10
  export { useDevice } from './useDevice'
11
11
  export { useEscapeKey } from './useEscapeKey'
12
+ export { useKeyboardInset } from './useKeyboardInset'
12
13
  export { useExcel } from './useExcel'
13
14
  export type { GradientDir, GradientDirProp, GradientProp } from './useGradientVariant'
14
15
  export { useGradientVariant } from './useGradientVariant'
@@ -0,0 +1,89 @@
1
+ import { onMounted, onUnmounted, readonly, ref } from 'vue'
2
+
3
+ /**
4
+ * Tracks the on-screen keyboard via `visualViewport` and publishes
5
+ * `--bgl-keyboard-inset` on `:root` so sticky footers / composers can lift.
6
+ *
7
+ * Gated on an editable focus — fold/unfold on iPhone Duo changes the visual
8
+ * viewport too, and must NOT be treated as a keyboard.
9
+ *
10
+ * Shared across callers (ref-counted install).
11
+ */
12
+
13
+ const MIN_KEYBOARD_PX = 80
14
+ const inset = ref(0)
15
+ let subscribers = 0
16
+ let installed = false
17
+ let blurTimer: ReturnType<typeof setTimeout> | undefined
18
+
19
+ function isEditableFocused(): boolean {
20
+ const el = document.activeElement as HTMLElement | null
21
+ if (!el) return false
22
+ const tag = el.tagName
23
+ return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || el.isContentEditable
24
+ }
25
+
26
+ function publish(px: number) {
27
+ inset.value = px
28
+ document.documentElement.style.setProperty('--bgl-keyboard-inset', `${px}px`)
29
+ }
30
+
31
+ function measure() {
32
+ const vv = window.visualViewport
33
+ if (!vv) {
34
+ publish(0)
35
+ return
36
+ }
37
+ const visibleBottom = vv.height + vv.offsetTop
38
+ const raw = Math.max(0, window.innerHeight - visibleBottom)
39
+ const next = isEditableFocused() && raw > MIN_KEYBOARD_PX ? Math.round(raw) : 0
40
+ if (next !== inset.value) publish(next)
41
+ }
42
+
43
+ function onFocusIn() {
44
+ clearTimeout(blurTimer)
45
+ // iOS keyboard animates in — remeasure a few times.
46
+ requestAnimationFrame(measure)
47
+ setTimeout(measure, 120)
48
+ setTimeout(measure, 320)
49
+ }
50
+
51
+ function onFocusOut() {
52
+ clearTimeout(blurTimer)
53
+ blurTimer = setTimeout(measure, 80)
54
+ }
55
+
56
+ function install() {
57
+ if (installed || typeof window === 'undefined') return
58
+ installed = true
59
+ window.visualViewport?.addEventListener('resize', measure)
60
+ window.visualViewport?.addEventListener('scroll', measure)
61
+ window.addEventListener('focusin', onFocusIn)
62
+ window.addEventListener('focusout', onFocusOut)
63
+ measure()
64
+ }
65
+
66
+ function uninstall() {
67
+ if (!installed) return
68
+ installed = false
69
+ clearTimeout(blurTimer)
70
+ window.visualViewport?.removeEventListener('resize', measure)
71
+ window.visualViewport?.removeEventListener('scroll', measure)
72
+ window.removeEventListener('focusin', onFocusIn)
73
+ window.removeEventListener('focusout', onFocusOut)
74
+ document.documentElement.style.removeProperty('--bgl-keyboard-inset')
75
+ inset.value = 0
76
+ }
77
+
78
+ /** Subscribe to the shared keyboard-inset tracker. Safe to call from many components. */
79
+ export function useKeyboardInset() {
80
+ onMounted(() => {
81
+ subscribers += 1
82
+ install()
83
+ })
84
+ onUnmounted(() => {
85
+ subscribers = Math.max(0, subscribers - 1)
86
+ if (subscribers === 0) uninstall()
87
+ })
88
+ return { inset: readonly(inset) }
89
+ }
@@ -172,15 +172,17 @@ defineExpose({ close })
172
172
 
173
173
  /* Base dialog styles.
174
174
  Height cascade: vh fallback → dvh (tracks iOS chrome / fold) → subtract
175
- asymmetric safe-area so content clears notch + home indicator on Duo. */
175
+ asymmetric safe-area so content clears notch + home indicator on Duo.
176
+ `--bgl-keyboard-inset` (from useKeyboardInset) lifts the dialog above the
177
+ on-screen keyboard without fighting safe-area when the keyboard is closed. */
176
178
  dialog {
177
179
  border-radius: var(--bgl-card-radius, 12px);
178
180
  max-width: var(--dialog-width);
179
181
  width: calc(100% - 2rem);
180
182
  max-height: calc(100vh - 2rem);
181
- max-height: calc(100dvh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
183
+ max-height: calc(100dvh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - var(--bgl-keyboard-inset, 0px));
182
184
  margin-top: max(1rem, env(safe-area-inset-top, 0px));
183
- margin-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
185
+ margin-bottom: max(1rem, env(safe-area-inset-bottom, 0px), var(--bgl-keyboard-inset, 0px));
184
186
  background: var(--bgl-popup-bg, #fff);
185
187
  color: var(--bgl-popup-text, black);
186
188
  }
@@ -296,11 +298,12 @@ dialog.dialog-bottom {
296
298
  width: 100%;
297
299
  max-width: 100%;
298
300
  margin-inline: 0;
299
- margin-bottom: 0;
300
- padding-bottom: env(safe-area-inset-bottom, 0px);
301
+ /* Lift above the iOS keyboard when `--bgl-keyboard-inset` is set. */
302
+ margin-bottom: var(--bgl-keyboard-inset, 0px);
303
+ padding-bottom: max(env(safe-area-inset-bottom, 0px), 0px);
301
304
  padding-left: env(safe-area-inset-left, 0px);
302
305
  padding-right: env(safe-area-inset-right, 0px);
303
- max-height: calc(100dvh - env(safe-area-inset-top, 0px));
306
+ max-height: calc(100dvh - env(safe-area-inset-top, 0px) - var(--bgl-keyboard-inset, 0px));
304
307
  box-sizing: border-box;
305
308
  }
306
309
  }
@@ -118,7 +118,8 @@
118
118
  "buttons": {
119
119
  "addCondition": "Add condition",
120
120
  "clearAll": "Clear all",
121
- "save": "Save"
121
+ "save": "Save",
122
+ "done": "Done"
122
123
  }
123
124
  },
124
125
  "multiStep": {
@@ -118,7 +118,8 @@
118
118
  "buttons": {
119
119
  "addCondition": "הוספת תנאי",
120
120
  "clearAll": "נקה הכל",
121
- "save": "שמירה"
121
+ "save": "שמירה",
122
+ "done": "סיום"
122
123
  }
123
124
  },
124
125
  "multiStep": {