@volverjs/ui-vue 0.0.8 → 0.0.9-beta.10

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 (136) hide show
  1. package/README.md +4 -4
  2. package/auto-imports.d.ts +2 -0
  3. package/dist/components/VvAccordion/VvAccordion.es.js +7 -0
  4. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +7 -0
  5. package/dist/components/VvAction/VvAction.es.js +9 -1
  6. package/dist/components/VvAction/VvAction.umd.js +1 -1
  7. package/dist/components/VvAction/VvAction.vue.d.ts +9 -0
  8. package/dist/components/VvAction/index.d.ts +4 -0
  9. package/dist/components/VvAlert/VvAlert.es.js +14 -6
  10. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  11. package/dist/components/VvAlert/VvAlert.vue.d.ts +6 -6
  12. package/dist/components/VvAlert/index.d.ts +3 -3
  13. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +54 -10
  14. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  15. package/dist/components/VvAvatar/VvAvatar.es.js +7 -0
  16. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +7 -0
  17. package/dist/components/VvBadge/VvBadge.es.js +7 -0
  18. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +7 -0
  19. package/dist/components/VvButton/VvButton.es.js +11 -2
  20. package/dist/components/VvButton/VvButton.umd.js +1 -1
  21. package/dist/components/VvButton/VvButton.vue.d.ts +9 -0
  22. package/dist/components/VvButton/index.d.ts +4 -0
  23. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +7 -0
  24. package/dist/components/VvCard/VvCard.es.js +7 -0
  25. package/dist/components/VvCheckbox/VvCheckbox.es.js +91 -14
  26. package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
  27. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +4 -4
  28. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +97 -15
  29. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  30. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +4 -4
  31. package/dist/components/VvCombobox/VvCombobox.es.js +164 -94
  32. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  33. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +35 -14
  34. package/dist/components/VvCombobox/index.d.ts +24 -7
  35. package/dist/components/VvDialog/VvDialog.es.js +67 -27
  36. package/dist/components/VvDialog/VvDialog.umd.js +1 -1
  37. package/dist/components/VvDropdown/VvDropdown.es.js +58 -20
  38. package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
  39. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +13 -12
  40. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +9 -0
  41. package/dist/components/VvDropdown/index.d.ts +1 -7
  42. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +9 -1
  43. package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
  44. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +7 -0
  45. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +7 -0
  46. package/dist/components/VvInputText/VvInputText.es.js +87 -14
  47. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  48. package/dist/components/VvInputText/VvInputText.vue.d.ts +4 -4
  49. package/dist/components/VvNav/VvNav.es.js +10 -2
  50. package/dist/components/VvNav/VvNav.umd.js +1 -1
  51. package/dist/components/VvNav/index.d.ts +1 -1
  52. package/dist/components/VvProgress/VvProgress.es.js +7 -0
  53. package/dist/components/VvRadio/VvRadio.es.js +91 -14
  54. package/dist/components/VvRadio/VvRadio.umd.js +1 -1
  55. package/dist/components/VvRadio/VvRadio.vue.d.ts +4 -4
  56. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +97 -15
  57. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  58. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +4 -4
  59. package/dist/components/VvSelect/VvSelect.es.js +87 -14
  60. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  61. package/dist/components/VvSelect/VvSelect.vue.d.ts +4 -4
  62. package/dist/components/VvTab/VvTab.es.js +10 -2
  63. package/dist/components/VvTab/VvTab.umd.js +1 -1
  64. package/dist/components/VvTextarea/VvTextarea.es.js +87 -14
  65. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  66. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +4 -4
  67. package/dist/components/VvTooltip/VvTooltip.es.js +7 -0
  68. package/dist/components/common/HintSlot.d.ts +4 -3
  69. package/dist/components/index.d.ts +5 -0
  70. package/dist/components/index.es.js +958 -431
  71. package/dist/components/index.umd.js +1 -1
  72. package/dist/composables/alert/useAlert.d.ts +27 -0
  73. package/dist/composables/index.d.ts +1 -0
  74. package/dist/composables/index.es.js +81 -0
  75. package/dist/composables/index.umd.js +1 -0
  76. package/dist/constants.d.ts +10 -0
  77. package/dist/directives/index.es.js +7 -0
  78. package/dist/directives/v-tooltip.es.js +7 -0
  79. package/dist/icons.es.js +3 -3
  80. package/dist/icons.umd.js +1 -1
  81. package/dist/props/index.d.ts +7 -0
  82. package/dist/resolvers/unplugin.es.js +3 -0
  83. package/dist/resolvers/unplugin.umd.js +1 -1
  84. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +43 -258
  85. package/dist/stories/Alert/Alert.settings.d.ts +3 -7
  86. package/dist/stories/AlertGroup/AlertGroupSlots.stories.d.ts +2 -2
  87. package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +6 -0
  88. package/dist/stories/Button/Button.settings.d.ts +3 -13
  89. package/dist/stories/Combobox/Combobox.settings.d.ts +117 -19
  90. package/dist/stories/Nav/Nav.settings.d.ts +3 -21
  91. package/package.json +54 -46
  92. package/src/assets/icons/detailed.json +1 -1
  93. package/src/assets/icons/normal.json +1 -1
  94. package/src/assets/icons/simple.json +1 -1
  95. package/src/components/VvAction/VvAction.vue +2 -1
  96. package/src/components/VvAlert/VvAlert.vue +5 -1
  97. package/src/components/VvAlert/index.ts +3 -3
  98. package/src/components/VvAlertGroup/VvAlertGroup.vue +30 -0
  99. package/src/components/VvAlertGroup/index.ts +11 -1
  100. package/src/components/VvButton/VvButton.vue +1 -0
  101. package/src/components/VvCheckbox/VvCheckbox.vue +8 -1
  102. package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +8 -1
  103. package/src/components/VvCombobox/VvCombobox.vue +9 -4
  104. package/src/components/VvCombobox/index.ts +24 -0
  105. package/src/components/VvDialog/VvDialog.vue +36 -17
  106. package/src/components/VvDialog/index.ts +13 -1
  107. package/src/components/VvDropdown/VvDropdown.vue +44 -15
  108. package/src/components/VvDropdown/index.ts +2 -8
  109. package/src/components/VvInputText/VvInputText.vue +8 -1
  110. package/src/components/VvNav/VvNav.vue +1 -1
  111. package/src/components/VvNav/index.ts +1 -1
  112. package/src/components/VvRadio/VvRadio.vue +8 -1
  113. package/src/components/VvRadioGroup/VvRadioGroup.vue +8 -1
  114. package/src/components/VvSelect/VvSelect.vue +8 -1
  115. package/src/components/VvTextarea/VvTextarea.vue +8 -1
  116. package/src/components/common/HintSlot.ts +26 -13
  117. package/src/components/index.ts +5 -0
  118. package/src/composables/alert/useAlert.ts +103 -0
  119. package/src/composables/index.ts +1 -0
  120. package/src/constants.ts +21 -0
  121. package/src/props/index.ts +7 -0
  122. package/src/resolvers/unplugin.ts +3 -0
  123. package/src/stories/Alert/Alert.settings.ts +3 -1
  124. package/src/stories/AlertGroup/AlertGroup.test.ts +13 -0
  125. package/src/stories/AlertGroup/AlertGroupSlots.stories.ts +3 -3
  126. package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +118 -0
  127. package/src/stories/Button/Button.settings.ts +5 -3
  128. package/src/stories/Combobox/Combobox.settings.ts +119 -2
  129. package/src/stories/Nav/Nav.settings.ts +3 -1
  130. package/src/stories/Tab/Tab.stories.ts +3 -3
  131. package/src/stories/Textarea/TextareaLength.stories.ts +1 -1
  132. package/src/types/alert.d.ts +20 -0
  133. /package/dist/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue.d.ts +0 -0
  134. /package/dist/components/{VvNavSeparator → VvNav}/VvNavSeparator.d.ts +0 -0
  135. /package/src/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue +0 -0
  136. /package/src/components/{VvNavSeparator → VvNav}/VvNavSeparator.ts +0 -0
