@yartsun/chat-widget-types 1.0.12 → 1.0.14

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.
@@ -7,12 +7,12 @@ export type Size = 'sm' | 'md' | 'lg'
7
7
  export type BorderRadius = '0' | 'sm' | 'md' | 'lg'
8
8
  export type BtnType = 'icon' | 'text' | 'both'
9
9
  export type LaunchView = 'closed' | 'compact'
10
- export type ChipStyle = 'filled' | 'outlined' | 'invisible'
11
10
  export type Loader = 'dots' | 'dots-pulse' | 'circle-pulse' | 'circle-pulse-1'
12
- export type BgType = 'plain' | 'bubble'
11
+ export type BgType = 'plain' | 'bubble' | 'gradient'
13
12
  export type InputStyle = 'inside' | 'stacked'
14
13
  export type ButtonStyle = 'filled' | 'outlined' | 'invisible'
15
14
  export type WarningStyle = 'gradient' | 'filled' | 'faded'
15
+ export type BackgroundStyle = 'invisible' | 'filled' | 'gradient'
16
16
 
17
17
  // Схема конфигурации
18
18
  export interface ConfigSchema {
@@ -25,13 +25,25 @@ export interface WidgetSettings {
25
25
  bgChat: string
26
26
  gapMessageLine: number
27
27
  fontFamily: string
28
- borderRadius: BorderRadius
28
+ borderRadius: number
29
29
  launchView: LaunchView
30
30
  letterSpacing: number
31
31
  logo: string
32
32
  fontWeight: number
33
33
  loader: Loader
34
34
  lineHeight: number
35
+ globalRoundingRadius: boolean
36
+ theme: 'light' | 'dark'
37
+ mode: 'collapsed'
38
+ position: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'top' | 'bottom' | 'left' | 'right'
39
+ size: {
40
+ width: number
41
+ height: number
42
+ }
43
+ offset: {
44
+ x: number
45
+ y: number
46
+ }
35
47
  }
36
48
 
37
49
  // Тексты виджета
@@ -45,6 +57,8 @@ export interface WidgetTexts {
45
57
  inputPlaceholder: string
46
58
  disableInputText: string
47
59
  disclaimer: string
60
+ typingLoader: string
61
+ sendButton: string
48
62
  }
49
63
 
50
64
  // Базовые типы для элементов
@@ -65,9 +79,34 @@ export interface UIElement {
65
79
  bgType?: BgType
66
80
  }
67
81
 
68
- export interface InputSendElement extends UIElement {
82
+ export interface UIChatElement {
83
+ color?: string
84
+ bgColor?: string
85
+ borderRadius?: number,
86
+ size?: Size,
87
+ fontSize?: number,
88
+ width?: number,
89
+ height?: number,
90
+ sidePadding?: number,
91
+ margin?: number,
92
+ verticalPadding?: number,
93
+ verticalSpacing?: number,
94
+ showType?: BtnType
95
+ borderWidth?: number
96
+ borderColor?: string
97
+ bgType?: BgType | ButtonStyle
98
+ icon?: {
99
+ showIcon: boolean
100
+ src?: string
101
+ color?: string
102
+ size?: number
103
+ }
104
+ }
105
+
106
+ export interface InputSendElement extends UIChatElement {
69
107
  inputStyle: InputStyle
70
- borderStyle: BorderStyle
108
+ paddingVertical?: number
109
+ paddingHorizontal?: number
71
110
  }
72
111
 
73
112
  // Типы для Active Snippet
@@ -79,36 +118,36 @@ export interface ActiveSnippetParams {
79
118
 
80
119
  export interface ActiveSnippetElement {
81
120
  params: ActiveSnippetParams
82
- color: string
83
- bgColor: string
84
- headerChip: ColorItems
121
+ element: UIChatElement
122
+ headerChip: UIChatElement
85
123
  propertyColor: string
86
124
  valueColor: string
87
- yesButton: ColorItems
88
- noButton: ColorItems
125
+ yesButton: UIChatElement
126
+ noButton: UIChatElement
89
127
  }
90
128
 
91
129
  // Типы для предупреждений
92
130
  export interface WarningParams {
93
- warningStyle: WarningStyle
94
131
  showIcon: boolean
95
132
  icon: string
96
133
  }
97
134
 
98
135
  export interface WarningElement {
99
- params: WarningParams
100
- iconColor: string
101
- bgColor: string
102
- headlineColor?: string
103
- color: string
104
- resetButton?: {
105
- color: string
106
- bgColor: string
136
+ warningStyle: WarningStyle
137
+ content: UIChatElement
138
+ resetButton?: UIChatElement
139
+ }
140
+
141
+ export interface LaunchWarningElement extends WarningElement {
142
+ content: UIChatElement & {
143
+ headlineColor?: string
144
+ headlineTextSize: number
145
+ subTextSize: number
107
146
  }
108
147
  }
109
148
 
110
149
  export interface WarningsSection {
111
- launchIssue: WarningElement
150
+ launchIssue: LaunchWarningElement
112
151
  connectionIssue: WarningElement
113
152
  reconnectIssue: WarningElement
114
153
  disableInputIssue: WarningElement
@@ -116,37 +155,34 @@ export interface WarningsSection {
116
155
 
117
156
  // Типы для лоадера
118
157
  export interface LoaderSection {
119
- completeStep: {
120
- icon: string
121
- color: string
122
- }
123
- activeStep: {
124
- icon: string
125
- color: string
126
- }
158
+ typingLoader: UIChatElement
159
+ completeStep: UIChatElement
160
+ activeStep: UIChatElement
127
161
  }
128
162
 
129
163
  // Типы для секций
130
164
  export interface TopSection {
131
165
  params: {
132
166
  size: Size
133
- chipStyle: ChipStyle
134
- chipType: BtnType
167
+ bgColor: string
168
+ bgStyle: BackgroundStyle
169
+ chipStyle: ButtonStyle
135
170
  buttonStyle: ButtonStyle
136
- buttonType: BtnType
171
+ paddingVertical: number
172
+ paddingHorizontal: number
137
173
  }
138
- chipWidgetTitle: ColorItems
139
- buttons: ColorItems
174
+ chipWidgetTitle: UIChatElement
175
+ buttons: UIChatElement
140
176
  }
141
177
 
142
178
  export interface InsideSection {
143
179
  params: {
144
180
  size: Size
145
181
  }
146
- messageUser: UIElement
147
- messageBot: UIElement
182
+ messageUser: UIChatElement
183
+ messageBot: UIChatElement
148
184
  activeSnippet: ActiveSnippetElement
149
- welcomeMessage: UIElement
185
+ welcomeMessage: UIChatElement
150
186
  }
151
187
 
152
188
  export interface BottomSection {
@@ -154,11 +190,21 @@ export interface BottomSection {
154
190
  size: Size
155
191
  disclaimerShow: boolean
156
192
  }
193
+ disclaimer: UIChatElement
157
194
  inputSend: InputSendElement
158
- btnSend: UIElement
195
+ btnSend: UIChatElement
159
196
  }
160
197
 
198
+ export interface ColapsedSection extends UIChatElement {}
199
+
161
200
  export interface WidgetSections {
201
+ colapsed: ColapsedSection & {
202
+ logo: string
203
+ icon: {
204
+ showIcon: boolean
205
+ size: number
206
+ }
207
+ }
162
208
  warnings: WarningsSection
163
209
  loader: LoaderSection
164
210
  top: TopSection
@@ -0,0 +1,183 @@
1
+ // @ts-nocheck
2
+ import type { WidgetConfig } from './config.types'
3
+
4
+ export const DEFAULT_CONFIG: WidgetConfig = {
5
+ schema: { // Схема віджета
6
+ version: '1.0',
7
+ required: ['settings', 'texts', 'sections'],
8
+ },
9
+ settings: { // Настройки
10
+ bgChat: '#434345', // Фон чата
11
+ gapMessageLine: 12, // Відстань між повідомленнями
12
+ fontFamily: 'MacPaw Fixel', // Шрифт
13
+ borderRadius: 12, // Радіус округлості чату
14
+ launchView: 'closed', // Початковий стан чату
15
+ letterSpacing: 0, // Інтервал між літерами
16
+ logo: '<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.22048 12.26L8.71413 11.1293C9.1535 10.1231 9.94426 9.32209 10.9307 8.88424L12.2895 8.28107C12.7215 8.08931 12.7215 7.46082 12.2895 7.26906L10.9731 6.68472C9.9613 6.23561 9.15637 5.40496 8.72453 4.3644L8.22447 3.15941C8.0389 2.71224 7.42105 2.71224 7.23548 3.15941L6.7354 4.36439C6.30357 5.40496 5.49861 6.23561 4.48686 6.68472L3.17045 7.26906C2.73843 7.46082 2.73843 8.08931 3.17045 8.28107L4.5293 8.88424C5.51569 9.32209 6.30646 10.1231 6.7458 11.1293L7.23948 12.26C7.42924 12.6946 8.03069 12.6946 8.22048 12.26ZM13.1632 15.0131L13.302 14.6949C13.5495 14.1275 13.9953 13.6758 14.5515 13.4287L14.9792 13.2386C15.2106 13.1358 15.2106 12.7996 14.9792 12.6969L14.5754 12.5174C14.0049 12.264 13.5511 11.7955 13.3078 11.2089L13.1653 10.865C13.0659 10.6254 12.7346 10.6254 12.6352 10.865L12.4927 11.2089C12.2494 11.7955 11.7957 12.264 11.2251 12.5174L10.8213 12.6969C10.59 12.7996 10.59 13.1358 10.8213 13.2386L11.249 13.4287C11.8053 13.6758 12.251 14.1275 12.4985 14.6949L12.6374 15.0131C12.739 15.246 13.0615 15.246 13.1632 15.0131Z" fill="currentColor"/></svg>',
17
+ fontWeight: 500, // Товщина шрифту
18
+ lineHeight: 1.2, // Висота рядка
19
+ loader: 'dots', // Тип лоадера
20
+ },
21
+ texts: { // Тексти
22
+ welcomeMessage:
23
+ '🖖 Hi there — I’m your assistant for finding documents, tracking access, and making sense of your files. \n\nHow can I help?', // Привітання
24
+ widgetTitle: 'HyperShadow', // Заголовок чату
25
+ launchIssueTitle: 'There was a glitch', // Заголовок помилки запуску
26
+ launchIssueText: 'Please restart the chat, it should work', // Текст помилки запуску
27
+ issueText: 'Something went wrong, please restart', // Текст помилки в процесі
28
+ reconnectText: 'Connection issue, trying to reconnect', // Текст помилки перепідключення
29
+ inputPlaceholder: 'Type question', // Плейсхолдер для введення тексту
30
+ disableInputText:
31
+ 'Can’t send a message while processing the previous request', // Текст заблокованого введення
32
+ disclaimer: 'AI-Copilot makes mistakes, please don’t consider 100% accurate', // Дисклеймер
33
+ },
34
+ sections: { // Секції віджета
35
+ warnings: { // Попередження
36
+ launchIssue: { // Помилка запуску
37
+ params: { // Параметри попередження
38
+ warningStyle: 'faded', // Стиль попередження
39
+ showIcon: true, // Показувати іконку
40
+ icon:
41
+ '<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21.76 16.42L15.36 4.9C14.5 3.35 13.31 2.5 12 2.5C10.69 2.5 9.5 3.35 8.64 4.9L2.24 16.42C1.43 17.89 1.34 19.3 1.99 20.41C2.64 21.52 3.92 22.13 5.6 22.13H18.4C20.08 22.13 21.36 21.52 22.01 20.41C22.66 19.3 22.57 17.88 21.76 16.42ZM12.71 18.21C12.66 18.25 12.61 18.29 12.56 18.33C12.5 18.37 12.44 18.4 12.38 18.42C12.32 18.45 12.26 18.47 12.19 18.48C12.13 18.49 12.06 18.5 12 18.5C11.94 18.5 11.87 18.49 11.8 18.48C11.74 18.47 11.68 18.45 11.62 18.42C11.56 18.4 11.5 18.37 11.44 18.33C11.39 18.29 11.34 18.25 11.29 18.21C11.11 18.02 11 17.76 11 17.5C11 17.24 11.11 16.98 11.29 16.79C11.34 16.75 11.39 16.71 11.44 16.67C11.5 16.63 11.56 16.6 11.62 16.58C11.68 16.55 11.74 16.53 11.8 16.52C11.93 16.49 12.07 16.49 12.19 16.52C12.26 16.53 12.32 16.55 12.38 16.58C12.44 16.6 12.5 16.63 12.56 16.67C12.61 16.71 12.66 16.75 12.71 16.79C12.89 16.98 13 17.24 13 17.5C13 17.76 12.89 18.02 12.71 18.21ZM11.25 9.5C11.25 9.09 11.59 8.75 12 8.75C12.41 8.75 12.75 9.09 12.75 9.5V14.5C12.75 14.91 12.41 15.25 12 15.25C11.59 15.25 11.25 14.91 11.25 14.5V9.5Z" fill="currentColor"/></svg>',
42
+ },
43
+ iconColor: '#FFCC77', // Колір іконки
44
+ bgColor: '#8A7045', // Колір фону
45
+ headlineColor: '#f9c97c', // Колір заголовка
46
+ color: '#fff', // Колір тексту
47
+ resetButton: { // Кнопка скидання
48
+ color: '#2e2e30', // Колір тексту кнопки
49
+ bgColor: '#e5e1dd', // Колір фону кнопки
50
+ },
51
+ },
52
+ connectionIssue: { // Помилка фатальна в процесі
53
+ params: { // Параметри попередження
54
+ warningStyle: 'faded', // Стиль попередження
55
+ showIcon: true, // Показувати іконку
56
+ icon:
57
+ '<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M21.76 16.42L15.36 4.9C14.5 3.35 13.31 2.5 12 2.5C10.69 2.5 9.49998 3.35 8.63998 4.9L2.23998 16.42C1.42998 17.89 1.33998 19.3 1.98998 20.41C2.63998 21.52 3.91998 22.13 5.59998 22.13H18.4C20.08 22.13 21.36 21.52 22.01 20.41C22.66 19.3 22.57 17.88 21.76 16.42ZM11.25 9.5C11.25 9.09 11.59 8.75 12 8.75C12.41 8.75 12.75 9.09 12.75 9.5V14.5C12.75 14.91 12.41 15.25 12 15.25C11.59 15.25 11.25 14.91 11.25 14.5V9.5ZM12.71 18.21C12.66 18.25 12.61 18.29 12.56 18.33C12.5 18.37 12.44 18.4 12.38 18.42C12.32 18.45 12.26 18.47 12.19 18.48C12.13 18.49 12.06 18.5 12 18.5C11.94 18.5 11.87 18.49 11.8 18.48C11.74 18.47 11.68 18.45 11.62 18.42C11.56 18.4 11.5 18.37 11.44 18.33C11.39 18.29 11.34 18.25 11.29 18.21C11.11 18.02 11 17.76 11 17.5C11 17.24 11.11 16.98 11.29 16.79C11.34 16.75 11.39 16.71 11.44 16.67C11.5 16.63 11.56 16.6 11.62 16.58C11.68 16.55 11.74 16.53 11.8 16.52C11.93 16.49 12.07 16.49 12.19 16.52C12.26 16.53 12.32 16.55 12.38 16.58C12.44 16.6 12.5 16.63 12.56 16.67C12.61 16.71 12.66 16.75 12.71 16.79C12.89 16.98 13 17.24 13 17.5C13 17.76 12.89 18.02 12.71 18.21Z" fill="#FFCC77"/>\n</svg>',
58
+ },
59
+ iconColor: '#fff', // Колір іконки
60
+ bgColor: '#8A7045', // Колір фону
61
+ color: '#fff', // Колір тексту
62
+ resetButton: { // Кнопка скидання
63
+ color: '#2F2F31', // Колір тексту кнопки
64
+ bgColor: '#E5E1DD', // Колір фону кнопки
65
+ },
66
+ },
67
+ reconnectIssue: { // Помилка перепідключення
68
+ params: { // Параметри попередження
69
+ warningStyle: 'gradient', // Стиль попередження
70
+ showIcon: true, // Показувати іконку
71
+ icon:
72
+ '<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d=\"M4 4.02667C3.06667 5.08667 2.5 6.48 2.5 8C2.5 11.3133 5.18667 14 8.5 14C11.8133 14 14.5 11.3133 14.5 8C14.5 4.68667 11.8133 2 8.5 2C8.02667 2 7.56667 2.05333 7.12667 2.16\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-miterlimit=\"10\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>',
73
+ },
74
+ iconColor: '#FFF', // Колір іконки
75
+ bgColor: '#8A7045', // Колір фону
76
+ color: '#fff', // Колір тексту
77
+ },
78
+ disableInputIssue: { // Блокування введення
79
+ params: { // Параметри попередження
80
+ warningStyle: 'gradient', // Стиль попередження
81
+ showIcon: true, // Показувати іконку
82
+ icon:
83
+ '<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d=\"M4 4.02667C3.06667 5.08667 2.5 6.48 2.5 8C2.5 11.3133 5.18667 14 8.5 14C11.8133 14 14.5 11.3133 14.5 8C14.5 4.68667 11.8133 2 8.5 2C8.02667 2 7.56667 2.05333 7.12667 2.16\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-miterlimit=\"10\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>',
84
+ },
85
+ iconColor: '#fff', // Колір іконки
86
+ bgColor: '#8A7045', // Колір фону
87
+ color: '#fff', // Колір тексту
88
+ },
89
+ },
90
+ loader: {
91
+ completeStep: {
92
+ icon: '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path opacity="0.4" d="M7.99967 14.6666C11.6816 14.6666 14.6663 11.6818 14.6663 7.99992C14.6663 4.31802 11.6816 1.33325 7.99967 1.33325C4.31778 1.33325 1.33301 4.31802 1.33301 7.99992C1.33301 11.6818 4.31778 14.6666 7.99967 14.6666Z" fill="currentColor"/><path d="M7.05297 10.3867C6.91964 10.3867 6.79297 10.3334 6.69964 10.2401L4.81297 8.3534C4.61964 8.16007 4.61964 7.84007 4.81297 7.64673C5.0063 7.4534 5.3263 7.4534 5.51964 7.64673L7.05297 9.18007L10.4796 5.7534C10.673 5.56007 10.993 5.56007 11.1863 5.7534C11.3796 5.94673 11.3796 6.26673 11.1863 6.46006L7.4063 10.2401C7.31297 10.3334 7.1863 10.3867 7.05297 10.3867Z" fill="currentColor"/></svg>',
93
+ color: '#8E8E8F',
94
+ },
95
+ activeStep: {
96
+ icon: '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 4.02667C2.56667 5.08667 2 6.48 2 8C2 11.3133 4.68667 14 8 14C11.3133 14 14 11.3133 14 8C14 4.68667 11.3133 2 8 2C7.52667 2 7.06667 2.05333 6.62667 2.16" stroke="currentColor" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/></svg>',
97
+ color: '#fff',
98
+ },
99
+ },
100
+ top: { // Верхня частина віджета
101
+ params: { // Параметри верхньої частини
102
+ size: 'md', // Розмір
103
+ chipStyle: 'filled', // Стиль чіпа
104
+ chipType: 'both', // Тип чіпа
105
+ buttonStyle: 'filled', // Стиль кнопки
106
+ buttonType: 'both', // Тип кнопки
107
+ },
108
+ chipWidgetTitle: { // Заголовок чипа
109
+ color: '#fff', // Колір тексту
110
+ bgColor: '#5E4AC6', // Колір фону
111
+ },
112
+ buttons: { // Кнопки
113
+ color: '#BBBBBD', // Колір тексту
114
+ bgColor: '#2F2F31', // Колір фону
115
+ },
116
+ },
117
+ inside: { // Внутрішня частина віджета
118
+ params: { // Параметри внутрішньої частини
119
+ size: 'md', // Розмір
120
+ },
121
+ messageUser: { // Повідомлення користувача
122
+ color: '#F9F8F8', // Колір тексту
123
+ bgColor: '#F8F8F933', // Колір фону
124
+ bgType: 'bubble', // Тип фону
125
+ },
126
+ messageBot: { // Повідомлення бота
127
+ color: '#fff', // Колір тексту
128
+ bgColor: '#5E4AC6', // Колір фону
129
+ bgType: 'plain', // Тип фону
130
+ },
131
+ activeSnippet: { // Сніппет
132
+ params: { // Параметри сніппета
133
+ buttonType: 'both', // Тип кнопки
134
+ buttonStyle: 'filled', // Стиль кнопки
135
+ size: 'md', // Розмір
136
+ },
137
+ color: '#fff', // Колір тексту
138
+ bgColor: '#373739', // Колір фону
139
+ headerChip: { // Заголовок чипа
140
+ color: '#fff', // Колір тексту
141
+ bgColor: '#69696A', // Колір фону
142
+ },
143
+ propertyColor: 'rgba(255, 255, 255, 0.30)', // Колір тексту
144
+ valueColor: '#fff', // Колір тексту
145
+ yesButton: { // Кнопка так
146
+ color: '#fff', // Колір тексту
147
+ bgColor: '#12A150', // Колір фону
148
+ },
149
+ noButton: { // Кнопка ні
150
+ color: '#fff', // Колір тексту
151
+ bgColor: '#C20E4D', // Колір фону
152
+ },
153
+ },
154
+ welcomeMessage: { // Привітання
155
+ color: '#fff', // Колір тексту
156
+ },
157
+ },
158
+ bottom: { // Нижня частина віджета
159
+ params: { // Параметри нижньої частини
160
+ size: 'md', // Розмір
161
+ disclaimerShow: false, // Показувати дисклеймер
162
+ },
163
+ inputSend: { // Кнопка відправлення
164
+ color: '#EEECEC', // Колір тексту
165
+ bgColor: '#373739', // Колір фону
166
+ borderStyle: { // Стиль бордера
167
+ borderColor: '#595959', // Колір бордера
168
+ borderWidth: 1, // Ширина бордера
169
+ },
170
+ inputStyle: 'inside', // Стиль введення
171
+ bgType: 'plain', // Тип фону
172
+ },
173
+ btnSend: { // Кнопка відправлення
174
+ color: '#1E1E1E', // Колір тексту
175
+ bgColor: 'rgba(255, 255, 255, 0.50)', // Колір фону
176
+ type: 'both', // Тип кнопки
177
+ },
178
+ },
179
+ },
180
+ }
181
+
182
+
183
+