@volverjs/ui-vue 0.0.1-beta.11 → 0.0.1-beta.12

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.
Files changed (81) hide show
  1. package/dist/components/VvBadge/VvBadge.d.ts +1 -1
  2. package/dist/components/VvBadge/VvBadge.es.js +165 -12
  3. package/dist/components/VvBadge/VvBadge.umd.js +1 -1
  4. package/dist/components/VvBadge/VvBadge.vue.d.ts +4 -4
  5. package/dist/components/VvBreadcrumb/VvBreadcrumb.d.ts +1 -1
  6. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +4 -4
  7. package/dist/components/VvButton/VvButton.d.ts +2 -33
  8. package/dist/components/VvButton/VvButton.es.js +183 -198
  9. package/dist/components/VvButton/VvButton.umd.js +1 -1
  10. package/dist/components/VvButton/VvButton.vue.d.ts +9 -44
  11. package/dist/components/VvButton/useButtonGroupProps.d.ts +1 -6
  12. package/dist/components/VvButtonGroup/VvButtonGroup.d.ts +2 -26
  13. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +68 -78
  14. package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
  15. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +9 -69
  16. package/dist/components/VvDropdown/VvDropdown.d.ts +1 -1
  17. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +4 -4
  18. package/dist/components/VvInputText/VvInputText.d.ts +1 -1
  19. package/dist/components/VvInputText/VvInputText.vue.d.ts +4 -4
  20. package/dist/components/VvProgress/VvProgress.d.ts +1 -1
  21. package/dist/components/VvProgress/VvProgress.vue.d.ts +4 -4
  22. package/dist/components/VvSelect/VvSelect.d.ts +5 -1
  23. package/dist/components/VvSelect/VvSelect.es.js +395 -207
  24. package/dist/components/VvSelect/VvSelect.umd.js +2 -2
  25. package/dist/components/VvSelect/VvSelect.vue.d.ts +12 -5
  26. package/dist/components/VvTextarea/VvTextarea.d.ts +1 -1
  27. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +4 -4
  28. package/dist/components/index.es.js +579 -610
  29. package/dist/components/index.umd.js +2 -2
  30. package/dist/composables/group/types/IButtonGroupState.d.ts +4 -0
  31. package/dist/icons.es.js +3 -3
  32. package/dist/icons.umd.js +1 -1
  33. package/dist/index.es.js +553 -585
  34. package/dist/index.umd.js +2 -2
  35. package/dist/props/index.d.ts +2 -1
  36. package/dist/stories/RadioGroup/RadioOption.test.d.ts +4 -0
  37. package/dist/stories/RadioGroup/RadioProperty.test.d.ts +1 -1
  38. package/dist/stories/RadioGroup/RadioSlots.test.d.ts +6 -0
  39. package/package.json +2 -2
  40. package/src/assets/icons/detailed.json +1 -1
  41. package/src/assets/icons/normal.json +1 -1
  42. package/src/assets/icons/simple.json +1 -1
  43. package/src/components/VvBadge/VvBadge.ts +4 -2
  44. package/src/components/VvBadge/VvBadge.vue +8 -3
  45. package/src/components/VvButton/VvButton.ts +4 -34
  46. package/src/components/VvButton/VvButton.vue +3 -12
  47. package/src/components/VvButton/useButtonGroupProps.ts +3 -11
  48. package/src/components/VvButtonGroup/VvButtonGroup.ts +4 -17
  49. package/src/components/VvButtonGroup/VvButtonGroup.vue +5 -16
  50. package/src/components/VvSelect/VvSelect.ts +5 -1
  51. package/src/components/VvSelect/VvSelect.vue +7 -1
  52. package/src/composables/group/types/IButtonGroupState.ts +4 -0
  53. package/src/props/index.ts +3 -1
  54. package/src/stories/Badge/BadgeColor.stories.mdx +4 -4
  55. package/src/stories/Badge/BadgeModifiers.stories.mdx +65 -0
  56. package/src/stories/Button/ButtonActive.stories.mdx +27 -0
  57. package/src/stories/Button/ButtonDisabled.stories.mdx +28 -0
  58. package/src/stories/Button/ButtonIconPosition.stories.mdx +0 -1
  59. package/src/stories/Button/ButtonModifiers.stories.mdx +103 -46
  60. package/src/stories/Button/ButtonSelected.stories.mdx +30 -0
  61. package/src/stories/ButtonGroup/ButtonGroupAction.stories.mdx +2 -2
  62. package/src/stories/ButtonGroup/ButtonGroupActionQuiet.stories.mdx +2 -2
  63. package/src/stories/ButtonGroup/ButtonGroupBlock.stories.mdx +1 -1
  64. package/src/stories/ButtonGroup/ButtonGroupRounded.stories.mdx +1 -1
  65. package/src/stories/RadioGroup/RadioGroupHintLabel.stories.mdx +6 -6
  66. package/src/stories/RadioGroup/RadioGroupLabel.stories.mdx +7 -2
  67. package/src/stories/RadioGroup/RadioGroupOptionLabel.stories.mdx +7 -19
  68. package/src/stories/RadioGroup/RadioGroupOptionValue.stories.mdx +7 -19
  69. package/src/stories/RadioGroup/RadioGroupOptions.stories.mdx +3 -17
  70. package/src/stories/RadioGroup/RadioGroupSlots.stories.mdx +10 -9
  71. package/src/stories/RadioGroup/RadioOption.test.ts +45 -0
  72. package/src/stories/RadioGroup/RadioProperty.test.ts +4 -4
  73. package/src/stories/RadioGroup/RadioSlots.test.ts +29 -0
  74. package/src/stories/Select/SelectNative.stories.mdx +45 -0
  75. package/src/stories/stories.scss +5 -27
  76. package/src/stories/Button/ButtonVariant.stories.mdx +0 -205
  77. package/src/stories/Button/test.js +0 -41
  78. package/src/stories/Radio/RadioTest.js +0 -90
  79. package/src/stories/RadioGroup/RadioOptionsTest.js +0 -78
  80. package/src/stories/RadioGroup/RadioPropertyTest.js +0 -131
  81. package/src/stories/RadioGroup/RadioSlotsTest.js +0 -20
