@redseed/redseed-ui-vue3 3.0.2 → 3.1.0
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed } from 'vue'
|
|
2
|
+
import { ref, computed } from 'vue'
|
|
3
3
|
|
|
4
4
|
const props = defineProps({
|
|
5
5
|
sm: {
|
|
@@ -47,9 +47,16 @@ const badgeClass = computed(() => [
|
|
|
47
47
|
},
|
|
48
48
|
])
|
|
49
49
|
|
|
50
|
+
const badgeRef = ref(null)
|
|
51
|
+
|
|
52
|
+
defineExpose({
|
|
53
|
+
badgeRef
|
|
54
|
+
})
|
|
50
55
|
</script>
|
|
51
56
|
<template>
|
|
52
|
-
<div
|
|
57
|
+
<div ref="badgeRef"
|
|
58
|
+
:class="badgeClass"
|
|
59
|
+
>
|
|
53
60
|
<slot></slot>
|
|
54
61
|
</div>
|
|
55
62
|
</template>
|
|
@@ -57,7 +64,7 @@ const badgeClass = computed(() => [
|
|
|
57
64
|
.rsui-badge {
|
|
58
65
|
@apply inline-flex items-center justify-center gap-x-1;
|
|
59
66
|
@apply w-fit h-fit rounded-full;
|
|
60
|
-
@apply text-
|
|
67
|
+
@apply text-sm font-medium leading-4;
|
|
61
68
|
&--sm {
|
|
62
69
|
@apply px-2 py-1;
|
|
63
70
|
}
|
|
@@ -81,7 +88,7 @@ const badgeClass = computed(() => [
|
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
:deep(svg) {
|
|
84
|
-
@apply size-
|
|
91
|
+
@apply size-4;
|
|
85
92
|
}
|
|
86
93
|
}
|
|
87
94
|
</style>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed, watch, watchPostEffect, useAttrs } from 'vue'
|
|
3
|
+
import Badge from './Badge.vue'
|
|
4
|
+
|
|
5
|
+
defineProps({
|
|
6
|
+
badgeEnd: {
|
|
7
|
+
type: Boolean,
|
|
8
|
+
default: false,
|
|
9
|
+
},
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const parentBadge = ref(null)
|
|
13
|
+
|
|
14
|
+
const childBadgeStyle = ref(getChildBadgeStyle())
|
|
15
|
+
|
|
16
|
+
const attrs = useAttrs()
|
|
17
|
+
|
|
18
|
+
// Watch the attrs for changes and update the child badge style
|
|
19
|
+
watch(() => attrs, () => {
|
|
20
|
+
childBadgeStyle.value = getChildBadgeStyle()
|
|
21
|
+
}, { deep: true, flush: 'post' })
|
|
22
|
+
|
|
23
|
+
// Watch the component for changes and update the child badge style
|
|
24
|
+
watchPostEffect(() => { childBadgeStyle.value = getChildBadgeStyle() }, { flush: 'post' })
|
|
25
|
+
|
|
26
|
+
function getChildBadgeStyle() {
|
|
27
|
+
if (!parentBadge.value) return {}
|
|
28
|
+
if (!parentBadge.value.badgeRef) return {}
|
|
29
|
+
|
|
30
|
+
// Get the parent badge element
|
|
31
|
+
const parentBadgeElement = parentBadge.value.badgeRef
|
|
32
|
+
|
|
33
|
+
// Get the computed style of the parent badge element
|
|
34
|
+
const parentBadgeStyle = window.getComputedStyle(parentBadgeElement)
|
|
35
|
+
|
|
36
|
+
// Use the background color of the parent badge as the text color of the child badge
|
|
37
|
+
const childColor = parentBadgeStyle.backgroundColor == 'rgba(0, 0, 0, 0)'
|
|
38
|
+
? 'white'
|
|
39
|
+
: parentBadgeStyle.backgroundColor
|
|
40
|
+
|
|
41
|
+
// Use the text color of the parent badge as the background color of the child badge
|
|
42
|
+
const childBackgroundColor = parentBadgeStyle.color
|
|
43
|
+
|
|
44
|
+
// Return the style for the child badge
|
|
45
|
+
return {
|
|
46
|
+
color: childColor,
|
|
47
|
+
backgroundColor: childBackgroundColor,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
<template>
|
|
52
|
+
<Badge v-if="$slots.badge || $slots.default"
|
|
53
|
+
ref="parentBadge"
|
|
54
|
+
:class="[
|
|
55
|
+
'badge-group',
|
|
56
|
+
{
|
|
57
|
+
'badge-group--badge-end': badgeEnd,
|
|
58
|
+
'badge-group--no-text': !$slots.default,
|
|
59
|
+
'badge-group--no-badge': !$slots.badge,
|
|
60
|
+
},
|
|
61
|
+
]"
|
|
62
|
+
>
|
|
63
|
+
<Badge v-if="$slots.badge"
|
|
64
|
+
class="badge-group__badge"
|
|
65
|
+
:style="childBadgeStyle"
|
|
66
|
+
>
|
|
67
|
+
<slot name="badge"></slot>
|
|
68
|
+
</Badge>
|
|
69
|
+
<slot></slot>
|
|
70
|
+
</Badge>
|
|
71
|
+
</template>
|
|
72
|
+
<style lang="scss" scoped>
|
|
73
|
+
.badge-group {
|
|
74
|
+
@apply pl-1 pr-3 gap-x-3;
|
|
75
|
+
&--badge-end {
|
|
76
|
+
@apply pl-3 pr-1;
|
|
77
|
+
}
|
|
78
|
+
&--no-text {
|
|
79
|
+
@apply px-1;
|
|
80
|
+
}
|
|
81
|
+
&--no-badge {
|
|
82
|
+
@apply px-2;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
.badge-group--badge-end {
|
|
86
|
+
.badge-group__badge {
|
|
87
|
+
@apply order-last;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
</style>
|
|
@@ -4,6 +4,7 @@ import BadgeInfo from './BadgeInfo.vue'
|
|
|
4
4
|
import BadgeNeutral from './BadgeNeutral.vue'
|
|
5
5
|
import BadgeSuccess from './BadgeSuccess.vue'
|
|
6
6
|
import BadgeWarning from './BadgeWarning.vue'
|
|
7
|
+
import BadgeGroup from './BadgeGroup.vue'
|
|
7
8
|
|
|
8
9
|
export {
|
|
9
10
|
Badge,
|
|
@@ -12,4 +13,5 @@ export {
|
|
|
12
13
|
BadgeNeutral,
|
|
13
14
|
BadgeSuccess,
|
|
14
15
|
BadgeWarning,
|
|
16
|
+
BadgeGroup,
|
|
15
17
|
}
|
|
@@ -82,29 +82,24 @@ function controlChanged(event) {
|
|
|
82
82
|
<slot></slot>
|
|
83
83
|
</div>
|
|
84
84
|
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
:totalItems="totalItems"
|
|
88
|
-
:controlChanged="controlChanged"
|
|
85
|
+
<div v-if="showControl"
|
|
86
|
+
class="rsui-list__control-bottom"
|
|
89
87
|
>
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
v-bind="$attrs"
|
|
93
|
-
class="rsui-list___control"
|
|
88
|
+
<slot name="control-bottom"
|
|
89
|
+
:showControl="showControl"
|
|
94
90
|
:totalItems="totalItems"
|
|
95
|
-
:
|
|
96
|
-
:sortable="false"
|
|
97
|
-
:filters="[]"
|
|
98
|
-
@change="controlChanged"
|
|
91
|
+
:controlChanged="controlChanged"
|
|
99
92
|
>
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
<ListControl
|
|
94
|
+
v-bind="$attrs"
|
|
95
|
+
:searchable="false"
|
|
96
|
+
:sortable="false"
|
|
97
|
+
:filters="[]"
|
|
98
|
+
:totalItems="totalItems"
|
|
99
|
+
@change="controlChanged"
|
|
100
|
+
></ListControl>
|
|
101
|
+
</slot>
|
|
102
|
+
</div>
|
|
108
103
|
|
|
109
104
|
<!--
|
|
110
105
|
Empty slot with a default empty component.
|
|
@@ -154,7 +149,7 @@ function controlChanged(event) {
|
|
|
154
149
|
class="rsui-list__empty"
|
|
155
150
|
>
|
|
156
151
|
<Empty>
|
|
157
|
-
<slot name="
|
|
152
|
+
<slot name="control-empty-description">No items meet your filter criteria.</slot>
|
|
158
153
|
</Empty>
|
|
159
154
|
</div>
|
|
160
155
|
</slot>
|
|
@@ -168,7 +163,7 @@ function controlChanged(event) {
|
|
|
168
163
|
&__empty {
|
|
169
164
|
@apply mt-6;
|
|
170
165
|
}
|
|
171
|
-
&
|
|
166
|
+
&__control-bottom {
|
|
172
167
|
@apply mt-3;
|
|
173
168
|
}
|
|
174
169
|
}
|