@cognigy/chat-components-vue 0.1.0 → 0.3.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/dist/chat-components-vue.css +1 -1
- package/dist/chat-components-vue.js +12386 -5741
- package/dist/components/Message.vue.d.ts +4 -0
- package/dist/components/common/Typography.vue.d.ts +1 -1
- package/dist/components/messages/AdaptiveCardRenderer.vue.d.ts +35 -0
- package/dist/components/messages/ListItem.vue.d.ts +1 -1
- package/dist/composables/useLiveRegion.d.ts +30 -0
- package/dist/index.d.ts +3 -2
- package/dist/types/index.d.ts +105 -1
- package/dist/utils/helpers.d.ts +3 -2
- package/dist/utils/matcher.d.ts +3 -3
- package/dist/utils/theme.d.ts +12 -1
- package/package.json +8 -3
- package/src/components/Message.vue +98 -55
- package/src/components/common/ActionButton.vue +16 -7
- package/src/components/common/ChatBubble.vue +8 -6
- package/src/components/common/ChatEvent.vue +5 -2
- package/src/components/common/TypingIndicator.vue +4 -1
- package/src/components/common/Typography.vue +56 -67
- package/src/components/messages/AdaptiveCard.vue +322 -225
- package/src/components/messages/AdaptiveCardRenderer.vue +260 -0
- package/src/components/messages/AudioMessage.vue +4 -1
- package/src/components/messages/DatePicker.vue +5 -27
- package/src/components/messages/FileMessage.vue +12 -3
- package/src/components/messages/Gallery.vue +96 -10
- package/src/components/messages/GalleryItem.vue +17 -5
- package/src/components/messages/ImageMessage.vue +20 -5
- package/src/components/messages/List.vue +56 -42
- package/src/components/messages/ListItem.vue +105 -68
- package/src/components/messages/TextMessage.vue +1 -1
- package/src/components/messages/TextWithButtons.vue +35 -11
- package/src/components/messages/VideoMessage.vue +35 -26
- package/src/composables/useCollation.ts +28 -45
- package/src/composables/useLiveRegion.ts +101 -0
- package/src/index.ts +4 -1
- package/src/types/index.ts +127 -2
- package/src/utils/helpers.ts +46 -24
- package/src/utils/matcher.ts +20 -6
- package/src/utils/sanitize.ts +1 -2
- package/src/utils/theme.ts +42 -1
|
@@ -64,7 +64,6 @@ const bubbleStyle = computed((): CSSProperties => {
|
|
|
64
64
|
|
|
65
65
|
<style module>
|
|
66
66
|
.bubble {
|
|
67
|
-
border-radius: 15px;
|
|
68
67
|
border: 1px solid var(--cc-border-bot-message, transparent);
|
|
69
68
|
padding: 12px;
|
|
70
69
|
max-width: 295px;
|
|
@@ -73,6 +72,9 @@ const bubbleStyle = computed((): CSSProperties => {
|
|
|
73
72
|
margin-block-end: 12px;
|
|
74
73
|
word-break: break-word;
|
|
75
74
|
white-space: pre-wrap;
|
|
75
|
+
box-shadow: var(--cc-message-shadow, rgba(151, 124, 156, 0.1) 0px 5px 9px 0px,
|
|
76
|
+
rgba(203, 195, 212, 0.1) 0px 5px 16px 0px,
|
|
77
|
+
rgba(216, 212, 221, 0.1) 0px 8px 20px 0px);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
.bubble.disableBorder {
|
|
@@ -97,13 +99,13 @@ article:global(.user) .bubble {
|
|
|
97
99
|
color: var(--cc-user-message-contrast-color, #ffffff);
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
.incoming {
|
|
103
|
+
margin-inline-start: 0;
|
|
104
|
+
border-radius: 15px 15px 15px 0;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
|
-
|
|
106
|
-
article:global(.user) .outgoing {
|
|
107
|
+
.outgoing {
|
|
107
108
|
margin-inline-start: auto;
|
|
109
|
+
border-radius: 15px 15px 0 15px;
|
|
108
110
|
}
|
|
109
111
|
</style>
|
|
@@ -68,9 +68,12 @@ const eventClasses = computed(() => {
|
|
|
68
68
|
|
|
69
69
|
.eventPillTextWrapper {
|
|
70
70
|
border-radius: 15px;
|
|
71
|
-
background: var(--cc-
|
|
72
|
-
color: var(--cc-
|
|
71
|
+
background: var(--cc-chat-event-background, rgba(0, 0, 0, 0.8));
|
|
72
|
+
color: var(--cc-chat-event-text-color, #ffffff);
|
|
73
73
|
padding: 8px 12px;
|
|
74
|
+
box-shadow: var(--cc-message-shadow, rgba(151, 124, 156, 0.1) 0px 5px 9px 0px,
|
|
75
|
+
rgba(203, 195, 212, 0.1) 0px 5px 16px 0px,
|
|
76
|
+
rgba(216, 212, 221, 0.1) 0px 8px 20px 0px);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
.eventText {
|
|
@@ -71,7 +71,7 @@ const indicatorClasses = computed(() => {
|
|
|
71
71
|
align-items: center;
|
|
72
72
|
background-color: var(--cc-white, #ffffff);
|
|
73
73
|
border-radius: 15px;
|
|
74
|
-
border: 1px solid var(--cc-black-80, rgba(0, 0, 0, 0.8));
|
|
74
|
+
border: 1px solid var(--cc-border-media-card, var(--cc-black-80, rgba(0, 0, 0, 0.8)));
|
|
75
75
|
box-sizing: border-box;
|
|
76
76
|
display: flex;
|
|
77
77
|
gap: 6px;
|
|
@@ -82,6 +82,9 @@ const indicatorClasses = computed(() => {
|
|
|
82
82
|
width: 62px;
|
|
83
83
|
margin-block: var(--webchat-message-margin-block, 24px);
|
|
84
84
|
margin-inline: var(--webchat-message-margin-inline, 20px);
|
|
85
|
+
box-shadow: var(--cc-message-shadow, rgba(151, 124, 156, 0.1) 0px 5px 9px 0px,
|
|
86
|
+
rgba(203, 195, 212, 0.1) 0px 5px 16px 0px,
|
|
87
|
+
rgba(216, 212, 221, 0.1) 0px 8px 20px 0px);
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
.typingIndicator.disableBorder {
|
|
@@ -1,94 +1,94 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, useCssModule, useAttrs, CSSProperties } from
|
|
2
|
+
import { computed, useCssModule, useAttrs, CSSProperties } from "vue";
|
|
3
3
|
|
|
4
4
|
export type TagVariant =
|
|
5
|
-
|
|
|
6
|
-
|
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
17
|
-
type ColorVariant =
|
|
5
|
+
| "h1-semibold"
|
|
6
|
+
| "h2-regular"
|
|
7
|
+
| "h2-semibold"
|
|
8
|
+
| "title1-semibold"
|
|
9
|
+
| "title1-regular"
|
|
10
|
+
| "title2-semibold"
|
|
11
|
+
| "title2-regular"
|
|
12
|
+
| "body-regular"
|
|
13
|
+
| "body-semibold"
|
|
14
|
+
| "copy-medium"
|
|
15
|
+
| "cta-semibold";
|
|
16
|
+
|
|
17
|
+
type ColorVariant = "primary" | "secondary";
|
|
18
18
|
|
|
19
19
|
interface Props {
|
|
20
|
-
variant?: TagVariant
|
|
21
|
-
component?: string
|
|
22
|
-
className?: string
|
|
23
|
-
style?: CSSProperties
|
|
24
|
-
color?: string
|
|
25
|
-
id?: string
|
|
26
|
-
ariaHidden?: boolean
|
|
27
|
-
tabIndex?: number
|
|
20
|
+
variant?: TagVariant;
|
|
21
|
+
component?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
color?: string;
|
|
25
|
+
id?: string;
|
|
26
|
+
ariaHidden?: boolean;
|
|
27
|
+
tabIndex?: number;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const props = withDefaults(defineProps<Props>(), {
|
|
31
|
-
variant:
|
|
31
|
+
variant: "body-regular",
|
|
32
32
|
component: undefined,
|
|
33
|
-
className:
|
|
33
|
+
className: "",
|
|
34
34
|
style: undefined,
|
|
35
35
|
color: undefined,
|
|
36
36
|
id: undefined,
|
|
37
37
|
ariaHidden: undefined,
|
|
38
38
|
tabIndex: undefined,
|
|
39
|
-
})
|
|
39
|
+
});
|
|
40
40
|
|
|
41
|
-
const attrs = useAttrs()
|
|
42
|
-
const styles = useCssModule()
|
|
41
|
+
const attrs = useAttrs();
|
|
42
|
+
const styles = useCssModule();
|
|
43
43
|
|
|
44
44
|
// Mapping between variants and default HTML tags
|
|
45
45
|
const variantsMapping: Record<TagVariant, string> = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
46
|
+
"h1-semibold": "h1",
|
|
47
|
+
"h2-regular": "h2",
|
|
48
|
+
"h2-semibold": "h2",
|
|
49
|
+
"title1-semibold": "h3",
|
|
50
|
+
"title1-regular": "h4",
|
|
51
|
+
"title2-semibold": "h5",
|
|
52
|
+
"title2-regular": "h6",
|
|
53
|
+
"body-semibold": "p",
|
|
54
|
+
"body-regular": "p",
|
|
55
|
+
"copy-medium": "p",
|
|
56
|
+
"cta-semibold": "p",
|
|
57
|
+
};
|
|
58
58
|
|
|
59
59
|
// Color mapping for predefined colors
|
|
60
60
|
const colorsMapping: Record<ColorVariant, string> = {
|
|
61
|
-
primary:
|
|
62
|
-
secondary:
|
|
63
|
-
}
|
|
61
|
+
primary: "var(--cc-primary-color)",
|
|
62
|
+
secondary: "var(--cc-secondary-color)",
|
|
63
|
+
};
|
|
64
64
|
|
|
65
65
|
// Determine which HTML element to render
|
|
66
66
|
const componentTag = computed(() => {
|
|
67
|
-
return props.component ?? variantsMapping[props.variant]
|
|
68
|
-
})
|
|
67
|
+
return props.component ?? variantsMapping[props.variant];
|
|
68
|
+
});
|
|
69
69
|
|
|
70
70
|
// Compute the color value
|
|
71
71
|
const typographyColor = computed(() => {
|
|
72
|
-
if (!props.color) return undefined
|
|
73
|
-
return colorsMapping[props.color as ColorVariant] ?? props.color
|
|
74
|
-
})
|
|
72
|
+
if (!props.color) return undefined;
|
|
73
|
+
return colorsMapping[props.color as ColorVariant] ?? props.color;
|
|
74
|
+
});
|
|
75
75
|
|
|
76
76
|
// Compute CSS classes
|
|
77
77
|
const componentClasses = computed(() => {
|
|
78
|
-
const classes = [styles[props.variant]]
|
|
79
|
-
if (props.className) classes.push(props.className)
|
|
80
|
-
if (props.color) classes.push(props.color)
|
|
81
|
-
return classes.filter(Boolean).join(
|
|
82
|
-
})
|
|
78
|
+
const classes = [styles[props.variant]];
|
|
79
|
+
if (props.className) classes.push(props.className);
|
|
80
|
+
if (props.color) classes.push(props.color);
|
|
81
|
+
return classes.filter(Boolean).join(" ");
|
|
82
|
+
});
|
|
83
83
|
|
|
84
84
|
// Compute merged styles
|
|
85
85
|
const componentStyle = computed(() => {
|
|
86
|
-
const mergedStyle: CSSProperties = { ...props.style }
|
|
86
|
+
const mergedStyle: CSSProperties = { ...props.style };
|
|
87
87
|
if (typographyColor.value) {
|
|
88
|
-
mergedStyle.color = typographyColor.value
|
|
88
|
+
mergedStyle.color = typographyColor.value;
|
|
89
89
|
}
|
|
90
|
-
return mergedStyle
|
|
91
|
-
})
|
|
90
|
+
return mergedStyle;
|
|
91
|
+
});
|
|
92
92
|
</script>
|
|
93
93
|
|
|
94
94
|
<template>
|
|
@@ -107,7 +107,6 @@ const componentStyle = computed(() => {
|
|
|
107
107
|
|
|
108
108
|
<style module>
|
|
109
109
|
.h1-semibold {
|
|
110
|
-
font-family: Figtree;
|
|
111
110
|
font-size: 2.125rem; /* 34px */
|
|
112
111
|
font-style: normal;
|
|
113
112
|
font-weight: 600;
|
|
@@ -115,7 +114,6 @@ const componentStyle = computed(() => {
|
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
.h2-regular {
|
|
118
|
-
font-family: Figtree;
|
|
119
117
|
font-size: 1.125rem; /* 18px */
|
|
120
118
|
font-style: normal;
|
|
121
119
|
font-weight: 400;
|
|
@@ -123,7 +121,6 @@ const componentStyle = computed(() => {
|
|
|
123
121
|
}
|
|
124
122
|
|
|
125
123
|
.h2-semibold {
|
|
126
|
-
font-family: Figtree;
|
|
127
124
|
font-size: 1.125rem; /* 18px */
|
|
128
125
|
font-style: normal;
|
|
129
126
|
font-weight: 600;
|
|
@@ -131,7 +128,6 @@ const componentStyle = computed(() => {
|
|
|
131
128
|
}
|
|
132
129
|
|
|
133
130
|
.title1-regular {
|
|
134
|
-
font-family: Figtree;
|
|
135
131
|
font-size: 1rem; /* 16px */
|
|
136
132
|
font-style: normal;
|
|
137
133
|
font-weight: 400;
|
|
@@ -139,7 +135,6 @@ const componentStyle = computed(() => {
|
|
|
139
135
|
}
|
|
140
136
|
|
|
141
137
|
.title1-semibold {
|
|
142
|
-
font-family: Figtree;
|
|
143
138
|
font-size: 1rem; /* 16px */
|
|
144
139
|
font-style: normal;
|
|
145
140
|
font-weight: 600;
|
|
@@ -147,7 +142,6 @@ const componentStyle = computed(() => {
|
|
|
147
142
|
}
|
|
148
143
|
|
|
149
144
|
.title2-regular {
|
|
150
|
-
font-family: Figtree;
|
|
151
145
|
font-size: 0.75rem; /* 12px */
|
|
152
146
|
font-style: normal;
|
|
153
147
|
font-weight: 400;
|
|
@@ -155,7 +149,6 @@ const componentStyle = computed(() => {
|
|
|
155
149
|
}
|
|
156
150
|
|
|
157
151
|
.title2-semibold {
|
|
158
|
-
font-family: Figtree;
|
|
159
152
|
font-size: 0.75rem; /* 12px */
|
|
160
153
|
font-style: normal;
|
|
161
154
|
font-weight: 600;
|
|
@@ -163,7 +156,6 @@ const componentStyle = computed(() => {
|
|
|
163
156
|
}
|
|
164
157
|
|
|
165
158
|
.body-regular {
|
|
166
|
-
font-family: Figtree;
|
|
167
159
|
font-size: 0.875rem; /* 14px */
|
|
168
160
|
font-style: normal;
|
|
169
161
|
font-weight: 400;
|
|
@@ -171,7 +163,6 @@ const componentStyle = computed(() => {
|
|
|
171
163
|
}
|
|
172
164
|
|
|
173
165
|
.body-semibold {
|
|
174
|
-
font-family: Figtree;
|
|
175
166
|
font-size: 0.875rem; /* 14px */
|
|
176
167
|
font-style: normal;
|
|
177
168
|
font-weight: 600;
|
|
@@ -179,7 +170,6 @@ const componentStyle = computed(() => {
|
|
|
179
170
|
}
|
|
180
171
|
|
|
181
172
|
.copy-medium {
|
|
182
|
-
font-family: Figtree;
|
|
183
173
|
font-size: 0.75rem; /* 12px */
|
|
184
174
|
font-style: normal;
|
|
185
175
|
font-weight: 500;
|
|
@@ -187,7 +177,6 @@ const componentStyle = computed(() => {
|
|
|
187
177
|
}
|
|
188
178
|
|
|
189
179
|
.cta-semibold {
|
|
190
|
-
font-family: Figtree;
|
|
191
180
|
font-size: 0.875rem; /* 14px */
|
|
192
181
|
font-style: normal;
|
|
193
182
|
font-weight: 600;
|