@@ -1,6 +1,7 @@
1
1
  import { Canvas, Meta, Story, Source } from '@storybook/addon-docs'
2
2
  import VvButton from '../../components/VvButton/VvButton.vue'
3
3
  import { testButton } from './Button.test'
4
+ import { Template } from './Button.stories.mdx'
4
5
 
5
6
  <Meta title="Components/Button/Props/modifiers" />
6
7
 
@@ -13,13 +14,8 @@ Stories of `VvButton` `modifiers`.
13
14
  Let's define a story for our `default` button:
14
15
 
15
16
  <Canvas>
16
- <Story name="default" play={testButton}>
17
- {() => {
18
- return {
19
- components: { VvButton },
20
- template: `<vv-button label="Default" data-testid="button" />`
21
- }
22
- }}
17
+ <Story name="default" play={testButton} args={{ label: 'Default' }}>
18
+ {Template.bind()}
23
19
  </Story>
24
20
  </Canvas>
25
21
 
@@ -36,13 +32,9 @@ Let's define a story for our `primary` button:
36
32
  testButton(ctx, {
37
33
  className: ['vv-button--primary']
38
34
  })
39
- }}>
40
- {() => {
41
- return {
42
- components: { VvButton },
43
- template: `<vv-button label="Primary" modifiers="primary" />`
44
- }
45
35
  }}
36
+ args={{ label: 'Primary', modifiers: 'primary' }}>
37
+ {Template.bind()}
46
38
  </Story>
47
39
  </Canvas>
48
40
 
@@ -57,13 +49,9 @@ Let's define a story for our `secondary` button:
57
49
  testButton(ctx, {
58
50
  className: 'vv-button--secondary'
59
51
  })
60
- }}>
61
- {() => {
62
- return {
63
- components: { VvButton },
64
- template: `<vv-button label="Secondary" modifiers="secondary" />`
65
- }
66
52
  }}
53
+ args={{ label: 'Secondary', modifiers: 'secondary' }}>
54
+ {Template.bind()}
67
55
  </Story>
68
56
  </Canvas>
69
57
 
