@kindly/react-chat 2.35.3 → 2.37.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/.storybook/main.js +72 -0
- package/.storybook/preview.js +48 -0
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +28 -12
- package/stories/assets/settingsJson.js +449 -0
- package/stories/decorators/withContainer.js +13 -0
- package/stories/decorators/withProvider.js +22 -0
- package/stories/screens.stories/Chat.stories.jsx +853 -0
- package/stories/screens.stories/ClosedButton.stories.jsx +87 -0
- package/stories/screens.stories/Feedback.stories.jsx +109 -0
- package/stories/screens.stories/Nudge.stories.jsx +125 -0
- package/stories/screens.stories/Options.stories.jsx +125 -0
- package/stories/screens.stories/StartChat.stories.jsx +109 -0
|
@@ -0,0 +1,853 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
/* eslint-disable react/prop-types */
|
|
3
|
+
import { expect } from '@storybook/jest';
|
|
4
|
+
import { screen, userEvent } from '@storybook/testing-library';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import withFetchMock from 'storybook-addon-mock';
|
|
7
|
+
|
|
8
|
+
import { IMAGE_SIZE } from 'app/constants';
|
|
9
|
+
|
|
10
|
+
import KindlyChatButton from '../../src/features/KindlyChatButton/KindlyChatButton';
|
|
11
|
+
import settingsJSON from '../assets/settingsJson';
|
|
12
|
+
import withContainer from '../decorators/withContainer';
|
|
13
|
+
import withMockProvider from '../decorators/withProvider';
|
|
14
|
+
|
|
15
|
+
const defaultBotSettings = {
|
|
16
|
+
welcomePage: settingsJSON.welcome_page,
|
|
17
|
+
feedbackForm: settingsJSON.feedback_form,
|
|
18
|
+
maintenanceAlert: settingsJSON.maintenance_alert,
|
|
19
|
+
...settingsJSON.settings,
|
|
20
|
+
...settingsJSON,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const Template = (args, context) => {
|
|
24
|
+
return <KindlyChatButton {...args} {...context} />;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
title: 'Screen/Chat',
|
|
29
|
+
component: KindlyChatButton,
|
|
30
|
+
decorators: [withFetchMock, withContainer, withMockProvider],
|
|
31
|
+
argTypes: {
|
|
32
|
+
initialStateModifierFromArgs: {
|
|
33
|
+
table: {
|
|
34
|
+
disable: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Regular = Template.bind({});
|
|
41
|
+
Regular.parameters = {
|
|
42
|
+
botSettings: defaultBotSettings,
|
|
43
|
+
initialStateModifier: {
|
|
44
|
+
chatbubble: {
|
|
45
|
+
active: true,
|
|
46
|
+
chatHasStarted: true,
|
|
47
|
+
currentLanguage: 'en',
|
|
48
|
+
},
|
|
49
|
+
messages: {
|
|
50
|
+
chatMessages: [
|
|
51
|
+
{
|
|
52
|
+
session_id: '1',
|
|
53
|
+
bot_id: 1234,
|
|
54
|
+
chat_id: '1',
|
|
55
|
+
chat_source: 'web',
|
|
56
|
+
chat_language_code: 'en',
|
|
57
|
+
from_bot: true,
|
|
58
|
+
sender: 'BOT',
|
|
59
|
+
message:
|
|
60
|
+
"Hi! I'm Kindly's Chatbot. I can answer questions about Kindly and our services. How can I help you? 🙂\n<br>\n<br>Feel free to ask me a short and concise question!",
|
|
61
|
+
message_format: 'txt',
|
|
62
|
+
exchange_type: 'greeting',
|
|
63
|
+
exchange_id: '1',
|
|
64
|
+
reply_type: 'STANDARD',
|
|
65
|
+
created: '2022-06-09T18:46:51.672Z',
|
|
66
|
+
id: '1',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: '2',
|
|
70
|
+
created: '2022-06-09T18:47:03.919Z',
|
|
71
|
+
message: 'What is the meaning of life?',
|
|
72
|
+
status: null,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
session_id: '6061c1d4-54da-4886-85a2-7f555c9cd42c',
|
|
76
|
+
bot_id: 3875,
|
|
77
|
+
chat_id: '1',
|
|
78
|
+
chat_source: 'web',
|
|
79
|
+
chat_language_code: 'en',
|
|
80
|
+
from_bot: true,
|
|
81
|
+
sender: 'BOT',
|
|
82
|
+
reply_to_id: '2',
|
|
83
|
+
last_user_message_id: '2',
|
|
84
|
+
message:
|
|
85
|
+
'Well... I don\'t have a conclusive answer for what the meaning of life is, but here are some suggestions:\n<ul style="padding-left:12px;">\n<li>To live a good life\n<li>To spread love\n<li>42\n</ul>',
|
|
86
|
+
message_format: 'txt',
|
|
87
|
+
exchange_type: 'usersays',
|
|
88
|
+
exchange_id: '3',
|
|
89
|
+
title: 'The meaning of life',
|
|
90
|
+
created: '2022-06-09T18:47:04.009Z',
|
|
91
|
+
id: '3',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
messageSentTime: '2022-06-09T18:47:03.697Z',
|
|
95
|
+
lastMessageSeen: {
|
|
96
|
+
id: '3',
|
|
97
|
+
index: 3,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const BotIsTyping = Template.bind({});
|
|
104
|
+
BotIsTyping.parameters = {
|
|
105
|
+
botSettings: defaultBotSettings,
|
|
106
|
+
initialStateModifier: {
|
|
107
|
+
chatbubble: {
|
|
108
|
+
active: true,
|
|
109
|
+
chatHasStarted: true,
|
|
110
|
+
currentLanguage: 'en',
|
|
111
|
+
},
|
|
112
|
+
messages: {
|
|
113
|
+
chatMessages: [
|
|
114
|
+
{
|
|
115
|
+
id: '2',
|
|
116
|
+
created: '2022-06-09T18:47:03.919Z',
|
|
117
|
+
message: 'What is the meaning of life?',
|
|
118
|
+
status: null,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
bot: {
|
|
123
|
+
isTyping: true,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const Maintenance = Template.bind({});
|
|
129
|
+
Maintenance.parameters = {
|
|
130
|
+
botSettings: defaultBotSettings,
|
|
131
|
+
initialStateModifier: {
|
|
132
|
+
chatbubble: {
|
|
133
|
+
active: true,
|
|
134
|
+
chatHasStarted: true,
|
|
135
|
+
currentLanguage: 'en',
|
|
136
|
+
},
|
|
137
|
+
maintenanceAlert: {
|
|
138
|
+
show: true,
|
|
139
|
+
textContent: 'Maintenance mode!',
|
|
140
|
+
linkText: 'Click here to know more',
|
|
141
|
+
linkLocation: 'https://example.com',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const HiddenInput = Template.bind({});
|
|
147
|
+
HiddenInput.parameters = {
|
|
148
|
+
botSettings: defaultBotSettings,
|
|
149
|
+
initialStateModifier: {
|
|
150
|
+
chatbubble: {
|
|
151
|
+
active: true,
|
|
152
|
+
chatHasStarted: true,
|
|
153
|
+
currentLanguage: 'en',
|
|
154
|
+
hideInputField: true,
|
|
155
|
+
},
|
|
156
|
+
messages: {
|
|
157
|
+
chatMessages: [
|
|
158
|
+
{
|
|
159
|
+
id: '1',
|
|
160
|
+
chat_source: 'web',
|
|
161
|
+
chat_language_code: 'en',
|
|
162
|
+
from_bot: true,
|
|
163
|
+
sender: 'BOT',
|
|
164
|
+
message: 'Here is a button',
|
|
165
|
+
message_format: 'txt',
|
|
166
|
+
buttons: [
|
|
167
|
+
{
|
|
168
|
+
id: '1',
|
|
169
|
+
button_type: 'quick_reply',
|
|
170
|
+
language_code: 'en',
|
|
171
|
+
label: 'Click here to continue',
|
|
172
|
+
value: 'clicked',
|
|
173
|
+
index: 0,
|
|
174
|
+
created_at: '2022-06-11T20:14:06.290705Z',
|
|
175
|
+
updated_at: '2022-06-11T20:14:06.291003Z',
|
|
176
|
+
is_active: true,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
created: '2022-06-11T20:14:06.290705Z',
|
|
180
|
+
title: 'noinput',
|
|
181
|
+
chatbubble_hide_input_field: true,
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const MultilineBotMessage = Template.bind({});
|
|
189
|
+
const MESSAGES = {
|
|
190
|
+
single: 'Single-line lonely message',
|
|
191
|
+
double: "Double-line message \n\n vibin'",
|
|
192
|
+
multi: 'This is a \n\n three-multiline \n\n bot message',
|
|
193
|
+
};
|
|
194
|
+
MultilineBotMessage.storyName = 'Multiline Bot & User Messages';
|
|
195
|
+
MultilineBotMessage.parameters = {
|
|
196
|
+
...Regular.parameters,
|
|
197
|
+
initialStateModifier: {
|
|
198
|
+
...Regular.parameters.initialStateModifier,
|
|
199
|
+
messages: {
|
|
200
|
+
chatMessages: [
|
|
201
|
+
{
|
|
202
|
+
from_bot: true,
|
|
203
|
+
sender: 'BOT',
|
|
204
|
+
message: MESSAGES.single,
|
|
205
|
+
created: '2022-06-09T18:46:51.672Z',
|
|
206
|
+
id: '1',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
from_bot: true,
|
|
210
|
+
sender: 'BOT',
|
|
211
|
+
message: MESSAGES.double,
|
|
212
|
+
created: '2022-06-09T18:47:51.672Z',
|
|
213
|
+
id: '2',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
from_bot: true,
|
|
217
|
+
sender: 'BOT',
|
|
218
|
+
message: MESSAGES.multi,
|
|
219
|
+
created: '2022-06-09T18:48:51.672Z',
|
|
220
|
+
id: '3',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
from_bot: false,
|
|
224
|
+
sender: 'USER',
|
|
225
|
+
message: MESSAGES.single,
|
|
226
|
+
created: '2022-06-09T18:46:51.672Z',
|
|
227
|
+
id: '1',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
from_bot: false,
|
|
231
|
+
sender: 'USER',
|
|
232
|
+
message: MESSAGES.double,
|
|
233
|
+
created: '2022-06-09T18:47:51.672Z',
|
|
234
|
+
id: '2',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
from_bot: false,
|
|
238
|
+
sender: 'USER',
|
|
239
|
+
message: MESSAGES.multi,
|
|
240
|
+
created: '2022-06-09T18:48:51.672Z',
|
|
241
|
+
id: '3',
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export const GroupsOfMessages = Template.bind({});
|
|
249
|
+
GroupsOfMessages.parameters = {
|
|
250
|
+
botSettings: defaultBotSettings,
|
|
251
|
+
initialStateModifier: {
|
|
252
|
+
chatbubble: {
|
|
253
|
+
active: true,
|
|
254
|
+
chatHasStarted: true,
|
|
255
|
+
currentLanguage: 'en',
|
|
256
|
+
},
|
|
257
|
+
messages: {
|
|
258
|
+
chatMessages: [
|
|
259
|
+
{
|
|
260
|
+
id: '1',
|
|
261
|
+
created: '2022-06-09T18:47:03.919Z',
|
|
262
|
+
message: 'Hipp',
|
|
263
|
+
status: null,
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
id: '2',
|
|
267
|
+
created: '2022-06-09T18:47:03.919Z',
|
|
268
|
+
message: 'Hipp',
|
|
269
|
+
status: null,
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: '3',
|
|
273
|
+
created: '2022-06-09T18:47:03.919Z',
|
|
274
|
+
message: 'Hurra!',
|
|
275
|
+
status: null,
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
id: '4',
|
|
279
|
+
from_bot: true,
|
|
280
|
+
sender: 'BOT',
|
|
281
|
+
message: 'Hipp',
|
|
282
|
+
created: '2022-06-09T18:47:04.009Z',
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
id: '5',
|
|
286
|
+
from_bot: true,
|
|
287
|
+
sender: 'BOT',
|
|
288
|
+
message: 'Hipp',
|
|
289
|
+
created: '2022-06-09T18:47:04.009Z',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: '6',
|
|
293
|
+
from_bot: true,
|
|
294
|
+
sender: 'BOT',
|
|
295
|
+
message: 'Hurra!',
|
|
296
|
+
created: '2022-06-09T18:47:04.009Z',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export const HandoverRequested = Template.bind({});
|
|
304
|
+
HandoverRequested.parameters = {
|
|
305
|
+
botSettings: defaultBotSettings,
|
|
306
|
+
initialStateModifier: {
|
|
307
|
+
chatbubble: {
|
|
308
|
+
active: true,
|
|
309
|
+
chatHasStarted: true,
|
|
310
|
+
currentLanguage: 'en',
|
|
311
|
+
},
|
|
312
|
+
agent: {
|
|
313
|
+
requestedTakeover: true,
|
|
314
|
+
takeoverClosed: false,
|
|
315
|
+
},
|
|
316
|
+
messages: {
|
|
317
|
+
chatMessages: [
|
|
318
|
+
{
|
|
319
|
+
id: '1',
|
|
320
|
+
created: '2022-06-09T18:47:03.919Z',
|
|
321
|
+
message: 'Could I please talk with a human person?',
|
|
322
|
+
status: null,
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export const HandoverCancelled = Template.bind({});
|
|
330
|
+
HandoverCancelled.parameters = HandoverRequested.parameters;
|
|
331
|
+
HandoverCancelled.play = async () => {
|
|
332
|
+
expect(await screen.findByText(defaultBotSettings.text.takeover_queue_text.en)).toBeInTheDocument();
|
|
333
|
+
const leaveQueueButton = await screen.findByText(defaultBotSettings.text.takeover_queue_link.en);
|
|
334
|
+
await userEvent.click(leaveQueueButton);
|
|
335
|
+
expect(await screen.findByText(defaultBotSettings.text.leave_queue_text.en)).toBeInTheDocument();
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
export const Checkbox = Template.bind({});
|
|
339
|
+
Checkbox.parameters = {
|
|
340
|
+
...Regular.parameters,
|
|
341
|
+
initialStateModifier: {
|
|
342
|
+
...Regular.parameters.initialStateModifier,
|
|
343
|
+
messages: {
|
|
344
|
+
chatMessages: [
|
|
345
|
+
{
|
|
346
|
+
chat_language_code: 'en',
|
|
347
|
+
from_bot: true,
|
|
348
|
+
sender: 'BOT',
|
|
349
|
+
message: 'Check out those checkboxes!',
|
|
350
|
+
message_format: 'txt',
|
|
351
|
+
buttons: [
|
|
352
|
+
{
|
|
353
|
+
id: '1',
|
|
354
|
+
button_type: 'checkbox',
|
|
355
|
+
language_code: 'en',
|
|
356
|
+
label: 'Checkbox label',
|
|
357
|
+
value: 'Checkbox value',
|
|
358
|
+
index: 0,
|
|
359
|
+
is_active: true,
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
id: '2',
|
|
363
|
+
button_type: 'checkbox',
|
|
364
|
+
language_code: 'en',
|
|
365
|
+
label: 'Checkbox label 2',
|
|
366
|
+
value: 'Checkbox value 2',
|
|
367
|
+
index: 1,
|
|
368
|
+
is_active: true,
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
id: '3',
|
|
372
|
+
button_type: 'submit',
|
|
373
|
+
language_code: 'en',
|
|
374
|
+
label: 'Submit',
|
|
375
|
+
index: 2,
|
|
376
|
+
is_active: true,
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
created: '2022-06-11T16:13:00.143Z',
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
const videoSources = [
|
|
387
|
+
['YouTube', 'https://www.youtube.com/watch?v=vvg5AfQEmUc'],
|
|
388
|
+
['Vimeo', 'https://vimeo.com/148751763'],
|
|
389
|
+
['Self hosted', 'https://www.crockpot.se/wp-content/uploads/2019/02/Comp-1-1.mp4'],
|
|
390
|
+
];
|
|
391
|
+
export const VideoEmbed = Template.bind({});
|
|
392
|
+
VideoEmbed.args = {
|
|
393
|
+
videoSource: videoSources[0][0],
|
|
394
|
+
videoSourceList: videoSources,
|
|
395
|
+
initialStateModifierFromArgs: ({ videoSource, videoSourceList }) => ({
|
|
396
|
+
...Regular.parameters.initialStateModifier,
|
|
397
|
+
messages: {
|
|
398
|
+
chatMessages: [
|
|
399
|
+
{
|
|
400
|
+
id: '1',
|
|
401
|
+
chat_language_code: 'en',
|
|
402
|
+
from_bot: true,
|
|
403
|
+
sender: 'BOT',
|
|
404
|
+
message: 'Here is Video embed',
|
|
405
|
+
message_format: 'txt',
|
|
406
|
+
video_source: videoSourceList.find((videoSourceMap) => videoSourceMap[0] === videoSource)[1],
|
|
407
|
+
title: 'embed',
|
|
408
|
+
created: '2022-06-11T16:22:15.425Z',
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
}),
|
|
413
|
+
};
|
|
414
|
+
VideoEmbed.argTypes = {
|
|
415
|
+
videoSource: {
|
|
416
|
+
options: videoSources.map((videoSource) => videoSource[0]),
|
|
417
|
+
control: { type: 'select' },
|
|
418
|
+
},
|
|
419
|
+
videoSourceList: {
|
|
420
|
+
table: {
|
|
421
|
+
disable: true,
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
};
|
|
425
|
+
VideoEmbed.parameters = {
|
|
426
|
+
botSettings: defaultBotSettings,
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
export const ImageGallery = Template.bind({});
|
|
430
|
+
const textSizes = [
|
|
431
|
+
undefined,
|
|
432
|
+
'Lorem ipsum dolor sit amet.',
|
|
433
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
|
|
434
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
435
|
+
];
|
|
436
|
+
ImageGallery.args = {
|
|
437
|
+
imageCarouselSize: 1000,
|
|
438
|
+
titleSize: 0,
|
|
439
|
+
descriptionSize: 0,
|
|
440
|
+
hasLink: false,
|
|
441
|
+
newTab: false,
|
|
442
|
+
initialStateModifierFromArgs: ({ imageCarouselSize, titleSize, descriptionSize, hasLink, newTab }) => ({
|
|
443
|
+
...Regular.parameters.initialStateModifier,
|
|
444
|
+
messages: {
|
|
445
|
+
chatMessages: [
|
|
446
|
+
{
|
|
447
|
+
id: '1',
|
|
448
|
+
chat_source: 'web',
|
|
449
|
+
chat_language_code: 'en',
|
|
450
|
+
from_bot: true,
|
|
451
|
+
sender: 'BOT',
|
|
452
|
+
message: 'Here is an image gallery',
|
|
453
|
+
message_format: 'txt',
|
|
454
|
+
image_carousel: [
|
|
455
|
+
{
|
|
456
|
+
id: '1',
|
|
457
|
+
imageUrl: 'https://i.imgur.com/Iz1nJrw.jpg',
|
|
458
|
+
title: textSizes[titleSize],
|
|
459
|
+
description: textSizes[descriptionSize],
|
|
460
|
+
linkUrl: hasLink ? 'https://example.com' : undefined,
|
|
461
|
+
altText: textSizes[titleSize],
|
|
462
|
+
newTab,
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
id: '2',
|
|
466
|
+
imageUrl: 'https://i.imgur.com/H49sTpN.jpg',
|
|
467
|
+
title: textSizes[titleSize],
|
|
468
|
+
description: textSizes[descriptionSize],
|
|
469
|
+
linkUrl: hasLink ? 'https://example.com' : undefined,
|
|
470
|
+
altText: textSizes[titleSize],
|
|
471
|
+
newTab,
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
id: '3',
|
|
475
|
+
imageUrl: 'https://i.imgur.com/Htlr2rv.jpg',
|
|
476
|
+
title: textSizes[titleSize],
|
|
477
|
+
description: textSizes[descriptionSize],
|
|
478
|
+
linkUrl: hasLink ? 'https://example.com' : undefined,
|
|
479
|
+
altText: textSizes[titleSize],
|
|
480
|
+
newTab,
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
image_carousel_size: imageCarouselSize,
|
|
484
|
+
title: 'Image Gallery',
|
|
485
|
+
created: '2022-06-11T16:44:33.885Z',
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
},
|
|
489
|
+
}),
|
|
490
|
+
};
|
|
491
|
+
ImageGallery.argTypes = {
|
|
492
|
+
imageCarouselSize: {
|
|
493
|
+
options: Object.keys(IMAGE_SIZE).map((size) => parseInt(size, 10)),
|
|
494
|
+
control: { type: 'radio' },
|
|
495
|
+
},
|
|
496
|
+
titleSize: {
|
|
497
|
+
control: { type: 'range', min: 0, max: textSizes.length - 1, step: 1 },
|
|
498
|
+
},
|
|
499
|
+
descriptionSize: {
|
|
500
|
+
control: { type: 'range', min: 0, max: textSizes.length - 1, step: 1 },
|
|
501
|
+
},
|
|
502
|
+
hasLink: {
|
|
503
|
+
control: 'boolean',
|
|
504
|
+
},
|
|
505
|
+
newTab: {
|
|
506
|
+
control: 'boolean',
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
ImageGallery.parameters = {
|
|
510
|
+
botSettings: defaultBotSettings,
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
export const ImageGalleryWithDescription = Template.bind({});
|
|
514
|
+
ImageGalleryWithDescription.args = {
|
|
515
|
+
...ImageGallery.args,
|
|
516
|
+
titleSize: 2,
|
|
517
|
+
descriptionSize: 2,
|
|
518
|
+
hasLink: true,
|
|
519
|
+
};
|
|
520
|
+
ImageGalleryWithDescription.argTypes = ImageGallery.argTypes;
|
|
521
|
+
ImageGalleryWithDescription.parameters = ImageGallery.parameters;
|
|
522
|
+
|
|
523
|
+
export const Slider = Template.bind({});
|
|
524
|
+
Slider.parameters = {
|
|
525
|
+
...Regular.parameters,
|
|
526
|
+
initialStateModifier: {
|
|
527
|
+
...Regular.parameters.initialStateModifier,
|
|
528
|
+
messages: {
|
|
529
|
+
chatMessages: [
|
|
530
|
+
{
|
|
531
|
+
chat_source: 'web',
|
|
532
|
+
chat_language_code: 'en',
|
|
533
|
+
from_bot: true,
|
|
534
|
+
sender: 'BOT',
|
|
535
|
+
message: 'Slide me!',
|
|
536
|
+
message_format: 'txt',
|
|
537
|
+
buttons: [
|
|
538
|
+
{
|
|
539
|
+
id: '1',
|
|
540
|
+
button_type: 'slider',
|
|
541
|
+
language_code: 'en',
|
|
542
|
+
label: 'Choose a value between 1 and 42',
|
|
543
|
+
index: 0,
|
|
544
|
+
created_at: '2022-06-15T19:03:46.186406Z',
|
|
545
|
+
slider_details: {
|
|
546
|
+
id: '1',
|
|
547
|
+
from_value: 1,
|
|
548
|
+
to_value: 42,
|
|
549
|
+
step_value: 1,
|
|
550
|
+
value: 10,
|
|
551
|
+
affix: 'SUFFIX',
|
|
552
|
+
affix_value: '%',
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
id: '2',
|
|
557
|
+
button_type: 'submit',
|
|
558
|
+
language_code: 'en',
|
|
559
|
+
label: 'Submit',
|
|
560
|
+
value: '1',
|
|
561
|
+
index: 1,
|
|
562
|
+
created_at: '2022-06-15T19:03:46.186495Z',
|
|
563
|
+
},
|
|
564
|
+
],
|
|
565
|
+
created: '2022-06-15T19:03:46.186495Z',
|
|
566
|
+
title: 'slider',
|
|
567
|
+
id: '1',
|
|
568
|
+
},
|
|
569
|
+
],
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
export const Form = Template.bind({});
|
|
575
|
+
Form.parameters = {
|
|
576
|
+
...Regular.parameters,
|
|
577
|
+
initialStateModifier: {
|
|
578
|
+
...Regular.parameters.initialStateModifier,
|
|
579
|
+
messages: {
|
|
580
|
+
chatMessages: [
|
|
581
|
+
{
|
|
582
|
+
chat_source: 'web',
|
|
583
|
+
chat_language_code: 'en',
|
|
584
|
+
from_bot: true,
|
|
585
|
+
sender: 'BOT',
|
|
586
|
+
message: '',
|
|
587
|
+
message_format: 'txt',
|
|
588
|
+
buttons: [],
|
|
589
|
+
created: '2022-06-15T19:03:46.186495Z',
|
|
590
|
+
title: '',
|
|
591
|
+
id: '1',
|
|
592
|
+
form: {
|
|
593
|
+
id: 'dddsauhi',
|
|
594
|
+
dialogue_id: 'ddda',
|
|
595
|
+
slug: 'ddas', // Auto generated by the backend, possibly humanly readable and unique
|
|
596
|
+
submit_dialogue_id: 'c0d685d3-3f11-41b8-9cfd-e35d54df2c95',
|
|
597
|
+
abandon_dialogue_id: 'b1cde0f3-0715-48eb-8482-a9355fa11ba8',
|
|
598
|
+
texts: [
|
|
599
|
+
{
|
|
600
|
+
id: 'hoho',
|
|
601
|
+
languageCode: 'en',
|
|
602
|
+
title: 'Form Title',
|
|
603
|
+
abandon_dialogue_message: 'Form exited, please ask something else',
|
|
604
|
+
unanswered_dialogue_message: 'Form unanswered',
|
|
605
|
+
cancel_button_text: 'Cancel',
|
|
606
|
+
send_button_text: 'Submit',
|
|
607
|
+
},
|
|
608
|
+
],
|
|
609
|
+
fields: [
|
|
610
|
+
{
|
|
611
|
+
type: 'text',
|
|
612
|
+
order: 0,
|
|
613
|
+
slug: 'gigi', // Auto generated by the backend, possibly humanly readable and unique
|
|
614
|
+
texts: [
|
|
615
|
+
{
|
|
616
|
+
id: 'gfd',
|
|
617
|
+
languageCode: 'en',
|
|
618
|
+
label: 'Name',
|
|
619
|
+
placeholder: 'Your name',
|
|
620
|
+
helper_text: 'Please fill in your full name here',
|
|
621
|
+
},
|
|
622
|
+
],
|
|
623
|
+
validators: [
|
|
624
|
+
{
|
|
625
|
+
required: true,
|
|
626
|
+
texts: [
|
|
627
|
+
{
|
|
628
|
+
id: 'gruh',
|
|
629
|
+
languageCode: 'en',
|
|
630
|
+
message: 'This field is required',
|
|
631
|
+
},
|
|
632
|
+
],
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
maxLength: 30,
|
|
636
|
+
texts: [
|
|
637
|
+
{
|
|
638
|
+
id: 'duh',
|
|
639
|
+
languageCode: 'en',
|
|
640
|
+
message: 'Maximum number of length is 30',
|
|
641
|
+
},
|
|
642
|
+
],
|
|
643
|
+
},
|
|
644
|
+
],
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
type: 'email',
|
|
648
|
+
order: 1,
|
|
649
|
+
slug: 'bras', // Auto generated by the backend, possibly humanly readable and unique
|
|
650
|
+
texts: [
|
|
651
|
+
{
|
|
652
|
+
id: 'tigg',
|
|
653
|
+
languageCode: 'en',
|
|
654
|
+
label: 'Email',
|
|
655
|
+
placeholder: 'Your email',
|
|
656
|
+
helper_text: 'Please fill in your email address here so we can contact you',
|
|
657
|
+
},
|
|
658
|
+
],
|
|
659
|
+
validators: [
|
|
660
|
+
{
|
|
661
|
+
required: true,
|
|
662
|
+
texts: [
|
|
663
|
+
{
|
|
664
|
+
id: 'gigu',
|
|
665
|
+
languageCode: 'en',
|
|
666
|
+
message: 'This field is required',
|
|
667
|
+
},
|
|
668
|
+
],
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
pattern: /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/.toString(),
|
|
672
|
+
texts: [
|
|
673
|
+
{
|
|
674
|
+
id: 'dada',
|
|
675
|
+
languageCode: 'en',
|
|
676
|
+
message: 'Please provide valid email',
|
|
677
|
+
},
|
|
678
|
+
],
|
|
679
|
+
},
|
|
680
|
+
],
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
type: 'range',
|
|
684
|
+
order: 2,
|
|
685
|
+
affix: 'PREFIX',
|
|
686
|
+
min: 10,
|
|
687
|
+
max: 100,
|
|
688
|
+
step: 10,
|
|
689
|
+
slug: 'yoyo', // Auto generated by the backend, possibly humanly readable and unique
|
|
690
|
+
texts: [
|
|
691
|
+
{
|
|
692
|
+
id: 'blabla',
|
|
693
|
+
languageCode: 'en',
|
|
694
|
+
label: 'Please select a value',
|
|
695
|
+
helper_text: 'Please fill in your full name here',
|
|
696
|
+
affix_value: '$',
|
|
697
|
+
},
|
|
698
|
+
],
|
|
699
|
+
validators: [],
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
type: 'checkbox', // not included in the v1
|
|
703
|
+
order: 3,
|
|
704
|
+
slug: 'dodo', // Auto generated by the backend, possibly humanly readable and unique
|
|
705
|
+
texts: [
|
|
706
|
+
{
|
|
707
|
+
id: 'gogo',
|
|
708
|
+
languageCode: 'en',
|
|
709
|
+
label: 'What animals do you like?',
|
|
710
|
+
helper_text: '',
|
|
711
|
+
},
|
|
712
|
+
],
|
|
713
|
+
list: [
|
|
714
|
+
{
|
|
715
|
+
slug: 'hhh', // Not sure if this needs one
|
|
716
|
+
value: 'cows',
|
|
717
|
+
order: 0,
|
|
718
|
+
texts: [
|
|
719
|
+
{
|
|
720
|
+
id: 'gras',
|
|
721
|
+
languageCode: 'en',
|
|
722
|
+
label: 'I like cows',
|
|
723
|
+
},
|
|
724
|
+
],
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
slug: 'ddsad',
|
|
728
|
+
value: 'snakes',
|
|
729
|
+
order: 1,
|
|
730
|
+
texts: [
|
|
731
|
+
{
|
|
732
|
+
id: 'grq',
|
|
733
|
+
languageCode: 'en',
|
|
734
|
+
label: 'I like snakes',
|
|
735
|
+
},
|
|
736
|
+
],
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
slug: 'abv',
|
|
740
|
+
value: 'foxes',
|
|
741
|
+
order: 2,
|
|
742
|
+
texts: [
|
|
743
|
+
{
|
|
744
|
+
id: 'abc',
|
|
745
|
+
languageCode: 'en',
|
|
746
|
+
label: 'I like foxes',
|
|
747
|
+
},
|
|
748
|
+
],
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
slug: '213',
|
|
752
|
+
value: 'owls',
|
|
753
|
+
order: 3,
|
|
754
|
+
texts: [
|
|
755
|
+
{
|
|
756
|
+
id: '321',
|
|
757
|
+
languageCode: 'en',
|
|
758
|
+
label: 'I like owls',
|
|
759
|
+
},
|
|
760
|
+
],
|
|
761
|
+
},
|
|
762
|
+
],
|
|
763
|
+
validators: [
|
|
764
|
+
{
|
|
765
|
+
required: true,
|
|
766
|
+
texts: [
|
|
767
|
+
{
|
|
768
|
+
id: '432',
|
|
769
|
+
languageCode: 'en',
|
|
770
|
+
message: 'This field is required',
|
|
771
|
+
},
|
|
772
|
+
],
|
|
773
|
+
},
|
|
774
|
+
],
|
|
775
|
+
},
|
|
776
|
+
],
|
|
777
|
+
},
|
|
778
|
+
},
|
|
779
|
+
],
|
|
780
|
+
},
|
|
781
|
+
},
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
export const LeaveContactDetails = Template.bind({});
|
|
785
|
+
LeaveContactDetails.parameters = {
|
|
786
|
+
...Regular.parameters,
|
|
787
|
+
initialStateModifier: {
|
|
788
|
+
...Regular.parameters.initialStateModifier,
|
|
789
|
+
messages: {
|
|
790
|
+
chatMessages: [
|
|
791
|
+
{
|
|
792
|
+
id: '1',
|
|
793
|
+
chat_language_code: 'en',
|
|
794
|
+
from_bot: true,
|
|
795
|
+
sender: 'BOT',
|
|
796
|
+
message: "Let's get in touch!",
|
|
797
|
+
message_format: 'txt',
|
|
798
|
+
buttons: [
|
|
799
|
+
{
|
|
800
|
+
id: '1',
|
|
801
|
+
button_type: 'phone',
|
|
802
|
+
language_code: 'en',
|
|
803
|
+
label: 'Call us',
|
|
804
|
+
value: '69420',
|
|
805
|
+
index: 0,
|
|
806
|
+
created_at: '2022-06-11T19:49:29.870793Z',
|
|
807
|
+
updated_at: '2022-06-11T19:49:29.871010Z',
|
|
808
|
+
is_active: true,
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
id: '2',
|
|
812
|
+
button_type: 'email',
|
|
813
|
+
language_code: 'en',
|
|
814
|
+
label: 'Email us',
|
|
815
|
+
value: "contact@kindly.ai?subject=Email%20from%20storybook&body=Don't%20send%20that!",
|
|
816
|
+
index: 1,
|
|
817
|
+
created_at: '2022-06-11T19:49:29.870865Z',
|
|
818
|
+
updated_at: '2022-06-11T19:49:29.871033Z',
|
|
819
|
+
is_active: true,
|
|
820
|
+
email_details: {
|
|
821
|
+
id: '1',
|
|
822
|
+
subject: 'Email from storybook',
|
|
823
|
+
body: "Don't send that!",
|
|
824
|
+
},
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
id: '3',
|
|
828
|
+
button_type: 'contact_details',
|
|
829
|
+
label: 'Contact me back',
|
|
830
|
+
index: 2,
|
|
831
|
+
is_active: true,
|
|
832
|
+
contact_details: {
|
|
833
|
+
id: 'ae14453c-0156-40c9-a13a-0037f46bd14a',
|
|
834
|
+
contact_type: 'email',
|
|
835
|
+
label: 'Your email:',
|
|
836
|
+
edit_text: 'Contact me back',
|
|
837
|
+
placeholder: 'me@example.com',
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
],
|
|
841
|
+
title: 'Contacts',
|
|
842
|
+
created: '2022-06-11T19:58:43.883Z',
|
|
843
|
+
},
|
|
844
|
+
],
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
};
|
|
848
|
+
LeaveContactDetails.play = async () => {
|
|
849
|
+
const LeaveContactButton = await screen.findByText(
|
|
850
|
+
LeaveContactDetails.parameters.initialStateModifier.messages.chatMessages[0].buttons[2].label,
|
|
851
|
+
);
|
|
852
|
+
await userEvent.click(LeaveContactButton);
|
|
853
|
+
};
|