@volverjs/ui-vue 0.0.8-beta.8 → 0.0.8

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.
@@ -381,7 +381,6 @@
381
381
  :role="DropdownRole.listbox"
382
382
  @after-expand="onAfterExpand"
383
383
  @after-collapse="onAfterCollapse"
384
- @click="$event.stopPropagation()"
385
384
  >
386
385
  <template
387
386
  v-if="searchable || $slots['dropdown::before']"
@@ -579,9 +578,10 @@
579
578
  <slot name="dropdown::after">
580
579
  <!-- Close button if dropdown custom position is enabled and floating-ui disabled -->
581
580
  <VvButton
582
- v-if="dropdownEl?.dropdownCustomPosition === 'true'"
581
+ v-if="dropdownEl?.customPosition"
583
582
  label="Close"
584
583
  modifiers="secondary"
584
+ @click="dropdownEl.hide()"
585
585
  />
586
586
  </slot>
587
587
  </template>
@@ -54,22 +54,24 @@
54
54
  })
55
55
 
56
56
  // ref to store the value of css-var "--dropdown-custom-position"
57
- const dropdownCustomPosition = ref()
58
-
59
- // set dropdownCustomPosition value from css-var "--dropdown-custom-position"
60
- const onChangeDropdownCustomPosition = () => {
61
- dropdownCustomPosition.value = window
62
- .getComputedStyle(floatingEl.value)
63
- .getPropertyValue('--dropdown-custom-position')
64
- ?.trim()
65
- }
57
+ const hasCustomPosition = ref(false)
66
58
 
67
59
  // observe dropdown style for "--dropdown-custom-position" css var to disable floating-ui
68
60
  onMounted(() => {
69
- useMutationObserver(floatingEl.value, onChangeDropdownCustomPosition, {
70
- attributeFilter: ['style'],
71
- window,
72
- })
61
+ useMutationObserver(
62
+ floatingEl.value,
63
+ () => {
64
+ hasCustomPosition.value =
65
+ window
66
+ .getComputedStyle(floatingEl.value)
67
+ .getPropertyValue('--dropdown-custom-position')
68
+ ?.trim() === 'true'
69
+ },
70
+ {
71
+ attributeFilter: ['style'],
72
+ window,
73
+ },
74
+ )
73
75
  })
74
76
 
75
77
  // floating ui
@@ -158,8 +160,8 @@
158
160
  },
159
161
  )
160
162
  const dropdownPlacement = computed(() => {
161
- if (dropdownCustomPosition?.value === 'true') {
162
- return {}
163
+ if (hasCustomPosition.value) {
164
+ return undefined
163
165
  }
164
166
  return {
165
167
  position: strategy.value,
@@ -175,31 +177,34 @@
175
177
  })
176
178
 
177
179
  // placement
178
- const side = computed(() => placement.value.split('-')[0])
179
- const staticSide = computed(
180
+ const side = computed(
180
181
  () =>
181
- ({
182
- top: 'bottom',
183
- right: 'left',
184
- bottom: 'top',
185
- left: 'right',
186
- }[side.value] ?? 'bottom'),
182
+ placement.value.split('-')[0] as
183
+ | 'top'
184
+ | 'right'
185
+ | 'bottom'
186
+ | 'left',
187
187
  )
188
188
  const arrowPlacement = computed(() => {
189
- if (dropdownCustomPosition?.value === 'true') {
190
- return {}
191
- }
192
- if (['bottom', 'top'].includes(staticSide.value)) {
193
- return {
194
- right: `${middlewareData.value.arrow?.x ?? 0}px`,
195
- [staticSide.value]: `${
196
- -(arrowEl.value?.offsetWidth ?? 0) / 2
197
- }px`,
198
- }
189
+ if (hasCustomPosition.value) {
190
+ return undefined
199
191
  }
192
+ const staticSide = {
193
+ top: 'bottom',
194
+ right: 'left',
195
+ bottom: 'top',
196
+ left: 'right',
197
+ }[side.value]
200
198
  return {
201
- top: `${middlewareData.value.arrow?.y ?? 0}px`,
202
- [staticSide.value]: `${-(arrowEl.value?.offsetWidth ?? 0) / 2}px`,
199
+ left:
200
+ middlewareData.value.arrow?.x !== undefined
201
+ ? `${middlewareData.value.arrow?.x}px`
202
+ : undefined,
203
+ top:
204
+ middlewareData.value.arrow?.y !== undefined
205
+ ? `${middlewareData.value.arrow?.y}px`
206
+ : undefined,
207
+ [staticSide]: `${-(arrowEl.value?.offsetWidth ?? 0) / 2}px`,
203
208
  }
204
209
  })
205
210
 
@@ -228,7 +233,13 @@
228
233
  const init = (el: HTMLElement) => {
229
234
  referenceEl.value = el
230
235
  }
231
- defineExpose({ toggle, show, hide, init, dropdownCustomPosition })
236
+ defineExpose({
237
+ toggle,
238
+ show,
239
+ hide,
240
+ init,
241
+ customPosition: hasCustomPosition,
242
+ })
232
243
  watch(expanded, (newValue) => {
233
244
  if (newValue && props.autofocusFirst) {
234
245
  nextTick(() => {
@@ -403,7 +414,6 @@
403
414
  ref="floatingEl"
404
415
  :style="dropdownPlacement"
405
416
  :class="bemCssClasses"
406
- @click="hide()"
407
417
  >
408
418
  <div
409
419
  v-if="props.arrow"