@volverjs/ui-vue 0.0.7 → 0.0.8-beta.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.
@@ -16,27 +16,45 @@
16
16
 
17
17
  <template>
18
18
  <div v-bind="hasProps">
19
- <div class="vv-alert__header">
19
+ <div
20
+ v-if="
21
+ $slots.header ||
22
+ $slots.title ||
23
+ $slots.close ||
24
+ $slots['title::before'] ||
25
+ $slots['title::after'] ||
26
+ title ||
27
+ dismissable ||
28
+ autoClose
29
+ "
30
+ class="vv-alert__header"
31
+ >
20
32
  <VvIcon v-if="hasIcon" v-bind="hasIcon" class="vv-alert__icon" />
21
33
  <!-- @slot Header slot -->
22
34
  <slot name="header">
23
35
  <!-- @slot Before title slot -->
24
36
  <slot name="title::before" />
25
37
  <strong :id="hasTitleId" class="vv-alert__title">
26
- {{ title }}
38
+ <!-- @slot Title slot -->
39
+ <slot name="title">
40
+ {{ title }}
41
+ </slot>
27
42
  </strong>
28
43
  <!-- @slot After title slot -->
29
44
  <slot name="title::after" />
30
45
  </slot>
31
- <button
32
- v-if="dismissable || autoClose"
33
- class="vv-alert__close"
34
- type="button"
35
- :aria-label="closeLabel"
36
- @click.stop="close"
37
- >
38
- <div class="vv-alert__close-mask"></div>
39
- </button>
46
+ <!-- @slot Close button slot -->
47
+ <slot name="close" v-bind="{ close }">
48
+ <button
49
+ v-if="dismissable || autoClose"
50
+ class="vv-alert__close"
51
+ type="button"
52
+ :aria-label="closeLabel"
53
+ @click.stop="close"
54
+ >
55
+ <div class="vv-alert__close-mask"></div>
56
+ </button>
57
+ </slot>
40
58
  </div>
41
59
  <div v-if="$slots.default || content" class="vv-alert__content">
42
60
  <!-- @slot Content slot -->
@@ -101,7 +101,9 @@
101
101
  const onAfterExpand = () => {
102
102
  if (searchable.value) {
103
103
  if (inputSearchEl.value) {
104
- inputSearchEl.value.focus()
104
+ inputSearchEl.value.focus({
105
+ preventScroll: true,
106
+ })
105
107
  }
106
108
  }
107
109
  }
@@ -210,7 +210,9 @@
210
210
  floatingEl.value,
211
211
  )
212
212
  if (focusableElements.length > 0) {
213
- focusableElements[0].focus()
213
+ focusableElements[0].focus({
214
+ preventScroll: true,
215
+ })
214
216
  }
215
217
  })
216
218
  }
@@ -286,9 +288,13 @@
286
288
  document.activeElement as HTMLElement,
287
289
  )
288
290
  if (activeElementIndex < focusableElements.length - 1) {
289
- focusableElements[activeElementIndex + 1].focus()
291
+ focusableElements[activeElementIndex + 1].focus({
292
+ preventScroll: true,
293
+ })
290
294
  } else {
291
- focusableElements[0].focus()
295
+ focusableElements[0].focus({
296
+ preventScroll: true,
297
+ })
292
298
  }
293
299
  }
294
300
  })
@@ -306,9 +312,13 @@
306
312
  document.activeElement as HTMLElement,
307
313
  )
308
314
  if (activeElementIndex > 0) {
309
- focusableElements[activeElementIndex - 1].focus()
315
+ focusableElements[activeElementIndex - 1].focus({
316
+ preventScroll: true,
317
+ })
310
318
  } else {
311
- focusableElements[focusableElements.length - 1].focus()
319
+ focusableElements[focusableElements.length - 1].focus({
320
+ preventScroll: true,
321
+ })
312
322
  }
313
323
  }
314
324
  })
@@ -87,6 +87,16 @@ export const argTypes = {
87
87
  },
88
88
  },
89
89
  },
90
+ close: {
91
+ control: {
92
+ type: 'text',
93
+ },
94
+ table: {
95
+ type: {
96
+ summary: 'html',
97
+ },
98
+ },
99
+ },
90
100
  default: {
91
101
  control: {
92
102
  type: 'text',
@@ -16,7 +16,7 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
16
16
 
17
17
  const alertHeaderEl =
18
18
  element.getElementsByClassName('vv-alert__header')?.[0]
19
- const closeButton = alertHeaderEl?.lastChild as HTMLElement
19
+ const closeButtonEl = element.getElementsByClassName('vv-alert__close')?.[0]
20
20
  const alertContentEl =
21
21
  element.getElementsByClassName('vv-alert__content')?.[0]
22
22
  const alertFooterEl =
@@ -32,14 +32,18 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
32
32
  // dismissable
33
33
  if (args.dismissable) {
34
34
  expect(element).toHaveClass('vv-alert--dismissable')
35
- expect(closeButton).toHaveClass('vv-alert__close')
35
+ expect(closeButtonEl).not.toBeUndefined()
36
36
  }
37
37
 
38
38
  // autoclose
39
39
  if (args.autoClose) {
40
40
  expect(element).toHaveClass('vv-alert--auto-close')
41
- expect(closeButton).toHaveClass('vv-alert__close')
42
- expect(closeButton.firstChild).toHaveClass('vv-alert__close-mask')
41
+ expect(closeButtonEl).not.toBeUndefined()
42
+ expect(closeButtonEl.firstChild).toHaveClass('vv-alert__close-mask')
43
+ }
44
+
45
+ if (!args.autoClose && !args.dismissable) {
46
+ expect(closeButtonEl).toBeUndefined()
43
47
  }
44
48
 
45
49
  // icon
@@ -18,7 +18,9 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
18
18
  }
19
19
 
20
20
  // check if tooltip is visible after focus
21
- await parentElement.focus()
21
+ await parentElement.focus({
22
+ preventScroll: true,
23
+ })
22
24
  await sleep(1200)
23
25
  await expect(window.getComputedStyle(element)).toHaveProperty(
24
26
  'opacity',