sprintify-ui 0.0.142 → 0.0.143
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.
|
@@ -14,6 +14,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
14
14
|
default: undefined;
|
|
15
15
|
type: PropType<(user: User) => RouteLocationRaw>;
|
|
16
16
|
};
|
|
17
|
+
max: {
|
|
18
|
+
default: number;
|
|
19
|
+
type: NumberConstructor;
|
|
20
|
+
};
|
|
17
21
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
18
22
|
users: {
|
|
19
23
|
required: true;
|
|
@@ -27,8 +31,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
27
31
|
default: undefined;
|
|
28
32
|
type: PropType<(user: User) => RouteLocationRaw>;
|
|
29
33
|
};
|
|
34
|
+
max: {
|
|
35
|
+
default: number;
|
|
36
|
+
type: NumberConstructor;
|
|
37
|
+
};
|
|
30
38
|
}>>, {
|
|
31
39
|
to: (user: User) => RouteLocationRaw;
|
|
32
40
|
size: string;
|
|
41
|
+
max: number;
|
|
33
42
|
}>;
|
|
34
43
|
export default _default;
|
package/package.json
CHANGED
|
@@ -18,23 +18,13 @@ const user = {
|
|
|
18
18
|
'https://images.unsplash.com/photo-1494790108377-be9c29b29330??auto=format&fit=crop&w=200&h=200&q=80&g=face',
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
user
|
|
27
|
-
|
|
28
|
-
user,
|
|
29
|
-
user,
|
|
30
|
-
user,
|
|
31
|
-
user,
|
|
32
|
-
user,
|
|
33
|
-
user,
|
|
34
|
-
user,
|
|
35
|
-
user,
|
|
36
|
-
user,
|
|
37
|
-
];
|
|
21
|
+
const n = 40;
|
|
22
|
+
|
|
23
|
+
const users = [];
|
|
24
|
+
|
|
25
|
+
for (let i = 0; i < n; i++) {
|
|
26
|
+
users.push(user);
|
|
27
|
+
}
|
|
38
28
|
|
|
39
29
|
const Template = (args) => ({
|
|
40
30
|
components: { BaseAvatarGroup },
|
|
@@ -57,3 +47,25 @@ Demo.args = {
|
|
|
57
47
|
return '/' + user.email;
|
|
58
48
|
},
|
|
59
49
|
};
|
|
50
|
+
|
|
51
|
+
const TemplateWithMaxItems = (args) => ({
|
|
52
|
+
components: { BaseAvatarGroup },
|
|
53
|
+
setup() {
|
|
54
|
+
return { args };
|
|
55
|
+
},
|
|
56
|
+
template: `
|
|
57
|
+
<p class="text-sm mt-2">Demo</p>
|
|
58
|
+
<BaseAvatarGroup v-bind="args"></BaseAvatarGroup>
|
|
59
|
+
|
|
60
|
+
<p class="text-sm mt-2">With small container</p>
|
|
61
|
+
<div style="max-width: 200px; overflow: hidden;"><BaseAvatarGroup v-bind="args"></BaseAvatarGroup></div>
|
|
62
|
+
`,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export const MaxItems = TemplateWithMaxItems.bind({});
|
|
66
|
+
MaxItems.args = {
|
|
67
|
+
users: users,
|
|
68
|
+
to(user) {
|
|
69
|
+
return '/' + user.email;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
@@ -19,6 +19,23 @@
|
|
|
19
19
|
/>
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
22
|
+
<div
|
|
23
|
+
v-if="isLimitReached"
|
|
24
|
+
class="z-10 shrink-0"
|
|
25
|
+
:style="{
|
|
26
|
+
marginLeft: '-' + spacing,
|
|
27
|
+
}"
|
|
28
|
+
>
|
|
29
|
+
<div class="rounded-full border-[3px] border-white bg-slate-300">
|
|
30
|
+
<div
|
|
31
|
+
:class="[sizeClass, fontSizeClass]"
|
|
32
|
+
class="flex items-center justify-center rounded-full font-semibold text-slate-700"
|
|
33
|
+
>
|
|
34
|
+
<span v-if="hiddenItemsCount > 99"> ... </span>
|
|
35
|
+
<span v-else> +{{ hiddenItemsCount }} </span>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
22
39
|
</div>
|
|
23
40
|
</template>
|
|
24
41
|
|
|
@@ -41,6 +58,10 @@ const props = defineProps({
|
|
|
41
58
|
default: undefined,
|
|
42
59
|
type: Function as PropType<(user: User) => RouteLocationRaw>,
|
|
43
60
|
},
|
|
61
|
+
max: {
|
|
62
|
+
default: 10,
|
|
63
|
+
type: Number,
|
|
64
|
+
},
|
|
44
65
|
});
|
|
45
66
|
|
|
46
67
|
const spacing = computed(() => {
|
|
@@ -59,4 +80,69 @@ const spacing = computed(() => {
|
|
|
59
80
|
return '1rem';
|
|
60
81
|
}
|
|
61
82
|
});
|
|
83
|
+
|
|
84
|
+
const maxInternal = computed(() => {
|
|
85
|
+
return props.max > 3 ? props.max : 3;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const users = computed(() => {
|
|
89
|
+
return props.users.length > maxInternal.value
|
|
90
|
+
? props.users.slice(0, maxInternal.value)
|
|
91
|
+
: props.users;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const hiddenItemsCount = computed(() => {
|
|
95
|
+
return Array.isArray(props.users) && props.users.length > maxInternal.value
|
|
96
|
+
? props.users.length - maxInternal.value
|
|
97
|
+
: 0;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const isLimitReached = computed(() => {
|
|
101
|
+
return (
|
|
102
|
+
(Array.isArray(props.users) && props.users.length > maxInternal.value) ??
|
|
103
|
+
false
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const sizeClass = computed((): string => {
|
|
108
|
+
const base = 'h-9 w-9';
|
|
109
|
+
|
|
110
|
+
if (props.size == 'xs') {
|
|
111
|
+
return 'h-6 w-6';
|
|
112
|
+
}
|
|
113
|
+
if (props.size == 'sm') {
|
|
114
|
+
return 'h-8 w-8';
|
|
115
|
+
}
|
|
116
|
+
if (props.size == 'base') {
|
|
117
|
+
return base;
|
|
118
|
+
}
|
|
119
|
+
if (props.size == 'lg') {
|
|
120
|
+
return 'h-12 w-12';
|
|
121
|
+
}
|
|
122
|
+
if (props.size == 'xl') {
|
|
123
|
+
return 'h-14 w-14';
|
|
124
|
+
}
|
|
125
|
+
return base;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const fontSizeClass = computed((): string => {
|
|
129
|
+
const base = 'text-xs';
|
|
130
|
+
|
|
131
|
+
if (props.size == 'xs') {
|
|
132
|
+
return 'text-[8px]';
|
|
133
|
+
}
|
|
134
|
+
if (props.size == 'sm') {
|
|
135
|
+
return 'text-[10px]';
|
|
136
|
+
}
|
|
137
|
+
if (props.size == 'base') {
|
|
138
|
+
return 'text-xs';
|
|
139
|
+
}
|
|
140
|
+
if (props.size == 'lg') {
|
|
141
|
+
return 'text-sm';
|
|
142
|
+
}
|
|
143
|
+
if (props.size == 'xl') {
|
|
144
|
+
return 'text-sm';
|
|
145
|
+
}
|
|
146
|
+
return base;
|
|
147
|
+
});
|
|
62
148
|
</script>
|