@redseed/redseed-ui-vue3 3.0.3 → 3.1.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/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
|
}
|
|
@@ -94,20 +94,28 @@ const showNotFoundMessage = computed(() => !props.totalItems && props.controlApp
|
|
|
94
94
|
<template #image>
|
|
95
95
|
<slot name="empty-image"></slot>
|
|
96
96
|
</template>
|
|
97
|
+
|
|
97
98
|
<template #title v-if="$slots['empty-title']">
|
|
98
99
|
<slot name="empty-title"></slot>
|
|
99
100
|
</template>
|
|
101
|
+
|
|
102
|
+
<slot name="empty-description">It looks like there's nothing here yet.</slot>
|
|
103
|
+
|
|
104
|
+
<template #actions="{ isWide }" v-if="$slots['empty-actions']">
|
|
105
|
+
<slot name="empty-actions" :isWide="isWide"></slot>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
100
108
|
<template #primary-action-label v-if="$slots['empty-action-label']">
|
|
101
109
|
<slot name="empty-action-label"></slot>
|
|
102
110
|
</template>
|
|
111
|
+
|
|
103
112
|
<template #secondary-action-label v-if="$slots['empty-secondary-action-label']">
|
|
104
113
|
<slot name="empty-secondary-action-label"></slot>
|
|
105
114
|
</template>
|
|
115
|
+
|
|
106
116
|
<template #tertiary-action-label v-if="$slots['empty-tertiary-action-label']">
|
|
107
117
|
<slot name="empty-tertiary-action-label"></slot>
|
|
108
118
|
</template>
|
|
109
|
-
|
|
110
|
-
<slot name="empty-description">It looks like there's nothing here yet.</slot>
|
|
111
119
|
</Empty>
|
|
112
120
|
</div>
|
|
113
121
|
<div v-if="showNotFoundMessage" class="rsui-card-group">
|