@@ -78,13 +66,9 @@ Let's define a story for our `danger` button:
78
66
  testButton(ctx, {
79
67
  className: 'vv-button--danger'
80
68
  })
81
- }}>
82
- {() => {
83
- return {
84
- components: { VvButton },
85
- template: `<vv-button label="Danger" modifiers="danger" />`
86
- }
87
69
  }}
70
+ args={{ label: 'Danger', modifiers: 'danger' }}>
71
+ {Template.bind()}
88
72
  </Story>
89
73
  </Canvas>
90
74
 
@@ -99,34 +83,26 @@ Let's define a story for our `ghost` button:
99
83
  testButton(ctx, {
100
84
  className: 'vv-button--ghost'
101
85
  })
102
- }}>
103
- {() => {
104
- return {
105
- components: { VvButton },
106
- template: `<vv-button label="Ghost" modifiers="ghost" />`
107
- }
108
86
  }}
87
+ args={{ label: 'Ghost', modifiers: 'ghost' }}>
88
+ {Template.bind()}
109
89
  </Story>
110
90
  </Canvas>
111
91
 
112
92
  ## Text
113
93
 
114
- Let's define a story for our `text` button:
94
+ Let's define a story for our `link` button:
115
95
 
116
96
  <Canvas>
117
97
  <Story
118
- name="text"
98
+ name="link"
119
99
  play={async (ctx) => {
120
100
  testButton(ctx, {
121
- className: 'vv-button--text'
101
+ className: 'vv-button--link'
122
102
  })
123
- }}>
124
- {() => {
125
- return {
126
- components: { VvButton },
127
- template: `<vv-button label="Text" modifiers="text" />`
128
- }
129
103
  }}
104
+ args={{ label: 'Link', modifiers: 'link' }}>
105
+ {Template.bind()}
130
106
  </Story>
131
107
  </Canvas>
132
108
 
@@ -169,12 +145,93 @@ Let's define a story for our `static-dark` button:
169
145
  testButton(ctx, {
170
146
  className: 'vv-button--static-dark'
171
147
  })
172
- }}>
173
- {() => {
174
- return {
175
- components: { VvButton },
176
- template: `<vv-button label="Static Dark" modifiers="static-dark" />`
177
- }
178
148
  }}
149
+ args={{ label: 'Static Dark', modifiers: 'static-dark' }}>
150
+ {Template.bind()}
151
+ </Story>
152
+ </Canvas>
153
+
154
+ ## Block
155
+
156
+ Let's define a story for our `block` button:
157
+
158
+ <Canvas>
159
+ <Story
160
+ name="block"
161
+ play={async (ctx) => {
162
+ testButton(ctx, {
163
+ className: 'vv-button--block'
164
+ })
165
+ }}
166
+ args={{ label: 'Block', modifiers: 'block' }}>
167
+ {Template.bind()}
168
+ </Story>
169
+ </Canvas>
170
+
171
+ ## Rounded
172
+
173
+ Let's define a story for our `rounded` button:
174
+
175
+ <Canvas>
176
+ <Story
177
+ name="rounded"
178
+ play={async (ctx) => {
179
+ testButton(ctx, {
180
+ className: 'vv-button--rounded'
181
+ })
182
+ }}
183
+ args={{ label: 'Rounded', modifiers: 'rounded' }}>
184
+ {Template.bind()}
185
+ </Story>
186
+ </Canvas>
187
+
188
+ ## Full-bleed
189
+
190
+ Let's define a story for our `full-bleed` button:
191
+
192
+ <Canvas>
193
+ <Story
194
+ name="full-bleed"
195
+ play={async (ctx) => {
196
+ testButton(ctx, {
197
+ className: 'vv-button--full-bleed'
198
+ })
199
+ }}
200
+ args={{ label: 'Full-bleed', modifiers: 'full-bleed' }}>
201
+ {Template.bind()}
202
+ </Story>
203
+ </Canvas>
204
+
205
+ ## Action
206
+
207
+ Let's define a story for our `action` button:
208
+
209
+ <Canvas>
210
+ <Story
211
+ name="action"
212
+ play={async (ctx) => {
213
+ testButton(ctx, {
214
+ className: 'vv-button--action'
215
+ })
216
+ }}
217
+ args={{ label: 'Action', modifiers: 'action' }}>
218
+ {Template.bind()}
219
+ </Story>
220
+ </Canvas>
221
+
222
+ ## Action-quiet
223
+
224
+ Let's define a story for our `action-quiet` button:
225
+
226
+ <Canvas>
227
+ <Story
228
+ name="action-quiet"
229
+ play={async (ctx) => {
230
+ testButton(ctx, {
231
+ className: 'vv-button--action-quiet'
232
+ })
233
+ }}
234
+ args={{ label: 'Action-quiet', modifiers: 'action-quiet' }}>
235
+ {Template.bind()}
179
236
  </Story>
