@bagelink/vue 1.15.337 → 1.15.340

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.15.337",
4
+ "version": "1.15.340",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -404,13 +404,16 @@ defineExpose({ show, hide, shown })
404
404
  <div
405
405
  v-if="!referenceEl"
406
406
  ref="triggerWrapRef" v-bind="$attrs"
407
- aria-haspopup="menu"
408
- :aria-expanded="shown"
409
- :aria-controls="bglId"
410
407
  @mouseenter="onTriggerMouseenter" @mouseleave="onTriggerMouseleave" @focus="onTriggerMouseenter"
411
408
  @blur="onTriggerMouseleave" @keydown="onTriggerKeydown"
412
409
  >
413
- <slot name="trigger" :show :hide :shown>
410
+ <slot
411
+ name="trigger"
412
+ :show
413
+ :hide
414
+ :shown
415
+ :trigger-attrs="{ 'aria-haspopup': 'menu', 'aria-expanded': shown, 'aria-controls': bglId }"
416
+ >
414
417
  <Btn
415
418
  :class="triggerClass" :iconEnd :icon="iconSet" :value :thin :flat :outline :frame :round :color
416
419
  :disabled @click="onTriggerClick"
@@ -78,6 +78,23 @@ export function useDraggable(options: DraggableOptions = {}) {
78
78
  const UPDATE_THRESHOLD = 150 // ms between updates
79
79
  const POSITION_CACHE = new Map<number, { top: number, bottom: number }>()
80
80
 
81
+ function appendToTopLayer(element: HTMLElement) {
82
+ document.body.appendChild(element)
83
+ element.setAttribute('popover', 'manual')
84
+ // The browser's popover UA styles use `inset: 0; margin: auto`, which
85
+ // recentres fixed-position drag helpers and offsets them from the cursor.
86
+ element.style.inset = 'auto'
87
+ element.style.margin = '0'
88
+ element.style.padding = '0'
89
+ element.style.border = '0'
90
+ element.showPopover()
91
+ }
92
+
93
+ function removeFromTopLayer(element: HTMLElement) {
94
+ if (element.matches(':popover-open')) element.hidePopover()
95
+ element.parentNode?.removeChild(element)
96
+ }
97
+
81
98
  function createGhost(el: DraggableElement) {
82
99
  if (!isBrowser) { return null }
83
100
  const ghost = el.cloneNode(true) as HTMLElement
@@ -94,7 +111,7 @@ export function useDraggable(options: DraggableOptions = {}) {
94
111
  ghost.style.cursor = 'grabbing'
95
112
  ghost.style.willChange = 'transform'
96
113
  ghost.classList.add(defaultOptions.ghostClass!)
97
- document.body.appendChild(ghost)
114
+ appendToTopLayer(ghost)
98
115
  return ghost
99
116
  }
100
117
 
@@ -122,7 +139,7 @@ export function useDraggable(options: DraggableOptions = {}) {
122
139
  dot.style.background = 'var(--primary-color, #0066ff)'
123
140
 
124
141
  line.appendChild(dot)
125
- document.body.appendChild(line)
142
+ appendToTopLayer(line)
126
143
  return line
127
144
  }
128
145
 
@@ -249,7 +266,7 @@ export function useDraggable(options: DraggableOptions = {}) {
249
266
  ghostElement.value.style.opacity = '0'
250
267
  ghostElement.value.style.transform += ' scale(0.8)'
251
268
  setTimeout(() => {
252
- ghostElement.value?.parentNode?.removeChild(ghostElement.value)
269
+ if (ghostElement.value) removeFromTopLayer(ghostElement.value)
253
270
  ghostElement.value = null
254
271
  }, 150)
255
272
  }
@@ -257,7 +274,7 @@ export function useDraggable(options: DraggableOptions = {}) {
257
274
  if (dropIndicator.value) {
258
275
  dropIndicator.value.style.opacity = '0'
259
276
  setTimeout(() => {
260
- dropIndicator.value?.parentNode?.removeChild(dropIndicator.value)
277
+ if (dropIndicator.value) removeFromTopLayer(dropIndicator.value)
261
278
  dropIndicator.value = null
262
279
  }, 150)
263
280
  }