@volverjs/ui-vue 0.0.3 → 0.0.5-beta.1
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/LICENSE +1 -1
- package/README.md +54 -15
- package/auto-imports.d.ts +12 -3
- package/bin/icons.cjs +1 -73
- package/dist/Volver.d.ts +23 -11
- package/dist/components/VvAccordion/VvAccordion.es.js +180 -74
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +4 -1
- package/dist/components/VvAccordion/index.d.ts +8 -3
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +280 -122
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +15 -12
- package/dist/components/VvAccordionGroup/index.d.ts +8 -0
- package/dist/components/VvAction/VvAction.es.js +338 -0
- package/dist/components/VvAction/VvAction.umd.js +1 -0
- package/dist/components/VvAction/VvAction.vue.d.ts +63 -0
- package/dist/components/VvAction/index.d.ts +24 -0
- package/dist/components/VvBadge/VvBadge.es.js +251 -22
- package/dist/components/VvBadge/VvBadge.umd.js +1 -1
- package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -2
- package/dist/components/VvBadge/index.d.ts +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +280 -62
- package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +11 -11
- package/dist/components/VvBreadcrumb/index.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +720 -261
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +54 -54
- package/dist/components/VvButton/index.d.ts +30 -75
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +296 -49
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -2
- package/dist/components/VvButtonGroup/index.d.ts +1 -1
- package/dist/components/VvCard/VvCard.es.js +60 -28
- package/dist/components/VvCard/VvCard.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +630 -172
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +4 -4
- package/dist/components/VvCheckbox/index.d.ts +6 -6
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +736 -228
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +9 -9
- package/dist/components/VvCheckboxGroup/index.d.ts +4 -4
- package/dist/components/VvCombobox/VvCombobox.es.js +1673 -768
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +159 -61
- package/dist/components/VvCombobox/index.d.ts +54 -23
- package/dist/components/VvDialog/VvDialog.es.js +426 -115
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDialog/VvDialog.vue.d.ts +12 -3
- package/dist/components/VvDialog/index.d.ts +4 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +504 -190
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +114 -42
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +61 -0
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +52 -0
- package/dist/components/VvDropdown/index.d.ts +35 -14
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +454 -0
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -0
- package/dist/components/VvDropdownItem/VvDropdownItem.es.js +48 -18
- package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +361 -0
- package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -0
- package/dist/components/VvIcon/VvIcon.es.js +116 -52
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.vue.d.ts +7 -7
- package/dist/components/VvIcon/index.d.ts +2 -2
- package/dist/components/VvInputText/VvInputPasswordAction.d.ts +2 -2
- package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputText.es.js +1054 -376
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +107 -20
- package/dist/components/VvInputText/VvInputTextActions.d.ts +1 -1
- package/dist/components/VvInputText/index.d.ts +67 -3
- package/dist/components/VvProgress/VvProgress.es.js +254 -23
- package/dist/components/VvProgress/VvProgress.umd.js +1 -1
- package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -2
- package/dist/components/VvProgress/index.d.ts +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +568 -137
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +4 -4
- package/dist/components/VvRadio/index.d.ts +6 -6
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +674 -193
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +9 -9
- package/dist/components/VvRadioGroup/index.d.ts +4 -4
- package/dist/components/VvSelect/VvSelect.es.js +703 -251
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +24 -17
- package/dist/components/VvSelect/index.d.ts +8 -8
- package/dist/components/VvTextarea/VvTextarea.es.js +747 -272
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +21 -14
- package/dist/components/VvTextarea/index.d.ts +7 -7
- package/dist/components/VvTooltip/VvTooltip.es.js +252 -24
- package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +7 -7
- package/dist/components/VvTooltip/index.d.ts +2 -2
- package/dist/components/index.es.js +3676 -2007
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/dropdown/useInjectDropdown.d.ts +1 -1
- package/dist/composables/dropdown/useProvideDropdown.d.ts +3 -3
- package/dist/composables/group/useInjectedGroupState.d.ts +2 -2
- package/dist/composables/group/useProvideGroupState.d.ts +1 -1
- package/dist/composables/useComponentFocus.d.ts +1 -1
- package/dist/composables/useComponentIcon.d.ts +7 -7
- package/dist/composables/useDebouncedInput.d.ts +4 -1
- package/dist/composables/useDefaults.d.ts +2 -0
- package/dist/composables/useModifiers.d.ts +1 -1
- package/dist/composables/useOptions.d.ts +2 -2
- package/dist/composables/useTextCount.d.ts +3 -3
- package/dist/composables/useUniqueId.d.ts +1 -1
- package/dist/composables/useVolver.d.ts +1 -1
- package/dist/constants.d.ts +30 -0
- package/dist/directives/index.es.js +288 -0
- package/dist/directives/index.umd.js +1 -0
- package/dist/directives/v-tooltip.es.js +285 -0
- package/dist/directives/v-tooltip.umd.js +1 -0
- package/dist/icons.es.js +38 -23
- package/dist/icons.umd.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +115 -3269
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +215 -23
- package/dist/resolvers/unplugin.d.ts +14 -8
- package/dist/resolvers/unplugin.es.js +94 -33
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/Combobox/Combobox.settings.d.ts +44 -0
- package/dist/stories/Dropdown/Dropdown.settings.d.ts +3 -2
- package/dist/stories/InputText/InputText.settings.d.ts +53 -0
- package/dist/stories/argTypes.d.ts +1 -1
- package/package.json +167 -63
- package/src/Volver.ts +60 -26
- 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/VvAccordion/VvAccordion.vue +19 -22
- package/src/components/VvAccordion/index.ts +12 -4
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +19 -10
- package/src/components/VvAccordionGroup/index.ts +8 -0
- package/src/components/VvAction/VvAction.vue +144 -0
- package/src/components/VvAction/index.ts +5 -0
- package/src/components/VvBadge/VvBadge.vue +2 -2
- package/src/components/VvBadge/index.ts +1 -1
- package/src/components/VvBreadcrumb/VvBreadcrumb.vue +3 -3
- package/src/components/VvButton/VvButton.vue +41 -124
- package/src/components/VvButton/index.ts +16 -88
- package/src/components/VvButtonGroup/VvButtonGroup.vue +4 -7
- package/src/components/VvButtonGroup/index.ts +1 -1
- package/src/components/VvCard/VvCard.vue +2 -2
- package/src/components/VvCheckbox/VvCheckbox.vue +3 -7
- package/src/components/VvCheckbox/index.ts +11 -7
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +7 -10
- package/src/components/VvCheckboxGroup/index.ts +1 -1
- package/src/components/VvCombobox/VvCombobox.vue +85 -57
- package/src/components/VvCombobox/index.ts +12 -10
- package/src/components/VvDialog/VvDialog.vue +28 -11
- package/src/components/VvDialog/index.ts +5 -2
- package/src/components/VvDropdown/VvDropdown.vue +6 -5
- package/src/components/VvDropdown/VvDropdownAction.vue +46 -0
- package/src/components/VvDropdown/VvDropdownOption.vue +72 -0
- package/src/components/VvDropdown/index.ts +6 -11
- package/src/components/VvIcon/VvIcon.vue +3 -3
- package/src/components/VvIcon/index.ts +3 -3
- package/src/components/VvInputText/VvInputClearAction.ts +2 -2
- package/src/components/VvInputText/VvInputPasswordAction.ts +3 -4
- package/src/components/VvInputText/VvInputStepAction.ts +3 -2
- package/src/components/VvInputText/VvInputText.vue +128 -35
- package/src/components/VvInputText/VvInputTextActions.ts +5 -8
- package/src/components/VvInputText/index.ts +62 -1
- package/src/components/VvProgress/VvProgress.vue +2 -2
- package/src/components/VvProgress/index.ts +1 -1
- package/src/components/VvRadio/VvRadio.vue +3 -7
- package/src/components/VvRadio/index.ts +11 -7
- package/src/components/VvRadioGroup/VvRadioGroup.vue +7 -10
- package/src/components/VvRadioGroup/index.ts +1 -1
- package/src/components/VvSelect/VvSelect.vue +4 -4
- package/src/components/VvSelect/index.ts +3 -5
- package/src/components/VvTextarea/VvTextarea.vue +4 -4
- package/src/components/VvTextarea/index.ts +1 -1
- package/src/components/VvTooltip/VvTooltip.vue +2 -2
- package/src/components/VvTooltip/index.ts +3 -3
- package/src/composables/dropdown/useInjectDropdown.ts +2 -2
- package/src/composables/dropdown/useProvideDropdown.ts +9 -11
- package/src/composables/group/useInjectedGroupState.ts +1 -1
- package/src/composables/group/useProvideGroupState.ts +1 -1
- package/src/composables/useComponentIcon.ts +1 -1
- package/src/composables/useDebouncedInput.ts +10 -3
- package/src/composables/useDefaults.ts +89 -0
- package/src/composables/useModifiers.ts +8 -9
- package/src/composables/useOptions.ts +1 -1
- package/src/composables/useVolver.ts +2 -2
- package/src/constants.ts +36 -0
- package/src/directives/index.ts +1 -1
- package/src/directives/v-tooltip.ts +2 -2
- package/src/index.ts +0 -2
- package/src/props/index.ts +111 -19
- package/src/resolvers/unplugin.ts +96 -49
- package/src/stories/Accordion/Accordion.stories.mdx +8 -2
- package/src/stories/Accordion/Accordion.test.ts +21 -15
- package/src/stories/Accordion/AccordionSlots.stories.mdx +8 -8
- package/src/stories/AccordionGroup/AccordionGroup.stories.mdx +17 -1
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +18 -12
- package/src/stories/AccordionGroup/AccordionGroupSlots.stories.mdx +3 -2
- package/src/stories/Breadcrumb/Breadcrumb.stories.mdx +2 -1
- package/src/stories/Button/Button.stories.mdx +4 -2
- package/src/stories/Button/Button.test.ts +3 -1
- package/src/stories/Button/ButtonModifiers.stories.mdx +2 -2
- package/src/stories/Button/ButtonSlots.stories.mdx +8 -7
- package/src/stories/Button/ButtonState.stories.mdx +2 -11
- package/src/stories/Card/Card.stories.mdx +2 -1
- package/src/stories/Checkbox/Checkbox.stories.mdx +2 -1
- package/src/stories/CheckboxGroup/CheckboxGroup.stories.mdx +2 -1
- package/src/stories/CheckboxGroup/CheckboxGroupSlots.stories.mdx +2 -1
- package/src/stories/Combobox/Combobox.settings.ts +44 -0
- package/src/stories/Combobox/Combobox.stories.mdx +40 -1
- package/src/stories/Dialog/Dialog.stories.mdx +2 -1
- package/src/stories/Dropdown/Dropdown.settings.ts +3 -2
- package/src/stories/Dropdown/Dropdown.stories.mdx +14 -12
- package/src/stories/Dropdown/DropdownMultilevel.stories.mdx +56 -0
- package/src/stories/Dropdown/DropdownSlots.stories.mdx +14 -13
- package/src/stories/Icon/Icon.stories.mdx +2 -1
- package/src/stories/Icon/IconsCollection.stories.mdx +2 -1
- package/src/stories/InputText/InputText.settings.ts +53 -0
- package/src/stories/InputText/InputText.stories.mdx +42 -1
- package/src/stories/InputText/InputText.test.ts +5 -2
- package/src/stories/Progress/Progress.stories.mdx +2 -1
- package/src/stories/Radio/Radio.stories.mdx +2 -1
- package/src/stories/RadioGroup/RadioGroup.stories.mdx +2 -1
- package/src/stories/RadioGroup/RadioGroupSlots.stories.mdx +2 -1
- package/src/stories/Select/Select.stories.mdx +2 -1
- package/src/stories/Textarea/Textarea.stories.mdx +2 -1
- package/src/stories/Tooltip/Tooltip.stories.mdx +2 -1
- package/src/stories/Tooltip/TooltipDirective.stories.mdx +2 -1
- package/src/stories/argTypes.ts +2 -2
- package/src/types/group.d.ts +5 -0
|
@@ -6,11 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { nanoid } from 'nanoid'
|
|
9
|
-
import {
|
|
10
|
-
VvAccordionEvents,
|
|
11
|
-
VvAccordionProps,
|
|
12
|
-
useGroupProps,
|
|
13
|
-
} from '@/components/VvAccordion'
|
|
9
|
+
import { VvAccordionEvents, VvAccordionProps, useGroupProps } from '.'
|
|
14
10
|
|
|
15
11
|
// props, attrs and emit
|
|
16
12
|
const props = defineProps(VvAccordionProps)
|
|
@@ -29,23 +25,28 @@
|
|
|
29
25
|
collapse,
|
|
30
26
|
modelValue,
|
|
31
27
|
isInGroup,
|
|
28
|
+
not,
|
|
32
29
|
} = useGroupProps(props, emit)
|
|
33
30
|
const localModelValue = ref(false)
|
|
34
31
|
const isOpen = computed({
|
|
35
32
|
get: () => {
|
|
33
|
+
let toReturn = modelValue.value as boolean
|
|
36
34
|
if (isInGroup.value) {
|
|
37
35
|
if (collapse.value && Array.isArray(modelValue.value)) {
|
|
38
|
-
|
|
36
|
+
toReturn = modelValue.value.includes(accordionName.value)
|
|
37
|
+
} else {
|
|
38
|
+
toReturn = modelValue.value === accordionName.value
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
} else if (modelValue.value === undefined) {
|
|
41
|
+
// localModelValue is used when the accordion is not in a group
|
|
42
|
+
toReturn = localModelValue.value
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
if (modelValue.value === undefined) {
|
|
44
|
-
return localModelValue.value
|
|
45
|
-
}
|
|
46
|
-
return modelValue.value as boolean
|
|
44
|
+
return not.value ? !toReturn : toReturn
|
|
47
45
|
},
|
|
48
46
|
set: (newValue) => {
|
|
47
|
+
if (not.value) {
|
|
48
|
+
newValue = !newValue
|
|
49
|
+
}
|
|
49
50
|
if (isInGroup.value) {
|
|
50
51
|
if (collapse.value && Array.isArray(modelValue.value)) {
|
|
51
52
|
if (newValue) {
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
})
|
|
74
75
|
|
|
75
76
|
// styles
|
|
76
|
-
const bemCssClasses =
|
|
77
|
+
const bemCssClasses = useModifiers(
|
|
77
78
|
'vv-accordion',
|
|
78
79
|
modifiers,
|
|
79
80
|
computed(() => ({
|
|
@@ -86,25 +87,21 @@
|
|
|
86
87
|
</script>
|
|
87
88
|
|
|
88
89
|
<template>
|
|
89
|
-
<details
|
|
90
|
-
:id="accordionName"
|
|
91
|
-
:class="bemCssClasses"
|
|
92
|
-
:open="isOpen"
|
|
93
|
-
@click.prevent="onClick()"
|
|
94
|
-
>
|
|
90
|
+
<details :id="accordionName" :class="bemCssClasses" :open="isOpen">
|
|
95
91
|
<summary
|
|
96
92
|
:aria-controls="accordionName"
|
|
97
93
|
:aria-expanded="isOpen"
|
|
98
|
-
class="vv-
|
|
94
|
+
class="vv-accordion__summary"
|
|
95
|
+
@click.prevent="onClick()"
|
|
99
96
|
>
|
|
100
97
|
<!-- @slot Slot for title -->
|
|
101
98
|
<slot name="summary" v-bind="{ open: isOpen }">
|
|
102
99
|
{{ title }}
|
|
103
100
|
</slot>
|
|
104
101
|
</summary>
|
|
105
|
-
<div :aria-hidden="!isOpen" class="vv-
|
|
102
|
+
<div :aria-hidden="!isOpen" class="vv-accordion__content">
|
|
106
103
|
<!-- @slot Slot for content -->
|
|
107
|
-
<slot name="
|
|
104
|
+
<slot name="default" v-bind="{ open: isOpen }">
|
|
108
105
|
{{ content }}
|
|
109
106
|
</slot>
|
|
110
107
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExtractPropTypes, Ref } from 'vue'
|
|
2
|
-
import type { AccordionGroupState } from '
|
|
3
|
-
import { INJECTION_KEY_ACCORDION_GROUP } from '
|
|
2
|
+
import type { AccordionGroupState } from '../../types/group'
|
|
3
|
+
import { INJECTION_KEY_ACCORDION_GROUP } from '../../constants'
|
|
4
4
|
|
|
5
5
|
export const VvAccordionProps = {
|
|
6
6
|
/**
|
|
@@ -30,6 +30,10 @@ export const VvAccordionProps = {
|
|
|
30
30
|
* If true, the accordion will be disabled
|
|
31
31
|
*/
|
|
32
32
|
disabled: Boolean,
|
|
33
|
+
/**
|
|
34
|
+
* If true, the accordion will be opened by default
|
|
35
|
+
*/
|
|
36
|
+
not: Boolean,
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
export const VvAccordionEvents = ['update:modelValue']
|
|
@@ -52,20 +56,24 @@ export function useGroupProps(
|
|
|
52
56
|
|
|
53
57
|
// group props
|
|
54
58
|
const modelValue = getGroupOrLocalRef('modelValue', props, emit)
|
|
55
|
-
const
|
|
59
|
+
const not = getGroupOrLocalRef('not', props) as Ref<boolean>
|
|
56
60
|
const collapse = getGroupOrLocalRef('collapse', props) as Ref<boolean>
|
|
57
61
|
const modifiers = getGroupOrLocalRef('modifiers', props) as Ref<
|
|
58
62
|
Array<string> | string
|
|
59
63
|
>
|
|
64
|
+
const disabled = computed(() =>
|
|
65
|
+
Boolean(props.disabled || group?.value?.disabled.value),
|
|
66
|
+
)
|
|
60
67
|
|
|
61
68
|
return {
|
|
62
69
|
// group props
|
|
63
70
|
modelValue,
|
|
64
|
-
|
|
71
|
+
not,
|
|
65
72
|
isInGroup,
|
|
66
73
|
group,
|
|
67
74
|
collapse,
|
|
68
75
|
modifiers,
|
|
76
|
+
disabled,
|
|
69
77
|
// local props
|
|
70
78
|
title,
|
|
71
79
|
content,
|
|
@@ -6,20 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import type { Ref } from 'vue'
|
|
9
|
-
import type { AccordionGroupState } from '
|
|
10
|
-
import { INJECTION_KEY_ACCORDION_GROUP } from '
|
|
11
|
-
import VvAccordion from '
|
|
12
|
-
import {
|
|
13
|
-
VvAccordionGroupProps,
|
|
14
|
-
VvAccordionGroupEvents,
|
|
15
|
-
} from '@/components/VvAccordionGroup/'
|
|
9
|
+
import type { AccordionGroupState } from '../../types/group'
|
|
10
|
+
import { INJECTION_KEY_ACCORDION_GROUP } from '../../constants'
|
|
11
|
+
import VvAccordion from '../VvAccordion/VvAccordion.vue'
|
|
12
|
+
import { VvAccordionGroupProps, VvAccordionGroupEvents } from '.'
|
|
16
13
|
|
|
17
14
|
// props and emit
|
|
18
15
|
const props = defineProps(VvAccordionGroupProps)
|
|
19
16
|
const emit = defineEmits(VvAccordionGroupEvents)
|
|
20
17
|
|
|
21
18
|
// data
|
|
22
|
-
const { disabled, collapse, modifiers, itemModifiers, items } =
|
|
19
|
+
const { disabled, collapse, modifiers, itemModifiers, items, not } =
|
|
23
20
|
toRefs(props)
|
|
24
21
|
watchEffect(() => {
|
|
25
22
|
if (typeof props.modelValue === 'string' && collapse.value) {
|
|
@@ -29,7 +26,18 @@
|
|
|
29
26
|
)
|
|
30
27
|
}
|
|
31
28
|
})
|
|
32
|
-
|
|
29
|
+
let localModelValue: Ref<string[]> = ref([])
|
|
30
|
+
watch(
|
|
31
|
+
() => props.storeKey,
|
|
32
|
+
(newKey) => {
|
|
33
|
+
if (newKey) {
|
|
34
|
+
localModelValue = useStorage(newKey, localModelValue.value)
|
|
35
|
+
} else {
|
|
36
|
+
localModelValue = ref([])
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{ immediate: true },
|
|
40
|
+
)
|
|
33
41
|
const modelValue = computed({
|
|
34
42
|
get: () => {
|
|
35
43
|
if (props.modelValue !== undefined) {
|
|
@@ -67,10 +75,11 @@
|
|
|
67
75
|
disabled,
|
|
68
76
|
collapse,
|
|
69
77
|
modifiers: itemModifiers,
|
|
78
|
+
not,
|
|
70
79
|
})
|
|
71
80
|
|
|
72
81
|
// styles
|
|
73
|
-
const bemCssClasses =
|
|
82
|
+
const bemCssClasses = useModifiers(
|
|
74
83
|
'vv-accordion-group',
|
|
75
84
|
modifiers,
|
|
76
85
|
computed(() => ({
|
|
@@ -35,6 +35,14 @@ export const VvAccordionGroupProps = {
|
|
|
35
35
|
* If true, the accordion items will be disabled
|
|
36
36
|
*/
|
|
37
37
|
disabled: Boolean,
|
|
38
|
+
/**
|
|
39
|
+
* If true, the accordion items will be opened by default
|
|
40
|
+
*/
|
|
41
|
+
not: Boolean,
|
|
42
|
+
/**
|
|
43
|
+
* Enable local storage persistence
|
|
44
|
+
*/
|
|
45
|
+
storeKey: String,
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
export const VvAccordionGroupEvents = ['update:modelValue']
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export default {
|
|
3
|
+
name: 'VvAction',
|
|
4
|
+
}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { VvActionProps, VvActionEvents } from '.'
|
|
9
|
+
import { ActionTag } from '../../constants'
|
|
10
|
+
|
|
11
|
+
// props and emit
|
|
12
|
+
const props = defineProps(VvActionProps)
|
|
13
|
+
const emit = defineEmits(VvActionEvents)
|
|
14
|
+
|
|
15
|
+
// inject plugin
|
|
16
|
+
const volver = useVolver()
|
|
17
|
+
|
|
18
|
+
const element = ref<HTMLElement | null>(null)
|
|
19
|
+
defineExpose({ $el: element })
|
|
20
|
+
|
|
21
|
+
// drowpdown trigger
|
|
22
|
+
const {
|
|
23
|
+
reference: dropdownTriggerReference,
|
|
24
|
+
bus: dropdownEventBus,
|
|
25
|
+
aria: dropdownAria,
|
|
26
|
+
expanded: dropdownExpanded,
|
|
27
|
+
} = useInjectedDropdownTrigger()
|
|
28
|
+
watch(
|
|
29
|
+
() => element.value,
|
|
30
|
+
(newValue) => {
|
|
31
|
+
if (dropdownTriggerReference) {
|
|
32
|
+
dropdownTriggerReference.value = newValue
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
// pressed
|
|
38
|
+
const pressed = computed(() => {
|
|
39
|
+
return props.pressed || dropdownExpanded?.value
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// dropdown parent
|
|
43
|
+
const { role } = useInjectedDropdownAction()
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @description The tag defined by props.
|
|
47
|
+
* @returns {string} The tag.
|
|
48
|
+
*/
|
|
49
|
+
const hasTag = computed(() => {
|
|
50
|
+
switch (true) {
|
|
51
|
+
case props.disabled:
|
|
52
|
+
return ActionTag.button
|
|
53
|
+
case props.to !== undefined:
|
|
54
|
+
return volver?.nuxt ? ActionTag.nuxtLink : ActionTag.routerLink
|
|
55
|
+
case props.href !== undefined:
|
|
56
|
+
return ActionTag.a
|
|
57
|
+
default:
|
|
58
|
+
return ActionTag.button
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @description Define component attributes.
|
|
64
|
+
* @returns {Object} The component attributes.
|
|
65
|
+
*/
|
|
66
|
+
const hasProps = computed(() => {
|
|
67
|
+
const toReturn = {
|
|
68
|
+
...dropdownAria?.value,
|
|
69
|
+
'aria-pressed': pressed.value ? true : undefined,
|
|
70
|
+
role,
|
|
71
|
+
}
|
|
72
|
+
switch (hasTag.value) {
|
|
73
|
+
case ActionTag.a:
|
|
74
|
+
return {
|
|
75
|
+
...toReturn,
|
|
76
|
+
href: props.href,
|
|
77
|
+
target: props.target,
|
|
78
|
+
rel: props.rel,
|
|
79
|
+
}
|
|
80
|
+
case ActionTag.routerLink:
|
|
81
|
+
case ActionTag.nuxtLink:
|
|
82
|
+
return {
|
|
83
|
+
...toReturn,
|
|
84
|
+
to: props.to,
|
|
85
|
+
target: props.target,
|
|
86
|
+
}
|
|
87
|
+
default:
|
|
88
|
+
return {
|
|
89
|
+
...toReturn,
|
|
90
|
+
type: props.type,
|
|
91
|
+
disabled: props.disabled,
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @description Catch click event
|
|
98
|
+
*/
|
|
99
|
+
const onClick = (e: Event) => {
|
|
100
|
+
if (props.disabled) {
|
|
101
|
+
e.preventDefault()
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
dropdownEventBus?.emit('click', e)
|
|
105
|
+
emit('click', e)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @description Catch mouseover event
|
|
110
|
+
*/
|
|
111
|
+
const onMouseover = (e: Event) => {
|
|
112
|
+
dropdownEventBus?.emit('mouseover', e)
|
|
113
|
+
emit('mouseover', e)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @description Catch mouseleave event
|
|
118
|
+
*/
|
|
119
|
+
const onMouseleave = (e: Event) => {
|
|
120
|
+
dropdownEventBus?.emit('mouseleave', e)
|
|
121
|
+
emit('mouseleave', e)
|
|
122
|
+
}
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<template>
|
|
126
|
+
<component
|
|
127
|
+
v-bind="hasProps"
|
|
128
|
+
:is="hasTag"
|
|
129
|
+
ref="element"
|
|
130
|
+
:class="{
|
|
131
|
+
active,
|
|
132
|
+
pressed,
|
|
133
|
+
disabled,
|
|
134
|
+
}"
|
|
135
|
+
@click.passive="onClick"
|
|
136
|
+
@mouseover.passive="onMouseover"
|
|
137
|
+
@mouseleave.passive="onMouseleave"
|
|
138
|
+
>
|
|
139
|
+
<!-- @slot Default slot -->
|
|
140
|
+
<slot>
|
|
141
|
+
{{ label }}
|
|
142
|
+
</slot>
|
|
143
|
+
</component>
|
|
144
|
+
</template>
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import { VvBadgeProps } from '
|
|
8
|
+
import { VvBadgeProps } from '.'
|
|
9
9
|
|
|
10
10
|
const props = defineProps(VvBadgeProps)
|
|
11
11
|
const { modifiers } = toRefs(props)
|
|
12
|
-
const bemCssClasses =
|
|
12
|
+
const bemCssClasses = useModifiers('vv-badge', modifiers)
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<template>
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import {
|
|
9
|
-
import { VvBreadcrumbProps } from '
|
|
8
|
+
import { useModifiers } from '../../composables/useModifiers'
|
|
9
|
+
import { VvBreadcrumbProps } from '.'
|
|
10
10
|
|
|
11
11
|
const props = defineProps(VvBreadcrumbProps)
|
|
12
12
|
const { modifiers } = toRefs(props)
|
|
13
|
-
const bemCssClasses =
|
|
13
|
+
const bemCssClasses = useModifiers('vv-breadcrumb', modifiers)
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<template>
|
|
@@ -5,14 +5,10 @@
|
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import VvIcon from '
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
VvButtonProps,
|
|
13
|
-
useGroupProps,
|
|
14
|
-
} from '@/components/VvButton'
|
|
15
|
-
import { Side } from '@/constants'
|
|
8
|
+
import VvIcon from '../VvIcon/VvIcon.vue'
|
|
9
|
+
import VvAction from '../VvAction/VvAction.vue'
|
|
10
|
+
import { VvButtonEvents, VvButtonProps, useGroupProps } from '.'
|
|
11
|
+
import { Side } from '../../constants'
|
|
16
12
|
|
|
17
13
|
// props, attrs, slots and emit
|
|
18
14
|
const props = defineProps(VvButtonProps)
|
|
@@ -35,74 +31,42 @@
|
|
|
35
31
|
const hasId = useUniqueId(id)
|
|
36
32
|
const name = computed(() => (attrs?.name as string) || hasId.value)
|
|
37
33
|
|
|
38
|
-
// inject plugin
|
|
39
|
-
const volver = useVolver()
|
|
40
|
-
|
|
41
34
|
// expose el
|
|
42
|
-
const
|
|
35
|
+
const element = ref<{ $el: HTMLElement } | null>(null)
|
|
36
|
+
const $el = computed(() => element.value?.$el)
|
|
43
37
|
defineExpose({ $el })
|
|
44
38
|
|
|
45
|
-
// drowpdown trigger
|
|
46
|
-
const {
|
|
47
|
-
reference: dropdownTriggerReference,
|
|
48
|
-
bus: dropdownEventBus,
|
|
49
|
-
aria: dropdownAria,
|
|
50
|
-
} = useInjectedDropdownTrigger()
|
|
51
|
-
watch(
|
|
52
|
-
() => $el.value,
|
|
53
|
-
(newValue) => {
|
|
54
|
-
if (dropdownTriggerReference) {
|
|
55
|
-
dropdownTriggerReference.value = newValue
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
// dropdown parent
|
|
61
|
-
const { role } = useInjectedDropdownAction()
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @description The tag defined by props.
|
|
65
|
-
* @returns {string} The tag.
|
|
66
|
-
*/
|
|
67
|
-
const hasTag = computed(() => {
|
|
68
|
-
switch (true) {
|
|
69
|
-
case disabled.value:
|
|
70
|
-
return ButtonTag.button
|
|
71
|
-
case props.to !== undefined:
|
|
72
|
-
return volver?.nuxt ? ButtonTag.nuxtLink : ButtonTag.routerLink
|
|
73
|
-
case props.href !== undefined:
|
|
74
|
-
return ButtonTag.a
|
|
75
|
-
default:
|
|
76
|
-
return ButtonTag.button
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
|
|
80
39
|
/**
|
|
81
40
|
* @description The component pressed state by prop or group.
|
|
82
41
|
* @returns {string} The component tag.
|
|
83
42
|
*/
|
|
84
|
-
const
|
|
85
|
-
if (!toggle.value)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
43
|
+
const pressed = computed(() => {
|
|
44
|
+
if (!toggle.value) {
|
|
45
|
+
return props.pressed
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(modelValue.value)) {
|
|
48
|
+
return contains(name.value, modelValue.value)
|
|
49
|
+
}
|
|
50
|
+
return equals(name.value, modelValue.value)
|
|
90
51
|
})
|
|
91
52
|
|
|
92
53
|
/**
|
|
93
54
|
* @description Define component classes with BEM style.
|
|
94
55
|
* @returns {Array} The component classes.
|
|
95
56
|
*/
|
|
96
|
-
const bemCssClasses =
|
|
57
|
+
const bemCssClasses = useModifiers(
|
|
97
58
|
'vv-button',
|
|
98
59
|
modifiers,
|
|
99
60
|
computed(() => ({
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
61
|
+
reverse: [Side.right, Side.bottom].includes(
|
|
62
|
+
iconPosition.value as Side,
|
|
63
|
+
),
|
|
64
|
+
column: [Side.top, Side.bottom].includes(
|
|
65
|
+
iconPosition.value as Side,
|
|
66
|
+
),
|
|
67
|
+
'icon-only': Boolean(
|
|
68
|
+
icon?.value && !label?.value && !slots.default,
|
|
69
|
+
),
|
|
106
70
|
})),
|
|
107
71
|
)
|
|
108
72
|
|
|
@@ -114,48 +78,10 @@
|
|
|
114
78
|
typeof icon?.value === 'string' ? { name: icon?.value } : icon?.value,
|
|
115
79
|
)
|
|
116
80
|
|
|
117
|
-
/**
|
|
118
|
-
* @description Define component attributes.
|
|
119
|
-
* @returns {Object} The component attributes.
|
|
120
|
-
*/
|
|
121
|
-
const hasProps = computed(() => {
|
|
122
|
-
const toReturn = {
|
|
123
|
-
...dropdownAria?.value,
|
|
124
|
-
'aria-pressed': isPressed.value ? true : undefined,
|
|
125
|
-
class: bemCssClasses.value,
|
|
126
|
-
role,
|
|
127
|
-
}
|
|
128
|
-
switch (hasTag.value) {
|
|
129
|
-
case ButtonTag.a:
|
|
130
|
-
return {
|
|
131
|
-
...toReturn,
|
|
132
|
-
role: toReturn.role ?? 'button',
|
|
133
|
-
href: props.href,
|
|
134
|
-
target: props.target,
|
|
135
|
-
rel: props.rel,
|
|
136
|
-
}
|
|
137
|
-
case ButtonTag.routerLink:
|
|
138
|
-
case ButtonTag.nuxtLink:
|
|
139
|
-
return {
|
|
140
|
-
...toReturn,
|
|
141
|
-
role: toReturn.role ?? 'button',
|
|
142
|
-
to: props.to,
|
|
143
|
-
target: props.target,
|
|
144
|
-
}
|
|
145
|
-
default:
|
|
146
|
-
return {
|
|
147
|
-
...toReturn,
|
|
148
|
-
type: props.type,
|
|
149
|
-
disabled: disabled.value,
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
|
|
154
81
|
/**
|
|
155
82
|
* @description Catch click event
|
|
156
83
|
*/
|
|
157
|
-
const onClick = (
|
|
158
|
-
dropdownEventBus?.emit('click', e)
|
|
84
|
+
const onClick = () => {
|
|
159
85
|
if (toggle.value) {
|
|
160
86
|
if (Array.isArray(modelValue.value)) {
|
|
161
87
|
if (contains(name.value, modelValue.value)) {
|
|
@@ -169,39 +95,31 @@
|
|
|
169
95
|
modelValue.value.push(name.value)
|
|
170
96
|
return
|
|
171
97
|
}
|
|
172
|
-
if (equals(name, modelValue.value) && unselectable.value) {
|
|
98
|
+
if (equals(name.value, modelValue.value) && unselectable.value) {
|
|
173
99
|
modelValue.value = undefined
|
|
174
100
|
return
|
|
175
101
|
}
|
|
176
102
|
modelValue.value = name.value
|
|
177
103
|
}
|
|
178
104
|
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @description Catch mouseover event
|
|
182
|
-
*/
|
|
183
|
-
const onMouseover = (e: Event) => {
|
|
184
|
-
dropdownEventBus?.emit('mouseover', e)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @description Catch mouseleave event
|
|
189
|
-
*/
|
|
190
|
-
const onMouseleave = (e: Event) => {
|
|
191
|
-
dropdownEventBus?.emit('mouseleave', e)
|
|
192
|
-
}
|
|
193
105
|
</script>
|
|
194
106
|
|
|
195
107
|
<template>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
108
|
+
<VvAction
|
|
109
|
+
v-bind="{
|
|
110
|
+
disabled,
|
|
111
|
+
pressed,
|
|
112
|
+
active,
|
|
113
|
+
type,
|
|
114
|
+
to,
|
|
115
|
+
href,
|
|
116
|
+
target,
|
|
117
|
+
rel,
|
|
118
|
+
}"
|
|
200
119
|
:id="hasId"
|
|
201
|
-
ref="
|
|
202
|
-
|
|
203
|
-
@
|
|
204
|
-
@mouseleave.passive="onMouseleave"
|
|
120
|
+
ref="element"
|
|
121
|
+
:class="bemCssClasses"
|
|
122
|
+
@click="onClick"
|
|
205
123
|
>
|
|
206
124
|
<!-- @slot Default slot -->
|
|
207
125
|
<slot>
|
|
@@ -238,6 +156,5 @@
|
|
|
238
156
|
</template>
|
|
239
157
|
<!-- #endregion -->
|
|
240
158
|
</slot>
|
|
241
|
-
</
|
|
242
|
-
<!-- #endregion -->
|
|
159
|
+
</VvAction>
|
|
243
160
|
</template>
|