@volverjs/ui-vue 0.0.9-beta.2 → 0.0.9-beta.21
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/README.md +3 -3
- package/auto-imports.d.ts +2 -0
- package/dist/components/VvAccordion/VvAccordion.es.js +15 -7
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +15 -7
- package/dist/components/VvAction/VvAction.es.js +17 -8
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +9 -0
- package/dist/components/VvAction/index.d.ts +4 -0
- package/dist/components/VvAlert/VvAlert.es.js +22 -13
- package/dist/components/VvAlert/VvAlert.umd.js +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +6 -6
- package/dist/components/VvAlert/index.d.ts +3 -3
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +22 -13
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +6 -6
- package/dist/components/VvAlertGroup/index.d.ts +2 -2
- package/dist/components/VvAvatar/VvAvatar.es.js +15 -7
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +15 -7
- package/dist/components/VvBadge/VvBadge.es.js +15 -7
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +15 -7
- package/dist/components/VvButton/VvButton.es.js +19 -9
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +9 -0
- package/dist/components/VvButton/index.d.ts +4 -0
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +15 -7
- package/dist/components/VvCard/VvCard.es.js +15 -7
- package/dist/components/VvCheckbox/VvCheckbox.es.js +99 -21
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +4 -4
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +105 -22
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +4 -4
- package/dist/components/VvCombobox/VvCombobox.es.js +256 -191
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +329 -101
- package/dist/components/VvCombobox/index.d.ts +123 -37
- package/dist/components/VvDialog/VvDialog.es.js +50 -37
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +32 -18
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +300 -92
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +9 -0
- package/dist/components/VvDropdown/index.d.ts +99 -30
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +17 -8
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +15 -7
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +15 -7
- package/dist/components/VvInputText/VvInputText.es.js +279 -116
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +23 -41
- package/dist/components/VvInputText/index.d.ts +15 -33
- package/dist/components/VvNav/VvNav.es.js +18 -9
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNav/index.d.ts +1 -1
- package/dist/components/VvProgress/VvProgress.es.js +15 -7
- package/dist/components/VvRadio/VvRadio.es.js +99 -21
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +4 -4
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +105 -22
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +4 -4
- package/dist/components/VvSelect/VvSelect.es.js +95 -21
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +5 -5
- package/dist/components/VvTab/VvTab.es.js +18 -9
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +103 -26
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +4 -4
- package/dist/components/VvTooltip/VvTooltip.es.js +15 -7
- package/dist/components/common/HintSlot.d.ts +4 -3
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.es.js +1212 -626
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useAlert.d.ts +27 -0
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.es.js +81 -0
- package/dist/composables/index.umd.js +1 -0
- package/dist/constants.d.ts +14 -0
- package/dist/directives/index.es.js +15 -7
- package/dist/directives/v-tooltip.es.js +15 -7
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +107 -31
- package/dist/resolvers/unplugin.es.js +3 -0
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +2 -2
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +54 -269
- package/dist/stories/Alert/Alert.settings.d.ts +3 -7
- package/dist/stories/AlertGroup/AlertGroupSlots.stories.d.ts +2 -2
- package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +6 -0
- package/dist/stories/Button/Button.settings.d.ts +3 -13
- package/dist/stories/Combobox/Combobox.settings.d.ts +117 -19
- package/dist/stories/InputText/InputText.settings.d.ts +31 -9
- package/dist/stories/InputText/InputText.stories.d.ts +0 -1
- package/dist/stories/InputText/InputTextMask.stories.d.ts +12 -0
- package/dist/stories/Nav/Nav.settings.d.ts +3 -21
- package/package.json +75 -66
- 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/components/VvAction/VvAction.vue +2 -1
- package/src/components/VvAlert/VvAlert.vue +5 -1
- package/src/components/VvAlert/index.ts +3 -3
- package/src/components/VvAlertGroup/VvAlertGroup.vue +2 -0
- package/src/components/VvButton/VvButton.vue +1 -0
- package/src/components/VvCheckbox/VvCheckbox.vue +8 -1
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +8 -1
- package/src/components/VvCombobox/VvCombobox.vue +43 -23
- package/src/components/VvCombobox/index.ts +24 -0
- package/src/components/VvDialog/VvDialog.vue +22 -19
- package/src/components/VvDropdown/VvDropdown.vue +24 -18
- package/src/components/VvInputText/VvInputText.vue +177 -55
- package/src/components/VvInputText/index.ts +32 -34
- package/src/components/VvNav/VvNav.vue +1 -1
- package/src/components/VvNav/index.ts +1 -1
- package/src/components/VvRadio/VvRadio.vue +8 -1
- package/src/components/VvRadioGroup/VvRadioGroup.vue +8 -1
- package/src/components/VvSelect/VvSelect.vue +8 -1
- package/src/components/VvTextarea/VvTextarea.vue +16 -6
- package/src/components/common/HintSlot.ts +26 -13
- package/src/components/index.ts +5 -0
- package/src/composables/alert/useAlert.ts +103 -0
- package/src/composables/index.ts +1 -0
- package/src/constants.ts +26 -0
- package/src/props/index.ts +14 -11
- package/src/resolvers/unplugin.ts +3 -0
- package/src/stories/Alert/Alert.settings.ts +3 -1
- package/src/stories/AlertGroup/AlertGroup.test.ts +13 -0
- package/src/stories/AlertGroup/AlertGroupSlots.stories.ts +3 -3
- package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +118 -0
- package/src/stories/Button/Button.settings.ts +5 -3
- package/src/stories/Combobox/Combobox.settings.ts +119 -2
- package/src/stories/Combobox/Combobox.test.ts +1 -1
- package/src/stories/InputText/InputText.settings.ts +36 -15
- package/src/stories/InputText/InputText.stories.ts +4 -12
- package/src/stories/InputText/InputText.test.ts +31 -15
- package/src/stories/InputText/InputTextMask.stories.ts +122 -0
- package/src/stories/Nav/Nav.settings.ts +3 -1
- package/src/stories/Tab/Tab.stories.ts +3 -3
- package/src/stories/Textarea/TextareaLength.stories.ts +1 -1
- package/src/types/alert.d.ts +20 -0
- /package/dist/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue.d.ts +0 -0
- /package/dist/components/{VvNavSeparator → VvNav}/VvNavSeparator.d.ts +0 -0
- /package/src/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue +0 -0
- /package/src/components/{VvNavSeparator → VvNav}/VvNavSeparator.ts +0 -0
|
@@ -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,9 +1,15 @@
|
|
|
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
|
|
|
8
|
+
export enum Strategy {
|
|
9
|
+
absolute = 'absolute',
|
|
10
|
+
fixed = 'fixed',
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
export enum Side {
|
|
8
14
|
left = 'left',
|
|
9
15
|
right = 'right',
|
|
@@ -110,3 +116,23 @@ export const INJECTION_KEY_ALERT_GROUP = Symbol.for(
|
|
|
110
116
|
name?: Ref<string | undefined>
|
|
111
117
|
bus?: Emitter<{ close: string }>
|
|
112
118
|
}>
|
|
119
|
+
export const DEFAULT_ALERT_AUTO_CLOSE = 10000
|
|
120
|
+
export const DEFAULT_ALERT_MODIFIERS = 'info'
|
|
121
|
+
export const DEFAULT_ALERT_DISMISSABLE = true
|
|
122
|
+
export const DEFAULT_ALERT_GROUP = 'default'
|
|
123
|
+
export const DEFAULT_ALERT_INFO_ICON = 'information'
|
|
124
|
+
export const DEFAULT_ALERT_SUCCESS_ICON = 'check-circle'
|
|
125
|
+
export const DEFAULT_ALERT_WARNING_ICON = 'warning'
|
|
126
|
+
export const DEFAULT_ALERT_DANGER_ICON = 'error'
|
|
127
|
+
export const DefaultAlertIconMap = new Map<AlertModifiers, string>([
|
|
128
|
+
['success', DEFAULT_ALERT_SUCCESS_ICON],
|
|
129
|
+
['info', DEFAULT_ALERT_INFO_ICON],
|
|
130
|
+
['warning', DEFAULT_ALERT_WARNING_ICON],
|
|
131
|
+
['danger', DEFAULT_ALERT_DANGER_ICON],
|
|
132
|
+
])
|
|
133
|
+
// {
|
|
134
|
+
// success: DEFAULT_ALERT_SUCCESS_ICON,
|
|
135
|
+
// info: DEFAULT_ALERT_INFO_ICON,
|
|
136
|
+
// warning: DEFAULT_ALERT_WARNING_ICON,
|
|
137
|
+
// danger: DEFAULT_ALERT_DANGER_ICON,
|
|
138
|
+
// }
|
package/src/props/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
} from '../types/floating-ui'
|
|
10
10
|
import {
|
|
11
11
|
Placement,
|
|
12
|
+
Strategy,
|
|
12
13
|
Position,
|
|
13
14
|
Side,
|
|
14
15
|
AnchorTarget,
|
|
@@ -228,22 +229,17 @@ export const DropdownProps = {
|
|
|
228
229
|
placement: {
|
|
229
230
|
type: String as PropType<`${Side}` | `${Placement}`>,
|
|
230
231
|
default: Side.bottom,
|
|
231
|
-
validator: (value: Side & Placement) =>
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
Object.values(Placement).includes(value)
|
|
235
|
-
)
|
|
236
|
-
},
|
|
232
|
+
validator: (value: Side & Placement) =>
|
|
233
|
+
Object.values(Side).includes(value) ||
|
|
234
|
+
Object.values(Placement).includes(value),
|
|
237
235
|
},
|
|
238
236
|
/**
|
|
239
237
|
* Dropdown strategy
|
|
240
238
|
*/
|
|
241
239
|
strategy: {
|
|
242
|
-
type: String as PropType
|
|
243
|
-
default:
|
|
244
|
-
validator: (value:
|
|
245
|
-
return ['fixed', 'absolute'].includes(value)
|
|
246
|
-
},
|
|
240
|
+
type: String as PropType<`${Strategy}`>,
|
|
241
|
+
default: undefined,
|
|
242
|
+
validator: (value: Strategy) => Object.values(Strategy).includes(value),
|
|
247
243
|
},
|
|
248
244
|
/**
|
|
249
245
|
* Dropdown show / hide transition name
|
|
@@ -457,4 +453,11 @@ export const ActionProps = {
|
|
|
457
453
|
validator: (value: ButtonType) =>
|
|
458
454
|
Object.values(ButtonType).includes(value),
|
|
459
455
|
},
|
|
456
|
+
/**
|
|
457
|
+
* Button aria-label
|
|
458
|
+
*/
|
|
459
|
+
ariaLabel: {
|
|
460
|
+
type: String,
|
|
461
|
+
default: undefined,
|
|
462
|
+
},
|
|
460
463
|
}
|
|
@@ -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
|
|
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
|
|
6
|
+
const meta: Meta<typeof VvAlertGroup> = {
|
|
7
7
|
title: 'Components/AlertGroup/Slots',
|
|
8
|
-
component:
|
|
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
|
-
|
|
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
|
|
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',
|
|
@@ -62,7 +62,7 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// select second value
|
|
65
|
-
if (args.options.length > 1) {
|
|
65
|
+
if (args.options && args.options.length > 1) {
|
|
66
66
|
await expect(dropdownSecondItem).toBeClicked()
|
|
67
67
|
await sleep()
|
|
68
68
|
const secondValue = getOptionValue(
|
|
@@ -174,43 +174,64 @@ export const argTypes = {
|
|
|
174
174
|
},
|
|
175
175
|
},
|
|
176
176
|
},
|
|
177
|
-
|
|
178
|
-
description: '
|
|
179
|
-
|
|
177
|
+
iMask: {
|
|
178
|
+
description: '[iMask](https://imask.js.org/guide.html) options',
|
|
179
|
+
control: {
|
|
180
|
+
type: 'object',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
masked: {
|
|
184
|
+
description: 'Masked input',
|
|
180
185
|
control: {
|
|
181
186
|
type: 'text',
|
|
182
187
|
},
|
|
183
188
|
},
|
|
184
|
-
|
|
185
|
-
description: '
|
|
189
|
+
autoWidth: {
|
|
190
|
+
description: 'Adjust input width to content',
|
|
191
|
+
control: {
|
|
192
|
+
type: 'boolean',
|
|
193
|
+
},
|
|
186
194
|
table: {
|
|
187
195
|
defaultValue: {
|
|
188
196
|
summary: false,
|
|
189
197
|
},
|
|
198
|
+
type: {
|
|
199
|
+
summary: 'boolean',
|
|
200
|
+
},
|
|
190
201
|
},
|
|
191
202
|
},
|
|
192
|
-
|
|
193
|
-
description: '
|
|
203
|
+
hideActions: {
|
|
204
|
+
description: 'Hide type number, password and search actions',
|
|
205
|
+
control: {
|
|
206
|
+
type: 'boolean',
|
|
207
|
+
},
|
|
194
208
|
table: {
|
|
195
209
|
defaultValue: {
|
|
196
210
|
summary: false,
|
|
197
211
|
},
|
|
212
|
+
type: {
|
|
213
|
+
summary: 'boolean',
|
|
214
|
+
},
|
|
198
215
|
},
|
|
199
216
|
},
|
|
200
|
-
|
|
201
|
-
description: 'Add
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
summary: 'undefined',
|
|
205
|
-
},
|
|
217
|
+
unit: {
|
|
218
|
+
description: 'Add unit label to input',
|
|
219
|
+
control: {
|
|
220
|
+
type: 'text',
|
|
206
221
|
},
|
|
207
222
|
},
|
|
208
|
-
|
|
209
|
-
description: '
|
|
223
|
+
selectOnFocus: {
|
|
224
|
+
description: 'Select input text on focus',
|
|
225
|
+
control: {
|
|
226
|
+
type: 'boolean',
|
|
227
|
+
},
|
|
210
228
|
table: {
|
|
211
229
|
defaultValue: {
|
|
212
230
|
summary: false,
|
|
213
231
|
},
|
|
232
|
+
type: {
|
|
233
|
+
summary: 'boolean',
|
|
234
|
+
},
|
|
214
235
|
},
|
|
215
236
|
},
|
|
216
237
|
before: {
|