@volverjs/ui-vue 0.0.8-beta.1 → 0.0.8-beta.4

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.
@@ -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
  })
@@ -1,4 +1,5 @@
1
1
  import type { Option } from '../types/generic'
2
+ import { get } from 'ts-dot-prop'
2
3
 
3
4
  // eslint-disable-next-line
4
5
  export function useOptions(props: any) {
@@ -11,7 +12,7 @@ export function useOptions(props: any) {
11
12
  return String(
12
13
  typeof labelKey.value === 'function'
13
14
  ? labelKey.value(option)
14
- : option[labelKey.value],
15
+ : get(option, labelKey.value),
15
16
  )
16
17
  }
17
18
 
@@ -20,7 +21,7 @@ export function useOptions(props: any) {
20
21
 
21
22
  return typeof valueKey.value === 'function'
22
23
  ? valueKey.value(option)
23
- : option[valueKey.value]
24
+ : get(option, valueKey.value)
24
25
  }
25
26
 
26
27
  const getOptionDisabled = (option: string | Option): boolean => {
@@ -28,7 +29,7 @@ export function useOptions(props: any) {
28
29
 
29
30
  return typeof disabledKey.value === 'function'
30
31
  ? disabledKey.value(option)
31
- : option[disabledKey.value]
32
+ : get(option, disabledKey.value)
32
33
  }
33
34
 
34
35
  const getOptionGrouped = (option: string | Option) => {
@@ -2,7 +2,6 @@ import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { within } from '@storybook/testing-library'
4
4
  import { sleep } from '@/test/sleep'
5
- import { getOptionValue } from '@/test/options'
6
5
  import { defaultTest as selectDefaultTest } from '@/stories/Select/Select.test'
7
6
 
8
7
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
@@ -49,11 +48,12 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
49
48
  // select first value
50
49
  await expect(dropdownFirstItem).toBeClicked()
51
50
  await sleep()
51
+
52
+ const { getOptionValue } = useOptions(args)
53
+
52
54
  const firstValue = getOptionValue(
53
- args.options[0].options ? args.options[0] : args,
54
- 0,
55
+ args.options[0].options?.[0] ?? args.options[0],
55
56
  )
56
-
57
57
  // in grouped options the first element is not selectable
58
58
  if (args.multiple) {
59
59
  await expect(JSON.parse(value.innerHTML)).toEqual([firstValue])
@@ -66,8 +66,7 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
66
66
  await expect(dropdownSecondItem).toBeClicked()
67
67
  await sleep()
68
68
  const secondValue = getOptionValue(
69
- args.options[0].options ? args.options[0] : args,
70
- 1,
69
+ args.options[0].options?.[1] ?? args.options[1],
71
70
  )
72
71
  if (args.multiple) {
73
72
  await expect(JSON.parse(value.innerHTML)).toEqual([
@@ -76,3 +76,21 @@ export const GroupedOptions: Story = {
76
76
  ],
77
77
  },
78
78
  }
79
+
80
+ export const DotPathOptions: Story = {
81
+ ...Default,
82
+ args: {
83
+ ...Default.args,
84
+ valueKey: 'value.val',
85
+ labelKey: 'label.en',
86
+ options: [
87
+ { value: { val: 'first' }, label: { it: 'Primo', en: 'First' } },
88
+ {
89
+ value: { val: 'second' },
90
+ label: { it: 'Secondo', en: 'Second' },
91
+ },
92
+ { value: { val: 'third' }, label: { it: 'Terzo', en: 'Third' } },
93
+ { value: { val: 'fourth' }, label: { it: 'Quarto', en: 'Fourth' } },
94
+ ],
95
+ },
96
+ }
@@ -2,7 +2,6 @@ import type { PlayAttributes } from '@/test/types'
2
2
  import { within } from '@storybook/testing-library'
3
3
  import { expect } from '@/test/expect'
4
4
  import { sleep } from '@/test/sleep'
5
- import { getOptionValue } from '@/test/options'
6
5
 
7
6
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
8
7
  const element = (await within(canvasElement).findByTestId(
@@ -16,6 +15,8 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
16
15
  )[0] as HTMLSelectElement
17
16
  const hint = element.getElementsByClassName('vv-select__hint')[0]
18
17
 
18
+ const { getOptionValue } = useOptions(args)
19
+
19
20
  if (
20
21
  !args.invalid &&
21
22
  !args.disabled &&
@@ -25,8 +26,7 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
25
26
  ) {
26
27
  // select first value
27
28
  const firstValue = getOptionValue(
28
- args.options[0].options ? args.options[0] : args,
29
- 0,
29
+ args.options[0].options?.[0] ?? args.options[0],
30
30
  )
31
31
  select.value = firstValue
32
32
  select.dispatchEvent(new Event('change'))
@@ -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',