180
237
  </Canvas>
@@ -0,0 +1,30 @@
1
+ import { Canvas, Meta, Story, Source } from '@storybook/addon-docs'
2
+ import VvButton from '../../components/VvButton/VvButton.vue'
3
+
4
+ <Meta title="Components/Button/Props/selected" />
5
+
6
+ ## Action Selected
7
+
8
+ Let's define a story for our `action` `selected` button.
9
+
10
+ <Canvas>
11
+ <Story
12
+ name="selected"
13
+ play={async (ctx) => {
14
+ testButton(ctx, {
15
+ className: 'vv-button--selected'
16
+ })
17
+ }}>
18
+ {() => {
19
+ return {
20
+ components: { VvButton },
21
+ template: `<vv-button label="Action Selected" modifiers="action" selected />`
22
+ }
23
+ }}
24
+ </Story>
25
+ </Canvas>
26
+
27
+ <Source
28
+ language="jsx"
29
+ code={'<vv-button label="Action" modifiers="action" selected />'}
30
+ />
@@ -25,7 +25,7 @@ A VvButtonGroup with the `action` prop
25
25
  components: { VvButton, VvButtonGroup },
26
26
  template: `
27
27
  <div class="flex flex-col">
28
- <vv-button-group action class="mt-22">
28
+ <vv-button-group modifiers="action" class="mt-22">
29
29
  <vv-button>Button 1</vv-button>
30
30
  <vv-button id="btn2">Button 2</vv-button>
31
31
  <vv-button>Button 3</vv-button>
@@ -60,7 +60,7 @@ A VvButtonGroup with the `action`, `toggle` and `compact` props
60
60
  },
61
61
  template: `
62
62
  <div class="flex">
63
- <vv-button-group v-model:modelValue="modelValue" action toggle compact class="mt-22">
63
+ <vv-button-group v-model:modelValue="modelValue" :modifiers="['action', 'toggle', 'compact']" class="mt-22">
64
64
  <vv-button name="first" icon="akar-icons:copy" label="First" />
65
65
  <vv-button name="second" icon="akar-icons:pencil" label="Second" />
66
66
  <vv-button name="third" icon="akar-icons:trash-bin" label="Third" />
@@ -28,7 +28,7 @@ A VvButtonGroup with the `action-quiet` prop
28
28
  components: { VvButton, VvButtonGroup },
