@kindly/react-chat 2.38.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kindly/react-chat",
3
- "version": "2.38.0",
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",
@@ -64,6 +68,7 @@
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,11 +77,13 @@
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",
78
84
  "@types/react": "^16.14.31",
79
85
  "@types/react-dom": "^16.9.16",
86
+ "axe-playwright": "^1.1.11",
80
87
  "babel-jest": "^26.6.3",
81
88
  "babel-loader": "^8.2.5",
82
89
  "babel-plugin-styled-components": "^1.13.3",
@@ -86,6 +93,7 @@
86
93
  "chromatic": "^6.8.0",
87
94
  "clean-webpack-plugin": "^3.0.0",
88
95
  "compression": "1.7.4",
96
+ "concurrently": "^7.3.0",
89
97
  "dotenv": "8.6.0",
90
98
  "exports-loader": "^0.7.0",
91
99
  "express": "^4.18.1",
@@ -107,6 +115,7 @@
107
115
  "resolve-url-loader": "^5.0.0",
108
116
  "storybook-addon-mock": "^2.4.1",
109
117
  "url-loader": "2.3.0",
118
+ "wait-on": "^6.0.1",
110
119
  "webpack": "^4.46.0",
111
120
  "webpack-bundle-analyzer": "^3.9.0",
112
121
  "webpack-cli": "^3.3.12",
@@ -117,5 +126,5 @@
117
126
  "silent": true,
118
127
  "webpackConfig": "./webpack.config.js"
119
128
  },
120
- "gitHead": "d58bb8e70b1359a91ea0700f52feefd7f83f9ce3"
129
+ "gitHead": "a10766ab8e4d989cbebae6522e8586209bab9035"
121
130
  }
@@ -99,6 +99,31 @@ Regular.parameters = {
99
99
  },
100
100
  };
101
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
+
102
127
  export const BotIsTyping = Template.bind({});
103
128
  BotIsTyping.parameters = {
104
129
  botSettings: defaultBotSettings,
@@ -382,9 +407,74 @@ Checkbox.parameters = {
382
407
  },
383
408
  };
384
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
+
385
475
  const videoSources = [
386
476
  ['YouTube', 'https://www.youtube.com/watch?v=vvg5AfQEmUc'],
387
- ['Vimeo', 'https://vimeo.com/148751763'],
477
+ ['Vimeo', 'https://vimeo.com/153882097'],
388
478
  ['Self hosted', 'https://www.crockpot.se/wp-content/uploads/2019/02/Comp-1-1.mp4'],
389
479
  ];
390
480
  export const VideoEmbed = Template.bind({});
@@ -436,9 +526,17 @@ ImageGallery.args = {
436
526
  imageCarouselSize: 1000,
437
527
  titleSize: 0,
438
528
  descriptionSize: 0,
529
+ imageQuantity: 3,
439
530
  hasLink: false,
440
531
  newTab: false,
441
- initialStateModifierFromArgs: ({ imageCarouselSize, titleSize, descriptionSize, hasLink, newTab }) => ({
532
+ initialStateModifierFromArgs: ({
533
+ imageCarouselSize,
534
+ imageQuantity,
535
+ titleSize,
536
+ descriptionSize,
537
+ hasLink,
538
+ newTab,
539
+ }) => ({
442
540
  ...Regular.parameters.initialStateModifier,
443
541
  messages: {
444
542
  chatMessages: [
@@ -457,7 +555,7 @@ ImageGallery.args = {
457
555
  title: textSizes[titleSize],
458
556
  description: textSizes[descriptionSize],
459
557
  linkUrl: hasLink ? 'https://example.com' : undefined,
460
- altText: textSizes[titleSize],
558
+ altText: textSizes[titleSize] || 'Alt text',
461
559
  newTab,
462
560
  },
463
561
  {
@@ -466,7 +564,7 @@ ImageGallery.args = {
466
564
  title: textSizes[titleSize],
467
565
  description: textSizes[descriptionSize],
468
566
  linkUrl: hasLink ? 'https://example.com' : undefined,
469
- altText: textSizes[titleSize],
567
+ altText: textSizes[titleSize] || 'Alt text',
470
568
  newTab,
471
569
  },
472
570
  {
@@ -475,10 +573,10 @@ ImageGallery.args = {
475
573
  title: textSizes[titleSize],
476
574
  description: textSizes[descriptionSize],
477
575
  linkUrl: hasLink ? 'https://example.com' : undefined,
478
- altText: textSizes[titleSize],
576
+ altText: textSizes[titleSize] || 'Alt text',
479
577
  newTab,
480
578
  },
481
- ],
579
+ ].slice(0, imageQuantity),
482
580
  image_carousel_size: imageCarouselSize,
483
581
  title: 'Image Gallery',
484
582
  created: '2022-06-11T16:44:33.885Z',
@@ -492,6 +590,9 @@ ImageGallery.argTypes = {
492
590
  options: Object.keys(IMAGE_SIZE).map((size) => parseInt(size, 10)),
493
591
  control: { type: 'radio' },
494
592
  },
593
+ imageQuantity: {
594
+ control: { type: 'range', min: 1, max: 3, step: 1 },
595
+ },
495
596
  titleSize: {
496
597
  control: { type: 'range', min: 0, max: textSizes.length - 1, step: 1 },
497
598
  },
@@ -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
+ };