@kindly/react-chat 2.37.1 → 2.38.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/.storybook/main.js +7 -3
- package/.storybook/preview.js +5 -0
- package/.storybook/test-runner.js +38 -0
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +15 -4
- package/stories/screens.stories/Chat.stories.jsx +111 -11
- package/stories/screens.stories/ClosedButton.stories.jsx +3 -3
- package/stories/screens.stories/Feedback.stories.jsx +2 -2
- package/stories/screens.stories/Nudge.stories.jsx +3 -3
- package/stories/screens.stories/Options.stories.jsx +2 -2
- package/stories/screens.stories/PushGreeting.stories.jsx +82 -0
- package/stories/screens.stories/StartChat.stories.jsx +2 -2
- package/jsconfig.json +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kindly/react-chat",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.38.1",
|
|
4
4
|
"description": "Kindly Chat react component",
|
|
5
5
|
"repository": "https://github.com/kindly-ai/kindly-chat/tree/main/packages/react-chat",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,10 +15,14 @@
|
|
|
15
15
|
"build:local": "webpack -p",
|
|
16
16
|
"prepublishOnly": "npm run build",
|
|
17
17
|
"test": "jest src",
|
|
18
|
+
"test:a11y": "test-storybook",
|
|
18
19
|
"update:browserslist": "npx browserslist@latest --update-db",
|
|
19
20
|
"storybook": "start-storybook -p 6006",
|
|
20
21
|
"build-storybook": "build-storybook"
|
|
21
22
|
},
|
|
23
|
+
"scriptsComments": {
|
|
24
|
+
"test-a11y": "Runs the storybook test-runner. Currently running only axe-core for a11y tests."
|
|
25
|
+
},
|
|
22
26
|
"browserslist": [
|
|
23
27
|
"> 1% in NO",
|
|
24
28
|
"not IE 11",
|
|
@@ -59,11 +63,12 @@
|
|
|
59
63
|
"react-dom": ">=16.9.0"
|
|
60
64
|
},
|
|
61
65
|
"devDependencies": {
|
|
62
|
-
"@babel/core": "^7.18.
|
|
66
|
+
"@babel/core": "^7.18.13",
|
|
63
67
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
64
68
|
"@babel/plugin-transform-runtime": "^7.18.10",
|
|
65
69
|
"@babel/preset-env": "^7.18.10",
|
|
66
70
|
"@babel/preset-react": "^7.18.6",
|
|
71
|
+
"@storybook/addon-a11y": "^6.5.10",
|
|
67
72
|
"@storybook/addon-actions": "^6.5.10",
|
|
68
73
|
"@storybook/addon-essentials": "^6.5.10",
|
|
69
74
|
"@storybook/addon-interactions": "^6.5.10",
|
|
@@ -72,18 +77,23 @@
|
|
|
72
77
|
"@storybook/jest": "^0.0.10",
|
|
73
78
|
"@storybook/manager-webpack4": "^6.5.10",
|
|
74
79
|
"@storybook/react": "^6.5.10",
|
|
80
|
+
"@storybook/test-runner": "^0.7.0",
|
|
75
81
|
"@storybook/testing-library": "^0.0.13",
|
|
76
82
|
"@testing-library/jest-dom": "^5.16.5",
|
|
77
83
|
"@testing-library/react": "^11.2.7",
|
|
84
|
+
"@types/react": "^16.14.31",
|
|
85
|
+
"@types/react-dom": "^16.9.16",
|
|
86
|
+
"axe-playwright": "^1.1.11",
|
|
78
87
|
"babel-jest": "^26.6.3",
|
|
79
88
|
"babel-loader": "^8.2.5",
|
|
80
89
|
"babel-plugin-styled-components": "^1.13.3",
|
|
81
90
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
82
91
|
"babel-plugin-transform-remove-console": "^6.9.4",
|
|
83
92
|
"browserslist": "^4.21.3",
|
|
84
|
-
"chromatic": "^6.
|
|
93
|
+
"chromatic": "^6.8.0",
|
|
85
94
|
"clean-webpack-plugin": "^3.0.0",
|
|
86
95
|
"compression": "1.7.4",
|
|
96
|
+
"concurrently": "^7.3.0",
|
|
87
97
|
"dotenv": "8.6.0",
|
|
88
98
|
"exports-loader": "^0.7.0",
|
|
89
99
|
"express": "^4.18.1",
|
|
@@ -105,6 +115,7 @@
|
|
|
105
115
|
"resolve-url-loader": "^5.0.0",
|
|
106
116
|
"storybook-addon-mock": "^2.4.1",
|
|
107
117
|
"url-loader": "2.3.0",
|
|
118
|
+
"wait-on": "^6.0.1",
|
|
108
119
|
"webpack": "^4.46.0",
|
|
109
120
|
"webpack-bundle-analyzer": "^3.9.0",
|
|
110
121
|
"webpack-cli": "^3.3.12",
|
|
@@ -115,5 +126,5 @@
|
|
|
115
126
|
"silent": true,
|
|
116
127
|
"webpackConfig": "./webpack.config.js"
|
|
117
128
|
},
|
|
118
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "a10766ab8e4d989cbebae6522e8586209bab9035"
|
|
119
130
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
2
|
/* eslint-disable react/prop-types */
|
|
3
|
-
import { expect } from '@storybook/jest';
|
|
4
3
|
import { screen, userEvent } from '@storybook/testing-library';
|
|
5
4
|
import React from 'react';
|
|
6
5
|
import withFetchMock from 'storybook-addon-mock';
|
|
@@ -20,9 +19,9 @@ const defaultBotSettings = {
|
|
|
20
19
|
...settingsJSON,
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
function Template(args, context) {
|
|
24
23
|
return <KindlyChatButton {...args} {...context} />;
|
|
25
|
-
}
|
|
24
|
+
}
|
|
26
25
|
|
|
27
26
|
export default {
|
|
28
27
|
title: 'Screen/Chat',
|
|
@@ -100,6 +99,31 @@ Regular.parameters = {
|
|
|
100
99
|
},
|
|
101
100
|
};
|
|
102
101
|
|
|
102
|
+
export const Annoucement = Template.bind({});
|
|
103
|
+
Annoucement.args = {
|
|
104
|
+
type: 'WARNING',
|
|
105
|
+
text: 'You seem to be offline, please check your internet connection',
|
|
106
|
+
initialStateModifierFromArgs: ({ type, text }) => ({
|
|
107
|
+
...Regular.parameters.initialStateModifier,
|
|
108
|
+
announcement: {
|
|
109
|
+
show: true,
|
|
110
|
+
type,
|
|
111
|
+
text,
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
};
|
|
115
|
+
Annoucement.argTypes = {
|
|
116
|
+
type: {
|
|
117
|
+
options: ['WARNING', 'CRITICAL'],
|
|
118
|
+
control: {
|
|
119
|
+
type: 'select',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
Annoucement.parameters = {
|
|
124
|
+
botSettings: defaultBotSettings,
|
|
125
|
+
};
|
|
126
|
+
|
|
103
127
|
export const BotIsTyping = Template.bind({});
|
|
104
128
|
BotIsTyping.parameters = {
|
|
105
129
|
botSettings: defaultBotSettings,
|
|
@@ -329,10 +353,10 @@ HandoverRequested.parameters = {
|
|
|
329
353
|
export const HandoverCancelled = Template.bind({});
|
|
330
354
|
HandoverCancelled.parameters = HandoverRequested.parameters;
|
|
331
355
|
HandoverCancelled.play = async () => {
|
|
332
|
-
|
|
356
|
+
await screen.findByText(defaultBotSettings.text.takeover_queue_text.en);
|
|
333
357
|
const leaveQueueButton = await screen.findByText(defaultBotSettings.text.takeover_queue_link.en);
|
|
334
358
|
await userEvent.click(leaveQueueButton);
|
|
335
|
-
|
|
359
|
+
await screen.findByText(defaultBotSettings.text.leave_queue_text.en);
|
|
336
360
|
};
|
|
337
361
|
|
|
338
362
|
export const Checkbox = Template.bind({});
|
|
@@ -383,9 +407,74 @@ Checkbox.parameters = {
|
|
|
383
407
|
},
|
|
384
408
|
};
|
|
385
409
|
|
|
410
|
+
export const Fallback = Template.bind({});
|
|
411
|
+
Fallback.parameters = {
|
|
412
|
+
...Regular.parameters,
|
|
413
|
+
initialStateModifier: {
|
|
414
|
+
...Regular.parameters.initialStateModifier,
|
|
415
|
+
messages: {
|
|
416
|
+
chatMessages: [
|
|
417
|
+
{
|
|
418
|
+
id: '0',
|
|
419
|
+
created: '2022-08-29T07:55:00.923Z',
|
|
420
|
+
message: 'What does recursive mean?',
|
|
421
|
+
status: null,
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
id: '1',
|
|
425
|
+
from_bot: true,
|
|
426
|
+
sender: 'BOT',
|
|
427
|
+
reply_to_message: 'What does recursive mean?',
|
|
428
|
+
message: "I didn't quite understand this.",
|
|
429
|
+
exchange_type: 'fallback_suggestion',
|
|
430
|
+
title: "I didn't quite understand this.",
|
|
431
|
+
chatbubble_hide_input_field: true,
|
|
432
|
+
handler: 'FALLBACK_SUGGESTION',
|
|
433
|
+
suggestions: [
|
|
434
|
+
{
|
|
435
|
+
preface: 'Did you mean:',
|
|
436
|
+
message: 'What does recursive mean?',
|
|
437
|
+
buttons: [
|
|
438
|
+
{
|
|
439
|
+
id: '2',
|
|
440
|
+
label: 'Yes',
|
|
441
|
+
value: '1',
|
|
442
|
+
button_type: 'suggestion_dialogue_trigger',
|
|
443
|
+
is_active: true,
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
id: '2',
|
|
447
|
+
label: 'No',
|
|
448
|
+
value: 'SUGGESTION_FALLBACK',
|
|
449
|
+
exchange_id: 'SUGGESTION_FALLBACK',
|
|
450
|
+
button_type: 'suggestion_dialogue_trigger',
|
|
451
|
+
is_active: true,
|
|
452
|
+
},
|
|
453
|
+
],
|
|
454
|
+
},
|
|
455
|
+
],
|
|
456
|
+
created: '2022-06-11T16:13:00.143Z',
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
from_bot: true,
|
|
460
|
+
sender: 'BOT',
|
|
461
|
+
reply_to_message: '🙅 [Fallback suggestion dismissed by user]',
|
|
462
|
+
message:
|
|
463
|
+
"I'm having trouble understanding what you mean. Feel free to rephrase your question and remember that I understand short and precise sentences the best.",
|
|
464
|
+
exchange_type: 'fallback',
|
|
465
|
+
title: '🙅 [Fallback suggestion dismissed by user]',
|
|
466
|
+
handler: 'FALLBACK',
|
|
467
|
+
created: '2022-08-29T08:15:42.712Z',
|
|
468
|
+
id: '2',
|
|
469
|
+
},
|
|
470
|
+
],
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
};
|
|
474
|
+
|
|
386
475
|
const videoSources = [
|
|
387
476
|
['YouTube', 'https://www.youtube.com/watch?v=vvg5AfQEmUc'],
|
|
388
|
-
['Vimeo', 'https://vimeo.com/
|
|
477
|
+
['Vimeo', 'https://vimeo.com/153882097'],
|
|
389
478
|
['Self hosted', 'https://www.crockpot.se/wp-content/uploads/2019/02/Comp-1-1.mp4'],
|
|
390
479
|
];
|
|
391
480
|
export const VideoEmbed = Template.bind({});
|
|
@@ -437,9 +526,17 @@ ImageGallery.args = {
|
|
|
437
526
|
imageCarouselSize: 1000,
|
|
438
527
|
titleSize: 0,
|
|
439
528
|
descriptionSize: 0,
|
|
529
|
+
imageQuantity: 3,
|
|
440
530
|
hasLink: false,
|
|
441
531
|
newTab: false,
|
|
442
|
-
initialStateModifierFromArgs: ({
|
|
532
|
+
initialStateModifierFromArgs: ({
|
|
533
|
+
imageCarouselSize,
|
|
534
|
+
imageQuantity,
|
|
535
|
+
titleSize,
|
|
536
|
+
descriptionSize,
|
|
537
|
+
hasLink,
|
|
538
|
+
newTab,
|
|
539
|
+
}) => ({
|
|
443
540
|
...Regular.parameters.initialStateModifier,
|
|
444
541
|
messages: {
|
|
445
542
|
chatMessages: [
|
|
@@ -458,7 +555,7 @@ ImageGallery.args = {
|
|
|
458
555
|
title: textSizes[titleSize],
|
|
459
556
|
description: textSizes[descriptionSize],
|
|
460
557
|
linkUrl: hasLink ? 'https://example.com' : undefined,
|
|
461
|
-
altText: textSizes[titleSize],
|
|
558
|
+
altText: textSizes[titleSize] || 'Alt text',
|
|
462
559
|
newTab,
|
|
463
560
|
},
|
|
464
561
|
{
|
|
@@ -467,7 +564,7 @@ ImageGallery.args = {
|
|
|
467
564
|
title: textSizes[titleSize],
|
|
468
565
|
description: textSizes[descriptionSize],
|
|
469
566
|
linkUrl: hasLink ? 'https://example.com' : undefined,
|
|
470
|
-
altText: textSizes[titleSize],
|
|
567
|
+
altText: textSizes[titleSize] || 'Alt text',
|
|
471
568
|
newTab,
|
|
472
569
|
},
|
|
473
570
|
{
|
|
@@ -476,10 +573,10 @@ ImageGallery.args = {
|
|
|
476
573
|
title: textSizes[titleSize],
|
|
477
574
|
description: textSizes[descriptionSize],
|
|
478
575
|
linkUrl: hasLink ? 'https://example.com' : undefined,
|
|
479
|
-
altText: textSizes[titleSize],
|
|
576
|
+
altText: textSizes[titleSize] || 'Alt text',
|
|
480
577
|
newTab,
|
|
481
578
|
},
|
|
482
|
-
],
|
|
579
|
+
].slice(0, imageQuantity),
|
|
483
580
|
image_carousel_size: imageCarouselSize,
|
|
484
581
|
title: 'Image Gallery',
|
|
485
582
|
created: '2022-06-11T16:44:33.885Z',
|
|
@@ -493,6 +590,9 @@ ImageGallery.argTypes = {
|
|
|
493
590
|
options: Object.keys(IMAGE_SIZE).map((size) => parseInt(size, 10)),
|
|
494
591
|
control: { type: 'radio' },
|
|
495
592
|
},
|
|
593
|
+
imageQuantity: {
|
|
594
|
+
control: { type: 'range', min: 1, max: 3, step: 1 },
|
|
595
|
+
},
|
|
496
596
|
titleSize: {
|
|
497
597
|
control: { type: 'range', min: 0, max: textSizes.length - 1, step: 1 },
|
|
498
598
|
},
|
|
@@ -16,9 +16,9 @@ const mockSettings = (response = settings) => ({
|
|
|
16
16
|
],
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
return <KindlyChat botKey=
|
|
21
|
-
}
|
|
19
|
+
function Template({ options, ...args }) {
|
|
20
|
+
return <KindlyChat botKey="1234" options={options || {}} {...args} />;
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
export default {
|
|
24
24
|
title: 'Screen/Button',
|
|
@@ -18,9 +18,9 @@ const defaultBotSettings = {
|
|
|
18
18
|
...settingsJSON,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
function Template(args, context) {
|
|
22
22
|
return <KindlyChatButton {...args} {...context} />;
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
24
|
|
|
25
25
|
export default {
|
|
26
26
|
title: 'Screen/Feedback',
|
|
@@ -16,10 +16,10 @@ const mockSettings = (response = settings) => ({
|
|
|
16
16
|
],
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
function Template({ slug, nudgeLayout, trackEvent, options, ...args }) {
|
|
20
20
|
return (
|
|
21
21
|
<KindlyChat
|
|
22
|
-
botKey=
|
|
22
|
+
botKey="1234"
|
|
23
23
|
options={options || {}}
|
|
24
24
|
{...args}
|
|
25
25
|
setKindlyChatRef={(api) => {
|
|
@@ -31,7 +31,7 @@ const Template = ({ slug, nudgeLayout, trackEvent, options, ...args }) => {
|
|
|
31
31
|
}}
|
|
32
32
|
/>
|
|
33
33
|
);
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
|
|
36
36
|
export default {
|
|
37
37
|
title: 'Screen/Nudges',
|
|
@@ -17,9 +17,9 @@ const defaultBotSettings = {
|
|
|
17
17
|
...settingsJSON,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
function Template(args, context) {
|
|
21
21
|
return <KindlyChatButton {...args} {...context} />;
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
|
|
24
24
|
export default {
|
|
25
25
|
title: 'Screen/Options',
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
/* eslint-disable react/prop-types */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import withFetchMock from 'storybook-addon-mock';
|
|
5
|
+
|
|
6
|
+
import KindlyChatButton from '../../src/features/KindlyChatButton/KindlyChatButton';
|
|
7
|
+
import settingsJSON from '../assets/settingsJson';
|
|
8
|
+
import withContainer from '../decorators/withContainer';
|
|
9
|
+
import withMockProvider from '../decorators/withProvider';
|
|
10
|
+
|
|
11
|
+
const defaultBotSettings = {
|
|
12
|
+
welcomePage: settingsJSON.welcome_page,
|
|
13
|
+
feedbackForm: settingsJSON.feedback_form,
|
|
14
|
+
maintenanceAlert: settingsJSON.maintenance_alert,
|
|
15
|
+
...settingsJSON.settings,
|
|
16
|
+
...settingsJSON,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function Template(args, context) {
|
|
20
|
+
return <KindlyChatButton {...args} {...context} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
title: 'Screen/PushGreeting',
|
|
25
|
+
component: KindlyChatButton,
|
|
26
|
+
decorators: [withFetchMock, withContainer, withMockProvider],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Default = Template.bind({});
|
|
30
|
+
Default.parameters = {
|
|
31
|
+
botSettings: {
|
|
32
|
+
...defaultBotSettings,
|
|
33
|
+
},
|
|
34
|
+
initialStateModifier: {
|
|
35
|
+
pushMessages: {
|
|
36
|
+
dismissedMessages: [],
|
|
37
|
+
show: true,
|
|
38
|
+
type: 'message',
|
|
39
|
+
text: 'This is a push greeting',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const NewMessage = Template.bind({});
|
|
45
|
+
NewMessage.args = {
|
|
46
|
+
agentName: 'John Doe',
|
|
47
|
+
avatar: null,
|
|
48
|
+
text: 'has sent a new message',
|
|
49
|
+
initialStateModifierFromArgs: ({ agentName, avatar, text }) => ({
|
|
50
|
+
botSettings: {
|
|
51
|
+
...defaultBotSettings,
|
|
52
|
+
},
|
|
53
|
+
pushMessages: {
|
|
54
|
+
dismissedMessages: [],
|
|
55
|
+
show: true,
|
|
56
|
+
type: 'takeover',
|
|
57
|
+
agent: {
|
|
58
|
+
name: agentName,
|
|
59
|
+
avatar,
|
|
60
|
+
},
|
|
61
|
+
text,
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const avatars = {
|
|
67
|
+
undefined: 'undefined',
|
|
68
|
+
'https://i.imgur.com/Iz1nJrw.jpg': 'Arash',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
NewMessage.argTypes = {
|
|
72
|
+
avatar: {
|
|
73
|
+
options: Object.keys(avatars),
|
|
74
|
+
control: {
|
|
75
|
+
type: 'select',
|
|
76
|
+
labels: avatars,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
NewMessage.parameters = {
|
|
81
|
+
botSettings: defaultBotSettings,
|
|
82
|
+
};
|
|
@@ -15,9 +15,9 @@ const defaultBotSettings = {
|
|
|
15
15
|
...settingsJSON,
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
function Template(args, context) {
|
|
19
19
|
return <KindlyChatButton {...args} {...context} />;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
|
|
22
22
|
export default {
|
|
23
23
|
title: 'Screen/StartChat',
|