@volverjs/ui-vue 0.0.4 → 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/README.md +2 -2
- package/auto-imports.d.ts +12 -3
- package/bin/icons.cjs +1 -73
- package/dist/Volver.d.ts +19 -11
- package/dist/components/VvAccordion/VvAccordion.es.js +165 -106
- 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 +264 -164
- 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 +266 -98
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +12 -12
- package/dist/components/VvAction/index.d.ts +2 -2
- package/dist/components/VvBadge/VvBadge.es.js +203 -44
- 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 +237 -75
- 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 +636 -360
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +18 -18
- package/dist/components/VvButton/index.d.ts +13 -13
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +251 -79
- 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 +57 -38
- package/dist/components/VvCard/VvCard.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +552 -274
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +2 -2
- package/dist/components/VvCheckbox/index.d.ts +5 -5
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +651 -340
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +7 -7
- package/dist/components/VvCheckboxGroup/index.d.ts +3 -3
- package/dist/components/VvCombobox/VvCombobox.es.js +1532 -983
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +125 -51
- package/dist/components/VvCombobox/index.d.ts +36 -10
- package/dist/components/VvDialog/VvDialog.es.js +377 -141
- 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 +440 -244
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +113 -41
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +13 -13
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -2
- package/dist/components/VvDropdown/index.d.ts +35 -11
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +363 -160
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownItem/VvDropdownItem.es.js +43 -28
- package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +275 -90
- package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +113 -65
- 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 +974 -460
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +96 -16
- package/dist/components/VvInputText/VvInputTextActions.d.ts +1 -1
- package/dist/components/VvInputText/index.d.ts +64 -11
- package/dist/components/VvProgress/VvProgress.es.js +206 -45
- 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 +489 -238
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +2 -2
- package/dist/components/VvRadio/index.d.ts +5 -5
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +588 -304
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +7 -7
- package/dist/components/VvRadioGroup/index.d.ts +3 -3
- package/dist/components/VvSelect/VvSelect.es.js +621 -324
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +13 -13
- package/dist/components/VvSelect/index.d.ts +3 -3
- package/dist/components/VvTextarea/VvTextarea.es.js +664 -353
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +10 -10
- package/dist/components/VvTextarea/index.d.ts +2 -2
- package/dist/components/VvTooltip/VvTooltip.es.js +205 -47
- 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 +3508 -2231
- 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/directives/index.es.js +215 -55
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-tooltip.es.js +212 -53
- package/dist/directives/v-tooltip.umd.js +1 -1
- 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 +112 -3607
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +40 -16
- package/dist/resolvers/unplugin.d.ts +7 -1
- package/dist/resolvers/unplugin.es.js +77 -37
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/InputText/InputText.settings.d.ts +53 -0
- package/dist/stories/argTypes.d.ts +1 -1
- package/package.json +114 -36
- package/src/Volver.ts +49 -22
- 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 +7 -7
- package/src/components/VvAction/index.ts +1 -1
- 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 +11 -11
- package/src/components/VvButton/index.ts +10 -9
- 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 +39 -23
- package/src/components/VvCombobox/index.ts +1 -1
- 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 +7 -5
- package/src/components/VvDropdown/VvDropdownOption.vue +17 -10
- package/src/components/VvDropdown/index.ts +3 -3
- 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 +1 -1
- 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 +2 -2
- 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 +4 -2
- package/src/composables/useOptions.ts +1 -1
- package/src/composables/useVolver.ts +2 -2
- 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 +8 -8
- package/src/resolvers/unplugin.ts +15 -1
- 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 +1 -1
- package/src/stories/InputText/InputText.settings.ts +53 -0
- package/src/stories/InputText/InputText.stories.mdx +40 -0
- package/src/stories/InputText/InputText.test.ts +5 -2
- package/src/stories/argTypes.ts +2 -2
- package/src/types/group.d.ts +5 -0
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import { unref
|
|
2
|
-
import { nanoid
|
|
3
|
-
import { useToggle
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
return ((
|
|
1
|
+
import { unref, inject, computed, toRef, toRefs, defineComponent, useAttrs, ref, openBlock, createElementBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, isRef, provide, watchEffect, watch, Fragment, renderList, createBlock, mergeProps, withCtx } from "vue";
|
|
2
|
+
import { nanoid } from "nanoid";
|
|
3
|
+
import { useToggle, useStorage } from "@vueuse/core";
|
|
4
|
+
const INJECTION_KEY_ACCORDION_GROUP = Symbol.for("accordionGroup");
|
|
5
|
+
function isEmpty(value) {
|
|
6
|
+
return ((value2) => value2 === null || value2 === void 0 || value2 === "" || Array.isArray(value2) && value2.length === 0 || !(value2 instanceof Date) && typeof value2 === "object" && Object.keys(value2).length === 0)(unref(value));
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
function useInjectedGroupState(groupKey) {
|
|
9
|
+
const group = inject(groupKey, void 0);
|
|
10
|
+
const isInGroup = computed(() => !isEmpty(group));
|
|
11
|
+
function getGroupOrLocalRef(propName, props, emit) {
|
|
12
|
+
if (group == null ? void 0 : group.value) {
|
|
13
|
+
const groupPropValue = unref(group.value)[propName];
|
|
14
|
+
return computed({
|
|
14
15
|
get() {
|
|
15
|
-
return
|
|
16
|
+
return groupPropValue == null ? void 0 : groupPropValue.value;
|
|
16
17
|
},
|
|
17
|
-
set(
|
|
18
|
-
|
|
18
|
+
set(value) {
|
|
19
|
+
groupPropValue.value = value;
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
const
|
|
23
|
-
return
|
|
23
|
+
const propRef = toRef(props, propName);
|
|
24
|
+
return computed({
|
|
24
25
|
get() {
|
|
25
|
-
return
|
|
26
|
+
return propRef.value;
|
|
26
27
|
},
|
|
27
|
-
set(
|
|
28
|
-
|
|
28
|
+
set(value) {
|
|
29
|
+
if (emit)
|
|
30
|
+
emit(`update:${propName}`, value);
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
return {
|
|
33
|
-
group
|
|
34
|
-
isInGroup
|
|
35
|
-
getGroupOrLocalRef
|
|
35
|
+
group,
|
|
36
|
+
isInGroup,
|
|
37
|
+
getGroupOrLocalRef
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
|
-
const
|
|
40
|
+
const VvAccordionProps = {
|
|
39
41
|
/**
|
|
40
42
|
* Accordion name
|
|
41
43
|
*/
|
|
@@ -62,110 +64,168 @@ const W = {
|
|
|
62
64
|
/**
|
|
63
65
|
* If true, the accordion will be disabled
|
|
64
66
|
*/
|
|
65
|
-
disabled: Boolean
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
disabled: Boolean,
|
|
68
|
+
/**
|
|
69
|
+
* If true, the accordion will be opened by default
|
|
70
|
+
*/
|
|
71
|
+
not: Boolean
|
|
72
|
+
};
|
|
73
|
+
const VvAccordionEvents = ["update:modelValue"];
|
|
74
|
+
function useGroupProps(props, emit) {
|
|
75
|
+
const { group, isInGroup, getGroupOrLocalRef } = useInjectedGroupState(
|
|
76
|
+
INJECTION_KEY_ACCORDION_GROUP
|
|
77
|
+
);
|
|
78
|
+
const { title, content } = toRefs(props);
|
|
79
|
+
const modelValue = getGroupOrLocalRef("modelValue", props, emit);
|
|
80
|
+
const not = getGroupOrLocalRef("not", props);
|
|
81
|
+
const collapse = getGroupOrLocalRef("collapse", props);
|
|
82
|
+
const modifiers = getGroupOrLocalRef("modifiers", props);
|
|
83
|
+
const disabled = computed(
|
|
84
|
+
() => {
|
|
85
|
+
var _a;
|
|
86
|
+
return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
|
|
87
|
+
}
|
|
88
|
+
);
|
|
71
89
|
return {
|
|
72
90
|
// group props
|
|
73
|
-
modelValue
|
|
74
|
-
|
|
75
|
-
isInGroup
|
|
76
|
-
group
|
|
77
|
-
collapse
|
|
78
|
-
modifiers
|
|
91
|
+
modelValue,
|
|
92
|
+
not,
|
|
93
|
+
isInGroup,
|
|
94
|
+
group,
|
|
95
|
+
collapse,
|
|
96
|
+
modifiers,
|
|
97
|
+
disabled,
|
|
79
98
|
// local props
|
|
80
|
-
title
|
|
81
|
-
content
|
|
99
|
+
title,
|
|
100
|
+
content
|
|
82
101
|
};
|
|
83
102
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
86
|
-
const
|
|
87
|
-
[
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
function useModifiers(prefix, modifiers, others) {
|
|
104
|
+
return computed(() => {
|
|
105
|
+
const toReturn = {
|
|
106
|
+
[prefix]: true
|
|
107
|
+
};
|
|
108
|
+
const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
|
|
109
|
+
if (modifiersArray) {
|
|
110
|
+
if (Array.isArray(modifiersArray)) {
|
|
111
|
+
modifiersArray.forEach((modifier) => {
|
|
112
|
+
if (modifier) {
|
|
113
|
+
toReturn[`${prefix}--${modifier}`] = true;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (others) {
|
|
119
|
+
Object.keys(others.value).forEach((key) => {
|
|
120
|
+
toReturn[`${prefix}--${key}`] = unref(others.value[key]);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return toReturn;
|
|
94
124
|
});
|
|
95
125
|
}
|
|
96
|
-
const
|
|
126
|
+
const _hoisted_1 = ["id", "open"];
|
|
127
|
+
const _hoisted_2 = ["aria-controls", "aria-expanded"];
|
|
128
|
+
const _hoisted_3 = ["aria-hidden"];
|
|
129
|
+
const __default__$1 = {
|
|
97
130
|
name: "VvAccordion"
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
131
|
+
};
|
|
132
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
133
|
+
...__default__$1,
|
|
134
|
+
props: VvAccordionProps,
|
|
135
|
+
emits: VvAccordionEvents,
|
|
136
|
+
setup(__props, { emit }) {
|
|
137
|
+
const props = __props;
|
|
138
|
+
const attrs = useAttrs();
|
|
139
|
+
const accordionName = computed(
|
|
140
|
+
() => props.name || (attrs == null ? void 0 : attrs.id) || nanoid()
|
|
141
|
+
);
|
|
142
|
+
const {
|
|
143
|
+
modifiers,
|
|
144
|
+
title,
|
|
145
|
+
content,
|
|
146
|
+
disabled,
|
|
147
|
+
collapse,
|
|
148
|
+
modelValue,
|
|
149
|
+
isInGroup,
|
|
150
|
+
not
|
|
151
|
+
} = useGroupProps(props, emit);
|
|
152
|
+
const localModelValue = ref(false);
|
|
153
|
+
const isOpen = computed({
|
|
154
|
+
get: () => {
|
|
155
|
+
let toReturn = modelValue.value;
|
|
156
|
+
if (isInGroup.value) {
|
|
157
|
+
if (collapse.value && Array.isArray(modelValue.value)) {
|
|
158
|
+
toReturn = modelValue.value.includes(accordionName.value);
|
|
159
|
+
} else {
|
|
160
|
+
toReturn = modelValue.value === accordionName.value;
|
|
161
|
+
}
|
|
162
|
+
} else if (modelValue.value === void 0) {
|
|
163
|
+
toReturn = localModelValue.value;
|
|
164
|
+
}
|
|
165
|
+
return not.value ? !toReturn : toReturn;
|
|
166
|
+
},
|
|
167
|
+
set: (newValue) => {
|
|
168
|
+
if (not.value) {
|
|
169
|
+
newValue = !newValue;
|
|
170
|
+
}
|
|
171
|
+
if (isInGroup.value) {
|
|
172
|
+
if (collapse.value && Array.isArray(modelValue.value)) {
|
|
173
|
+
if (newValue) {
|
|
174
|
+
modelValue.value.push(accordionName.value);
|
|
120
175
|
return;
|
|
121
176
|
}
|
|
122
|
-
|
|
123
|
-
(
|
|
177
|
+
modelValue.value = modelValue.value.filter(
|
|
178
|
+
(name) => name !== accordionName.value
|
|
124
179
|
);
|
|
125
180
|
return;
|
|
126
181
|
}
|
|
127
|
-
|
|
182
|
+
modelValue.value = newValue ? accordionName.value : null;
|
|
128
183
|
return;
|
|
129
184
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
185
|
+
if (modelValue.value === void 0 && typeof newValue === "boolean") {
|
|
186
|
+
localModelValue.value = newValue;
|
|
132
187
|
return;
|
|
133
188
|
}
|
|
134
|
-
|
|
189
|
+
modelValue.value = newValue;
|
|
135
190
|
}
|
|
136
|
-
})
|
|
191
|
+
});
|
|
192
|
+
const bemCssClasses = useModifiers(
|
|
137
193
|
"vv-accordion",
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
disabled:
|
|
194
|
+
modifiers,
|
|
195
|
+
computed(() => ({
|
|
196
|
+
disabled: disabled.value
|
|
141
197
|
}))
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
G("summary", {
|
|
150
|
-
"aria-controls": l(o),
|
|
151
|
-
"aria-expanded": l(u),
|
|
152
|
-
class: "vv-collapse__summary"
|
|
153
|
-
}, [
|
|
154
|
-
A(p.$slots, "summary", V(b({ open: l(u) })), () => [
|
|
155
|
-
C(E(l(v)), 1)
|
|
156
|
-
])
|
|
157
|
-
], 8, ee),
|
|
158
|
-
G("div", {
|
|
159
|
-
"aria-hidden": !l(u),
|
|
160
|
-
class: "vv-collapse__content"
|
|
198
|
+
);
|
|
199
|
+
const onClick = useToggle(isOpen);
|
|
200
|
+
return (_ctx, _cache) => {
|
|
201
|
+
return openBlock(), createElementBlock("details", {
|
|
202
|
+
id: unref(accordionName),
|
|
203
|
+
class: normalizeClass(unref(bemCssClasses)),
|
|
204
|
+
open: unref(isOpen)
|
|
161
205
|
}, [
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
206
|
+
createElementVNode("summary", {
|
|
207
|
+
"aria-controls": unref(accordionName),
|
|
208
|
+
"aria-expanded": unref(isOpen),
|
|
209
|
+
class: "vv-accordion__summary",
|
|
210
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => unref(onClick)(), ["prevent"]))
|
|
211
|
+
}, [
|
|
212
|
+
renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps({ open: unref(isOpen) })), () => [
|
|
213
|
+
createTextVNode(toDisplayString(unref(title)), 1)
|
|
214
|
+
])
|
|
215
|
+
], 8, _hoisted_2),
|
|
216
|
+
createElementVNode("div", {
|
|
217
|
+
"aria-hidden": !unref(isOpen),
|
|
218
|
+
class: "vv-accordion__content"
|
|
219
|
+
}, [
|
|
220
|
+
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ open: unref(isOpen) })), () => [
|
|
221
|
+
createTextVNode(toDisplayString(unref(content)), 1)
|
|
222
|
+
])
|
|
223
|
+
], 8, _hoisted_3)
|
|
224
|
+
], 10, _hoisted_1);
|
|
225
|
+
};
|
|
167
226
|
}
|
|
168
|
-
})
|
|
227
|
+
});
|
|
228
|
+
const VvAccordionGroupProps = {
|
|
169
229
|
/**
|
|
170
230
|
* VModel
|
|
171
231
|
*/
|
|
@@ -193,79 +253,119 @@ const w = ["id", "open"], ee = ["aria-controls", "aria-expanded"], oe = ["aria-h
|
|
|
193
253
|
/**
|
|
194
254
|
* If true, the accordion items will be disabled
|
|
195
255
|
*/
|
|
196
|
-
disabled: Boolean
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
256
|
+
disabled: Boolean,
|
|
257
|
+
/**
|
|
258
|
+
* If true, the accordion items will be opened by default
|
|
259
|
+
*/
|
|
260
|
+
not: Boolean,
|
|
261
|
+
/**
|
|
262
|
+
* Enable local storage persistence
|
|
263
|
+
*/
|
|
264
|
+
storeKey: String
|
|
265
|
+
};
|
|
266
|
+
const VvAccordionGroupEvents = ["update:modelValue"];
|
|
267
|
+
function useProvideGroupState(groupState) {
|
|
268
|
+
if (Object.keys(groupState).some(
|
|
269
|
+
(k) => k !== "key" && !isRef(groupState[k])
|
|
201
270
|
))
|
|
202
271
|
throw Error("One or more groupState props aren't ref.");
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
272
|
+
provide(
|
|
273
|
+
groupState.key,
|
|
274
|
+
computed(() => groupState)
|
|
206
275
|
);
|
|
207
276
|
}
|
|
208
|
-
const
|
|
277
|
+
const __default__ = {
|
|
209
278
|
name: "VvAccordionGroup"
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
)
|
|
279
|
+
};
|
|
280
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
281
|
+
...__default__,
|
|
282
|
+
props: VvAccordionGroupProps,
|
|
283
|
+
emits: VvAccordionGroupEvents,
|
|
284
|
+
setup(__props, { emit }) {
|
|
285
|
+
const props = __props;
|
|
286
|
+
const { disabled, collapse, modifiers, itemModifiers, items, not } = toRefs(props);
|
|
287
|
+
watchEffect(() => {
|
|
288
|
+
if (typeof props.modelValue === "string" && collapse.value) {
|
|
289
|
+
console.warn(
|
|
290
|
+
`[VvAccordionGroup]: modelValue is a string but collapse is true.`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
220
293
|
});
|
|
221
|
-
|
|
294
|
+
let localModelValue = ref([]);
|
|
295
|
+
watch(
|
|
296
|
+
() => props.storeKey,
|
|
297
|
+
(newKey) => {
|
|
298
|
+
if (newKey) {
|
|
299
|
+
localModelValue = useStorage(newKey, localModelValue.value);
|
|
300
|
+
} else {
|
|
301
|
+
localModelValue = ref([]);
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{ immediate: true }
|
|
305
|
+
);
|
|
306
|
+
const modelValue = computed({
|
|
222
307
|
get: () => {
|
|
223
|
-
var
|
|
224
|
-
|
|
308
|
+
var _a;
|
|
309
|
+
if (props.modelValue !== void 0) {
|
|
310
|
+
if (!collapse.value) {
|
|
311
|
+
return Array.isArray(props.modelValue) ? props.modelValue[0] : props.modelValue;
|
|
312
|
+
}
|
|
313
|
+
return props.modelValue;
|
|
314
|
+
}
|
|
315
|
+
return !collapse.value ? (_a = localModelValue.value) == null ? void 0 : _a[0] : localModelValue.value;
|
|
225
316
|
},
|
|
226
|
-
set: (
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
317
|
+
set: (newValue) => {
|
|
318
|
+
if (props.modelValue !== void 0) {
|
|
319
|
+
if ((Array.isArray(props.modelValue) || collapse.value) && !Array.isArray(newValue)) {
|
|
320
|
+
newValue = [newValue];
|
|
321
|
+
}
|
|
322
|
+
return emit("update:modelValue", newValue);
|
|
323
|
+
}
|
|
324
|
+
localModelValue.value = Array.isArray(newValue) ? newValue : [newValue];
|
|
230
325
|
}
|
|
231
326
|
});
|
|
232
|
-
|
|
233
|
-
key:
|
|
234
|
-
modelValue
|
|
235
|
-
disabled
|
|
236
|
-
collapse
|
|
237
|
-
modifiers:
|
|
327
|
+
useProvideGroupState({
|
|
328
|
+
key: INJECTION_KEY_ACCORDION_GROUP,
|
|
329
|
+
modelValue,
|
|
330
|
+
disabled,
|
|
331
|
+
collapse,
|
|
332
|
+
modifiers: itemModifiers,
|
|
333
|
+
not
|
|
238
334
|
});
|
|
239
|
-
const
|
|
335
|
+
const bemCssClasses = useModifiers(
|
|
240
336
|
"vv-accordion-group",
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
disabled:
|
|
337
|
+
modifiers,
|
|
338
|
+
computed(() => ({
|
|
339
|
+
disabled: disabled.value
|
|
244
340
|
}))
|
|
245
341
|
);
|
|
246
|
-
return (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
342
|
+
return (_ctx, _cache) => {
|
|
343
|
+
return openBlock(), createElementBlock("div", {
|
|
344
|
+
class: normalizeClass(unref(bemCssClasses))
|
|
345
|
+
}, [
|
|
346
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
347
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(items), (item) => {
|
|
348
|
+
return openBlock(), createBlock(_sfc_main$1, mergeProps({
|
|
349
|
+
key: item.title
|
|
350
|
+
}, {
|
|
351
|
+
name: item.name,
|
|
352
|
+
title: item.title,
|
|
353
|
+
content: item.content
|
|
354
|
+
}), {
|
|
355
|
+
header: withCtx((data) => [
|
|
356
|
+
renderSlot(_ctx.$slots, `header::${item.name}`, normalizeProps(guardReactiveProps(data)))
|
|
357
|
+
]),
|
|
358
|
+
details: withCtx((data) => [
|
|
359
|
+
renderSlot(_ctx.$slots, `details::${item.name}`, normalizeProps(guardReactiveProps(data)))
|
|
360
|
+
]),
|
|
361
|
+
_: 2
|
|
362
|
+
}, 1040);
|
|
363
|
+
}), 128))
|
|
364
|
+
])
|
|
365
|
+
], 2);
|
|
366
|
+
};
|
|
267
367
|
}
|
|
268
368
|
});
|
|
269
369
|
export {
|
|
270
|
-
|
|
370
|
+
_sfc_main as default
|
|
271
371
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","nanoid","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvAccordionGroup=o(e.vue,e.nanoid,e.core)}(this,(function(e,o,r){"use strict";const t=Symbol.for("accordionGroup");function l(o){const r=e.inject(o,void 0),t=e.computed((()=>{return o=r,!(null==(t=e.unref(o))||""===t||Array.isArray(t)&&0===t.length||!(t instanceof Date)&&"object"==typeof t&&0===Object.keys(t).length);var o,t}));return{group:r,isInGroup:t,getGroupOrLocalRef:function(o,t,l){if(null==r?void 0:r.value){const t=e.unref(r.value)[o];return e.computed({get:()=>null==t?void 0:t.value,set(e){t.value=e}})}const a=e.toRef(t,o);return e.computed({get:()=>a.value,set(e){l&&l(`update:${o}`,e)}})}}}const a={name:String,title:String,content:String,modelValue:{type:Boolean,default:void 0},modifiers:[String,Array],disabled:Boolean,not:Boolean};function n(o,r,t){return e.computed((()=>{const l={[o]:!0},a="string"==typeof(null==r?void 0:r.value)?r.value.split(" "):null==r?void 0:r.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(l[`${o}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((r=>{l[`${o}--${r}`]=e.unref(t.value[r])})),l}))}const u=["id","open"],i=["aria-controls","aria-expanded"],d=["aria-hidden"],s=e.defineComponent({name:"VvAccordion",props:a,emits:["update:modelValue"],setup(a,{emit:s}){const c=a,v=e.useAttrs(),p=e.computed((()=>c.name||(null==v?void 0:v.id)||o.nanoid())),{modifiers:m,title:f,content:y,disabled:g,collapse:A,modelValue:V,isInGroup:b,not:h}=function(o,r){const{group:a,isInGroup:n,getGroupOrLocalRef:u}=l(t),{title:i,content:d}=e.toRefs(o),s=u("modelValue",o,r),c=u("not",o),v=u("collapse",o),p=u("modifiers",o),m=e.computed((()=>{var e;return Boolean(o.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{modelValue:s,not:c,isInGroup:n,group:a,collapse:v,modifiers:p,disabled:m,title:i,content:d}}(c,s),S=e.ref(!1),k=e.computed({get:()=>{let e=V.value;return b.value?e=A.value&&Array.isArray(V.value)?V.value.includes(p.value):V.value===p.value:void 0===V.value&&(e=S.value),h.value?!e:e},set:e=>{if(h.value&&(e=!e),b.value)return A.value&&Array.isArray(V.value)?e?void V.value.push(p.value):void(V.value=V.value.filter((e=>e!==p.value))):void(V.value=e?p.value:null);void 0!==V.value||"boolean"!=typeof e?V.value=e:S.value=e}}),B=n("vv-accordion",m,e.computed((()=>({disabled:g.value})))),$=r.useToggle(k);return(o,r)=>(e.openBlock(),e.createElementBlock("details",{id:e.unref(p),class:e.normalizeClass(e.unref(B)),open:e.unref(k)},[e.createElementVNode("summary",{"aria-controls":e.unref(p),"aria-expanded":e.unref(k),class:"vv-accordion__summary",onClick:r[0]||(r[0]=e.withModifiers((o=>e.unref($)()),["prevent"]))},[e.renderSlot(o.$slots,"summary",e.normalizeProps(e.guardReactiveProps({open:e.unref(k)})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(f)),1)]))],8,i),e.createElementVNode("div",{"aria-hidden":!e.unref(k),class:"vv-accordion__content"},[e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({open:e.unref(k)})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(y)),1)]))],8,d)],10,u))}}),c={modelValue:[String,Array],items:{type:Array,default:()=>[]},collapse:Boolean,modifiers:[String,Array],itemModifiers:{type:[String,Array],default:""},disabled:Boolean,not:Boolean,storeKey:String};return e.defineComponent({name:"VvAccordionGroup",props:c,emits:["update:modelValue"],setup(o,{emit:l}){const a=o,{disabled:u,collapse:i,modifiers:d,itemModifiers:c,items:v,not:p}=e.toRefs(a);e.watchEffect((()=>{"string"==typeof a.modelValue&&i.value&&console.warn("[VvAccordionGroup]: modelValue is a string but collapse is true.")}));let m=e.ref([]);e.watch((()=>a.storeKey),(o=>{m=o?r.useStorage(o,m.value):e.ref([])}),{immediate:!0});const f=e.computed({get:()=>{var e;return void 0!==a.modelValue?i.value?a.modelValue:Array.isArray(a.modelValue)?a.modelValue[0]:a.modelValue:i.value?m.value:null==(e=m.value)?void 0:e[0]},set:e=>{if(void 0!==a.modelValue)return!Array.isArray(a.modelValue)&&!i.value||Array.isArray(e)||(e=[e]),l("update:modelValue",e);m.value=Array.isArray(e)?e:[e]}});!function(o){if(Object.keys(o).some((r=>"key"!==r&&!e.isRef(o[r]))))throw Error("One or more groupState props aren't ref.");e.provide(o.key,e.computed((()=>o)))}({key:t,modelValue:f,disabled:u,collapse:i,modifiers:c,not:p});const y=n("vv-accordion-group",d,e.computed((()=>({disabled:u.value}))));return(o,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(y))},[e.renderSlot(o.$slots,"default",{},(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),(r=>(e.openBlock(),e.createBlock(s,e.mergeProps({key:r.title},{name:r.name,title:r.title,content:r.content}),{header:e.withCtx((t=>[e.renderSlot(o.$slots,`header::${r.name}`,e.normalizeProps(e.guardReactiveProps(t)))])),details:e.withCtx((t=>[e.renderSlot(o.$slots,`details::${r.name}`,e.normalizeProps(e.guardReactiveProps(t)))])),_:2},1040)))),128))]))],2))}})}));
|
|
@@ -2,10 +2,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
2
2
|
modelValue: (StringConstructor | ArrayConstructor)[];
|
|
3
3
|
items: {
|
|
4
4
|
type: {
|
|
5
|
-
(arrayLength: number): import("
|
|
6
|
-
(...items: import("
|
|
7
|
-
new (arrayLength: number): import("
|
|
8
|
-
new (...items: import("
|
|
5
|
+
(arrayLength: number): import(".").VvAccordionGroupItem[];
|
|
6
|
+
(...items: import(".").VvAccordionGroupItem[]): import(".").VvAccordionGroupItem[];
|
|
7
|
+
new (arrayLength: number): import(".").VvAccordionGroupItem[];
|
|
8
|
+
new (...items: import(".").VvAccordionGroupItem[]): import(".").VvAccordionGroupItem[];
|
|
9
9
|
isArray(arg: any): arg is any[];
|
|
10
10
|
readonly prototype: any[];
|
|
11
11
|
from<T>(arrayLike: ArrayLike<T>): T[];
|
|
@@ -37,14 +37,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
37
37
|
default: string;
|
|
38
38
|
};
|
|
39
39
|
disabled: BooleanConstructor;
|
|
40
|
+
not: BooleanConstructor;
|
|
41
|
+
storeKey: StringConstructor;
|
|
40
42
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
41
43
|
modelValue: (StringConstructor | ArrayConstructor)[];
|
|
42
44
|
items: {
|
|
43
45
|
type: {
|
|
44
|
-
(arrayLength: number): import("
|
|
45
|
-
(...items: import("
|
|
46
|
-
new (arrayLength: number): import("
|
|
47
|
-
new (...items: import("
|
|
46
|
+
(arrayLength: number): import(".").VvAccordionGroupItem[];
|
|
47
|
+
(...items: import(".").VvAccordionGroupItem[]): import(".").VvAccordionGroupItem[];
|
|
48
|
+
new (arrayLength: number): import(".").VvAccordionGroupItem[];
|
|
49
|
+
new (...items: import(".").VvAccordionGroupItem[]): import(".").VvAccordionGroupItem[];
|
|
48
50
|
isArray(arg: any): arg is any[];
|
|
49
51
|
readonly prototype: any[];
|
|
50
52
|
from<T>(arrayLike: ArrayLike<T>): T[];
|
|
@@ -76,16 +78,17 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
76
78
|
default: string;
|
|
77
79
|
};
|
|
78
80
|
disabled: BooleanConstructor;
|
|
81
|
+
not: BooleanConstructor;
|
|
82
|
+
storeKey: StringConstructor;
|
|
79
83
|
}>> & {
|
|
80
84
|
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
81
85
|
}, {
|
|
82
86
|
disabled: boolean;
|
|
87
|
+
not: boolean;
|
|
83
88
|
collapse: boolean;
|
|
84
|
-
items: import("
|
|
89
|
+
items: import(".").VvAccordionGroupItem[];
|
|
85
90
|
itemModifiers: string | string[];
|
|
86
|
-
}>, Record<string, (_: any) => any> & Record<string, (_: {
|
|
87
|
-
open: boolean;
|
|
88
|
-
}) => any> & {
|
|
91
|
+
}>, Record<string, (_: any) => any> & Record<string, (_: any) => any> & {
|
|
89
92
|
default: (_: {}) => any;
|
|
90
93
|
}>;
|
|
91
94
|
export default _default;
|
|
@@ -63,5 +63,13 @@ export declare const VvAccordionGroupProps: {
|
|
|
63
63
|
* If true, the accordion items will be disabled
|
|
64
64
|
*/
|
|
65
65
|
disabled: BooleanConstructor;
|
|
66
|
+
/**
|
|
67
|
+
* If true, the accordion items will be opened by default
|
|
68
|
+
*/
|
|
69
|
+
not: BooleanConstructor;
|
|
70
|
+
/**
|
|
71
|
+
* Enable local storage persistence
|
|
72
|
+
*/
|
|
73
|
+
storeKey: StringConstructor;
|
|
66
74
|
};
|
|
67
75
|
export declare const VvAccordionGroupEvents: string[];
|