@volverjs/ui-vue 0.0.5 → 0.0.6-beta.2
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/dist/components/VvAvatar/VvAvatar.es.js +279 -0
- package/dist/components/VvAvatar/VvAvatar.umd.js +1 -0
- package/dist/components/VvAvatar/VvAvatar.vue.d.ts +15 -0
- package/dist/components/VvAvatar/index.d.ts +7 -0
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +361 -0
- package/dist/components/VvAvatarGroup/VvAvatarGroup.umd.js +1 -0
- package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +68 -0
- package/dist/components/VvAvatarGroup/index.d.ts +38 -0
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/stories/Avatar/Avatar.settings.d.ts +36 -0
- package/dist/stories/Avatar/Avatar.test.d.ts +2 -0
- package/dist/stories/AvatarGroup/AvatarGroup.settings.d.ts +56 -0
- package/dist/stories/AvatarGroup/AvatarGroup.test.d.ts +2 -0
- package/dist/test/expect.d.ts +3 -0
- package/package.json +17 -1
- 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/VvAvatar/VvAvatar.vue +21 -0
- package/src/components/VvAvatar/index.ts +9 -0
- package/src/components/VvAvatarGroup/VvAvatarGroup.vue +65 -0
- package/src/components/VvAvatarGroup/index.ts +28 -0
- package/src/stories/Avatar/Avatar.settings.ts +36 -0
- package/src/stories/Avatar/Avatar.stories.mdx +40 -0
- package/src/stories/Avatar/Avatar.test.ts +34 -0
- package/src/stories/Avatar/AvatarBadge.stories.mdx +41 -0
- package/src/stories/Avatar/AvatarModifiers.stories.mdx +87 -0
- package/src/stories/Avatar/AvatarSlotDefault.stories.mdx +29 -0
- package/src/stories/AvatarGroup/AvatarGroup.settings.ts +60 -0
- package/src/stories/AvatarGroup/AvatarGroup.stories.mdx +30 -0
- package/src/stories/AvatarGroup/AvatarGroup.test.ts +36 -0
- package/src/stories/AvatarGroup/AvatarGroupModifiers.stories.mdx +24 -0
- package/src/stories/AvatarGroup/AvatarGroupSlotDefault.stories.mdx +45 -0
- package/src/test/expect.ts +15 -0
package/README.md
CHANGED
|
@@ -164,8 +164,8 @@ The following features are planned for the next releases:
|
|
|
164
164
|
- [x] (v0.0.3) Redesign of `VvCombobox` for better accessibility and more features;
|
|
165
165
|
- [x] (v0.0.3) Rewrite of `VvDropdown` to get it applicable to any element;
|
|
166
166
|
- [x] (v0.0.5) Input masks for `VvInputText` component;
|
|
167
|
-
- [
|
|
168
|
-
- [
|
|
167
|
+
- [x] `VvAvatar` component;
|
|
168
|
+
- [x] `VvAvatarGroup` component;
|
|
169
169
|
- [ ] Alerts, notifications and toasts with `VvAlert` and `VvToast` component;
|
|
170
170
|
- [ ] Loaders with `VvLoader` and `VvSkeleton`;
|
|
171
171
|
- [ ] Menus, navigation and tabs with `VvNav`;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { computed, unref, defineComponent, toRefs, openBlock, createElementBlock, normalizeClass, renderSlot, createCommentVNode } from "vue";
|
|
2
|
+
var Side = /* @__PURE__ */ ((Side2) => {
|
|
3
|
+
Side2["left"] = "left";
|
|
4
|
+
Side2["right"] = "right";
|
|
5
|
+
Side2["top"] = "top";
|
|
6
|
+
Side2["bottom"] = "bottom";
|
|
7
|
+
return Side2;
|
|
8
|
+
})(Side || {});
|
|
9
|
+
var Placement = /* @__PURE__ */ ((Placement2) => {
|
|
10
|
+
Placement2["topStart"] = "top-start";
|
|
11
|
+
Placement2["topEnd"] = "top-end";
|
|
12
|
+
Placement2["bottomStart"] = "bottom-start";
|
|
13
|
+
Placement2["bottomEnd"] = "bottom-end";
|
|
14
|
+
Placement2["leftStart"] = "left-start";
|
|
15
|
+
Placement2["leftEnd"] = "left-end";
|
|
16
|
+
Placement2["rightStart"] = "right-start";
|
|
17
|
+
Placement2["rightEnd"] = "right-end";
|
|
18
|
+
return Placement2;
|
|
19
|
+
})(Placement || {});
|
|
20
|
+
var Position = /* @__PURE__ */ ((Position2) => {
|
|
21
|
+
Position2["before"] = "before";
|
|
22
|
+
Position2["after"] = "after";
|
|
23
|
+
return Position2;
|
|
24
|
+
})(Position || {});
|
|
25
|
+
var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
|
|
26
|
+
ButtonType2["button"] = "button";
|
|
27
|
+
ButtonType2["submit"] = "submit";
|
|
28
|
+
ButtonType2["reset"] = "reset";
|
|
29
|
+
return ButtonType2;
|
|
30
|
+
})(ButtonType || {});
|
|
31
|
+
var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
32
|
+
AnchorTarget2["_blank"] = "_blank";
|
|
33
|
+
AnchorTarget2["_self"] = "_self";
|
|
34
|
+
AnchorTarget2["_parent"] = "_parent";
|
|
35
|
+
AnchorTarget2["_top"] = "_top";
|
|
36
|
+
return AnchorTarget2;
|
|
37
|
+
})(AnchorTarget || {});
|
|
38
|
+
const LinkProps = {
|
|
39
|
+
/**
|
|
40
|
+
* The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
|
|
41
|
+
* @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
|
|
42
|
+
*/
|
|
43
|
+
to: {
|
|
44
|
+
type: [String, Object]
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Anchor href
|
|
48
|
+
*/
|
|
49
|
+
href: String,
|
|
50
|
+
/**
|
|
51
|
+
* Anchor target
|
|
52
|
+
*/
|
|
53
|
+
target: {
|
|
54
|
+
type: String,
|
|
55
|
+
validator: (value) => Object.values(AnchorTarget).includes(value)
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Anchor rel
|
|
59
|
+
*/
|
|
60
|
+
rel: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "noopener noreferrer"
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const DisabledProps = {
|
|
66
|
+
/**
|
|
67
|
+
* Whether the form control is disabled
|
|
68
|
+
*/
|
|
69
|
+
disabled: Boolean
|
|
70
|
+
};
|
|
71
|
+
const ActiveProps = {
|
|
72
|
+
/**
|
|
73
|
+
* Whether the item is active
|
|
74
|
+
*/
|
|
75
|
+
active: Boolean
|
|
76
|
+
};
|
|
77
|
+
const PressedProps = {
|
|
78
|
+
/**
|
|
79
|
+
* Whether the item is pressed
|
|
80
|
+
*/
|
|
81
|
+
pressed: Boolean
|
|
82
|
+
};
|
|
83
|
+
const LabelProps = {
|
|
84
|
+
/**
|
|
85
|
+
* The item label
|
|
86
|
+
*/
|
|
87
|
+
label: [String, Number]
|
|
88
|
+
};
|
|
89
|
+
const ModifiersProps = {
|
|
90
|
+
/**
|
|
91
|
+
* Component BEM modifiers
|
|
92
|
+
*/
|
|
93
|
+
modifiers: [String, Array]
|
|
94
|
+
};
|
|
95
|
+
({
|
|
96
|
+
/**
|
|
97
|
+
* VvIcon name or props
|
|
98
|
+
* @see VVIcon
|
|
99
|
+
*/
|
|
100
|
+
icon: { type: [String, Object] },
|
|
101
|
+
/**
|
|
102
|
+
* VvIcon position
|
|
103
|
+
*/
|
|
104
|
+
iconPosition: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: Position.before,
|
|
107
|
+
validation: (value) => Object.values(Position).includes(value)
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
({
|
|
111
|
+
/**
|
|
112
|
+
* Dropdown placement
|
|
113
|
+
*/
|
|
114
|
+
placement: {
|
|
115
|
+
type: String,
|
|
116
|
+
default: Side.bottom,
|
|
117
|
+
validator: (value) => {
|
|
118
|
+
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* Dropdown strategy
|
|
123
|
+
*/
|
|
124
|
+
strategy: {
|
|
125
|
+
type: String,
|
|
126
|
+
default: "absolute",
|
|
127
|
+
validator: (value) => {
|
|
128
|
+
return ["fixed", "absolute"].includes(value);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Dropdown show / hide transition name
|
|
133
|
+
*/
|
|
134
|
+
transitionName: {
|
|
135
|
+
type: String
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* Offset of the dropdown from the trigger
|
|
139
|
+
* @see https://floating-ui.com/docs/offset
|
|
140
|
+
*/
|
|
141
|
+
offset: {
|
|
142
|
+
type: [Number, String, Object],
|
|
143
|
+
default: 0
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* Move dropdown to the side if there is no space in the default position
|
|
147
|
+
* @see https://floating-ui.com/docs/shift
|
|
148
|
+
*/
|
|
149
|
+
shift: {
|
|
150
|
+
type: [Boolean, Object],
|
|
151
|
+
default: false
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Flip dropdown position if there is no space in the default position
|
|
155
|
+
* @see https://floating-ui.com/docs/flip
|
|
156
|
+
*/
|
|
157
|
+
flip: {
|
|
158
|
+
type: [Boolean, Object],
|
|
159
|
+
default: true
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* Size of the dropdown
|
|
163
|
+
* @see https://floating-ui.com/docs/size
|
|
164
|
+
*/
|
|
165
|
+
size: {
|
|
166
|
+
type: [Boolean, Object],
|
|
167
|
+
default: () => ({ padding: 10 })
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* Automatically change the position of the dropdown
|
|
171
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
172
|
+
*/
|
|
173
|
+
autoPlacement: {
|
|
174
|
+
type: [Boolean, Object],
|
|
175
|
+
default: false
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* Add arrow to the dropdown
|
|
179
|
+
* @see https://floating-ui.com/docs/arrow
|
|
180
|
+
*/
|
|
181
|
+
arrow: {
|
|
182
|
+
type: Boolean,
|
|
183
|
+
default: false
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* Close dropdown on click outside
|
|
187
|
+
*/
|
|
188
|
+
autoClose: {
|
|
189
|
+
type: Boolean,
|
|
190
|
+
default: true
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Autofocus first item on dropdown open
|
|
194
|
+
*/
|
|
195
|
+
autofocusFirst: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
default: true
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* Set dropdown width to the same as the trigger
|
|
201
|
+
*/
|
|
202
|
+
triggerWidth: {
|
|
203
|
+
type: Boolean
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
({
|
|
207
|
+
...DisabledProps,
|
|
208
|
+
...LabelProps,
|
|
209
|
+
...PressedProps,
|
|
210
|
+
...ActiveProps,
|
|
211
|
+
...LinkProps,
|
|
212
|
+
/**
|
|
213
|
+
* Button type
|
|
214
|
+
*/
|
|
215
|
+
type: {
|
|
216
|
+
type: String,
|
|
217
|
+
default: ButtonType.button,
|
|
218
|
+
validator: (value) => Object.values(ButtonType).includes(value)
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
const VvAvatarProps = {
|
|
222
|
+
...ModifiersProps,
|
|
223
|
+
/**
|
|
224
|
+
* Image src for avatar
|
|
225
|
+
*/
|
|
226
|
+
imgSrc: String
|
|
227
|
+
};
|
|
228
|
+
function useModifiers(prefix, modifiers, others) {
|
|
229
|
+
return computed(() => {
|
|
230
|
+
const toReturn = {
|
|
231
|
+
[prefix]: true
|
|
232
|
+
};
|
|
233
|
+
const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
|
|
234
|
+
if (modifiersArray) {
|
|
235
|
+
if (Array.isArray(modifiersArray)) {
|
|
236
|
+
modifiersArray.forEach((modifier) => {
|
|
237
|
+
if (modifier) {
|
|
238
|
+
toReturn[`${prefix}--${modifier}`] = true;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (others) {
|
|
244
|
+
Object.keys(others.value).forEach((key) => {
|
|
245
|
+
toReturn[`${prefix}--${key}`] = unref(others.value[key]);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return toReturn;
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
const _hoisted_1 = ["role", "aria-label"];
|
|
252
|
+
const _hoisted_2 = ["src"];
|
|
253
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
254
|
+
__name: "VvAvatar",
|
|
255
|
+
props: VvAvatarProps,
|
|
256
|
+
setup(__props) {
|
|
257
|
+
const props = __props;
|
|
258
|
+
const { modifiers } = toRefs(props);
|
|
259
|
+
const bemCssClasses = useModifiers("vv-avatar", modifiers);
|
|
260
|
+
return (_ctx, _cache) => {
|
|
261
|
+
return openBlock(), createElementBlock("span", {
|
|
262
|
+
class: normalizeClass(unref(bemCssClasses)),
|
|
263
|
+
role: _ctx.imgSrc ? void 0 : "img",
|
|
264
|
+
"aria-label": _ctx.imgSrc ? void 0 : "avatar"
|
|
265
|
+
}, [
|
|
266
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
267
|
+
_ctx.imgSrc ? (openBlock(), createElementBlock("img", {
|
|
268
|
+
key: 0,
|
|
269
|
+
src: _ctx.imgSrc,
|
|
270
|
+
alt: "avatar"
|
|
271
|
+
}, null, 8, _hoisted_2)) : createCommentVNode("", true)
|
|
272
|
+
])
|
|
273
|
+
], 10, _hoisted_1);
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
export {
|
|
278
|
+
_sfc_main as default
|
|
279
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue")):"function"==typeof define&&define.amd?define(["vue"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvAvatar=o(e.vue)}(this,(function(e){"use strict";var o=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(o||{}),t=(e=>(e.before="before",e.after="after",e))(t||{}),r=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(r||{});Boolean,Boolean,Boolean;const n={modifiers:[String,Array]};t.before,o.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,r.button;const a={...n,imgSrc:String};const l=["role","aria-label"],i=["src"];return e.defineComponent({__name:"VvAvatar",props:a,setup(o){const t=o,{modifiers:r}=e.toRefs(t),n=function(o,t,r){return e.computed((()=>{const n={[o]:!0},a="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(n[`${o}--${e}`]=!0)})),r&&Object.keys(r.value).forEach((t=>{n[`${o}--${t}`]=e.unref(r.value[t])})),n}))}("vv-avatar",r);return(o,t)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(e.unref(n)),role:o.imgSrc?void 0:"img","aria-label":o.imgSrc?void 0:"avatar"},[e.renderSlot(o.$slots,"default",{},(()=>[o.imgSrc?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.imgSrc,alt:"avatar"},null,8,i)):e.createCommentVNode("",!0)]))],10,l))}})}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
2
|
+
imgSrc: StringConstructor;
|
|
3
|
+
modifiers: globalThis.PropType<string | string[]>;
|
|
4
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
5
|
+
imgSrc: StringConstructor;
|
|
6
|
+
modifiers: globalThis.PropType<string | string[]>;
|
|
7
|
+
}>>, {}>, {
|
|
8
|
+
default: (_: {}) => any;
|
|
9
|
+
}>;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { computed, unref, defineComponent, toRefs, openBlock, createElementBlock, normalizeClass, renderSlot, createCommentVNode, Fragment, renderList, createBlock, mergeProps, withCtx, toDisplayString, createTextVNode } from "vue";
|
|
2
|
+
var Side = /* @__PURE__ */ ((Side2) => {
|
|
3
|
+
Side2["left"] = "left";
|
|
4
|
+
Side2["right"] = "right";
|
|
5
|
+
Side2["top"] = "top";
|
|
6
|
+
Side2["bottom"] = "bottom";
|
|
7
|
+
return Side2;
|
|
8
|
+
})(Side || {});
|
|
9
|
+
var Placement = /* @__PURE__ */ ((Placement2) => {
|
|
10
|
+
Placement2["topStart"] = "top-start";
|
|
11
|
+
Placement2["topEnd"] = "top-end";
|
|
12
|
+
Placement2["bottomStart"] = "bottom-start";
|
|
13
|
+
Placement2["bottomEnd"] = "bottom-end";
|
|
14
|
+
Placement2["leftStart"] = "left-start";
|
|
15
|
+
Placement2["leftEnd"] = "left-end";
|
|
16
|
+
Placement2["rightStart"] = "right-start";
|
|
17
|
+
Placement2["rightEnd"] = "right-end";
|
|
18
|
+
return Placement2;
|
|
19
|
+
})(Placement || {});
|
|
20
|
+
var Position = /* @__PURE__ */ ((Position2) => {
|
|
21
|
+
Position2["before"] = "before";
|
|
22
|
+
Position2["after"] = "after";
|
|
23
|
+
return Position2;
|
|
24
|
+
})(Position || {});
|
|
25
|
+
var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
|
|
26
|
+
ButtonType2["button"] = "button";
|
|
27
|
+
ButtonType2["submit"] = "submit";
|
|
28
|
+
ButtonType2["reset"] = "reset";
|
|
29
|
+
return ButtonType2;
|
|
30
|
+
})(ButtonType || {});
|
|
31
|
+
var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
32
|
+
AnchorTarget2["_blank"] = "_blank";
|
|
33
|
+
AnchorTarget2["_self"] = "_self";
|
|
34
|
+
AnchorTarget2["_parent"] = "_parent";
|
|
35
|
+
AnchorTarget2["_top"] = "_top";
|
|
36
|
+
return AnchorTarget2;
|
|
37
|
+
})(AnchorTarget || {});
|
|
38
|
+
const LinkProps = {
|
|
39
|
+
/**
|
|
40
|
+
* The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
|
|
41
|
+
* @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
|
|
42
|
+
*/
|
|
43
|
+
to: {
|
|
44
|
+
type: [String, Object]
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Anchor href
|
|
48
|
+
*/
|
|
49
|
+
href: String,
|
|
50
|
+
/**
|
|
51
|
+
* Anchor target
|
|
52
|
+
*/
|
|
53
|
+
target: {
|
|
54
|
+
type: String,
|
|
55
|
+
validator: (value) => Object.values(AnchorTarget).includes(value)
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Anchor rel
|
|
59
|
+
*/
|
|
60
|
+
rel: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "noopener noreferrer"
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const DisabledProps = {
|
|
66
|
+
/**
|
|
67
|
+
* Whether the form control is disabled
|
|
68
|
+
*/
|
|
69
|
+
disabled: Boolean
|
|
70
|
+
};
|
|
71
|
+
const ActiveProps = {
|
|
72
|
+
/**
|
|
73
|
+
* Whether the item is active
|
|
74
|
+
*/
|
|
75
|
+
active: Boolean
|
|
76
|
+
};
|
|
77
|
+
const PressedProps = {
|
|
78
|
+
/**
|
|
79
|
+
* Whether the item is pressed
|
|
80
|
+
*/
|
|
81
|
+
pressed: Boolean
|
|
82
|
+
};
|
|
83
|
+
const LabelProps = {
|
|
84
|
+
/**
|
|
85
|
+
* The item label
|
|
86
|
+
*/
|
|
87
|
+
label: [String, Number]
|
|
88
|
+
};
|
|
89
|
+
const ModifiersProps = {
|
|
90
|
+
/**
|
|
91
|
+
* Component BEM modifiers
|
|
92
|
+
*/
|
|
93
|
+
modifiers: [String, Array]
|
|
94
|
+
};
|
|
95
|
+
({
|
|
96
|
+
/**
|
|
97
|
+
* VvIcon name or props
|
|
98
|
+
* @see VVIcon
|
|
99
|
+
*/
|
|
100
|
+
icon: { type: [String, Object] },
|
|
101
|
+
/**
|
|
102
|
+
* VvIcon position
|
|
103
|
+
*/
|
|
104
|
+
iconPosition: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: Position.before,
|
|
107
|
+
validation: (value) => Object.values(Position).includes(value)
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
({
|
|
111
|
+
/**
|
|
112
|
+
* Dropdown placement
|
|
113
|
+
*/
|
|
114
|
+
placement: {
|
|
115
|
+
type: String,
|
|
116
|
+
default: Side.bottom,
|
|
117
|
+
validator: (value) => {
|
|
118
|
+
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* Dropdown strategy
|
|
123
|
+
*/
|
|
124
|
+
strategy: {
|
|
125
|
+
type: String,
|
|
126
|
+
default: "absolute",
|
|
127
|
+
validator: (value) => {
|
|
128
|
+
return ["fixed", "absolute"].includes(value);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Dropdown show / hide transition name
|
|
133
|
+
*/
|
|
134
|
+
transitionName: {
|
|
135
|
+
type: String
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* Offset of the dropdown from the trigger
|
|
139
|
+
* @see https://floating-ui.com/docs/offset
|
|
140
|
+
*/
|
|
141
|
+
offset: {
|
|
142
|
+
type: [Number, String, Object],
|
|
143
|
+
default: 0
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* Move dropdown to the side if there is no space in the default position
|
|
147
|
+
* @see https://floating-ui.com/docs/shift
|
|
148
|
+
*/
|
|
149
|
+
shift: {
|
|
150
|
+
type: [Boolean, Object],
|
|
151
|
+
default: false
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Flip dropdown position if there is no space in the default position
|
|
155
|
+
* @see https://floating-ui.com/docs/flip
|
|
156
|
+
*/
|
|
157
|
+
flip: {
|
|
158
|
+
type: [Boolean, Object],
|
|
159
|
+
default: true
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* Size of the dropdown
|
|
163
|
+
* @see https://floating-ui.com/docs/size
|
|
164
|
+
*/
|
|
165
|
+
size: {
|
|
166
|
+
type: [Boolean, Object],
|
|
167
|
+
default: () => ({ padding: 10 })
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* Automatically change the position of the dropdown
|
|
171
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
172
|
+
*/
|
|
173
|
+
autoPlacement: {
|
|
174
|
+
type: [Boolean, Object],
|
|
175
|
+
default: false
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* Add arrow to the dropdown
|
|
179
|
+
* @see https://floating-ui.com/docs/arrow
|
|
180
|
+
*/
|
|
181
|
+
arrow: {
|
|
182
|
+
type: Boolean,
|
|
183
|
+
default: false
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* Close dropdown on click outside
|
|
187
|
+
*/
|
|
188
|
+
autoClose: {
|
|
189
|
+
type: Boolean,
|
|
190
|
+
default: true
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Autofocus first item on dropdown open
|
|
194
|
+
*/
|
|
195
|
+
autofocusFirst: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
default: true
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* Set dropdown width to the same as the trigger
|
|
201
|
+
*/
|
|
202
|
+
triggerWidth: {
|
|
203
|
+
type: Boolean
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
({
|
|
207
|
+
...DisabledProps,
|
|
208
|
+
...LabelProps,
|
|
209
|
+
...PressedProps,
|
|
210
|
+
...ActiveProps,
|
|
211
|
+
...LinkProps,
|
|
212
|
+
/**
|
|
213
|
+
* Button type
|
|
214
|
+
*/
|
|
215
|
+
type: {
|
|
216
|
+
type: String,
|
|
217
|
+
default: ButtonType.button,
|
|
218
|
+
validator: (value) => Object.values(ButtonType).includes(value)
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
const VvAvatarGroupProps = {
|
|
222
|
+
...ModifiersProps,
|
|
223
|
+
/**
|
|
224
|
+
* avatar items
|
|
225
|
+
*/
|
|
226
|
+
items: {
|
|
227
|
+
type: Array,
|
|
228
|
+
default: () => [],
|
|
229
|
+
required: true
|
|
230
|
+
},
|
|
231
|
+
toShow: {
|
|
232
|
+
type: Number,
|
|
233
|
+
default: 3
|
|
234
|
+
},
|
|
235
|
+
totalItems: {
|
|
236
|
+
type: Number
|
|
237
|
+
},
|
|
238
|
+
avatarModifiers: [String, Array]
|
|
239
|
+
};
|
|
240
|
+
const VvAvatarProps = {
|
|
241
|
+
...ModifiersProps,
|
|
242
|
+
/**
|
|
243
|
+
* Image src for avatar
|
|
244
|
+
*/
|
|
245
|
+
imgSrc: String
|
|
246
|
+
};
|
|
247
|
+
function useModifiers(prefix, modifiers, others) {
|
|
248
|
+
return computed(() => {
|
|
249
|
+
const toReturn = {
|
|
250
|
+
[prefix]: true
|
|
251
|
+
};
|
|
252
|
+
const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
|
|
253
|
+
if (modifiersArray) {
|
|
254
|
+
if (Array.isArray(modifiersArray)) {
|
|
255
|
+
modifiersArray.forEach((modifier) => {
|
|
256
|
+
if (modifier) {
|
|
257
|
+
toReturn[`${prefix}--${modifier}`] = true;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (others) {
|
|
263
|
+
Object.keys(others.value).forEach((key) => {
|
|
264
|
+
toReturn[`${prefix}--${key}`] = unref(others.value[key]);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return toReturn;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const _hoisted_1$1 = ["role", "aria-label"];
|
|
271
|
+
const _hoisted_2 = ["src"];
|
|
272
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
273
|
+
__name: "VvAvatar",
|
|
274
|
+
props: VvAvatarProps,
|
|
275
|
+
setup(__props) {
|
|
276
|
+
const props = __props;
|
|
277
|
+
const { modifiers } = toRefs(props);
|
|
278
|
+
const bemCssClasses = useModifiers("vv-avatar", modifiers);
|
|
279
|
+
return (_ctx, _cache) => {
|
|
280
|
+
return openBlock(), createElementBlock("span", {
|
|
281
|
+
class: normalizeClass(unref(bemCssClasses)),
|
|
282
|
+
role: _ctx.imgSrc ? void 0 : "img",
|
|
283
|
+
"aria-label": _ctx.imgSrc ? void 0 : "avatar"
|
|
284
|
+
}, [
|
|
285
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
286
|
+
_ctx.imgSrc ? (openBlock(), createElementBlock("img", {
|
|
287
|
+
key: 0,
|
|
288
|
+
src: _ctx.imgSrc,
|
|
289
|
+
alt: "avatar"
|
|
290
|
+
}, null, 8, _hoisted_2)) : createCommentVNode("", true)
|
|
291
|
+
])
|
|
292
|
+
], 10, _hoisted_1$1);
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
const _hoisted_1 = { key: 0 };
|
|
297
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
298
|
+
__name: "VvAvatarGroup",
|
|
299
|
+
props: VvAvatarGroupProps,
|
|
300
|
+
setup(__props) {
|
|
301
|
+
const props = __props;
|
|
302
|
+
const { modifiers, items, toShow, totalItems, avatarModifiers } = toRefs(props);
|
|
303
|
+
const bemCssClasses = useModifiers("vv-avatar-group", modifiers);
|
|
304
|
+
const stringModifiers = computed(() => {
|
|
305
|
+
if ((avatarModifiers == null ? void 0 : avatarModifiers.value) && Array.isArray(avatarModifiers == null ? void 0 : avatarModifiers.value)) {
|
|
306
|
+
return avatarModifiers.value.join(" ");
|
|
307
|
+
}
|
|
308
|
+
return (avatarModifiers == null ? void 0 : avatarModifiers.value) || "";
|
|
309
|
+
});
|
|
310
|
+
const avatarItems = computed(() => {
|
|
311
|
+
return items.value.slice(0, toShow.value).map((item, index) => {
|
|
312
|
+
let modifiers2 = [];
|
|
313
|
+
let itemModifiers = [];
|
|
314
|
+
if (avatarModifiers == null ? void 0 : avatarModifiers.value) {
|
|
315
|
+
modifiers2 = Array.isArray(avatarModifiers == null ? void 0 : avatarModifiers.value) ? avatarModifiers == null ? void 0 : avatarModifiers.value : [avatarModifiers == null ? void 0 : avatarModifiers.value];
|
|
316
|
+
}
|
|
317
|
+
if (item.modifiers) {
|
|
318
|
+
itemModifiers = Array.isArray(item.modifiers) ? item.modifiers : [item.modifiers];
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
...item,
|
|
322
|
+
key: item.key || `${index}_${(/* @__PURE__ */ new Date()).getTime()}`,
|
|
323
|
+
modifiers: [...modifiers2, ...itemModifiers]
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
return (_ctx, _cache) => {
|
|
328
|
+
return openBlock(), createElementBlock("span", {
|
|
329
|
+
class: normalizeClass(unref(bemCssClasses))
|
|
330
|
+
}, [
|
|
331
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
332
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(avatarItems), (avatarItem) => {
|
|
333
|
+
return openBlock(), createBlock(_sfc_main$1, mergeProps({
|
|
334
|
+
key: avatarItem.key
|
|
335
|
+
}, {
|
|
336
|
+
modifiers: avatarItem.modifiers,
|
|
337
|
+
imgSrc: avatarItem.imgSrc
|
|
338
|
+
}), {
|
|
339
|
+
default: withCtx(() => [
|
|
340
|
+
avatarItem.text ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(avatarItem.text), 1)) : createCommentVNode("", true)
|
|
341
|
+
]),
|
|
342
|
+
_: 2
|
|
343
|
+
}, 1040);
|
|
344
|
+
}), 128)),
|
|
345
|
+
(unref(totalItems) || unref(items).length) > unref(toShow) ? (openBlock(), createBlock(_sfc_main$1, {
|
|
346
|
+
key: 0,
|
|
347
|
+
modifiers: `${unref(stringModifiers)} surface bordered`
|
|
348
|
+
}, {
|
|
349
|
+
default: withCtx(() => [
|
|
350
|
+
createTextVNode(toDisplayString(`+${(unref(totalItems) || unref(items).length) - unref(toShow)}`), 1)
|
|
351
|
+
]),
|
|
352
|
+
_: 1
|
|
353
|
+
}, 8, ["modifiers"])) : createCommentVNode("", true)
|
|
354
|
+
])
|
|
355
|
+
], 2);
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
export {
|
|
360
|
+
_sfc_main as default
|
|
361
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue")):"function"==typeof define&&define.amd?define(["vue"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvAvatarGroup=o(e.vue)}(this,(function(e){"use strict";var o=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(o||{}),r=(e=>(e.before="before",e.after="after",e))(r||{}),t=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(t||{});Boolean,Boolean,Boolean;const a={modifiers:[String,Array]};r.before,o.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,t.button;const l={...a,items:{type:Array,default:()=>[],required:!0},toShow:{type:Number,default:3},totalItems:{type:Number},avatarModifiers:[String,Array]},n={...a,imgSrc:String};function i(o,r,t){return e.computed((()=>{const a={[o]:!0},l="string"==typeof(null==r?void 0:r.value)?r.value.split(" "):null==r?void 0:r.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(a[`${o}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((r=>{a[`${o}--${r}`]=e.unref(t.value[r])})),a}))}const u=["role","aria-label"],s=["src"],f=e.defineComponent({__name:"VvAvatar",props:n,setup(o){const r=o,{modifiers:t}=e.toRefs(r),a=i("vv-avatar",t);return(o,r)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(e.unref(a)),role:o.imgSrc?void 0:"img","aria-label":o.imgSrc?void 0:"avatar"},[e.renderSlot(o.$slots,"default",{},(()=>[o.imgSrc?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.imgSrc,alt:"avatar"},null,8,s)):e.createCommentVNode("",!0)]))],10,u))}}),m={key:0};return e.defineComponent({__name:"VvAvatarGroup",props:l,setup(o){const r=o,{modifiers:t,items:a,toShow:l,totalItems:n,avatarModifiers:u}=e.toRefs(r),s=i("vv-avatar-group",t),c=e.computed((()=>(null==u?void 0:u.value)&&Array.isArray(null==u?void 0:u.value)?u.value.join(" "):(null==u?void 0:u.value)||"")),d=e.computed((()=>a.value.slice(0,l.value).map(((e,o)=>{let r=[],t=[];return(null==u?void 0:u.value)&&(r=Array.isArray(null==u?void 0:u.value)?null==u?void 0:u.value:[null==u?void 0:u.value]),e.modifiers&&(t=Array.isArray(e.modifiers)?e.modifiers:[e.modifiers]),{...e,key:e.key||`${o}_${(new Date).getTime()}`,modifiers:[...r,...t]}}))));return(o,r)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(e.unref(s))},[e.renderSlot(o.$slots,"default",{},(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(d),(o=>(e.openBlock(),e.createBlock(f,e.mergeProps({key:o.key},{modifiers:o.modifiers,imgSrc:o.imgSrc}),{default:e.withCtx((()=>[o.text?(e.openBlock(),e.createElementBlock("span",m,e.toDisplayString(o.text),1)):e.createCommentVNode("",!0)])),_:2},1040)))),128)),(e.unref(n)||e.unref(a).length)>e.unref(l)?(e.openBlock(),e.createBlock(f,{key:0,modifiers:`${e.unref(c)} surface bordered`},{default:e.withCtx((()=>[e.createTextVNode(e.toDisplayString("+"+((e.unref(n)||e.unref(a).length)-e.unref(l))),1)])),_:1},8,["modifiers"])):e.createCommentVNode("",!0)]))],2))}})}));
|