@@ -1,4 +1,5 @@
1
1
  import type { ExtractPropTypes, Slots } from 'vue'
2
+ import type { Ref } from 'vue'
2
3
 
3
4
  /**
4
5
  * Merge array of string
@@ -19,7 +20,7 @@ export type HintSlotProps = Readonly<
19
20
  default: ''
20
21
  required: true
21
22
  }
22
- modelValue: null
23
+ modelValue: unknown
23
24
  valid: BooleanConstructor
24
25
  validLabel: (StringConstructor | ArrayConstructor)[]
25
26
  invalid: BooleanConstructor
@@ -35,27 +36,39 @@ export type HintSlotProps = Readonly<
35
36
  * @param {Slots} parentSlots vue slots
36
37
  * @returns {Component} vue component
37
38
  */
38
- export function HintSlotFactory(props: HintSlotProps, slots: Slots) {
39
+ export function HintSlotFactory(
40
+ propsOrRef: HintSlotProps | Ref<HintSlotProps>,
41
+ slots: Slots,
42
+ ) {
43
+ const props = computed(() => {
44
+ if (isRef(propsOrRef)) {
45
+ return propsOrRef.value
46
+ }
47
+ return propsOrRef
48
+ })
49
+
39
50
  // label
40
- const invalidLabel = computed(() => joinLines(props.invalidLabel))
41
- const validLabel = computed(() => joinLines(props.validLabel))
42
- const loadingLabel = computed(() => props.loadingLabel)
43
- const hintLabel = computed(() => props.hintLabel)
51
+ const invalidLabel = computed(() => joinLines(props.value.invalidLabel))
52
+ const validLabel = computed(() => joinLines(props.value.validLabel))
53
+ const loadingLabel = computed(() => props.value.loadingLabel)
54
+ const hintLabel = computed(() => props.value.hintLabel)
44
55
 
45
56
  // type
46
57
  const hasLoadingLabelOrSlot = computed(() =>
47
- Boolean(props.loading && (slots.loading || loadingLabel.value)),
58
+ Boolean(props.value.loading && (slots.loading || loadingLabel.value)),
48
59
  )
49
60
  const hasInvalidLabelOrSlot = computed(
50
61
  () =>
51
62
  !hasLoadingLabelOrSlot.value &&
52
- Boolean(props.invalid && (slots.invalid || invalidLabel.value)),
63
+ Boolean(
64
+ props.value.invalid && (slots.invalid || invalidLabel.value),
65
+ ),
53
66
  )
54
67
  const hasValidLabelOrSlot = computed(
55
68
  () =>
56
69
  !hasLoadingLabelOrSlot.value &&
57
70
  !hasInvalidLabelOrSlot.value &&
58
- Boolean(props.valid && (slots.valid || validLabel.value)),
71
+ Boolean(props.value.valid && (slots.valid || validLabel.value)),
59
72
  )
60
73
  const hasHintLabelOrSlot = computed(
61
74
  () =>
@@ -72,10 +85,10 @@ export function HintSlotFactory(props: HintSlotProps, slots: Slots) {
72
85
  hasHintLabelOrSlot.value,
73
86
  )
74
87
  const hintSlotScope = computed(() => ({
75
- modelValue: props.modelValue,
76
- valid: props.valid,
77
- invalid: props.invalid,
78
- loading: props.loading,
88
+ modelValue: props.value.modelValue,
89
+ valid: props.value.valid,
90
+ invalid: props.value.invalid,
91
+ loading: props.value.loading,
79
92
  }))
80
93
  // component
81
94
  const HintSlot = defineComponent({
@@ -1,5 +1,7 @@
1
1
  export { default as VvAccordion } from './VvAccordion/VvAccordion.vue'
2
2
  export { default as VvAccordionGroup } from './VvAccordionGroup/VvAccordionGroup.vue'
3
+ export { default as VvAction } from './VvAction/VvAction.vue'
4
+ export { default as VvAlert } from './VvAlert/VvAlert.vue'
3
5
  export { default as VvBadge } from './VvBadge/VvBadge.vue'
4
6
  export { default as VvBreadcrumb } from './VvBreadcrumb/VvBreadcrumb.vue'
5
7
  export { default as VvButton } from './VvButton/VvButton.vue'
@@ -12,8 +14,11 @@ export { default as VvDialog } from './VvDialog/VvDialog.vue'
12
14
  export { default as VvDropdown } from './VvDropdown/VvDropdown.vue'
13
15
  export { default as VvIcon } from './VvIcon/VvIcon.vue'
14
16
  export { default as VvInputText } from './VvInputText/VvInputText.vue'
17
+ export { default as VvNav } from './VvNav/VvNav.vue'
15
18
  export { default as VvProgress } from './VvProgress/VvProgress.vue'
16
19
  export { default as VvRadio } from './VvRadio/VvRadio.vue'
17
20
  export { default as VvRadioGroup } from './VvRadioGroup/VvRadioGroup.vue'
18
21
  export { default as VvSelect } from './VvSelect/VvSelect.vue'
22
+ export { default as VvTab } from './VvTab/VvTab.vue'
19
23
  export { default as VvTextarea } from './VvTextarea/VvTextarea.vue'
24
+ export { default as VvTooltip } from './VvTooltip/VvTooltip.vue'
@@ -0,0 +1,103 @@
1
+ import {
2
+ DEFAULT_ALERT_AUTO_CLOSE,
3
+ DEFAULT_ALERT_DISMISSABLE,
4
+ DEFAULT_ALERT_GROUP,
5
+ DEFAULT_ALERT_MODIFIERS,
6
+ DEFAULT_ALERT_INFO_ICON,
7
+ DefaultAlertIconMap,
8
+ } from '@/constants'
9
+ import type { Alert, AlertModifiers } from '@/types/alert'
10
+
11
+ const groups = reactive(
12
+ new Map<string, Map<string, Alert>>([
13
+ [DEFAULT_ALERT_GROUP, new Map<string, Alert>()],
14
+ ]),
15
+ )
16
+
17
+ /**
18
+ * @description Composable to access alert groups, alerts and functions to add, remove and get alerts by group.
19
+ * @example
20
+ * const { groups, alerts, addAlert, removeAlert, getAlerts } = useAlert()
21
+ * addAlert({
22
+ * title: 'Success!',
23
+ * modifiers: 'success',
24
+ * })
25
+ *
26
+ * `<vv-alert-group :items="alerts" :onClose="removeAlert" />`
27
+ *
28
+ * @returns {
29
+ * alerts: ComputedRef<Alert[]> reactive list of alerts default group,
30
+ * groups: ReactiveRef<Map<string, Map<string, Alert>>>,
31
+ * addAlert: Function to add alert,
32
+ * removeAlert: Function to remove alert,
33
+ * getAlerts: Function to get alerts by group
34
+ * }
35
+ */
36
+ export const useAlert = () => {
37
+ const addAlert = (
38
+ {
39
+ id = crypto.randomUUID(),
40
+ group = DEFAULT_ALERT_GROUP,
41
+ title,
42
+ icon = DEFAULT_ALERT_INFO_ICON,
43
+ content,
44
+ footer,
45
+ modifiers = DEFAULT_ALERT_MODIFIERS,
46
+ dismissable = DEFAULT_ALERT_DISMISSABLE,
47
+ autoClose = DEFAULT_ALERT_AUTO_CLOSE,
48
+ } = {} as Partial<Alert>,
49
+ ) => {
50
+ if (!groups.has(group)) {
51
+ groups.set(group, new Map<string, Alert>())
52
+ }
53
+ const groupMap = groups.get(group)
54
+ const normalizedModifiers =
55
+ typeof modifiers === 'string' ? modifiers.split(' ') : modifiers
56
+
57
+ if (!icon) {
58
+ const alertModifier = normalizedModifiers.find((modifier) =>
59
+ DefaultAlertIconMap.has(modifier as AlertModifiers),
60
+ ) as AlertModifiers | undefined
61
+
62
+ if (alertModifier) {
63
+ icon = DefaultAlertIconMap.get(alertModifier) as string
64
+ }
65
+ }
66
+ groupMap?.set(id.toString(), {
67
+ id,
68
+ group,
69
+ title,
70
+ icon,
71
+ content,
72
+ footer,
73
+ modifiers,
74
+ dismissable,
75
+ autoClose,
76
+ timestamp: Date.now(),
77
+ })
78
+ }
79
+
80
+ const removeAlert = (id: string | number, group = DEFAULT_ALERT_GROUP) => {
81
+ const groupMap = groups.get(group)
82
+ groupMap?.delete(id.toString())
83
+ }
84
+
85
+ const getAlerts = (group = DEFAULT_ALERT_GROUP) => {
86
+ return computed(() => {
87
+ const groupMap = groups.get(group)
88
+ return groupMap && groupMap instanceof Map
89
+ ? Array.from(groupMap?.values()).sort(
90
+ (a, b) => a.timestamp - b.timestamp,
91
+ )
92
+ : []
93
+ })
94
+ }
95
+
96
+ return {
97
+ groups,
98
+ alerts: getAlerts(),
99
+ addAlert,
100
+ removeAlert,
101
+ getAlerts,
102
+ }
103
+ }
@@ -0,0 +1 @@
1
+ export { useAlert } from './alert/useAlert'
package/src/constants.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { InjectionKey, Ref } from 'vue'
2
2
  import type { Emitter } from 'mitt'
3
3
  import type { Volver } from './Volver'
4
+ import type { AlertModifiers } from './types/alert'
4
5
 
5
6
  export const DEFAULT_ICONIFY_PROVIDER = 'vv'
6
7
 
@@ -110,3 +111,23 @@ export const INJECTION_KEY_ALERT_GROUP = Symbol.for(
110
111
  name?: Ref<string | undefined>
111
112
  bus?: Emitter<{ close: string }>
112
113
  }>
114
+ export const DEFAULT_ALERT_AUTO_CLOSE = 10000
115
+ export const DEFAULT_ALERT_MODIFIERS = 'info'
116
+ export const DEFAULT_ALERT_DISMISSABLE = true
117
+ export const DEFAULT_ALERT_GROUP = 'default'
118
+ export const DEFAULT_ALERT_INFO_ICON = 'information'
119
+ export const DEFAULT_ALERT_SUCCESS_ICON = 'check-circle'
120
+ export const DEFAULT_ALERT_WARNING_ICON = 'warning'
121
+ export const DEFAULT_ALERT_DANGER_ICON = 'error'
122
+ export const DefaultAlertIconMap = new Map<AlertModifiers, string>([
123
+ ['success', DEFAULT_ALERT_SUCCESS_ICON],
124
+ ['info', DEFAULT_ALERT_INFO_ICON],
125
+ ['warning', DEFAULT_ALERT_WARNING_ICON],
126
+ ['danger', DEFAULT_ALERT_DANGER_ICON],
127
+ ])
128
+ // {
129
+ // success: DEFAULT_ALERT_SUCCESS_ICON,
130
+ // info: DEFAULT_ALERT_INFO_ICON,
131
+ // warning: DEFAULT_ALERT_WARNING_ICON,
132
+ // danger: DEFAULT_ALERT_DANGER_ICON,
133
+ // }
@@ -457,4 +457,11 @@ export const ActionProps = {
457
457
  validator: (value: ButtonType) =>
458
458
  Object.values(ButtonType).includes(value),
459
459
  },
460
+ /**
461
+ * Button aria-label
462
+ */
463
+ ariaLabel: {
464
+ type: String,
465
+ default: undefined,
466
+ },
460
467
  }
@@ -60,6 +60,9 @@ export const getStyleNames = function (kebabName: string) {
60
60
  'vv-dropdown-action',
61
61
  ]
62
62
  }
63
+ if (kebabName === 'vv-button-group') {
64
+ return ['vv-button', 'vv-button-group']
65
+ }
63
66
  if (kebabName === 'vv-accordion-group') {
64
67
  return ['vv-accordion', 'vv-accordion-group']
65
68
  }
@@ -1,7 +1,9 @@
1
+ import type { Meta } from '@storybook/vue3'
2
+ import type { VvAlert } from '@/components'
1
3
  import { IconArgTypes } from '../argTypes'
2
4
  import { ModifiersArgTypes } from '../argTypes'
3
5
 
4
- export const defaultArgs = {
6
+ export const defaultArgs: Meta<typeof VvAlert>['args'] = {
5
7
  title: 'Alert title!',
6
8
  content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
7
9
  dismissable: false,
@@ -6,6 +6,8 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
6
6
  const element = (await within(canvasElement).findByTestId(
7
7
  'element',
8
8
  )) as HTMLElement
9
+ const buttons =
10
+ canvasElement.getElementsByClassName('buttons-container')?.[0]
9
11
 
10
12
  expect(element).toHaveClass('vv-alert-group')
11
13
 
@@ -71,6 +73,17 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
71
73
  expect(element.lastElementChild?.innerHTML).toEqual(div.innerHTML)
72
74
  }
73
75
 
76
+ if (buttons) {
77
+ // click every button child and expect to have alert with correct css class
78
+ for (let i = 0; i < buttons.children.length; i++) {
79
+ const button = buttons.children[i] as HTMLElement
80
+ await button.click()
81
+ expect(alertGroupList.lastElementChild).toHaveClass(
82
+ `vv-alert--${button.id}`,
83
+ )
84
+ }
85
+ }
86
+
74
87
  // check accessibility
75
88
  await expect(element).toHaveNoViolations()
76
89
  }
@@ -1,11 +1,11 @@
1
1
  import type { Meta } from '@storybook/vue3'
2
- import VvAlert from '@/components/VvAlert/VvAlert.vue'
2
+ import VvAlertGroup from '@/components/VvAlertGroup/VvAlertGroup.vue'
3
3
  import { defaultArgs, argTypes } from './AlertGroup.settings'
4
4
  import { Default as DefaultStory, type Story } from './AlertGroup.stories'
5
5
 
6
- const meta: Meta<typeof VvAlert> = {
6
+ const meta: Meta<typeof VvAlertGroup> = {
7
7
  title: 'Components/AlertGroup/Slots',
8
- component: VvAlert,
8
+ component: VvAlertGroup,
9
9
  args: defaultArgs,
10
10
  argTypes,
11
11
  }
@@ -0,0 +1,118 @@
1
+ import type { Meta } from '@storybook/vue3'
2
+ import VvAlertGroup from '@/components/VvAlertGroup/VvAlertGroup.vue'
3
+ import VvButton from '@/components/VvButton/VvButton.vue'
4
+ import { defaultArgs, argTypes } from './AlertGroup.settings'
5
+ import { Default as DefaultStory, type Story } from './AlertGroup.stories'
6
+ import { useAlert } from '@/composables/alert/useAlert'
7
+
8
+ const meta: Meta<typeof VvAlertGroup> = {
9
+ title: 'Components/AlertGroup/UseComposable',
10
+ component: VvAlertGroup,
11
+ args: defaultArgs,
12
+ argTypes,
13
+ tags: ['autodocs'],
14
+ }
15
+
16
+ export default meta
17
+
18
+ export const UseComposable: Story = {
19
+ ...DefaultStory,
20
+ parameters: {
21
+ docs: {
22
+ source: {
23
+ type: 'code',
24
+ language: 'html',
25
+ code: /* html */ `
26
+ <div class="flex gap-md">
27
+ <vv-button label="Show success" modifiers="secondary" @click="showSuccess" class="mb-lg" />
28
+ <vv-button label="Show danger" modifiers="secondary" @click="showDanger" class="mb-lg" />
29
+ <vv-button label="Show warning" modifiers="secondary" @click="showWarning" class="mb-lg" />
30
+ <vv-button label="Show info" modifiers="secondary" @click="showInfo" class="mb-lg" />
31
+ </div>
32
+ <vv-alert-group v-bind="args" :items="alerts" :onClose="removeAlert" data-testId="element" />
33
+
34
+ <script setup lang='ts'>
35
+ import { useAlert } from '@volverjs/ui-vue/composables'
36
+
37
+ const { addAlert, removeAlert, alerts } = useAlert()
38
+
39
+ function showSuccess() {
40
+ addAlert({
41
+ title: 'Success!',
42
+ modifiers: 'success',
43
+ })
44
+ }
45
+ function showDanger() {
46
+ addAlert({
47
+ title: 'Danger!',
48
+ modifiers: 'danger',
49
+ })
50
+ }
51
+ function showWarning() {
52
+ addAlert({
53
+ title: 'Warning!',
54
+ modifiers: 'warning',
55
+ })
56
+ }
57
+ function showInfo() {
58
+ addAlert({
59
+ title: 'Info!',
60
+ modifiers: 'info',
61
+ })
62
+ }
63
+ </script>
64
+ `,
65
+ },
66
+ },
67
+ },
68
+ render: (args) => ({
69
+ components: { VvAlertGroup, VvButton },
70
+ setup() {
71
+ const { addAlert, removeAlert, alerts } = useAlert()
72
+
73
+ function showSuccess() {
74
+ addAlert({
75
+ title: 'Success!',
76
+ modifiers: 'success',
77
+ })
78
+ }
79
+ function showDanger() {
80
+ addAlert({
81
+ title: 'Danger!',
82
+ modifiers: 'danger',
83
+ })
84
+ }
85
+ function showWarning() {
86
+ addAlert({
87
+ title: 'Warning!',
88
+ modifiers: 'warning',
89
+ })
90
+ }
91
+ function showInfo() {
92
+ addAlert({
93
+ title: 'Info!',
94
+ modifiers: 'info',
95
+ })
96
+ }
97
+
98
+ return {
99
+ args,
100
+ alerts,
101
+ removeAlert,
102
+ showSuccess,
103
+ showDanger,
104
+ showWarning,
105
+ showInfo,
106
+ }
107
+ },
108
+ template: /* html */ `
109
+ <div class="buttons-container flex gap-md" >
110
+ <vv-button id="success" label="Show success" modifiers="secondary" @click="showSuccess" class="mb-lg" />
111
+ <vv-button id="danger" label="Show danger" modifiers="secondary" @click="showDanger" class="mb-lg" />
112
+ <vv-button id="warning" label="Show warning" modifiers="secondary" @click="showWarning" class="mb-lg" />
113
+ <vv-button id="info" label="Show info" modifiers="secondary" @click="showInfo" class="mb-lg" />
114
+ </div>
115
+ <vv-alert-group v-bind="args" :items="alerts" :onClose="removeAlert" data-testId="element" />
116
+ `,
117
+ }),
118
+ }
@@ -1,3 +1,5 @@
1
+ import type { Meta } from '@storybook/vue3'
2
+ import type { VvButton } from '@/components'
1
3
  import {
2
4
  DefaultSlotArgTypes,
3
5
  ModifiersArgTypes,
@@ -7,7 +9,7 @@ import {
7
9
  } from '@/stories/argTypes'
8
10
  import normal from '@/assets/icons/normal.json'
9
11
 
10
- export const defaultArgs = {
12
+ export const defaultArgs: Meta<typeof VvButton>['args'] = {
11
13
  label: 'Button',
12
14
  type: 'button',
13
15
  toggle: false,
@@ -22,7 +24,7 @@ export const defaultArgs = {
22
24
  }
23
25
 
24
26
  export const argTypes = {
25
- modifiers: {
27
+ modifiers: {
26
28
  ...ModifiersArgTypes.modifiers,
27
29
  options: [
28
30
  'primary',
@@ -153,5 +155,5 @@ export const argTypes = {
153
155
  summary: 'html',
154
156
  },
155
157
  },
156
- },
158
+ },
157
159
  }
@@ -1,3 +1,5 @@
1
+ import type { VvCombobox } from '@/components'
2
+ import type { Meta } from '@storybook/vue3'
1
3
  import {
2
4
  ValidArgTypes,
3
5
  InvalidArgTypes,
@@ -15,7 +17,7 @@ import {
15
17
  } from '@/stories/argTypes'
16
18
  import { VvComboboxProps } from '@/components/VvCombobox'
17
19
 
18
- export const defaultArgs = {
20
+ export const defaultArgs: Meta<typeof VvCombobox>['args'] = {
19
21
  ...propsToObject(VvComboboxProps),
20
22
  name: 'vv-combobox',
21
23
  maxValues: undefined,
@@ -43,6 +45,7 @@ export const defaultArgs = {
43
45
  ],
44
46
  placeholder: 'Select an option',
45
47
  label: 'Combobox label',
48
+ strategy: 'fixed',
46
49
  }
47
50
 
48
51
  export const argTypes = {
@@ -83,7 +86,7 @@ export const argTypes = {
83
86
  },
84
87
  },
85
88
  noResultsLabel: {
86
- description: 'Label of "no results" options',
89
+ description: 'Label for no search results',
87
90
  control: {
88
91
  type: 'text',
89
92
  },
@@ -93,6 +96,83 @@ export const argTypes = {
93
96
  },
94
97
  },
95
98
  },
99
+ noOptionsLabel: {
100
+ description: 'Label for no options available',
101
+ control: {
102
+ type: 'text',
103
+ },
104
+ table: {
105
+ defaultValue: {
106
+ summary: 'No options available',
107
+ },
108
+ },
109
+ },
110
+ selectedHintLabel: {
111
+ description: 'Label for selected option hint',
112
+ control: {
113
+ type: 'text',
114
+ },
115
+ table: {
116
+ defaultValue: {
117
+ summary: 'Selected',
118
+ },
119
+ },
120
+ },
121
+ deselectActionLabel: {
122
+ description: 'Label for deselect action button',
123
+ control: {
124
+ type: 'text',
125
+ },
126
+ table: {
127
+ defaultValue: {
128
+ summary: 'Deselect',
129
+ },
130
+ },
131
+ },
132
+ selectHintLabel: {
133
+ description: 'Label for select option hint',
134
+ control: {
135
+ type: 'text',
136
+ },
137
+ table: {
138
+ defaultValue: {
139
+ summary: 'Press enter to select',
140
+ },
141
+ },
142
+ },
143
+ deselectHintLabel: {
144
+ description: 'Label for deselected option hint',
145
+ control: {
146
+ type: 'text',
147
+ },
148
+ table: {
149
+ defaultValue: {
150
+ summary: 'Press enter to remove',
151
+ },
152
+ },
153
+ },
154
+ closeLabel: {
155
+ description: 'Label for close button',
156
+ control: {
157
+ type: 'text',
158
+ },
159
+ table: {
160
+ defaultValue: {
161
+ summary: 'Close',
162
+ },
163
+ },
164
+ },
165
+ loadingLabel: {
166
+ description: 'Label for loading',
167
+ control: {
168
+ type: 'text',
169
+ },
170
+ table: {
171
+ defaultValue: {
172
+ summary: 'Loading...',
173
+ },
174
+ },
175
+ },
96
176
  placeholder: {
97
177
  description: 'Text that appears when it has no value set.',
98
178
  control: {
@@ -107,12 +187,25 @@ export const argTypes = {
107
187
  },
108
188
  },
109
189
  },
190
+ searchFunction: {
191
+ description: 'Search function to filter options',
192
+ table: {
193
+ defaultValue: {
194
+ summary: undefined,
195
+ },
196
+ },
197
+ },
110
198
  searchPlaceholder: {
111
199
  description:
112
200
  'Text that appears in the in the search input when it has no value set..',
113
201
  control: {
114
202
  type: 'text',
115
203
  },
204
+ table: {
205
+ defaultValue: {
206
+ summary: 'Search...',
207
+ },
208
+ },
116
209
  },
117
210
  debounceSearch: {
118
211
  description: 'Debounce milliseconds for search',
@@ -170,6 +263,22 @@ export const argTypes = {
170
263
  type: 'text',
171
264
  },
172
265
  description: 'Modifiers for dropdown',
266
+ table: {
267
+ defaultValue: {
268
+ summary: 'mobile',
269
+ },
270
+ },
271
+ },
272
+ transitionName: {
273
+ control: {
274
+ type: 'text',
275
+ },
276
+ description: 'Transition name for dropdown',
277
+ table: {
278
+ defaultValue: {
279
+ summary: 'vv-dropdown--mobile-fade-block',
280
+ },
281
+ },
173
282
  },
174
283
  autoOpen: {
175
284
  description: 'Open dropdown on focus',
@@ -187,6 +296,14 @@ export const argTypes = {
187
296
  },
188
297
  },
189
298
  },
299
+ autofocusFirst: {
300
+ description: 'Autofocus first option on open dropdown',
301
+ table: {
302
+ defaultValue: {
303
+ summary: true,
304
+ },
305
+ },
306
+ },
190
307
  before: {
191
308
  control: {
192
309
  type: 'text',
@@ -1,7 +1,9 @@
1
+ import type { Meta } from '@storybook/vue3'
2
+ import type { VvNav } from '@/components'
1
3
  import { VvNavProps } from '@/components/VvNav'
2
4
  import { ModifiersArgTypes } from '@/stories/argTypes'
3
5
 
4
- export const defaultArgs = {
6
+ export const defaultArgs: Meta<typeof VvNav>['args'] = {
5
7
  ...propsToObject(VvNavProps),
6
8
  items: [
7
9
  {
@@ -20,9 +20,9 @@ export const Default: Story = {
20
20
  ...defaultArgs,
21
21
  },
22
22
  render: (args) => ({
23
- components: {VvTab},
23
+ components: { VvTab },
24
24
  setup() {
25
- return {args}
25
+ return { args }
26
26
  },
27
27
  template: /* html */ `
28
28
  <div class="m-md w-1/2">
@@ -64,7 +64,7 @@ export const Default: Story = {
64
64
  </p>
65
65
  </template>
66
66
  </vv-tab>
67
- </div>`
67
+ </div>`,
68
68
  }),
69
69
  play: defaultTest,
70
70
  }
@@ -35,7 +35,7 @@ export const Count: Story = {
35
35
  args: {
36
36
  ...Default.args,
37
37
  count: true,
38
- minLength: 100,
38
+ minlength: 100,
39
39
  },
40
40
  }
41
41