29
29
  template: `
30
30
  <div class="flex flex-col">
31
- <vv-button-group action-quiet>
31
+ <vv-button-group modifiers="action-quiet">
32
32
  <vv-button>Button 1</vv-button>
33
33
  <vv-button>Button 2</vv-button>
34
34
  <vv-button>Button 3</vv-button>
@@ -42,7 +42,7 @@ A VvButtonGroup with the `action-quiet` prop
42
42
 
43
43
  <Source
44
44
  language="html"
45
- code={`<vv-button-group action-quiet>
45
+ code={`<vv-button-group modifiers="action-quiet">
46
46
  <vv-button>Button 1</vv-button>
47
47
  <vv-button>Button 2</vv-button>
48
48
  <vv-button>Button 3</vv-button>
@@ -27,7 +27,7 @@ A VvButtonGroup with the <strong>block</strong> prop will be render with <strong
27
27
  components: { VvButton, VvButtonGroup },
28
28
  template: `
29
29
  <div class="flex flex-col">
30
- <vv-button-group block class="mt-22">
30
+ <vv-button-group modifiers="block" class="mt-22">
31
31
  <vv-button>Button 1</vv-button>
32
32
  <vv-button id="btn2">Button 2</vv-button>
33
33
  <vv-button>Button 3</vv-button>
@@ -26,7 +26,7 @@ A VvButtonGroup with the <strong>rounded</strong> prop will be render with <stro
26
26
  return {
27
27
  components: { VvButton, VvButtonGroup },
28
28
  template: `
29
- <vv-button-group rounded>
29
+ <vv-button-group modifiers="rounded">
30
30
  <vv-button>Button 1</vv-button>
31
31
  <vv-button id="btn2">Button 2</vv-button>
32
32
  <vv-button>Button 3</vv-button>
@@ -3,7 +3,7 @@ import { Canvas, Meta, Story, Source, ArgsTable } from '@storybook/addon-docs'
3
3
  import VvRadioGroup from '../../components/VvRadioGroup/VvRadioGroup.vue'
4
4
  import VvRadio from '../../components/VvRadio/VvRadio.vue'
5
5
 
6
- import { labelTest, radioGroupTest } from './RadioProperty.test.ts'
6
+ import { labelTest } from './RadioProperty.test.ts'
7
7
 
8
8
  <Meta title="Components/RadioGroup/HintLabel" component={VvRadioGroup} />
9
9
 
@@ -12,11 +12,11 @@ import { labelTest, radioGroupTest } from './RadioProperty.test.ts'
12
12
  <Canvas>
13
13
  <Story
14
14
  name="HintLabel"
15
- play={async ({ canvasElement, args }) => {
16
- labelTest(
17
- { canvasElement, args },
18
- { child: 1, propName: 'hintLabel' }
19
- )
15
+ play={async (ctx) => {
16
+ labelTest(ctx, {
17
+ child: 1,
18
+ propName: 'hintLabel'
19
+ })
20
20
  }}
21
21
  args={{
22
22
  name: 'vv-group-options-hint-label',
@@ -4,7 +4,7 @@ import VvRadioGroup from '../../components/VvRadioGroup/VvRadioGroup.vue'
4
4
  import VvRadio from '../../components/VvRadio/VvRadio.vue'
5
5
 
6
6
  import { Template } from './RadioGroup.stories.mdx'
7
- import { labelTest } from './RadioPropertyTest.js'
7
+ import { labelTest } from './RadioProperty.test.ts'
8
8
 
9
9
  <Meta title="Components/RadioGroup/Label" component={VvRadioGroup} />
10
10
 
@@ -13,7 +13,12 @@ import { labelTest } from './RadioPropertyTest.js'
13
13
  <Canvas>
14
14
  <Story
15
15
  name="Label"
16
- play={labelTest}
16
+ play={async (ctx) => {
17
+ labelTest(ctx, {
18
+ chid: 0,
19
+ propName: 'label'
20
+ })
21
+ }}
17
22
  args={{
18
23
  name: 'story-label',
19
24
  options: [
@@ -3,11 +3,7 @@ import { Canvas, Meta, Story, Source, ArgsTable } from '@storybook/addon-docs'
3
3
  import VvRadioGroup from '../../components/VvRadioGroup/VvRadioGroup.vue'
4
4
  import VvRadio from '../../components/VvRadio/VvRadio.vue'
5
5
 
6
- import {
7
- mainOptionsTest,
8
- optionsLabelStringTest,
9
- optionsLabelFunctionTest
10
- } from './RadioOptionsTest'
6
+ import { radioOptionsTest } from './RadioOption.test.ts'
11
7
  import { Template } from './RadioGroup.stories.mdx'
12
8
 
13
9
  <Meta title="Components/RadioGroup/OptionLabel" component={VvRadioGroup} />
@@ -19,12 +15,7 @@ Change object prop for label
19
15
  <Canvas>
20
16
  <Story
21
17
  name="OptionsLabel - string"
22
- play={(ctx) =>
23
- mainOptionsTest({
24
- ...ctx,
25
- functions: [optionsLabelStringTest]
26
- })
27
- }
18
+ play={radioOptionsTest}
28
19
  args={{
29
20
  name: 'options',
30
21
  options: [
@@ -32,7 +23,8 @@ Change object prop for label
32
23
  { value: 2, name: 'Pera' },
33
24
  { value: 3, name: 'Banana' }
34
25
  ],
35
- optionLabel: 'name'
26
+ optionLabel: 'name',
27
+ role: 'radiogroup'
36
28
  }}>
37
29
  {Template.bind({})}
38
30
  </Story>
@@ -45,12 +37,7 @@ Use function to define option label
45
37
  <Canvas>
46
38
  <Story
47
39
  name="OptionsLabel - function"
48
- play={(ctx) =>
49
- mainOptionsTest({
50
- ...ctx,
51
- functions: [optionsLabelFunctionTest]
52
- })
53
- }
40
+ play={radioOptionsTest}
54
41
  args={{
55
42
  name: 'options',
56
43
  options: [
@@ -58,7 +45,8 @@ Use function to define option label
58
45
  { value: 2, name: 'Pera' },
59
46
  { value: 3, name: 'Banana' }
60
47
  ],
61
- optionLabel: (o) => `Frutto: ${o.name}`
48
+ optionLabel: (o) => `Frutto: ${o.name}`,
49
+ role: 'radiogroup'
62
50
  }}>
63
51
  {Template.bind({})}
64
52
  </Story>
@@ -3,11 +3,7 @@ import { Canvas, Meta, Story, Source, ArgsTable } from '@storybook/addon-docs'
3
3
  import VvRadioGroup from '../../components/VvRadioGroup/VvRadioGroup.vue'
4
4
  import VvRadio from '../../components/VvRadio/VvRadio.vue'
5
5
 
6
- import {
7
- mainOptionsTest,
8
- optionsValueStringTest,
9
- optionsValueFunctionTest
10
- } from './RadioOptionsTest.js'
6
+ import { radioOptionsTest } from './RadioOption.test.ts'
11
7
  import { Template } from './RadioGroup.stories.mdx'
12
8
 
13
9
  <Meta title="Components/RadioGroup/OptionsValue" component={VvRadioGroup} />
@@ -19,12 +15,7 @@ Change object prop for value
19
15
  <Canvas>
20
16
  <Story
21
17
  name="OptionsValue - string"
22
- play={(ctx) =>
23
- mainOptionsTest({
24
- ...ctx,
25
- functions: [optionsValueStringTest]
26
- })
27
- }
18
+ play={radioOptionsTest}
28
19
  args={{
29
20
  name: 'options',
30
21
  options: [
@@ -32,7 +23,8 @@ Change object prop for value
32
23
  { qta: 2, label: 'Pera' },
33
24
  { qta: 3, label: 'Banana' }
34
25
  ],
35
- optionValue: 'qta'
26
+ optionValue: 'qta',
27
+ role: 'radiogroup'
36
28
  }}>
37
29
  {Template.bind({})}
38
30
  </Story>
@@ -45,12 +37,7 @@ Use function to define option value
45
37
  <Canvas>
46
38
  <Story
47
39
  name="OptionsValue - function"
48
- play={(ctx) =>
49
- mainOptionsTest({
50
- ...ctx,
51
- functions: [optionsValueFunctionTest]
52
- })
53
- }
40
+ play={radioOptionsTest}
54
41
  args={{
55
42
  name: 'options',
56
43
  options: [
@@ -58,7 +45,8 @@ Use function to define option value
58
45
  { qta: 2, label: 'Pera' },
59
46
  { qta: 3, label: 'Banana' }
60
47
  ],
61
- optionValue: (o) => `${o.qta}_${o.label}`
48
+ optionValue: (o) => `${o.qta}_${o.label}`,
49
+ role: 'radiogroup'
62
50
  }}>
63
51
  {Template.bind({})}
64
52
  </Story>
@@ -3,11 +3,7 @@ import { Canvas, Meta, Story, Source, ArgsTable } from '@storybook/addon-docs'
3
3
  import VvRadioGroup from '../../components/VvRadioGroup/VvRadioGroup.vue'
4
4
  import VvRadio from '../../components/VvRadio/VvRadio.vue'
5
5
 
6
- import {
7
- mainOptionsTest,
8
- radioOptionsTest,
9
- arrayOptionsTest
10
- } from './RadioOptionsTest.js'
6
+ import { radioOptionsTest, arrayOptionsTest } from './RadioOption.test.ts'
11
7
  import { Template } from './RadioGroup.stories.mdx'
12
8
 
13
9
  <Meta title="Components/RadioGroup/Options" component={VvRadioGroup} />
@@ -19,12 +15,7 @@ Check group based on list of object list
19
15
  <Canvas>
20
16
  <Story
21
17
  name="Options"
22
- play={(ctx) =>
23
- mainOptionsTest({
24
- ...ctx,
25
- functions: [radioOptionsTest]
26
- })
27
- }
18
+ play={radioOptionsTest}
28
19
  args={{
29
20
  name: 'options',
30
21
  options: [
@@ -43,12 +34,7 @@ Check group based on list of object list
43
34
  <Canvas>
44
35
  <Story
45
36
  name="Options as Array"
46
- play={(ctx) =>
47
- mainOptionsTest({
48
- ...ctx,
49
- functions: [arrayOptionsTest]
50
- })
51
- }
37
+ play={arrayOptionsTest}
52
38
  args={{
53
39
  name: 'options',
54
40
  options: ['Primo', 'Secondo', 'Terzo']
@@ -3,7 +3,7 @@ import { Canvas, Meta, Story, Source } from '@storybook/addon-docs'
3
3
  import VvRadioGroup from '../../components/VvRadioGroup/VvRadioGroup.vue'
4
4
  import VvRadio from '../../components/VvRadio/VvRadio.vue'
5
5
 
6
- import { slotsTest } from './RadioSlotsTest.js'
6
+ import { slotsTest } from './RadioSlots.test.ts'
7
7
 
8
8
  <Meta title="Components/RadioGroup/Slots" component={VvRadioGroup} />
9
9
 
@@ -44,11 +44,10 @@ import { slotsTest } from './RadioSlotsTest.js'
44
44
  <Canvas>
45
45
  <Story
46
46
  name="Hint"
47
- play={async ({ canvasElement }) => {
48
- slotsTest({ canvasElement })
49
- }}
47
+ play={slotsTest}
50
48
  args={{
51
- name: 'story-slot-hint'
49
+ name: 'story-slot-hint',
50
+ role: 'radiogroup'
52
51
  }}>
53
52
  {(args) => {
54
53
  return {
@@ -85,11 +84,12 @@ import { slotsTest } from './RadioSlotsTest.js'
85
84
  <Story
86
85
  name="Valid"
87
86
  play={async ({ canvasElement }) => {
88
- slotsTest({ canvasElement }, 'valid')
87
+ slotsTest({ canvasElement }, { className: 'valid' })
89
88
  }}
90
89
  args={{
91
90
  name: 'story-slot-valid',
92
- valid: true
91
+ valid: true,
92
+ role: 'radiogroup'
93
93
  }}>
94
94
  {(args) => {
95
95
  return {
@@ -126,11 +126,12 @@ import { slotsTest } from './RadioSlotsTest.js'
126
126
  <Story
127
127
  name="Error"
128
128
  play={async ({ canvasElement }) => {
129
- slotsTest({ canvasElement }, 'invalid')
129
+ slotsTest({ canvasElement }, { className: 'invalid' })
130
130
  }}
131
131
  args={{
132
132
  name: 'story-slot-error',
133
- error: true
133
+ error: true,
134
+ role: 'radiogroup'
134
135
  }}>
135
136
  {(args) => {
136
137
  return {
@@ -0,0 +1,45 @@
1
+ import type { PlayAttributes } from '@/test/types'
2
+ import { within } from '@storybook/testing-library'
3
+ import { expect } from '@/test/expect'
4
+ import { radioGroupTest } from './RadioProperty.test'
5
+
6
+ type optionFn = (a: { [key: string]: string }) => string
7
+
8
+ function getValueToTest(
9
+ option: { [key: string]: string },
10
+ key: string | optionFn
11
+ ) {
12
+ return typeof key == 'string' ? `${option[key]}` : `${key(option)}`
13
+ }
14
+
15
+ async function radioOptionsTest({ canvasElement, ...data }: PlayAttributes) {
16
+ const radioGroup = await within(canvasElement).findByRole('radiogroup')
17
+ const radioGroupWrapper = radioGroup.children[0]
18
+ const optionParamLabel = data.args.optionLabel || 'label'
19
+ const optionParamValue = data.args.optionValue || 'value'
20
+ const options: { [key: string]: string }[] = data.args.options
21
+ options.forEach((option, index: number) => {
22
+ const radio = radioGroupWrapper.children[index] as HTMLElement
23
+ const radioValue = radio.children[0]
24
+ const radioLabel = radio.innerText
25
+ expect(radioLabel).toEqual(getValueToTest(option, optionParamLabel))
26
+ expect(radioValue).toEqual(getValueToTest(option, optionParamValue))
27
+ })
28
+ radioGroupTest({ canvasElement, ...data })
29
+ }
30
+
31
+ async function arrayOptionsTest({ canvasElement, ...data }: PlayAttributes) {
32
+ const radioGroup = await within(canvasElement).findByRole('radiogroup')
33
+ const radioGroupWrapper = radioGroup.children[0]
34
+ const options: { [key: string]: string }[] = data.args.options
35
+ options.forEach((option, index: number) => {
36
+ const radio = radioGroupWrapper.children[index] as HTMLElement
37
+ const radioValue = radio.children[0]
38
+ const radioLabel = radio.innerText
39
+ expect(radioLabel).toEqual(option)
40
+ expect(radioValue).toEqual(option)
41
+ })
42
+ radioGroupTest({ canvasElement, ...data })
43
+ }
44
+
45
+ export { radioOptionsTest, arrayOptionsTest }
@@ -11,7 +11,7 @@ interface RadioConfig {
11
11
  }
12
12
 
13
13
  async function radioGroupTest(
14
- { canvasElement, ...data }: PlayAttributes = {} as PlayAttributes,
14
+ { canvasElement }: PlayAttributes = {} as PlayAttributes,
15
15
  {
16
16
  isClickDisabled = false,
17
17
  className = null,
@@ -21,9 +21,9 @@ async function radioGroupTest(
21
21
  const radioGroupParent = await within(canvasElement).findByRole(
22
22
  'radiogroup'
23
23
  )
24
- const prefix = data.args.name
25
- const radio1 = document.getElementById(`${prefix}_opt1`) as HTMLInputElement
26
- const radio2 = document.getElementById(`${prefix}_opt2`) as HTMLInputElement
24
+ const radios = document.getElementsByClassName('vv-input-radio__input')
25
+ const radio1 = radios[0] as HTMLInputElement
26
+ const radio2 = radios[1] as HTMLInputElement
27
27
  expect(radioGroupParent).toHaveClass('vv-input-radio-group')
28
28
  if (!isVertical) {
29
29
  expect(radioGroupParent).toHaveClass([
@@ -0,0 +1,29 @@
1
+ import type { PlayAttributes } from '@/test/types'
2
+ import { within } from '@storybook/testing-library'
3
+ import { expect } from '@/test/expect'
4
+ import { radioGroupTest } from './RadioProperty.test'
5
+
6
+ interface RadioConfig {
7
+ className?: string
8
+ }
9
+
10
+ async function slotsTest(
11
+ { canvasElement, ...args }: PlayAttributes = {} as PlayAttributes,
12
+ { className }: RadioConfig = {} as RadioConfig
13
+ ) {
14
+ const radioGroupParent = await within(canvasElement).findByRole(
15
+ 'radiogroup'
16
+ )
17
+ const slot = radioGroupParent.lastElementChild as HTMLElement
18
+ expect(slot).toHaveClass('vv-input-radio-group__hint')
19
+ expect(slot.innerText).toBeTruthy()
20
+ if (className) {
21
+ expect(radioGroupParent).toHaveClass(
22
+ `vv-input-radio-group--${className}`
23
+ )
24
+ }
25
+ expect(slot).toHaveNoViolations()
26
+ await radioGroupTest({ canvasElement, ...args })
27
+ }
28
+
29
+ export { slotsTest }