@volverjs/ui-vue 0.0.8-beta.3 → 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.
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +4 -3
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.es.js +4 -3
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +4 -3
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.es.js +4 -3
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/index.es.js +4 -3
- package/dist/components/index.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/stories/Combobox/ComboboxOptions.stories.d.ts +1 -0
- package/package.json +2 -1
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/composables/useOptions.ts +4 -3
- package/src/stories/Combobox/Combobox.test.ts +5 -6
- package/src/stories/Combobox/ComboboxOptions.stories.ts +18 -0
- package/src/stories/Select/Select.test.ts +3 -3
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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'))
|