@cognigy/chat-components-vue 0.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/LICENSE +20 -0
- package/README.md +178 -0
- package/dist/assets/svg/ArrowBackIcon.vue.d.ts +9 -0
- package/dist/assets/svg/AudioPauseIcon.vue.d.ts +2 -0
- package/dist/assets/svg/AudioPlayIcon.vue.d.ts +2 -0
- package/dist/assets/svg/CloseIcon.vue.d.ts +2 -0
- package/dist/assets/svg/DownloadIcon.vue.d.ts +2 -0
- package/dist/assets/svg/VideoPlayIcon.vue.d.ts +9 -0
- package/dist/assets/svg/index.d.ts +7 -0
- package/dist/chat-components-vue.css +1 -0
- package/dist/chat-components-vue.js +9858 -0
- package/dist/components/Message.vue.d.ts +11 -0
- package/dist/components/common/ActionButton.vue.d.ts +59 -0
- package/dist/components/common/ActionButtons.vue.d.ts +36 -0
- package/dist/components/common/ChatBubble.vue.d.ts +22 -0
- package/dist/components/common/ChatEvent.vue.d.ts +20 -0
- package/dist/components/common/LinkIcon.vue.d.ts +2 -0
- package/dist/components/common/TypingIndicator.vue.d.ts +21 -0
- package/dist/components/common/Typography.vue.d.ts +38 -0
- package/dist/components/messages/AdaptiveCard.vue.d.ts +2 -0
- package/dist/components/messages/AudioMessage.vue.d.ts +5 -0
- package/dist/components/messages/DatePicker.vue.d.ts +2 -0
- package/dist/components/messages/FileMessage.vue.d.ts +2 -0
- package/dist/components/messages/Gallery.vue.d.ts +2 -0
- package/dist/components/messages/GalleryItem.vue.d.ts +7 -0
- package/dist/components/messages/ImageMessage.vue.d.ts +5 -0
- package/dist/components/messages/List.vue.d.ts +2 -0
- package/dist/components/messages/ListItem.vue.d.ts +16 -0
- package/dist/components/messages/TextMessage.vue.d.ts +15 -0
- package/dist/components/messages/TextWithButtons.vue.d.ts +2 -0
- package/dist/components/messages/VideoMessage.vue.d.ts +5 -0
- package/dist/composables/useChannelPayload.d.ts +47 -0
- package/dist/composables/useCollation.d.ts +47 -0
- package/dist/composables/useImageContext.d.ts +13 -0
- package/dist/composables/useMessageContext.d.ts +18 -0
- package/dist/composables/useSanitize.d.ts +8 -0
- package/dist/index.d.ts +33 -0
- package/dist/types/index.d.ts +275 -0
- package/dist/utils/helpers.d.ts +56 -0
- package/dist/utils/matcher.d.ts +20 -0
- package/dist/utils/sanitize.d.ts +28 -0
- package/dist/utils/theme.d.ts +18 -0
- package/package.json +94 -0
- package/src/assets/svg/ArrowBackIcon.vue +30 -0
- package/src/assets/svg/AudioPauseIcon.vue +20 -0
- package/src/assets/svg/AudioPlayIcon.vue +19 -0
- package/src/assets/svg/CloseIcon.vue +10 -0
- package/src/assets/svg/DownloadIcon.vue +10 -0
- package/src/assets/svg/VideoPlayIcon.vue +25 -0
- package/src/assets/svg/index.ts +7 -0
- package/src/components/Message.vue +152 -0
- package/src/components/common/ActionButton.vue +354 -0
- package/src/components/common/ActionButtons.vue +170 -0
- package/src/components/common/ChatBubble.vue +109 -0
- package/src/components/common/ChatEvent.vue +84 -0
- package/src/components/common/LinkIcon.vue +34 -0
- package/src/components/common/TypingIndicator.vue +202 -0
- package/src/components/common/Typography.vue +196 -0
- package/src/components/messages/AdaptiveCard.vue +292 -0
- package/src/components/messages/AudioMessage.vue +391 -0
- package/src/components/messages/DatePicker.vue +135 -0
- package/src/components/messages/FileMessage.vue +195 -0
- package/src/components/messages/Gallery.vue +296 -0
- package/src/components/messages/GalleryItem.vue +214 -0
- package/src/components/messages/ImageMessage.vue +368 -0
- package/src/components/messages/List.vue +149 -0
- package/src/components/messages/ListItem.vue +344 -0
- package/src/components/messages/TextMessage.vue +203 -0
- package/src/components/messages/TextWithButtons.vue +119 -0
- package/src/components/messages/VideoMessage.vue +343 -0
- package/src/composables/useChannelPayload.ts +101 -0
- package/src/composables/useCollation.ts +163 -0
- package/src/composables/useImageContext.ts +27 -0
- package/src/composables/useMessageContext.ts +41 -0
- package/src/composables/useSanitize.ts +25 -0
- package/src/index.ts +71 -0
- package/src/types/index.ts +373 -0
- package/src/utils/helpers.ts +164 -0
- package/src/utils/matcher.ts +283 -0
- package/src/utils/sanitize.ts +133 -0
- package/src/utils/theme.ts +58 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { IMessage, IWebchatQuickReply as QuickReply, IWebchatTemplateAttachment as TemplateAttachment, IWebchatAudioAttachment as AudioAttachment, IWebchatImageAttachment as ImageAttachment, IWebchatVideoAttachment as VideoAttachment } from '@cognigy/socket-client';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* Extended IMessage with optional runtime properties not in base interface.
|
|
5
|
+
* The socket-client IMessage doesn't include 'id', but it may be present at runtime.
|
|
6
|
+
*/
|
|
7
|
+
export interface IMessageWithId extends IMessage {
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to check if a message has an id property
|
|
12
|
+
*/
|
|
13
|
+
export declare function hasMessageId(message: IMessage): message is IMessageWithId & {
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Get message ID with fallback to timestamp-based ID
|
|
18
|
+
*/
|
|
19
|
+
export declare function getMessageId(message: IMessage): string;
|
|
20
|
+
/**
|
|
21
|
+
* Adaptive card payload structure.
|
|
22
|
+
* Used for type narrowing when accessing adaptive card data from message payloads.
|
|
23
|
+
*/
|
|
24
|
+
export interface IAdaptiveCardPayload {
|
|
25
|
+
adaptiveCard: unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Type guard to check if a payload contains an adaptive card
|
|
29
|
+
*/
|
|
30
|
+
export declare function isAdaptiveCardPayload(payload: unknown): payload is IAdaptiveCardPayload;
|
|
31
|
+
declare global {
|
|
32
|
+
interface Window {
|
|
33
|
+
/** Test-only: Message ID for component testing */
|
|
34
|
+
__TEST_MESSAGE_ID__?: string;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Configuration for the chat components
|
|
39
|
+
* Mirrors IWebchatConfig from React version
|
|
40
|
+
*/
|
|
41
|
+
export interface ChatConfig {
|
|
42
|
+
active?: boolean;
|
|
43
|
+
URLToken?: string;
|
|
44
|
+
initialSessionId?: string;
|
|
45
|
+
settings?: ChatSettings;
|
|
46
|
+
isConfigLoaded?: boolean;
|
|
47
|
+
isTimedOut?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface ChatSettings {
|
|
50
|
+
layout?: {
|
|
51
|
+
title?: string;
|
|
52
|
+
logoUrl?: string;
|
|
53
|
+
botAvatarName?: string;
|
|
54
|
+
botLogoUrl?: string;
|
|
55
|
+
agentAvatarName?: string;
|
|
56
|
+
agentLogoUrl?: string;
|
|
57
|
+
disableHtmlContentSanitization?: boolean;
|
|
58
|
+
enableGenericHTMLStyling?: boolean;
|
|
59
|
+
disableBotOutputBorder?: boolean;
|
|
60
|
+
botOutputMaxWidthPercentage?: number;
|
|
61
|
+
disableUrlButtonSanitization?: boolean;
|
|
62
|
+
dynamicImageAspectRatio?: boolean;
|
|
63
|
+
showEngagementInChat?: boolean;
|
|
64
|
+
};
|
|
65
|
+
colors?: {
|
|
66
|
+
primaryColor?: string;
|
|
67
|
+
primaryColorHover?: string;
|
|
68
|
+
primaryColorFocus?: string;
|
|
69
|
+
primaryColorDisabled?: string;
|
|
70
|
+
primaryContrastColor?: string;
|
|
71
|
+
secondaryColor?: string;
|
|
72
|
+
botMessageColor?: string;
|
|
73
|
+
botMessageContrastColor?: string;
|
|
74
|
+
userMessageColor?: string;
|
|
75
|
+
userMessageContrastColor?: string;
|
|
76
|
+
agentMessageColor?: string;
|
|
77
|
+
agentMessageContrastColor?: string;
|
|
78
|
+
borderBotMessage?: string;
|
|
79
|
+
borderUserMessage?: string;
|
|
80
|
+
borderAgentMessage?: string;
|
|
81
|
+
textLinkColor?: string;
|
|
82
|
+
};
|
|
83
|
+
behavior?: {
|
|
84
|
+
renderMarkdown?: boolean;
|
|
85
|
+
enableTypingIndicator?: boolean;
|
|
86
|
+
messageDelay?: number;
|
|
87
|
+
collateStreamedOutputs?: boolean;
|
|
88
|
+
focusInputAfterPostback?: boolean;
|
|
89
|
+
};
|
|
90
|
+
widgetSettings?: {
|
|
91
|
+
enableDefaultPreview?: boolean;
|
|
92
|
+
enableStrictMessengerSync?: boolean;
|
|
93
|
+
customAllowedHtmlTags?: string[];
|
|
94
|
+
enableAutoFocus?: boolean;
|
|
95
|
+
disableRenderURLsAsLinks?: boolean;
|
|
96
|
+
disableTextInputSanitization?: boolean;
|
|
97
|
+
sourceDirectionMapping?: {
|
|
98
|
+
user?: 'incoming' | 'outgoing';
|
|
99
|
+
bot?: 'incoming' | 'outgoing';
|
|
100
|
+
agent?: 'incoming' | 'outgoing';
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
customTranslations?: {
|
|
104
|
+
ariaLabels?: {
|
|
105
|
+
messageHeader?: {
|
|
106
|
+
user?: string;
|
|
107
|
+
bot?: string;
|
|
108
|
+
timestamp?: string;
|
|
109
|
+
};
|
|
110
|
+
opensInNewTab?: string;
|
|
111
|
+
actionButtonPositionText?: string;
|
|
112
|
+
viewImageInFullsize?: string;
|
|
113
|
+
fullSizeImageViewerTitle?: string;
|
|
114
|
+
downloadFullsizeImage?: string;
|
|
115
|
+
closeFullsizeImageModal?: string;
|
|
116
|
+
playAudio?: string;
|
|
117
|
+
pauseAudio?: string;
|
|
118
|
+
audioPlaybackProgress?: string;
|
|
119
|
+
audioTimeRemaining?: string;
|
|
120
|
+
downloadTranscript?: string;
|
|
121
|
+
playVideo?: string;
|
|
122
|
+
slide?: string;
|
|
123
|
+
[key: string]: any;
|
|
124
|
+
};
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Theme configuration
|
|
130
|
+
*/
|
|
131
|
+
export interface ChatTheme {
|
|
132
|
+
primaryColor?: string;
|
|
133
|
+
primaryColorHover?: string;
|
|
134
|
+
secondaryColor?: string;
|
|
135
|
+
backgroundBotMessage?: string;
|
|
136
|
+
backgroundUserMessage?: string;
|
|
137
|
+
textDark?: string;
|
|
138
|
+
textLight?: string;
|
|
139
|
+
fontFamily?: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Message sender callback type.
|
|
143
|
+
* The data parameter uses Record<string, any> because it passes through
|
|
144
|
+
* unchanged to @cognigy/socket-client - shape is determined by backend.
|
|
145
|
+
*/
|
|
146
|
+
export type MessageSender = (text?: string, data?: Record<string, any> | null, options?: Partial<SendMessageOptions>) => void;
|
|
147
|
+
export interface SendMessageOptions {
|
|
148
|
+
label: string;
|
|
149
|
+
collate: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Custom icon for action buttons.
|
|
153
|
+
* Can be a Vue component or a string identifier.
|
|
154
|
+
*/
|
|
155
|
+
export type CustomIcon = Component | string;
|
|
156
|
+
/**
|
|
157
|
+
* Analytics event data passed to analytics callbacks.
|
|
158
|
+
* Shape varies by event type, so we use Record<string, any> for flexibility.
|
|
159
|
+
*/
|
|
160
|
+
export type AnalyticsEventData = Record<string, any>;
|
|
161
|
+
/**
|
|
162
|
+
* Callback for emitting analytics events from components.
|
|
163
|
+
*/
|
|
164
|
+
export type AnalyticsEventCallback = (event: string, data?: AnalyticsEventData) => void;
|
|
165
|
+
/**
|
|
166
|
+
* Props for the Message component
|
|
167
|
+
*/
|
|
168
|
+
export interface MessageProps {
|
|
169
|
+
message: IMessage;
|
|
170
|
+
action?: MessageSender;
|
|
171
|
+
config?: ChatConfig;
|
|
172
|
+
theme?: ChatTheme;
|
|
173
|
+
prevMessage?: IMessage;
|
|
174
|
+
disableHeader?: boolean;
|
|
175
|
+
plugins?: MessagePlugin[];
|
|
176
|
+
onEmitAnalytics?: (event: string, payload?: unknown) => void;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Options for match rules and plugins
|
|
180
|
+
*/
|
|
181
|
+
export interface MatchRuleOptions {
|
|
182
|
+
/** If true, continue matching after this rule (allows multiple components) */
|
|
183
|
+
passthrough?: boolean;
|
|
184
|
+
/** Render component in fullscreen mode */
|
|
185
|
+
fullscreen?: boolean;
|
|
186
|
+
/** Render component at full width */
|
|
187
|
+
fullwidth?: boolean;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Internal match rule used by the matcher system.
|
|
191
|
+
* These define which message types map to which internal components.
|
|
192
|
+
* Components are resolved by name lookup in Message.vue.
|
|
193
|
+
*/
|
|
194
|
+
export interface MatchRule {
|
|
195
|
+
/** Unique name identifying this rule (maps to component in Message.vue) */
|
|
196
|
+
name: string;
|
|
197
|
+
/** Function to determine if this rule matches a message */
|
|
198
|
+
match: (message: IMessage, config?: ChatConfig) => boolean;
|
|
199
|
+
/** Optional rule behavior settings */
|
|
200
|
+
options?: MatchRuleOptions;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* External message plugin for custom message types.
|
|
204
|
+
* Users provide these to handle custom message formats.
|
|
205
|
+
*/
|
|
206
|
+
export interface MessagePlugin extends MatchRule {
|
|
207
|
+
/** Vue component to render for matched messages (required for external plugins) */
|
|
208
|
+
component: Component;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Union type for matcher results - can be internal rule or external plugin
|
|
212
|
+
*/
|
|
213
|
+
export type MatchResult = MatchRule | MessagePlugin;
|
|
214
|
+
/**
|
|
215
|
+
* Type guard to check if a match result is an external plugin with a component
|
|
216
|
+
*/
|
|
217
|
+
export declare function isMessagePlugin(rule: MatchResult): rule is MessagePlugin;
|
|
218
|
+
/**
|
|
219
|
+
* Check if a value is a valid Vue component (not null/undefined/empty)
|
|
220
|
+
*/
|
|
221
|
+
export declare function isValidComponent(component: unknown): component is Component;
|
|
222
|
+
/** @deprecated Use MatchRuleOptions instead */
|
|
223
|
+
export type MessagePluginOptions = MatchRuleOptions;
|
|
224
|
+
/**
|
|
225
|
+
* Context provided to message components
|
|
226
|
+
*/
|
|
227
|
+
export interface MessageContext {
|
|
228
|
+
message: IMessage;
|
|
229
|
+
config?: ChatConfig;
|
|
230
|
+
theme?: ChatTheme;
|
|
231
|
+
action?: MessageSender;
|
|
232
|
+
onEmitAnalytics?: (event: string, payload?: unknown) => void;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* DatePicker plugin data interface
|
|
236
|
+
*/
|
|
237
|
+
export interface IDatePickerData {
|
|
238
|
+
openPickerButtonText?: string;
|
|
239
|
+
submitButtonText?: string;
|
|
240
|
+
eventName?: string;
|
|
241
|
+
dateFormat?: string;
|
|
242
|
+
defaultDate?: string;
|
|
243
|
+
minDate?: string;
|
|
244
|
+
maxDate?: string;
|
|
245
|
+
mode?: 'single' | 'multiple' | 'range';
|
|
246
|
+
enableTime?: boolean;
|
|
247
|
+
time_24hr?: boolean;
|
|
248
|
+
noCalendar?: boolean;
|
|
249
|
+
weekNumbers?: boolean;
|
|
250
|
+
locale?: string;
|
|
251
|
+
enable_disable?: string[];
|
|
252
|
+
function_enable_disable?: string;
|
|
253
|
+
wantDisable?: boolean;
|
|
254
|
+
defaultHour?: number;
|
|
255
|
+
defaultMinute?: number;
|
|
256
|
+
hourIncrement?: number;
|
|
257
|
+
minuteIncrement?: number;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Export types from @cognigy/socket-client for convenience
|
|
261
|
+
*/
|
|
262
|
+
export type { IMessage } from '@cognigy/socket-client';
|
|
263
|
+
export type { IWebchatButton, IWebchatQuickReply, IWebchatTemplateAttachment, IWebchatAttachmentElement, IWebchatAudioAttachment, IWebchatImageAttachment, IWebchatVideoAttachment, IUploadFileAttachmentData, } from '@cognigy/socket-client';
|
|
264
|
+
/**
|
|
265
|
+
* Webchat channel payload structure
|
|
266
|
+
* This is the shape of _webchat, _facebook, or _defaultPreview in message.data._cognigy
|
|
267
|
+
*/
|
|
268
|
+
export interface IWebchatChannelPayload {
|
|
269
|
+
message?: {
|
|
270
|
+
text?: string;
|
|
271
|
+
quick_replies?: QuickReply[];
|
|
272
|
+
attachment?: TemplateAttachment | AudioAttachment | ImageAttachment | VideoAttachment;
|
|
273
|
+
};
|
|
274
|
+
adaptiveCard?: unknown;
|
|
275
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { IWebchatButton, IWebchatQuickReply } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the label for a button
|
|
4
|
+
* Returns "Call" for phone_number buttons without title
|
|
5
|
+
*/
|
|
6
|
+
export declare function getWebchatButtonLabel(button: IWebchatButton | IWebchatQuickReply): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Interpolates a template string with replacements
|
|
9
|
+
* Example: interpolateString("{position} of {total}", { position: "1", total: "4" })
|
|
10
|
+
* Returns: "1 of 4"
|
|
11
|
+
*/
|
|
12
|
+
export declare function interpolateString(template: string, replacements: Record<string, string>): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generates a random ID with optional prefix
|
|
15
|
+
*/
|
|
16
|
+
export declare function getRandomId(prefix?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Move focus to the visually hidden focus target
|
|
19
|
+
* This prevents focus loss for keyboard users
|
|
20
|
+
*/
|
|
21
|
+
export declare function moveFocusToMessageFocusTarget(dataMessageId: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Helper function that replaces URLs in a string with HTML anchor elements
|
|
24
|
+
* - Works with URLs starting with http/https, www., or just domain/subdomain
|
|
25
|
+
* - Will only match URLs at the beginning or following whitespace
|
|
26
|
+
* - Will not work with emails
|
|
27
|
+
*/
|
|
28
|
+
export declare function replaceUrlsWithHTMLanchorElem(text: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Sanitizes a URL for use in CSS background-image property
|
|
31
|
+
* Returns url("...") string or undefined if invalid
|
|
32
|
+
*/
|
|
33
|
+
export declare function getBackgroundImage(url: string): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Extracts filename without extension
|
|
36
|
+
* Example: "document.pdf" → "document."
|
|
37
|
+
*/
|
|
38
|
+
export declare function getFileName(fileNameWithExtension: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts file extension
|
|
41
|
+
* Example: "document.pdf" → "pdf"
|
|
42
|
+
*/
|
|
43
|
+
export declare function getFileExtension(fileNameWithExtension: string): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Formats file size in MB or KB
|
|
46
|
+
* Example: 1500000 → "1.50 MB"
|
|
47
|
+
*/
|
|
48
|
+
export declare function getSizeLabel(size: number): string;
|
|
49
|
+
/**
|
|
50
|
+
* Valid image MIME types for file attachments
|
|
51
|
+
*/
|
|
52
|
+
export declare const VALID_IMAGE_MIME_TYPES: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Checks if attachment is a valid image type
|
|
55
|
+
*/
|
|
56
|
+
export declare function isImageAttachment(mimeType: string): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IMessage } from '@cognigy/socket-client';
|
|
2
|
+
import { ChatConfig, MatchRule, MessagePlugin, MatchResult } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Check if message has channel payload
|
|
5
|
+
*/
|
|
6
|
+
export declare function getChannelPayload(message: IMessage, config?: ChatConfig): any;
|
|
7
|
+
/**
|
|
8
|
+
* Default match rules for internal message types.
|
|
9
|
+
* These rules map message data structures to component names.
|
|
10
|
+
* Components are resolved by name lookup in Message.vue.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDefaultMatchRules(): MatchRule[];
|
|
13
|
+
/**
|
|
14
|
+
* Match a message to component(s)
|
|
15
|
+
* @param message - The message to match
|
|
16
|
+
* @param config - Optional configuration
|
|
17
|
+
* @param externalPlugins - Custom plugins to check first (these provide their own components)
|
|
18
|
+
* @returns Array of matched rules/plugins
|
|
19
|
+
*/
|
|
20
|
+
export declare function match(message: IMessage, config?: ChatConfig, externalPlugins?: MessagePlugin[]): MatchResult[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML sanitization utilities
|
|
3
|
+
* Uses DOMPurify to sanitize HTML content
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Default allowed HTML tags
|
|
7
|
+
* Same as React version
|
|
8
|
+
*/
|
|
9
|
+
export declare const allowedHtmlTags: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Default allowed HTML attributes
|
|
12
|
+
*/
|
|
13
|
+
export declare const allowedHtmlAttributes: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Sanitize HTML with custom configuration
|
|
16
|
+
* @param text - HTML text to sanitize
|
|
17
|
+
* @param customAllowedHtmlTags - Optional custom allowed tags
|
|
18
|
+
* @returns Sanitized HTML string
|
|
19
|
+
*/
|
|
20
|
+
export declare function sanitizeHTMLWithConfig(text: string, customAllowedHtmlTags?: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Sanitize content if sanitization is enabled
|
|
23
|
+
* @param content - Content to sanitize
|
|
24
|
+
* @param isSanitizeEnabled - Whether sanitization is enabled
|
|
25
|
+
* @param customAllowedHtmlTags - Custom allowed tags
|
|
26
|
+
* @returns Sanitized or raw content
|
|
27
|
+
*/
|
|
28
|
+
export declare function sanitizeContent(content: string | undefined, isSanitizeEnabled: boolean, customAllowedHtmlTags?: string[]): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChatSettings } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Maps config.settings.colors to CSS custom properties.
|
|
4
|
+
* Returns an object suitable for use as an inline style that sets CSS variables.
|
|
5
|
+
*
|
|
6
|
+
* @param colors - The colors object from ChatSettings
|
|
7
|
+
* @returns A record of CSS variable names to their values
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const style = configColorsToCssVariables({
|
|
12
|
+
* primaryColor: '#0b3694',
|
|
13
|
+
* botMessageColor: '#f5f5f5',
|
|
14
|
+
* })
|
|
15
|
+
* // Returns: { '--cc-primary-color': '#0b3694', '--cc-background-bot-message': '#f5f5f5' }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function configColorsToCssVariables(colors?: ChatSettings['colors']): Record<string, string>;
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cognigy/chat-components-vue",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Vue 3 version of @cognigy/chat-components",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/Cognigy/chat-components-vue.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/Cognigy/chat-components-vue#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Cognigy/chat-components-vue/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"vue",
|
|
17
|
+
"vue3",
|
|
18
|
+
"chat",
|
|
19
|
+
"components",
|
|
20
|
+
"cognigy",
|
|
21
|
+
"webchat",
|
|
22
|
+
"messaging"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"registry": "https://registry.npmjs.org",
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/chat-components-vue.js",
|
|
29
|
+
"module": "./dist/chat-components-vue.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/chat-components-vue.js",
|
|
35
|
+
"default": "./dist/chat-components-vue.js"
|
|
36
|
+
},
|
|
37
|
+
"./style.css": "./dist/chat-components-vue.css",
|
|
38
|
+
"./dist/*": "./dist/*"
|
|
39
|
+
},
|
|
40
|
+
"sideEffects": [
|
|
41
|
+
"**/*.css"
|
|
42
|
+
],
|
|
43
|
+
"files": [
|
|
44
|
+
"dist/**",
|
|
45
|
+
"src/**"
|
|
46
|
+
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"dev": "vite",
|
|
49
|
+
"build": "vue-tsc && vite build",
|
|
50
|
+
"preview": "vite preview",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:watch": "vitest",
|
|
53
|
+
"test:ui": "vitest --ui",
|
|
54
|
+
"test:coverage": "vitest run --coverage",
|
|
55
|
+
"lint": "eslint .",
|
|
56
|
+
"type-check": "vue-tsc --noEmit",
|
|
57
|
+
"prepare": "npm run build"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"vue": "^3.4.0"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@braintree/sanitize-url": "^7.1.1",
|
|
64
|
+
"@cognigy/socket-client": "5.0.0-beta.25",
|
|
65
|
+
"@fontsource/figtree": "5.2.10",
|
|
66
|
+
"dompurify": "^3.0.11",
|
|
67
|
+
"flatpickr": "^4.6.13",
|
|
68
|
+
"markdown-it": "^14.1.0",
|
|
69
|
+
"moment": "^2.30.1",
|
|
70
|
+
"swiper": "^12.0.3"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@types/markdown-it": "^14.1.2",
|
|
74
|
+
"@types/node": "^25.0.9",
|
|
75
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
76
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
77
|
+
"@vue/test-utils": "^2.4.0",
|
|
78
|
+
"eslint": "^9.0.0",
|
|
79
|
+
"eslint-plugin-vue": "^10.7.0",
|
|
80
|
+
"globals": "^17.0.0",
|
|
81
|
+
"jsdom": "^27.0.0",
|
|
82
|
+
"npm-check-updates": "^19.3.1",
|
|
83
|
+
"typescript": "^5.9.0",
|
|
84
|
+
"typescript-eslint": "^8.53.1",
|
|
85
|
+
"vite": "^7.0.0",
|
|
86
|
+
"vite-plugin-dts": "^4.2.0",
|
|
87
|
+
"vitest": "^4.0.0",
|
|
88
|
+
"vue": "^3.5.27",
|
|
89
|
+
"vue-tsc": "^3.2.2"
|
|
90
|
+
},
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": ">=22.12.0"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
:width="width"
|
|
5
|
+
:height="height"
|
|
6
|
+
viewBox="0 0 16 16"
|
|
7
|
+
fill="none"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
>
|
|
10
|
+
<path
|
|
11
|
+
fill-rule="evenodd"
|
|
12
|
+
clip-rule="evenodd"
|
|
13
|
+
d="M11.7578 1.34923C12.1172 1.76855 12.0687 2.39985 11.6494 2.75927L5.53516 8.00002L11.6494 13.2408C12.0687 13.6002 12.1172 14.2315 11.7578 14.6508C11.3984 15.0701 10.7671 15.1187 10.3478 14.7593L4.23357 9.51853C3.30235 8.72034 3.30235 7.2797 4.23357 6.4815L10.3478 1.24076C10.7671 0.881339 11.3984 0.929901 11.7578 1.34923Z"
|
|
14
|
+
fill="white"
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
withDefaults(
|
|
21
|
+
defineProps<{
|
|
22
|
+
width?: string
|
|
23
|
+
height?: string
|
|
24
|
+
}>(),
|
|
25
|
+
{
|
|
26
|
+
width: '16',
|
|
27
|
+
height: '16',
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
width="30"
|
|
4
|
+
height="30"
|
|
5
|
+
viewBox="0 0 30 30"
|
|
6
|
+
fill="none"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
>
|
|
10
|
+
<g>
|
|
11
|
+
<circle cx="15" cy="15" r="15" fill="#1A1A1A" />
|
|
12
|
+
<rect height="10" width="2.5" x="10.8" y="10" fill="#FFFFFF" />
|
|
13
|
+
<rect height="10" width="2.5" x="16.8" y="10" fill="#FFFFFF" />
|
|
14
|
+
</g>
|
|
15
|
+
</svg>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
// Audio pause button icon
|
|
20
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
width="30"
|
|
4
|
+
height="30"
|
|
5
|
+
viewBox="0 0 30 30"
|
|
6
|
+
fill="none"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
>
|
|
10
|
+
<g>
|
|
11
|
+
<circle cx="15" cy="15" r="15" fill="#1A1A1A" />
|
|
12
|
+
<path d="M12.5 10L20 15L12.5 20V10Z" fill="white"/>
|
|
13
|
+
</g>
|
|
14
|
+
</svg>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
// Audio play button icon
|
|
19
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.7265 1.29289C15.117 1.68342 15.117 2.31658 14.7265 2.70711L2.70567 14.7279C2.31515 15.1184 1.68198 15.1184 1.29146 14.7279C0.900934 14.3374 0.900934 13.7042 1.29146 13.3137L13.3123 1.29289C13.7028 0.902369 14.336 0.902369 14.7265 1.29289Z" fill="#1A1A1A"/>
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.7266 14.7279C14.3361 15.1184 13.7029 15.1184 13.3124 14.7279L1.29161 2.70711C0.901084 2.31658 0.901084 1.68342 1.29161 1.29289C1.68213 0.902369 2.3153 0.90237 2.70582 1.29289L14.7266 13.3137C15.1172 13.7042 15.1172 14.3374 14.7266 14.7279Z" fill="#1A1A1A"/>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
// Close icon for image lightbox and modals
|
|
10
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
3
|
+
<path d="M9 1C9 0.447715 8.55228 0 8 0C7.44772 0 7 0.447715 7 1V10.0097L4.09689 7.84985C3.65379 7.5202 3.02734 7.61217 2.69768 8.05528C2.36802 8.49839 2.46 9.12484 2.90311 9.45449L7.40311 12.8023C7.75739 13.0659 8.24261 13.0659 8.5969 12.8023L13.0969 9.45449C13.54 9.12484 13.632 8.49839 13.3023 8.05528C12.9727 7.61217 12.3462 7.5202 11.9031 7.84985L9 10.0097V1Z" fill="#1A1A1A"/>
|
|
4
|
+
<path d="M1 14C0.447715 14 0 14.4477 0 15C0 15.5523 0.447715 16 1 16H15C15.5523 16 16 15.5523 16 15C16 14.4477 15.5523 14 15 14H1Z" fill="#1A1A1A"/>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
// Download icon for image lightbox and buttons
|
|
10
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
:width="width"
|
|
4
|
+
:height="height"
|
|
5
|
+
viewBox="0 0 30 30"
|
|
6
|
+
fill="none"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
>
|
|
10
|
+
<g>
|
|
11
|
+
<circle cx="15" cy="15" r="15" fill="white" fill-opacity="90%" />
|
|
12
|
+
<path d="M12.5 10L20 15L12.5 20V10Z" fill="#1A1A1A"/>
|
|
13
|
+
</g>
|
|
14
|
+
</svg>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
withDefaults(defineProps<{
|
|
19
|
+
width?: string
|
|
20
|
+
height?: string
|
|
21
|
+
}>(), {
|
|
22
|
+
width: '30',
|
|
23
|
+
height: '30',
|
|
24
|
+
})
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as CloseIcon } from './CloseIcon.vue'
|
|
2
|
+
export { default as DownloadIcon } from './DownloadIcon.vue'
|
|
3
|
+
export { default as VideoPlayIcon } from './VideoPlayIcon.vue'
|
|
4
|
+
export { default as AudioPlayIcon } from './AudioPlayIcon.vue'
|
|
5
|
+
export { default as AudioPauseIcon } from './AudioPauseIcon.vue'
|
|
6
|
+
export { default as ArrowBackIcon } from './ArrowBackIcon.vue'
|
|
7
|
+
export { default as LinkIcon } from '../../components/common/LinkIcon.vue'
|