@kindly/react-chat 2.48.3 → 2.48.4

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.
@@ -1,203 +0,0 @@
1
- import React from 'react';
2
-
3
- import { IMAGE_WIDTH } from '../../../src/constants';
4
- import KindlyChatButton from '../../../src/features/KindlyChatButton/KindlyChatButton';
5
- import settingsJSON from '../../assets/settingsJson';
6
- import withContainer from '../../decorators/withContainer';
7
- import withMockProvider from '../../decorators/withProvider';
8
-
9
- const defaultBotSettings = {
10
- welcomePage: settingsJSON.welcome_page,
11
- feedbackForm: settingsJSON.feedback_form,
12
- maintenanceAlert: settingsJSON.maintenance_alert,
13
- ...settingsJSON.settings,
14
- ...settingsJSON,
15
- };
16
-
17
- const todayTime = new Date();
18
- todayTime.setHours(13);
19
- todayTime.setMinutes(37);
20
- const created = todayTime.toISOString();
21
-
22
- export default {
23
- title: 'Screen/Chat/ImageCarousel',
24
- component: KindlyChatButton,
25
- decorators: [withContainer, withMockProvider],
26
- argTypes: {
27
- initialStateModifierFromArgs: {
28
- table: {
29
- disable: true,
30
- },
31
- },
32
- },
33
- };
34
-
35
- const defaultParameters = {
36
- botSettings: defaultBotSettings,
37
- initialStateModifier: {
38
- chatbubble: {
39
- active: true,
40
- chatHasStarted: true,
41
- currentLanguage: 'en',
42
- },
43
- },
44
- };
45
-
46
- function Template(args, context) {
47
- return <KindlyChatButton {...args} {...context} />;
48
- }
49
-
50
- export const ImageGallery = Template.bind({});
51
- const textSizes = [
52
- undefined,
53
- 'Lorem ipsum dolor sit amet.',
54
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
55
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. \n\n Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
56
- ];
57
- const buttons = [
58
- {
59
- id: '1',
60
- label: 'Add to cart',
61
- value: 'https://example.com',
62
- button_type: 'link',
63
- },
64
- {
65
- id: '2',
66
- label: 'Send as a gift',
67
- value: '123',
68
- button_type: 'dialogue_trigger',
69
- },
70
- {
71
- id: '3',
72
- label: 'Add to wishlist',
73
- value: '234',
74
- button_type: 'dialogue_trigger',
75
- },
76
- ];
77
- ImageGallery.args = {
78
- imageCarouselSize: 1000,
79
- titleSize: 0,
80
- descriptionSize: 0,
81
- imageQuantity: 3,
82
- buttonQuantity: 0,
83
- hasLink: false,
84
- newTab: false,
85
- initialStateModifierFromArgs: ({
86
- imageCarouselSize,
87
- imageQuantity,
88
- titleSize,
89
- descriptionSize,
90
- buttonQuantity,
91
- hasLink,
92
- newTab,
93
- }) => ({
94
- ...defaultParameters.initialStateModifier,
95
- messages: {
96
- chatMessages: [
97
- {
98
- id: '1',
99
- chat_source: 'web',
100
- chat_language_code: 'en',
101
- from_bot: true,
102
- sender: 'BOT',
103
- message: 'Here is an image gallery',
104
- message_format: 'txt',
105
- image_carousel: [
106
- {
107
- id: '1',
108
- imageUrl: 'https://i.imgur.com/Iz1nJrw.jpg',
109
- title: textSizes[titleSize],
110
- description: textSizes[descriptionSize],
111
- linkUrl: hasLink ? 'https://example.com' : undefined,
112
- altText: textSizes[titleSize] || 'Alt text',
113
- newTab,
114
- buttons: buttons.slice(0, buttonQuantity),
115
- },
116
- {
117
- id: '2',
118
- imageUrl: 'https://i.imgur.com/H49sTpN.jpg',
119
- title: textSizes[titleSize],
120
- description: textSizes[descriptionSize],
121
- linkUrl: hasLink ? 'https://example.com' : undefined,
122
- altText: textSizes[titleSize] || 'Alt text',
123
- newTab,
124
- buttons: buttons.slice(0, buttonQuantity - 1 > 0 ? buttonQuantity - 1 : 0),
125
- },
126
- {
127
- id: '3',
128
- imageUrl: 'https://i.imgur.com/Htlr2rv.jpg',
129
- title: textSizes[titleSize],
130
- description: textSizes[descriptionSize],
131
- linkUrl: hasLink ? 'https://example.com' : undefined,
132
- altText: textSizes[titleSize] || 'Alt text',
133
- newTab,
134
- buttons: buttons.slice(0, buttonQuantity - 2 > 0 ? buttonQuantity - 2 : 0),
135
- },
136
- ].slice(0, imageQuantity),
137
- image_carousel_size: imageCarouselSize,
138
- title: 'Image Gallery',
139
- created,
140
- },
141
- ],
142
- },
143
- }),
144
- };
145
- ImageGallery.argTypes = {
146
- imageCarouselSize: {
147
- options: Object.keys(IMAGE_WIDTH).map((size) => parseInt(size, 10)),
148
- control: { type: 'radio' },
149
- },
150
- imageQuantity: {
151
- control: { type: 'range', min: 1, max: 3, step: 1 },
152
- },
153
- titleSize: {
154
- control: { type: 'range', min: 0, max: textSizes.length - 1, step: 1 },
155
- },
156
- descriptionSize: {
157
- control: { type: 'range', min: 0, max: textSizes.length - 1, step: 1 },
158
- },
159
- buttonQuantity: {
160
- control: { type: 'range', min: 0, max: buttons.length, step: 1 },
161
- },
162
- hasLink: {
163
- control: 'boolean',
164
- },
165
- newTab: {
166
- control: 'boolean',
167
- },
168
- };
169
- ImageGallery.parameters = {
170
- botSettings: defaultBotSettings,
171
- };
172
-
173
- export const ImageGalleryWithDescription = Template.bind({});
174
- ImageGalleryWithDescription.args = {
175
- ...ImageGallery.args,
176
- titleSize: 2,
177
- descriptionSize: 3,
178
- hasLink: true,
179
- };
180
- ImageGalleryWithDescription.argTypes = ImageGallery.argTypes;
181
- ImageGalleryWithDescription.parameters = ImageGallery.parameters;
182
-
183
- export const ImageGalleryWithButtons = Template.bind({});
184
- ImageGalleryWithButtons.args = {
185
- ...ImageGallery.args,
186
- titleSize: 0,
187
- descriptionSize: 0,
188
- hasLink: true,
189
- buttonQuantity: 3,
190
- };
191
- ImageGalleryWithButtons.argTypes = ImageGallery.argTypes;
192
- ImageGalleryWithButtons.parameters = ImageGallery.parameters;
193
-
194
- export const ImageGalleryWithButtonsAndDescription = Template.bind({});
195
- ImageGalleryWithButtonsAndDescription.args = {
196
- ...ImageGallery.args,
197
- titleSize: 1,
198
- descriptionSize: 1,
199
- hasLink: false,
200
- buttonQuantity: 2,
201
- };
202
- ImageGalleryWithButtonsAndDescription.argTypes = ImageGallery.argTypes;
203
- ImageGalleryWithButtonsAndDescription.parameters = ImageGallery.parameters;
@@ -1,184 +0,0 @@
1
- import React from 'react';
2
-
3
- import { DEFAULT_ALERT_TYPES } from '../../../src/constants';
4
- import KindlyChatButton from '../../../src/features/KindlyChatButton/KindlyChatButton';
5
- import { showInChatNotification } from '../../../src/state/actions';
6
- import settingsJSON from '../../assets/settingsJson';
7
- import withContainer from '../../decorators/withContainer';
8
- import withMockProvider from '../../decorators/withProvider';
9
-
10
- const defaultBotSettings = {
11
- welcomePage: settingsJSON.welcome_page,
12
- feedbackForm: settingsJSON.feedback_form,
13
- maintenanceAlert: settingsJSON.maintenance_alert,
14
- ...settingsJSON.settings,
15
- ...settingsJSON,
16
- };
17
-
18
- function Template(args, context) {
19
- return <KindlyChatButton {...args} {...context} />;
20
- }
21
-
22
- export default {
23
- title: 'Screen/Chat/Notifications',
24
- component: KindlyChatButton,
25
- decorators: [withContainer, withMockProvider],
26
- argTypes: {
27
- initialStateModifierFromArgs: {
28
- table: {
29
- disable: true,
30
- },
31
- },
32
- },
33
- };
34
-
35
- export const Maintenance = Template.bind({});
36
- Maintenance.parameters = {
37
- botSettings: defaultBotSettings,
38
- initialStateModifier: {
39
- chatbubble: {
40
- active: true,
41
- chatHasStarted: true,
42
- currentLanguage: 'en',
43
- },
44
- bot: {
45
- maintenanceAlert: {
46
- alert_enabled: true,
47
- link_text: { en: 'Click here to learn more', nb: '', nn: '', sv: '' },
48
- link_location: { en: 'https://example.com', nb: '', nn: '', sv: '' },
49
- text_content: { en: 'Maintenance!', nb: '', nn: '', sv: '' },
50
- },
51
- maintenanceAlertEnabled: true,
52
- },
53
- },
54
- };
55
-
56
- export const WithIcon = Template.bind({});
57
- WithIcon.parameters = {
58
- botSettings: defaultBotSettings,
59
- initialStateModifier: {
60
- chatbubble: {
61
- active: true,
62
- chatHasStarted: true,
63
- currentLanguage: 'en',
64
- },
65
- },
66
- };
67
- WithIcon.play = async () => {
68
- const notification = {
69
- content: 'I detected english and switched language. Go to [settings](#settings/language-select) to switch back.',
70
- icon: 'language',
71
- };
72
- window.store.dispatch(showInChatNotification(notification, Math.random()));
73
- };
74
-
75
- export const WithIconAndButton = Template.bind({});
76
- WithIconAndButton.parameters = {
77
- botSettings: defaultBotSettings,
78
- initialStateModifier: {
79
- chatbubble: {
80
- active: true,
81
- chatHasStarted: true,
82
- currentLanguage: 'en',
83
- },
84
- },
85
- };
86
- WithIconAndButton.play = async () => {
87
- const notification = {
88
- content: 'I am a notification',
89
- buttonHref: 'https://example.com',
90
- buttonText: 'Click me',
91
- icon: 'language',
92
- };
93
- window.store.dispatch(showInChatNotification(notification, Math.random()));
94
- };
95
-
96
- export const StackedNotifications = Template.bind({});
97
- StackedNotifications.parameters = {
98
- botSettings: defaultBotSettings,
99
- initialStateModifier: {
100
- chatbubble: {
101
- active: true,
102
- chatHasStarted: true,
103
- currentLanguage: 'en',
104
- },
105
- },
106
- };
107
- StackedNotifications.play = async () => {
108
- const notifications = [
109
- {
110
- content: 'I am a notification',
111
- buttonHref: 'https://example.com',
112
- buttonText: 'Click me',
113
- },
114
- {
115
- content: 'With a long text that will wrap. I am a notification. I am long. Maybe too long?',
116
- buttonHref: 'https://example.com',
117
- buttonText: 'With a long text that will wrap. I am a notification. I am long. Maybe too long?',
118
- },
119
- {
120
- content: 'Without a button',
121
- },
122
- ];
123
- notifications.forEach((notification) => {
124
- window.store.dispatch(showInChatNotification(notification, Math.random()));
125
- });
126
- let i = 0;
127
- const { store } = window;
128
- const interval = setInterval(() => {
129
- store.dispatch(showInChatNotification(notifications[(i + 1) % notifications.length], Math.random()));
130
- i += 1;
131
- if (window.store !== store) {
132
- clearInterval(interval);
133
- }
134
- }, [4000]);
135
- };
136
-
137
- export const OnWelcomePage = Template.bind({});
138
- OnWelcomePage.parameters = {
139
- botSettings: defaultBotSettings,
140
- initialStateModifier: {
141
- chatbubble: {
142
- active: true,
143
- chatHasStarted: false,
144
- currentLanguage: 'en',
145
- },
146
- },
147
- };
148
-
149
- OnWelcomePage.play = async () => {
150
- const notifications = [
151
- {
152
- content: 'I am a notification',
153
- buttonHref: 'https://example.com',
154
- buttonText: 'Click me',
155
- },
156
- ];
157
- notifications.forEach((notification) => {
158
- window.store.dispatch(showInChatNotification(notification, Math.random()));
159
- });
160
- };
161
-
162
- export const QuickSetting = Template.bind({});
163
- QuickSetting.parameters = {
164
- botSettings: defaultBotSettings,
165
- initialStateModifier: {
166
- chatbubble: {
167
- active: true,
168
- chatHasStarted: true,
169
- currentLanguage: 'en',
170
- },
171
- },
172
- };
173
-
174
- QuickSetting.play = async () => {
175
- const notifications = [
176
- {
177
- content:
178
- 'I detected [english](and) switched language. Go to [settings](#settings/language-select) to switch back.',
179
- },
180
- ];
181
- notifications.forEach((notification) => {
182
- window.store.dispatch(showInChatNotification(notification, DEFAULT_ALERT_TYPES.LANGUAGE_SWITCH));
183
- });
184
- };
@@ -1,143 +0,0 @@
1
- import React from 'react';
2
-
3
- import KindlyChatButton from '../../../src/features/KindlyChatButton/KindlyChatButton';
4
- import settingsJSON from '../../assets/settingsJson';
5
- import withContainer from '../../decorators/withContainer';
6
- import withMockProvider from '../../decorators/withProvider';
7
-
8
- const todayTime = new Date();
9
- todayTime.setHours(13);
10
- todayTime.setMinutes(37);
11
- const created = todayTime.toISOString();
12
-
13
- const defaultBotSettings = {
14
- welcomePage: settingsJSON.welcome_page,
15
- feedbackForm: settingsJSON.feedback_form,
16
- maintenanceAlert: settingsJSON.maintenance_alert,
17
- ...settingsJSON.settings,
18
- ...settingsJSON,
19
- };
20
-
21
- const defaultParameters = {
22
- botSettings: defaultBotSettings,
23
- initialStateModifier: {
24
- chatbubble: {
25
- active: true,
26
- chatHasStarted: true,
27
- currentLanguage: 'en',
28
- },
29
- messages: {
30
- chatMessages: [
31
- {
32
- session_id: '1',
33
- bot_id: 1234,
34
- chat_id: '1',
35
- chat_source: 'web',
36
- chat_language_code: 'en',
37
- from_bot: true,
38
- sender: 'BOT',
39
- message:
40
- "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!",
41
- message_format: 'txt',
42
- exchange_type: 'greeting',
43
- exchange_id: '1',
44
- reply_type: 'STANDARD',
45
- created,
46
- id: '1',
47
- },
48
- ],
49
- messageSentTime: '2020-12-01T12:00:00.000Z',
50
- lastMessageSeen: {
51
- id: '3',
52
- index: 3,
53
- },
54
- },
55
- },
56
- };
57
-
58
- export default {
59
- title: 'Screen/Chat/TypingIndicator',
60
- component: KindlyChatButton,
61
- decorators: [withContainer, withMockProvider],
62
- argTypes: {
63
- initialStateModifierFromArgs: {
64
- table: {
65
- disable: true,
66
- },
67
- },
68
- },
69
- };
70
-
71
- function Template(args, context) {
72
- return <KindlyChatButton {...args} {...context} />;
73
- }
74
-
75
- export const BotTypingIndicator = Template.bind({});
76
-
77
- BotTypingIndicator.parameters = {
78
- botSettings: defaultBotSettings,
79
- initialStateModifier: {
80
- chatbubble: {
81
- active: true,
82
- chatHasStarted: true,
83
- currentLanguage: 'en',
84
- },
85
- messages: {
86
- chatMessages: [
87
- {
88
- id: '2',
89
- created,
90
- message: 'What is the meaning of life?',
91
- status: null,
92
- },
93
- ],
94
- },
95
- bot: {
96
- isTyping: true,
97
- },
98
- },
99
- };
100
-
101
- export const MimirTypingIndicator = Template.bind({});
102
-
103
- MimirTypingIndicator.parameters = {
104
- botSettings: defaultBotSettings,
105
- initialStateModifier: {
106
- chatbubble: {
107
- active: true,
108
- chatHasStarted: true,
109
- currentLanguage: 'en',
110
- },
111
- messages: {
112
- chatMessages: [
113
- {
114
- id: '1',
115
- created,
116
- message: 'What is the meaning of life?',
117
- status: null,
118
- },
119
- ],
120
- },
121
- },
122
- };
123
-
124
- MimirTypingIndicator.args = {
125
- text: settingsJSON.text.gpt_search_text.en,
126
- initialStateModifierFromArgs: ({ text }) => {
127
- return {
128
- ...defaultParameters.initialStateModifier,
129
- bot: {
130
- isMimirTyping: true,
131
- text: {
132
- gpt_search_text: {
133
- en: text,
134
- },
135
- },
136
- },
137
- };
138
- },
139
- };
140
-
141
- MimirTypingIndicator.argTypes = {
142
- text: 'string',
143
- };