@seamly/web-ui 20.3.1 → 20.6.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/CHANGELOG.md +769 -0
- package/build/dist/lib/index.debug.js +66 -99
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +8 -20
- package/build/dist/lib/index.js +748 -4372
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +0 -5
- package/build/dist/lib/standalone.js +606 -4449
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +373 -178
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles.css +1 -1
- package/package.json +2 -4
- package/src/javascripts/api/index.js +17 -1
- package/src/javascripts/domains/config/reducer.js +2 -0
- package/src/javascripts/domains/forms/provider.js +14 -6
- package/src/javascripts/domains/store/index.js +11 -11
- package/src/javascripts/domains/store/state-reducer.js +1 -0
- package/src/javascripts/domains/translations/middleware.js +6 -5
- package/src/javascripts/domains/visibility/actions.js +2 -0
- package/src/javascripts/domains/visibility/hooks.js +60 -1
- package/src/javascripts/domains/visibility/reducer.js +5 -0
- package/src/javascripts/domains/visibility/selectors.js +5 -0
- package/src/javascripts/domains/visibility/utils.js +5 -1
- package/src/javascripts/style-guide/components/app.js +2 -0
- package/src/javascripts/style-guide/states.js +86 -51
- package/src/javascripts/ui/components/conversation/conversation.js +40 -36
- package/src/javascripts/ui/components/conversation/event/card-component.js +1 -2
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +19 -9
- package/src/javascripts/ui/components/conversation/event/cta.js +1 -2
- package/src/javascripts/ui/components/conversation/event/image.js +11 -3
- package/src/javascripts/ui/components/conversation/event/participant.js +2 -11
- package/src/javascripts/ui/components/conversation/event/splash.js +1 -3
- package/src/javascripts/ui/components/conversation/event/text.js +9 -9
- package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +6 -0
- package/src/javascripts/ui/components/layout/chat.js +52 -48
- package/src/javascripts/ui/components/suggestions/suggestions-list.js +12 -14
- package/src/javascripts/ui/components/view/deprecated-view.js +16 -11
- package/src/javascripts/ui/components/view/inline-view.js +13 -8
- package/src/javascripts/ui/hooks/seamly-entry-hooks.js +3 -2
- package/src/javascripts/ui/hooks/seamly-state-hooks.js +7 -3
- package/src/javascripts/ui/hooks/use-seamly-chat.js +41 -29
- package/src/javascripts/ui/hooks/use-seamly-commands.js +16 -4
- package/src/javascripts/ui/utils/seamly-utils.js +27 -7
- package/src/stylesheets/5-components/_message-count.scss +5 -2
- package/webpack/parts/dev-server.js +10 -1
- package/src/.DS_Store +0 -0
- package/src/javascripts/lib/parse-body.js +0 -10
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +0 -35
|
@@ -129,6 +129,7 @@ const baseState = {
|
|
|
129
129
|
},
|
|
130
130
|
initialState: {},
|
|
131
131
|
unreadEvents: 0,
|
|
132
|
+
loadedImageEventIds: [],
|
|
132
133
|
isLoading: false,
|
|
133
134
|
idleDetachCountdown: {
|
|
134
135
|
hasCountdown: false,
|
|
@@ -171,7 +172,8 @@ const baseState = {
|
|
|
171
172
|
},
|
|
172
173
|
currentUploads: []
|
|
173
174
|
};
|
|
174
|
-
const avatar = 'data:image/svg+xml;base64,
|
|
175
|
+
const avatar = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMiAzMiIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMzIgMzIiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8cGF0aCBmaWxsPSIjNEE0OEMxIiBkPSJNMTAsMTQuOGMtMS4xLDAtMi0wLjktMi0yczAuOS0yLDItMnMyLDAuOSwyLDJTMTEuMSwxNC44LDEwLDE0Ljh6IE0xNS45LDE0LjhjMS4xLDAsMi0wLjksMi0ycy0wLjktMi0yLTIKCXMtMiwwLjktMiwyUzE0LjgsMTQuOCwxNS45LDE0Ljh6IE0yMS44LDEwLjhjLTEuMSwwLTIsMC45LTIsMnMwLjksMiwyLDJzMi0wLjksMi0yUzIyLjksMTAuOCwyMS44LDEwLjh6IE0yMS4zLDE4LjFIMTAuNwoJQzExLjcsMjMuOSwyMC4yLDIzLjksMjEuMywxOC4xeiIvPgo8L3N2Zz4K';
|
|
176
|
+
const transferAvatar = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMiAzMiIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMzIgMzIiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8cGF0aCBmaWxsPSIjNEE0OEMxIiBkPSJNMTAuMSwxNC45Yy0xLjEsMC0yLTAuOS0yLTJzMC45LTIsMi0yczIsMC45LDIsMlMxMS4yLDE0LjksMTAuMSwxNC45eiBNMjEuOSwxMC45Yy0xLjEsMC0yLDAuOS0yLDIKCXMwLjksMiwyLDJzMi0wLjksMi0yUzIzLDEwLjksMjEuOSwxMC45eiBNMjEuNCwxOC4ySDEwLjhDMTEuOCwyNCwyMC4zLDI0LDIxLjQsMTguMnogTTE3LjIsMjUuM2gtMi40Yy0wLjYsMC0xLjIsMC40LTEuNCwxCgljLTUuMS0wLjItOS4yLTQuNC05LjQtOS42YzAuMSwwLDAuMiwwLjEsMC40LDAuMWgwLjFjMC44LDAsMS40LTAuNiwxLjQtMS40di00LjdjMC0wLjgtMC42LTEuNC0xLjQtMS40aDBjLTAuOCwwLTEuNCwwLjYtMS40LDEuNAoJdjIuN3YydjEuMWMwLDUuOSw0LjcsMTAuNiwxMC41LDEwLjhjMC4yLDAuNSwwLjcsMC44LDEuMiwwLjhoMi40YzAuOCwwLDEuNC0wLjYsMS40LTEuNFMxOCwyNS4zLDE3LjIsMjUuM3oiLz4KPC9zdmc+Cg==';
|
|
175
177
|
const participantInfo = {
|
|
176
178
|
participants: {
|
|
177
179
|
agent: {
|
|
@@ -272,8 +274,7 @@ const infoMessage = {
|
|
|
272
274
|
payload: {
|
|
273
275
|
body: {
|
|
274
276
|
text: 'This is a system generated info message',
|
|
275
|
-
type: 'text'
|
|
276
|
-
variables: {}
|
|
277
|
+
type: 'text'
|
|
277
278
|
},
|
|
278
279
|
fromClient: false,
|
|
279
280
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
@@ -326,7 +327,7 @@ const participantMessage = {
|
|
|
326
327
|
participant: {
|
|
327
328
|
avatar,
|
|
328
329
|
id: 'agent',
|
|
329
|
-
introduction: "You're now talking to
|
|
330
|
+
introduction: "You're now talking to Mrs. Bot gimme a minit",
|
|
330
331
|
name: 'Mrs. Bot',
|
|
331
332
|
service: {
|
|
332
333
|
expose: {
|
|
@@ -343,6 +344,33 @@ const participantMessage = {
|
|
|
343
344
|
type: 'participant'
|
|
344
345
|
}
|
|
345
346
|
};
|
|
347
|
+
const participantTransferMessage = {
|
|
348
|
+
type: 'participant',
|
|
349
|
+
payload: {
|
|
350
|
+
fromClient: false,
|
|
351
|
+
fromHistory: true,
|
|
352
|
+
id: (0,web_ui_namespaceObject.randomId)(),
|
|
353
|
+
messageStatus: 'received',
|
|
354
|
+
participant: {
|
|
355
|
+
introduction: 'Welcome, you are now chatting with Mrs. Bot 2, give me a minit to read back the chat history.',
|
|
356
|
+
id: 'agent',
|
|
357
|
+
avatar: transferAvatar,
|
|
358
|
+
name: 'Two',
|
|
359
|
+
service: {
|
|
360
|
+
expose: {
|
|
361
|
+
map: {},
|
|
362
|
+
version: 3
|
|
363
|
+
},
|
|
364
|
+
meta: {},
|
|
365
|
+
name: 'new service',
|
|
366
|
+
serviceSessionId: (0,web_ui_namespaceObject.randomId)(),
|
|
367
|
+
settings: {}
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
transactionId: (0,web_ui_namespaceObject.randomId)(),
|
|
371
|
+
type: 'participant'
|
|
372
|
+
}
|
|
373
|
+
};
|
|
346
374
|
const participantMessageDefaultIcon = {
|
|
347
375
|
type: 'participant',
|
|
348
376
|
payload: {
|
|
@@ -352,7 +380,7 @@ const participantMessageDefaultIcon = {
|
|
|
352
380
|
messageStatus: 'received',
|
|
353
381
|
participant: {
|
|
354
382
|
id: 'user',
|
|
355
|
-
introduction: "You're now talking to
|
|
383
|
+
introduction: "You're now talking to Mrs. Bot gimme a minit",
|
|
356
384
|
name: 'Mrs. Bot',
|
|
357
385
|
service: {
|
|
358
386
|
expose: {
|
|
@@ -380,8 +408,7 @@ const getCustomMessage = ({
|
|
|
380
408
|
body: {
|
|
381
409
|
type,
|
|
382
410
|
text,
|
|
383
|
-
data
|
|
384
|
-
variables: {}
|
|
411
|
+
data
|
|
385
412
|
},
|
|
386
413
|
participant: 'agent',
|
|
387
414
|
service: {
|
|
@@ -406,8 +433,7 @@ const shortTextMessage = {
|
|
|
406
433
|
payload: {
|
|
407
434
|
body: {
|
|
408
435
|
text: 'What do you want to do?',
|
|
409
|
-
type: 'text'
|
|
410
|
-
variables: {}
|
|
436
|
+
type: 'text'
|
|
411
437
|
},
|
|
412
438
|
fromClient: false,
|
|
413
439
|
fromHistory: true,
|
|
@@ -442,7 +468,7 @@ const ctaMessage = {
|
|
|
442
468
|
type: 'message',
|
|
443
469
|
payload: {
|
|
444
470
|
body: {
|
|
445
|
-
description: 'Thanks for chatting!\n\nMore info about our
|
|
471
|
+
description: 'Thanks for chatting!\n\nMore info about our <strong>products</strong>?',
|
|
446
472
|
buttonLink: 'https://seamly.ai',
|
|
447
473
|
buttonText: 'View website',
|
|
448
474
|
buttonNewTab: true
|
|
@@ -471,8 +497,7 @@ const longTextMessage = {
|
|
|
471
497
|
payload: {
|
|
472
498
|
body: {
|
|
473
499
|
text: 'What do you want to do? This is a really long message from a bot that has a lot to say about a lot of things. Currently I am contemplating my own bot existence and constantly asking myself who I am. What do you want to do? This is a really long message from a bot that has a lot to say about a lot of things. Currently I am contemplating my own bot existence and constantly asking myself who I am. What do you want to do? This is a really long message from a bot that has a lot to say about a lot of things. Currently I am contemplating my own bot existence and constantly asking myself who I am.',
|
|
474
|
-
type: 'text'
|
|
475
|
-
variables: {}
|
|
500
|
+
type: 'text'
|
|
476
501
|
},
|
|
477
502
|
fromClient: false,
|
|
478
503
|
fromHistory: true,
|
|
@@ -495,9 +520,8 @@ const textMessageBoldItalicUnderline = {
|
|
|
495
520
|
type: 'message',
|
|
496
521
|
payload: {
|
|
497
522
|
body: {
|
|
498
|
-
text: 'Bubble with
|
|
499
|
-
type: 'text'
|
|
500
|
-
variables: {}
|
|
523
|
+
text: 'Bubble with <strong>bold</strong> <em>italic</em> <u>underline</u>',
|
|
524
|
+
type: 'text'
|
|
501
525
|
},
|
|
502
526
|
fromClient: false,
|
|
503
527
|
fromHistory: true,
|
|
@@ -522,24 +546,8 @@ const textMessageWithLinks = {
|
|
|
522
546
|
type: 'message',
|
|
523
547
|
payload: {
|
|
524
548
|
body: {
|
|
525
|
-
text: '
|
|
526
|
-
type: 'text'
|
|
527
|
-
variables: {
|
|
528
|
-
link_1: {
|
|
529
|
-
id: '1',
|
|
530
|
-
name: 'Link in same window',
|
|
531
|
-
newTab: false,
|
|
532
|
-
type: 'link',
|
|
533
|
-
url: 'https://google.com'
|
|
534
|
-
},
|
|
535
|
-
link_2: {
|
|
536
|
-
id: '2',
|
|
537
|
-
name: 'link in new window',
|
|
538
|
-
newTab: true,
|
|
539
|
-
type: 'link',
|
|
540
|
-
url: 'https://google.com'
|
|
541
|
-
}
|
|
542
|
-
}
|
|
549
|
+
text: '<a href="https://google.com" data-link-id="1">Link in same window</a> and <a href="https://google.com" data-link-id="2" target="_blank">link in new window</a> embedded in text',
|
|
550
|
+
type: 'text'
|
|
543
551
|
},
|
|
544
552
|
fromClient: false,
|
|
545
553
|
fromHistory: true,
|
|
@@ -564,17 +572,8 @@ const textMessageWithLongLink = {
|
|
|
564
572
|
type: 'message',
|
|
565
573
|
payload: {
|
|
566
574
|
body: {
|
|
567
|
-
text: 'Here is a long link
|
|
568
|
-
type: 'text'
|
|
569
|
-
variables: {
|
|
570
|
-
link_1: {
|
|
571
|
-
id: '1',
|
|
572
|
-
name: 'click me click me please click me yoohoooo please please click me here I am click me now what are you waiting for click me now now now now now click meeeeeeeeeeeeee',
|
|
573
|
-
newTab: false,
|
|
574
|
-
type: 'link',
|
|
575
|
-
url: 'https://google.com'
|
|
576
|
-
}
|
|
577
|
-
}
|
|
575
|
+
text: 'Here is a long link <a href="https://google.com" data-link-id="1">click me click me please click me yoohoooo please please click me here I am click me now what are you waiting for click me now now now now now click meeeeeeeeeeeeee</a> embedded in text',
|
|
576
|
+
type: 'text'
|
|
578
577
|
},
|
|
579
578
|
fromClient: false,
|
|
580
579
|
fromHistory: true,
|
|
@@ -600,8 +599,7 @@ const textMesageWithBullets = {
|
|
|
600
599
|
payload: {
|
|
601
600
|
body: {
|
|
602
601
|
text: '<ul>\n<li>Bullets</li>\n<li>bullets</li>\n<li>bullets</li>\n</ul>\n',
|
|
603
|
-
type: 'text'
|
|
604
|
-
variables: {}
|
|
602
|
+
type: 'text'
|
|
605
603
|
},
|
|
606
604
|
fromClient: false,
|
|
607
605
|
fromHistory: true,
|
|
@@ -762,8 +760,7 @@ const userMessage = {
|
|
|
762
760
|
payload: {
|
|
763
761
|
body: {
|
|
764
762
|
text: 'This is what the user typed',
|
|
765
|
-
type: 'text'
|
|
766
|
-
variables: {}
|
|
763
|
+
type: 'text'
|
|
767
764
|
},
|
|
768
765
|
fromClient: true,
|
|
769
766
|
fromHistory: true,
|
|
@@ -780,8 +777,24 @@ const userMessageLong = {
|
|
|
780
777
|
payload: {
|
|
781
778
|
body: {
|
|
782
779
|
text: 'This is what the user typed. And sometimes the user has quite a lot to say and then we get longer lines that need to wrap well and not break the styling so here goes with just such a line right here!!',
|
|
783
|
-
type: 'text'
|
|
784
|
-
|
|
780
|
+
type: 'text'
|
|
781
|
+
},
|
|
782
|
+
fromClient: true,
|
|
783
|
+
fromHistory: true,
|
|
784
|
+
id: (0,web_ui_namespaceObject.randomId)(),
|
|
785
|
+
messageStatus: 'read',
|
|
786
|
+
participant: 'user',
|
|
787
|
+
transactionId: '1cdefea9-7437-4672-bcf8-2c75dc99244c',
|
|
788
|
+
transactionLast: null,
|
|
789
|
+
type: 'text'
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
const userMessageWithLinks = {
|
|
793
|
+
type: 'message',
|
|
794
|
+
payload: {
|
|
795
|
+
body: {
|
|
796
|
+
text: '<a href="https://google.com" data-link-id="1">Link in same window</a> and <a href="https://google.com" data-link-id="2" target="_blank">link in new window</a> embedded in text',
|
|
797
|
+
type: 'text'
|
|
785
798
|
},
|
|
786
799
|
fromClient: true,
|
|
787
800
|
fromHistory: true,
|
|
@@ -967,7 +980,7 @@ const cardAskText = {
|
|
|
967
980
|
type: 'ask'
|
|
968
981
|
},
|
|
969
982
|
buttonText: 'Ask about pizzas!',
|
|
970
|
-
description: 'Pizza Margherita is a
|
|
983
|
+
description: 'Pizza Margherita is a <strong>typical Neapolitan pizza</strong>.\n\nIt is made with San Marzano tomatoes, mozzarella cheese, fresh basil, salt, and extra-virgin olive oil.',
|
|
971
984
|
image: 'https://developers.seamly.ai/clients/web-ui/static/photos/card-square.jpg',
|
|
972
985
|
title: 'Pizza Margherita'
|
|
973
986
|
}
|
|
@@ -985,7 +998,7 @@ const cardNavigate = {
|
|
|
985
998
|
type: 'navigate'
|
|
986
999
|
},
|
|
987
1000
|
buttonText: 'Order now!',
|
|
988
|
-
description: 'Pizza Margherita is a
|
|
1001
|
+
description: 'Pizza Margherita is a <strong>typical Neapolitan pizza</strong>.',
|
|
989
1002
|
image: 'https://developers.seamly.ai/clients/web-ui/static/photos/card-landscape.jpg',
|
|
990
1003
|
title: 'Pizza Margherita'
|
|
991
1004
|
}
|
|
@@ -1163,7 +1176,7 @@ const standardState = {
|
|
|
1163
1176
|
payload: states_objectSpread(states_objectSpread({}, choicePromptMessage.payload), {}, {
|
|
1164
1177
|
id: `${choicePromptMessage.payload.id}XXX`
|
|
1165
1178
|
})
|
|
1166
|
-
}), longTextMessage, userMessage, textMessageBoldItalicUnderline, newTopicDivider, imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage]
|
|
1179
|
+
}), longTextMessage, participantTransferMessage, userMessage, textMessageBoldItalicUnderline, userMessageWithLinks, newTopicDivider, imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage]
|
|
1167
1180
|
}),
|
|
1168
1181
|
userMessages: states_objectSpread(states_objectSpread({
|
|
1169
1182
|
category: categoryKeys.messages,
|
|
@@ -1171,7 +1184,7 @@ const standardState = {
|
|
|
1171
1184
|
description: ''
|
|
1172
1185
|
}, baseState), {}, {
|
|
1173
1186
|
participantInfo,
|
|
1174
|
-
events: [userMessage, userMessageLong, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage]
|
|
1187
|
+
events: [userMessage, userMessageLong, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, userMessageWithLinks]
|
|
1175
1188
|
}),
|
|
1176
1189
|
withParticipants: states_objectSpread(states_objectSpread({
|
|
1177
1190
|
category: categoryKeys.messages,
|
|
@@ -1238,11 +1251,10 @@ const standardState = {
|
|
|
1238
1251
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1239
1252
|
body: {
|
|
1240
1253
|
text: 'Long ago when a dialog started',
|
|
1241
|
-
type: 'text'
|
|
1242
|
-
variables: {}
|
|
1254
|
+
type: 'text'
|
|
1243
1255
|
}
|
|
1244
1256
|
})
|
|
1245
|
-
}, participantMessage, participantMessageDefaultIcon, newTopicDivider, transcriptInfoMessage, ...[newTranslationDividerStart, newTranslationDividerStop].map(addTranslationData), infoMessage]
|
|
1257
|
+
}, participantMessage, participantMessageDefaultIcon, participantTransferMessage, newTopicDivider, transcriptInfoMessage, ...[newTranslationDividerStart, newTranslationDividerStop].map(addTranslationData), infoMessage]
|
|
1246
1258
|
}),
|
|
1247
1259
|
choicePromptMessages: states_objectSpread(states_objectSpread({
|
|
1248
1260
|
category: categoryKeys.messages,
|
|
@@ -1283,8 +1295,7 @@ const standardState = {
|
|
|
1283
1295
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1284
1296
|
body: {
|
|
1285
1297
|
text: 'Long ago when a dialog started',
|
|
1286
|
-
type: 'text'
|
|
1287
|
-
variables: {}
|
|
1298
|
+
type: 'text'
|
|
1288
1299
|
}
|
|
1289
1300
|
})
|
|
1290
1301
|
}, {
|
|
@@ -1294,8 +1305,7 @@ const standardState = {
|
|
|
1294
1305
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1295
1306
|
body: {
|
|
1296
1307
|
text: 'Above me should be a time indicator showing the full date',
|
|
1297
|
-
type: 'text'
|
|
1298
|
-
variables: {}
|
|
1308
|
+
type: 'text'
|
|
1299
1309
|
}
|
|
1300
1310
|
})
|
|
1301
1311
|
}, {
|
|
@@ -1305,8 +1315,7 @@ const standardState = {
|
|
|
1305
1315
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1306
1316
|
body: {
|
|
1307
1317
|
text: 'Another message',
|
|
1308
|
-
type: 'text'
|
|
1309
|
-
variables: {}
|
|
1318
|
+
type: 'text'
|
|
1310
1319
|
}
|
|
1311
1320
|
})
|
|
1312
1321
|
}, {
|
|
@@ -1316,8 +1325,7 @@ const standardState = {
|
|
|
1316
1325
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1317
1326
|
body: {
|
|
1318
1327
|
text: 'And another message',
|
|
1319
|
-
type: 'text'
|
|
1320
|
-
variables: {}
|
|
1328
|
+
type: 'text'
|
|
1321
1329
|
}
|
|
1322
1330
|
})
|
|
1323
1331
|
}, {
|
|
@@ -1327,8 +1335,7 @@ const standardState = {
|
|
|
1327
1335
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1328
1336
|
body: {
|
|
1329
1337
|
text: 'Above me should be a time indicator showing "yesterday"',
|
|
1330
|
-
type: 'text'
|
|
1331
|
-
variables: {}
|
|
1338
|
+
type: 'text'
|
|
1332
1339
|
}
|
|
1333
1340
|
})
|
|
1334
1341
|
}, {
|
|
@@ -1338,8 +1345,7 @@ const standardState = {
|
|
|
1338
1345
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1339
1346
|
body: {
|
|
1340
1347
|
text: 'Another message',
|
|
1341
|
-
type: 'text'
|
|
1342
|
-
variables: {}
|
|
1348
|
+
type: 'text'
|
|
1343
1349
|
}
|
|
1344
1350
|
})
|
|
1345
1351
|
}, {
|
|
@@ -1349,8 +1355,7 @@ const standardState = {
|
|
|
1349
1355
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1350
1356
|
body: {
|
|
1351
1357
|
text: 'And another message',
|
|
1352
|
-
type: 'text'
|
|
1353
|
-
variables: {}
|
|
1358
|
+
type: 'text'
|
|
1354
1359
|
}
|
|
1355
1360
|
})
|
|
1356
1361
|
}, {
|
|
@@ -1360,8 +1365,7 @@ const standardState = {
|
|
|
1360
1365
|
id: (0,web_ui_namespaceObject.randomId)(),
|
|
1361
1366
|
body: {
|
|
1362
1367
|
text: 'Above me should be a time indicator showing me the dialog continues today',
|
|
1363
|
-
type: 'text'
|
|
1364
|
-
variables: {}
|
|
1368
|
+
type: 'text'
|
|
1365
1369
|
}
|
|
1366
1370
|
})
|
|
1367
1371
|
}]
|
|
@@ -1798,6 +1802,26 @@ const inlineInterface = {
|
|
|
1798
1802
|
})
|
|
1799
1803
|
})
|
|
1800
1804
|
},
|
|
1805
|
+
minimizedInlineCharacterLimit: {
|
|
1806
|
+
category: categoryKeys.minimizedInline,
|
|
1807
|
+
headingText: 'Inline minimized with limited characters',
|
|
1808
|
+
description: '',
|
|
1809
|
+
inline: states_objectSpread(states_objectSpread({}, baseState), {}, {
|
|
1810
|
+
config: states_objectSpread(states_objectSpread({}, baseState.config), {}, {
|
|
1811
|
+
layoutMode: 'inline'
|
|
1812
|
+
}),
|
|
1813
|
+
visibility: states_objectSpread(states_objectSpread({}, baseState.visibility), {}, {
|
|
1814
|
+
visibility: web_ui_namespaceObject.visibilityStates.minimized
|
|
1815
|
+
}),
|
|
1816
|
+
entryMeta: states_objectSpread(states_objectSpread({}, baseState.entryMeta), {}, {
|
|
1817
|
+
options: {
|
|
1818
|
+
text: {
|
|
1819
|
+
limit: 120
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
})
|
|
1823
|
+
})
|
|
1824
|
+
},
|
|
1801
1825
|
minimizedInlinePrechat: {
|
|
1802
1826
|
category: categoryKeys.minimizedInline,
|
|
1803
1827
|
headingText: 'Inline minimized with pre-chat messages',
|
|
@@ -1919,7 +1943,7 @@ const newInterface = {
|
|
|
1919
1943
|
headingText: 'Suggestions message',
|
|
1920
1944
|
description: ''
|
|
1921
1945
|
}, baseState), {}, {
|
|
1922
|
-
events: [{
|
|
1946
|
+
events: [getCustomMessage(shortTextMessage.payload.body), {
|
|
1923
1947
|
type: 'service_data',
|
|
1924
1948
|
payload: {
|
|
1925
1949
|
type: 'suggestion',
|
|
@@ -2228,6 +2252,7 @@ function seamly_utils_objectSpread(target) { for (var i = 1; i < arguments.lengt
|
|
|
2228
2252
|
function seamly_utils_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2229
2253
|
|
|
2230
2254
|
|
|
2255
|
+
|
|
2231
2256
|
const eventTypes = {
|
|
2232
2257
|
info: 'info',
|
|
2233
2258
|
message: 'message',
|
|
@@ -2292,6 +2317,7 @@ const seamly_utils_seamlyActions = {
|
|
|
2292
2317
|
CLEAR_EVENTS: 'CLEAR_EVENTS',
|
|
2293
2318
|
SET_HISTORY: 'SET_HISTORY',
|
|
2294
2319
|
SET_EVENTS_READ: 'SET_EVENTS_READ',
|
|
2320
|
+
SET_LOADED_IMAGE_EVENT_IDS: 'SET_LOADED_IMAGE_EVENT_IDS',
|
|
2295
2321
|
ACK_EVENT: 'ACK_EVENT',
|
|
2296
2322
|
SET_IS_LOADING: 'SET_IS_LOADING',
|
|
2297
2323
|
CLEAR_PARTICIPANTS: 'CLEAR_PARTICIPANTS',
|
|
@@ -2337,6 +2363,7 @@ const {
|
|
|
2337
2363
|
CLEAR_EVENTS,
|
|
2338
2364
|
SET_HISTORY,
|
|
2339
2365
|
SET_EVENTS_READ,
|
|
2366
|
+
SET_LOADED_IMAGE_EVENT_IDS,
|
|
2340
2367
|
ACK_EVENT,
|
|
2341
2368
|
SET_IS_LOADING,
|
|
2342
2369
|
CLEAR_PARTICIPANTS,
|
|
@@ -2390,14 +2417,16 @@ const orderHistory = events => {
|
|
|
2390
2417
|
};
|
|
2391
2418
|
|
|
2392
2419
|
const mergeHistory = (stateEvents, historyEvents) => {
|
|
2393
|
-
const
|
|
2394
|
-
|
|
2420
|
+
const newStateEvents = stateEvents.filter(stateEvent => // Deduplicate the event streams, giving events in historyEvents
|
|
2421
|
+
// precedence so the server is able to push changes to events.
|
|
2422
|
+
!historyEvents.some(historyEvent => historyEvent.payload.id === stateEvent.payload.id));
|
|
2423
|
+
const newHistoryEvents = historyEvents.filter(historyEvent => // Remove all non displayable participant messages
|
|
2395
2424
|
!(historyEvent.type === 'participant' && !historyEvent.payload.participant.introduction)) // Reverse is done here because the server sends the history in the order
|
|
2396
2425
|
// newest to oldest. In the case of exactly the same occurredAt timestamps
|
|
2397
2426
|
// these messages will be shown in the wrong order if not reversed. For
|
|
2398
2427
|
// the normal merging logic there is no added effect.
|
|
2399
2428
|
.reverse();
|
|
2400
|
-
return orderHistory([...newHistoryEvents, ...
|
|
2429
|
+
return orderHistory([...newHistoryEvents, ...newStateEvents]);
|
|
2401
2430
|
};
|
|
2402
2431
|
|
|
2403
2432
|
const participantReducer = (state, action) => {
|
|
@@ -2547,7 +2576,10 @@ const seamlyStateReducer = (state, action) => {
|
|
|
2547
2576
|
// event optimistically.
|
|
2548
2577
|
payload: seamly_utils_objectSpread(seamly_utils_objectSpread({}, incrementUnread && {
|
|
2549
2578
|
messageStatus: payload.fromClient ? readStates.read : readStates.received
|
|
2550
|
-
}),
|
|
2579
|
+
}), {}, {
|
|
2580
|
+
// We add a randomid to use as key for mapping of Events to avoid rerendering
|
|
2581
|
+
key: id_randomId()
|
|
2582
|
+
}, payload)
|
|
2551
2583
|
})]
|
|
2552
2584
|
});
|
|
2553
2585
|
|
|
@@ -2576,6 +2608,7 @@ const seamlyStateReducer = (state, action) => {
|
|
|
2576
2608
|
case CLEAR_EVENTS:
|
|
2577
2609
|
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
2578
2610
|
unreadEvents: 0,
|
|
2611
|
+
loadedImageEventIds: [],
|
|
2579
2612
|
events: []
|
|
2580
2613
|
});
|
|
2581
2614
|
|
|
@@ -2595,6 +2628,11 @@ const seamlyStateReducer = (state, action) => {
|
|
|
2595
2628
|
})
|
|
2596
2629
|
});
|
|
2597
2630
|
|
|
2631
|
+
case SET_LOADED_IMAGE_EVENT_IDS:
|
|
2632
|
+
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
2633
|
+
loadedImageEventIds: [...state.loadedImageEventIds, action.eventId]
|
|
2634
|
+
});
|
|
2635
|
+
|
|
2598
2636
|
case SET_HISTORY:
|
|
2599
2637
|
const {
|
|
2600
2638
|
events: history,
|
|
@@ -2772,8 +2810,12 @@ const seamlyStateReducer = (state, action) => {
|
|
|
2772
2810
|
});
|
|
2773
2811
|
|
|
2774
2812
|
case SET_INITIAL_STATE:
|
|
2813
|
+
const {
|
|
2814
|
+
initialState
|
|
2815
|
+
} = action;
|
|
2775
2816
|
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
2776
|
-
initialState
|
|
2817
|
+
initialState,
|
|
2818
|
+
unreadEvents: initialState.unreadMessageCount
|
|
2777
2819
|
});
|
|
2778
2820
|
|
|
2779
2821
|
case SET_SERVICE_DATA_ITEM:
|
|
@@ -2986,7 +3028,7 @@ function createAction(type, identityReducer = payload => ({
|
|
|
2986
3028
|
|
|
2987
3029
|
action.toString = () => String(type);
|
|
2988
3030
|
|
|
2989
|
-
action.match = obj => obj
|
|
3031
|
+
action.match = obj => (obj === null || obj === void 0 ? void 0 : obj.type) === String(type);
|
|
2990
3032
|
|
|
2991
3033
|
return action;
|
|
2992
3034
|
}
|
|
@@ -3076,7 +3118,7 @@ function createThunk(type, payloadCreator) {
|
|
|
3076
3118
|
}
|
|
3077
3119
|
function createReducer(domain, handlers = {}, defaultState) {
|
|
3078
3120
|
const reducer = (state = defaultState, action) => {
|
|
3079
|
-
const typeReducer = handlers
|
|
3121
|
+
const typeReducer = handlers === null || handlers === void 0 ? void 0 : handlers[action === null || action === void 0 ? void 0 : action.type];
|
|
3080
3122
|
return typeReducer ? typeReducer(state, action) : state;
|
|
3081
3123
|
};
|
|
3082
3124
|
|
|
@@ -3507,7 +3549,7 @@ function selectors_defineProperty(obj, key, value) { if (key in obj) { Object.de
|
|
|
3507
3549
|
|
|
3508
3550
|
const selectConfig = createSelector(selectState, config => {
|
|
3509
3551
|
let newConfig = selectors_objectSpread({
|
|
3510
|
-
visible: config
|
|
3552
|
+
visible: (config === null || config === void 0 ? void 0 : config.layoutMode) === 'inline' ? constants_visibilityStates.open : constants_visibilityStates.minimized,
|
|
3511
3553
|
appContainerClassNames: config.appContainerClassNames || []
|
|
3512
3554
|
}, config);
|
|
3513
3555
|
|
|
@@ -3599,6 +3641,8 @@ function hooks_useSelector(selector, deps = []) {
|
|
|
3599
3641
|
useLayoutEffect(() => {
|
|
3600
3642
|
// we subscribe to the store changes
|
|
3601
3643
|
return store.subscribe(() => {
|
|
3644
|
+
var _selectorRef$current;
|
|
3645
|
+
|
|
3602
3646
|
const newState = store.getState(); // prevent recalculating if the state hasn't changed
|
|
3603
3647
|
// if the selector changed, it was already handled synchronously
|
|
3604
3648
|
|
|
@@ -3607,7 +3651,7 @@ function hooks_useSelector(selector, deps = []) {
|
|
|
3607
3651
|
} // calculate the new value based on selector+state
|
|
3608
3652
|
|
|
3609
3653
|
|
|
3610
|
-
const newValue = selectorRef.current
|
|
3654
|
+
const newValue = (_selectorRef$current = selectorRef.current) === null || _selectorRef$current === void 0 ? void 0 : _selectorRef$current.call(selectorRef, store.getState()); // only if the value changed we update. this saves heaps of re-rendering
|
|
3611
3655
|
|
|
3612
3656
|
if (newValue !== valueRef.current) {
|
|
3613
3657
|
valueRef.current = newValue;
|
|
@@ -3670,7 +3714,9 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
3670
3714
|
events,
|
|
3671
3715
|
serviceData
|
|
3672
3716
|
}, config, userHasResponded) => {
|
|
3673
|
-
|
|
3717
|
+
var _serviceData$suggesti;
|
|
3718
|
+
|
|
3719
|
+
if (userHasResponded || config.layoutMode === 'inline' || !serviceData.suggestion || !((_serviceData$suggesti = serviceData.suggestion) !== null && _serviceData$suggesti !== void 0 && _serviceData$suggesti.body.length)) {
|
|
3674
3720
|
return events;
|
|
3675
3721
|
}
|
|
3676
3722
|
|
|
@@ -3681,10 +3727,12 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
3681
3727
|
return [...events, suggestionsEvent];
|
|
3682
3728
|
});
|
|
3683
3729
|
const selectEvents = createSelector(selectEventsWithSuggestion, selectConfig, (events, config) => {
|
|
3730
|
+
var _config$messages;
|
|
3731
|
+
|
|
3684
3732
|
const {
|
|
3685
3733
|
enabled,
|
|
3686
3734
|
threshold
|
|
3687
|
-
} = config
|
|
3735
|
+
} = (config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) ?? {};
|
|
3688
3736
|
|
|
3689
3737
|
if (!enabled) {
|
|
3690
3738
|
return events;
|
|
@@ -3713,12 +3761,15 @@ const seamly_state_hooks_useEvents = () => useSelector(selectEvents, []);
|
|
|
3713
3761
|
const useSeamlyIsLoading = () => seamly_state_hooks_useSeamlyStateContext().isLoading;
|
|
3714
3762
|
const useSeamlyHeaderData = () => seamly_state_hooks_useSeamlyStateContext().headerTitles;
|
|
3715
3763
|
const seamly_state_hooks_useSeamlyUnreadCount = () => seamly_state_hooks_useSeamlyStateContext().unreadEvents;
|
|
3764
|
+
const useLoadedImageEventIds = () => seamly_state_hooks_useSeamlyStateContext().loadedImageEventIds;
|
|
3716
3765
|
const seamly_state_hooks_useSkiplink = () => seamly_state_hooks_useSeamlyStateContext().skiplinkTargetId;
|
|
3717
3766
|
const useSeamlyParticipant = participantId => seamly_state_hooks_useSeamlyStateContext().participantInfo.participants[participantId];
|
|
3718
3767
|
const useSeamlyServiceInfo = () => seamly_state_hooks_useSeamlyStateContext().serviceInfo;
|
|
3719
3768
|
const selectLastMessageEventId = createSelector(selectEvents, events => {
|
|
3769
|
+
var _filteredEvents;
|
|
3770
|
+
|
|
3720
3771
|
const filteredEvents = events.filter(event => event.type === 'message');
|
|
3721
|
-
return filteredEvents[filteredEvents.length - 1]
|
|
3772
|
+
return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
|
|
3722
3773
|
});
|
|
3723
3774
|
const useLastMessageEventId = () => useSelector(selectLastMessageEventId);
|
|
3724
3775
|
const useSeamlyIsHistoryLoaded = () => seamly_state_hooks_useSeamlyStateContext().historyLoaded;
|
|
@@ -3735,18 +3786,23 @@ const useEntryTextLimit = () => {
|
|
|
3735
3786
|
entryMeta: {
|
|
3736
3787
|
options: {
|
|
3737
3788
|
text
|
|
3789
|
+
},
|
|
3790
|
+
optionsOverride: {
|
|
3791
|
+
text: overrideText
|
|
3738
3792
|
}
|
|
3739
3793
|
}
|
|
3740
3794
|
} = seamly_state_hooks_useSeamlyStateContext();
|
|
3741
3795
|
const {
|
|
3742
3796
|
limit
|
|
3743
|
-
} = text || {
|
|
3797
|
+
} = overrideText || text || {
|
|
3798
|
+
limit: null
|
|
3799
|
+
};
|
|
3744
3800
|
return {
|
|
3745
|
-
hasLimit: limit
|
|
3746
|
-
limit: limit
|
|
3801
|
+
hasLimit: limit !== null,
|
|
3802
|
+
limit: limit !== null ? limit : null
|
|
3747
3803
|
};
|
|
3748
3804
|
};
|
|
3749
|
-
const
|
|
3805
|
+
const seamly_state_hooks_useSeamlyLayoutMode = () => {
|
|
3750
3806
|
const {
|
|
3751
3807
|
layoutMode
|
|
3752
3808
|
} = useConfig();
|
|
@@ -3779,7 +3835,12 @@ const calculateVisibility = ({
|
|
|
3779
3835
|
} = config;
|
|
3780
3836
|
const {
|
|
3781
3837
|
visible: defaultVisibility
|
|
3782
|
-
} = defaults || {}; //
|
|
3838
|
+
} = defaults || {}; // The app layout should always be open by default.
|
|
3839
|
+
|
|
3840
|
+
if (layoutMode === 'app' && !previousVisibility) {
|
|
3841
|
+
return constants_visibilityStates.open;
|
|
3842
|
+
} // Requesting open should override the responded check.
|
|
3843
|
+
|
|
3783
3844
|
|
|
3784
3845
|
if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== constants_visibilityStates.open) {
|
|
3785
3846
|
return hasResponded ? requestedVisibility || previousVisibility || constants_visibilityStates.open : constants_visibilityStates.hidden;
|
|
@@ -3798,6 +3859,7 @@ const calculateVisibility = ({
|
|
|
3798
3859
|
|
|
3799
3860
|
|
|
3800
3861
|
const selectVisibility = createSelector(visibility_utils_selectState, state => state.visibility);
|
|
3862
|
+
const selectors_selectShowInlineView = createSelector(visibility_utils_selectState, state => state.showInlineView);
|
|
3801
3863
|
|
|
3802
3864
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/actions.js
|
|
3803
3865
|
function actions_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -3815,6 +3877,7 @@ function actions_defineProperty(obj, key, value) { if (key in obj) { Object.defi
|
|
|
3815
3877
|
const setFromStorage = visibility_utils_createAction('setFromStorage', visibility => ({
|
|
3816
3878
|
visibility
|
|
3817
3879
|
}));
|
|
3880
|
+
const setShowInlineView = visibility_utils_createAction('setShowInlineView');
|
|
3818
3881
|
const validVisibilityStates = [constants_visibilityStates.open, constants_visibilityStates.minimized, constants_visibilityStates.hidden];
|
|
3819
3882
|
const setVisibility = visibility_utils_createThunk('set', (requestedVisibility, {
|
|
3820
3883
|
getState,
|
|
@@ -3875,11 +3938,13 @@ const actions_initialize = visibility_utils_createThunk('initialize', async (loc
|
|
|
3875
3938
|
api
|
|
3876
3939
|
}
|
|
3877
3940
|
}) => {
|
|
3941
|
+
var _api$store$get;
|
|
3942
|
+
|
|
3878
3943
|
// initialize stored visibility
|
|
3879
3944
|
const {
|
|
3880
3945
|
layoutMode
|
|
3881
3946
|
} = selectConfig(getState());
|
|
3882
|
-
const storedVisibility = api.store.get(StoreKey)
|
|
3947
|
+
const storedVisibility = (_api$store$get = api.store.get(StoreKey)) === null || _api$store$get === void 0 ? void 0 : _api$store$get[layoutMode];
|
|
3883
3948
|
|
|
3884
3949
|
if (storedVisibility) {
|
|
3885
3950
|
dispatch(setFromStorage(storedVisibility));
|
|
@@ -3917,13 +3982,13 @@ class SeamlyBaseError extends Error {
|
|
|
3917
3982
|
|
|
3918
3983
|
this.originalError = originalError;
|
|
3919
3984
|
|
|
3920
|
-
if (originalError
|
|
3985
|
+
if (originalError !== null && originalError !== void 0 && originalError.payload) {
|
|
3921
3986
|
this.originalEvent = originalError;
|
|
3922
3987
|
this.originalError = originalError.payload.error;
|
|
3923
3988
|
this.message = `Event of type ${originalError.payload.type} encountered`;
|
|
3924
3989
|
}
|
|
3925
3990
|
|
|
3926
|
-
if (originalError
|
|
3991
|
+
if (originalError !== null && originalError !== void 0 && originalError.error) {
|
|
3927
3992
|
this.originalError = originalError.error;
|
|
3928
3993
|
}
|
|
3929
3994
|
}
|
|
@@ -3962,7 +4027,7 @@ const clear = interrupt_utils_createAction('clear');
|
|
|
3962
4027
|
|
|
3963
4028
|
|
|
3964
4029
|
|
|
3965
|
-
const
|
|
4030
|
+
const actions_setHasResponded = app_utils_createAction('setHasResponded', hasResponded => ({
|
|
3966
4031
|
hasResponded
|
|
3967
4032
|
}));
|
|
3968
4033
|
const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
@@ -3972,8 +4037,10 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
3972
4037
|
config
|
|
3973
4038
|
}
|
|
3974
4039
|
}) => {
|
|
4040
|
+
var _config$context;
|
|
4041
|
+
|
|
3975
4042
|
dispatch(initialize(config));
|
|
3976
|
-
let locale = config
|
|
4043
|
+
let locale = config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale;
|
|
3977
4044
|
|
|
3978
4045
|
try {
|
|
3979
4046
|
const {
|
|
@@ -4000,7 +4067,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4000
4067
|
startChatIcon
|
|
4001
4068
|
}));
|
|
4002
4069
|
|
|
4003
|
-
if (agentParticipant
|
|
4070
|
+
if (agentParticipant !== null && agentParticipant !== void 0 && agentParticipant.name) {
|
|
4004
4071
|
dispatch({
|
|
4005
4072
|
type: seamly_utils_seamlyActions.SET_HEADER_SUB_TITLE,
|
|
4006
4073
|
title: agentParticipant.name
|
|
@@ -4012,18 +4079,22 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4012
4079
|
|
|
4013
4080
|
try {
|
|
4014
4081
|
if (api.hasConversation()) {
|
|
4082
|
+
var _initialState$transla;
|
|
4083
|
+
|
|
4015
4084
|
const initialState = await api.getConversationIntitialState();
|
|
4016
4085
|
dispatch({
|
|
4017
4086
|
type: seamly_utils_seamlyActions.SET_INITIAL_STATE,
|
|
4018
4087
|
initialState
|
|
4019
4088
|
});
|
|
4020
|
-
locale = initialState.translation
|
|
4089
|
+
locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
|
|
4021
4090
|
|
|
4022
4091
|
if ('userResponded' in initialState) {
|
|
4023
|
-
dispatch(
|
|
4092
|
+
dispatch(actions_setHasResponded(initialState.userResponded));
|
|
4024
4093
|
}
|
|
4025
4094
|
} else {
|
|
4026
|
-
|
|
4095
|
+
var _config$context2, _config$context3;
|
|
4096
|
+
|
|
4097
|
+
if (config !== null && config !== void 0 && (_config$context2 = config.context) !== null && _config$context2 !== void 0 && _config$context2.topic) {
|
|
4027
4098
|
api.send('action', {
|
|
4028
4099
|
type: seamly_utils_actionTypes.setTopic,
|
|
4029
4100
|
body: {
|
|
@@ -4035,7 +4106,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4035
4106
|
});
|
|
4036
4107
|
}
|
|
4037
4108
|
|
|
4038
|
-
if (config
|
|
4109
|
+
if (config !== null && config !== void 0 && (_config$context3 = config.context) !== null && _config$context3 !== void 0 && _config$context3.translationLocale) {
|
|
4039
4110
|
locale = config.context.translationLocale;
|
|
4040
4111
|
api.send('action', {
|
|
4041
4112
|
type: seamly_utils_actionTypes.setTranslation,
|
|
@@ -4081,6 +4152,7 @@ const initialState = {
|
|
|
4081
4152
|
events: [],
|
|
4082
4153
|
initialState: {},
|
|
4083
4154
|
unreadEvents: 0,
|
|
4155
|
+
loadedImageEventIds: [],
|
|
4084
4156
|
isLoading: false,
|
|
4085
4157
|
idleDetachCountdown: {
|
|
4086
4158
|
hasCountdown: false,
|
|
@@ -4142,7 +4214,9 @@ function utils_validate(values, schema = {}) {
|
|
|
4142
4214
|
validations = [validations];
|
|
4143
4215
|
}
|
|
4144
4216
|
|
|
4145
|
-
for (let i = 0; i < validations
|
|
4217
|
+
for (let i = 0; i < ((_validations = validations) === null || _validations === void 0 ? void 0 : _validations.length) ?? 0; i++) {
|
|
4218
|
+
var _validations;
|
|
4219
|
+
|
|
4146
4220
|
if (!validations[i].fn(values[key], validations[i].compareValue)) {
|
|
4147
4221
|
errors[key] = validations[i].errorText;
|
|
4148
4222
|
break;
|
|
@@ -4202,7 +4276,7 @@ const getPropSelector = (propName, orDefault) => (_, props) => props[propName] |
|
|
|
4202
4276
|
|
|
4203
4277
|
const getState = forms_utils_selectState;
|
|
4204
4278
|
const selectors_getFormById = createSelector(getState, getPropSelector('formId'), (forms, formId) => forms[formId]);
|
|
4205
|
-
const getFormControlsByFormId = createSelector(selectors_getFormById, form => form
|
|
4279
|
+
const getFormControlsByFormId = createSelector(selectors_getFormById, form => (form === null || form === void 0 ? void 0 : form.controls) || {});
|
|
4206
4280
|
const selectors_getFormValuesByFormId = createSelector(getFormControlsByFormId, controls => {
|
|
4207
4281
|
const valuesObj = {};
|
|
4208
4282
|
Object.entries(controls).forEach(([key, {
|
|
@@ -4212,8 +4286,16 @@ const selectors_getFormValuesByFormId = createSelector(getFormControlsByFormId,
|
|
|
4212
4286
|
});
|
|
4213
4287
|
return valuesObj;
|
|
4214
4288
|
});
|
|
4215
|
-
const selectors_getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) =>
|
|
4216
|
-
|
|
4289
|
+
const selectors_getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
4290
|
+
var _controls$name;
|
|
4291
|
+
|
|
4292
|
+
return (_controls$name = controls[name]) === null || _controls$name === void 0 ? void 0 : _controls$name.value;
|
|
4293
|
+
});
|
|
4294
|
+
const selectors_getControlTouchedByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
4295
|
+
var _controls$name2;
|
|
4296
|
+
|
|
4297
|
+
return (_controls$name2 = controls[name]) === null || _controls$name2 === void 0 ? void 0 : _controls$name2.touched;
|
|
4298
|
+
});
|
|
4217
4299
|
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/context.js
|
|
4218
4300
|
|
|
4219
4301
|
const context_FormContext = (0,external_preact_namespaceObject.createContext)({});
|
|
@@ -4273,7 +4355,7 @@ function hooks_useFormControl(name) {
|
|
|
4273
4355
|
formId,
|
|
4274
4356
|
name
|
|
4275
4357
|
}, [formId, name]);
|
|
4276
|
-
const error = errors
|
|
4358
|
+
const error = errors === null || errors === void 0 ? void 0 : errors[name];
|
|
4277
4359
|
const isValid = !error;
|
|
4278
4360
|
useEffect(() => {
|
|
4279
4361
|
// Make sure the form is registered
|
|
@@ -4325,6 +4407,7 @@ function provider_objectWithoutPropertiesLoose(source, excluded) { if (source ==
|
|
|
4325
4407
|
|
|
4326
4408
|
|
|
4327
4409
|
|
|
4410
|
+
|
|
4328
4411
|
function provider_FormProvider(_ref) {
|
|
4329
4412
|
let {
|
|
4330
4413
|
children,
|
|
@@ -4374,19 +4457,21 @@ function provider_FormProvider(_ref) {
|
|
|
4374
4457
|
});
|
|
4375
4458
|
}, [setExternalErrors]);
|
|
4376
4459
|
const handleSubmit = useCallback(e => {
|
|
4460
|
+
var _e$submitter;
|
|
4461
|
+
|
|
4377
4462
|
e.preventDefault(); // If the submitter is set to being aria-disabled, block the submit action
|
|
4378
4463
|
|
|
4379
|
-
const ariaDisabled = e.submitter
|
|
4464
|
+
const ariaDisabled = ((_e$submitter = e.submitter) === null || _e$submitter === void 0 ? void 0 : _e$submitter.ariaDisabled) === 'true';
|
|
4380
4465
|
setIsSubmitted(!ariaDisabled);
|
|
4381
4466
|
|
|
4382
4467
|
if (!ariaDisabled && validationIsValid) {
|
|
4468
|
+
dispatch(setHasResponded(true));
|
|
4383
4469
|
onSubmit(values, {
|
|
4384
4470
|
updateControlValue,
|
|
4385
4471
|
setError
|
|
4386
4472
|
});
|
|
4387
4473
|
}
|
|
4388
|
-
}, [validationIsValid, onSubmit, values, updateControlValue, setError]);
|
|
4389
|
-
|
|
4474
|
+
}, [validationIsValid, dispatch, onSubmit, values, updateControlValue, setError]);
|
|
4390
4475
|
useEffect(() => {
|
|
4391
4476
|
if (onError) {
|
|
4392
4477
|
onError({
|
|
@@ -4443,7 +4528,9 @@ const initialControlState = {
|
|
|
4443
4528
|
};
|
|
4444
4529
|
|
|
4445
4530
|
function updateFormControl(state, formId, name, controlState) {
|
|
4446
|
-
|
|
4531
|
+
var _state$formId;
|
|
4532
|
+
|
|
4533
|
+
const currentControlState = ((_state$formId = state[formId]) === null || _state$formId === void 0 ? void 0 : _state$formId.controls[name]) || initialControlState;
|
|
4447
4534
|
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
|
|
4448
4535
|
[formId]: reducer_objectSpread(reducer_objectSpread({}, state[formId]), {}, {
|
|
4449
4536
|
controls: reducer_objectSpread(reducer_objectSpread({}, state[formId].controls), {}, {
|
|
@@ -4471,9 +4558,11 @@ function updateFormControl(state, formId, name, controlState) {
|
|
|
4471
4558
|
[deregisterForm]: (state, {
|
|
4472
4559
|
formId
|
|
4473
4560
|
}) => {
|
|
4561
|
+
var _newState$formId;
|
|
4562
|
+
|
|
4474
4563
|
const newState = reducer_objectSpread({}, state);
|
|
4475
4564
|
|
|
4476
|
-
if (!newState[formId]
|
|
4565
|
+
if (!((_newState$formId = newState[formId]) !== null && _newState$formId !== void 0 && _newState$formId.persistData)) {
|
|
4477
4566
|
delete newState[formId];
|
|
4478
4567
|
}
|
|
4479
4568
|
|
|
@@ -4631,6 +4720,7 @@ function config_reducer_defineProperty(obj, key, value) { if (key in obj) { Obje
|
|
|
4631
4720
|
|
|
4632
4721
|
const config_reducer_initialState = config_reducer_objectSpread(config_reducer_objectSpread({}, defaultConfig), {}, {
|
|
4633
4722
|
hideOnNoUserResponse: false,
|
|
4723
|
+
connectWhenInView: true,
|
|
4634
4724
|
showDisclaimer: false,
|
|
4635
4725
|
showFaq: false,
|
|
4636
4726
|
customComponents: {},
|
|
@@ -4638,7 +4728,7 @@ const config_reducer_initialState = config_reducer_objectSpread(config_reducer_o
|
|
|
4638
4728
|
preChatEvents: []
|
|
4639
4729
|
});
|
|
4640
4730
|
|
|
4641
|
-
const configKeys = ['hideOnNoUserResponse', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback', 'agentParticipant', 'userParticipant', 'startChatIcon'];
|
|
4731
|
+
const configKeys = ['hideOnNoUserResponse', 'connectWhenInView', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback', 'agentParticipant', 'userParticipant', 'startChatIcon'];
|
|
4642
4732
|
|
|
4643
4733
|
const updateState = (state, {
|
|
4644
4734
|
config
|
|
@@ -5907,6 +5997,7 @@ function hooks_useUserHasResponded() {
|
|
|
5907
5997
|
|
|
5908
5998
|
|
|
5909
5999
|
|
|
6000
|
+
|
|
5910
6001
|
const hooks_useVisibility = () => {
|
|
5911
6002
|
const dispatch = useStoreDispatch();
|
|
5912
6003
|
const visible = useSelector(Selectors.selectVisibility);
|
|
@@ -5922,6 +6013,69 @@ const hooks_useVisibility = () => {
|
|
|
5922
6013
|
setVisibility
|
|
5923
6014
|
};
|
|
5924
6015
|
};
|
|
6016
|
+
/**
|
|
6017
|
+
* Custom hook which enables initializing of IntersectionObserver on any node ref.
|
|
6018
|
+
* @param {object} options Hook options.
|
|
6019
|
+
* @param {boolean=} options.freezeOnceVisible Stops observing when the root element is visible.
|
|
6020
|
+
* @param {boolean=} options.enabled Determines if useIntersect is enabled.
|
|
6021
|
+
*/
|
|
6022
|
+
|
|
6023
|
+
const useIntersect = ({
|
|
6024
|
+
freezeOnceVisible = false,
|
|
6025
|
+
enabled = true
|
|
6026
|
+
}) => {
|
|
6027
|
+
const [entry, setEntry] = useState(null);
|
|
6028
|
+
const containerRef = useRef(null);
|
|
6029
|
+
const isVisible = !!(entry !== null && entry !== void 0 && entry.isIntersecting) || !enabled;
|
|
6030
|
+
const frozen = isVisible && freezeOnceVisible;
|
|
6031
|
+
|
|
6032
|
+
const observerCallback = ([updatedEntry]) => setEntry(updatedEntry);
|
|
6033
|
+
|
|
6034
|
+
useEffect(() => {
|
|
6035
|
+
const node = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
6036
|
+
const hasIOSupport = !!window.IntersectionObserver;
|
|
6037
|
+
|
|
6038
|
+
if (!node && "production" === 'development') {} // Return an arrow function to have a consistent return value
|
|
6039
|
+
|
|
6040
|
+
|
|
6041
|
+
if (!hasIOSupport || frozen || !node || !enabled) return () => undefined;
|
|
6042
|
+
const observerOptions = {
|
|
6043
|
+
threshold: 0,
|
|
6044
|
+
root: null,
|
|
6045
|
+
rootMargin: '0%'
|
|
6046
|
+
};
|
|
6047
|
+
const observer = new IntersectionObserver(observerCallback, observerOptions);
|
|
6048
|
+
observer.observe(node);
|
|
6049
|
+
return () => observer.disconnect();
|
|
6050
|
+
}, [enabled, frozen]);
|
|
6051
|
+
return {
|
|
6052
|
+
isVisible,
|
|
6053
|
+
containerRef
|
|
6054
|
+
};
|
|
6055
|
+
};
|
|
6056
|
+
|
|
6057
|
+
const useShowInlineView = () => {
|
|
6058
|
+
const dispatch = useStoreDispatch();
|
|
6059
|
+
const {
|
|
6060
|
+
connectWhenInView
|
|
6061
|
+
} = useConfig();
|
|
6062
|
+
const showInlineView = useSelector(Selectors.selectShowInlineView);
|
|
6063
|
+
const {
|
|
6064
|
+
containerRef,
|
|
6065
|
+
isVisible
|
|
6066
|
+
} = useIntersect({
|
|
6067
|
+
enabled: connectWhenInView,
|
|
6068
|
+
freezeOnceVisible: true
|
|
6069
|
+
});
|
|
6070
|
+
useEffect(() => {
|
|
6071
|
+
if (!isVisible) return;
|
|
6072
|
+
dispatch(Actions.setShowInlineView());
|
|
6073
|
+
}, [dispatch, isVisible]);
|
|
6074
|
+
return {
|
|
6075
|
+
containerRef,
|
|
6076
|
+
showInlineView
|
|
6077
|
+
};
|
|
6078
|
+
};
|
|
5925
6079
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/reducer.js
|
|
5926
6080
|
function visibility_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5927
6081
|
|
|
@@ -5933,7 +6087,8 @@ function visibility_reducer_defineProperty(obj, key, value) { if (key in obj) {
|
|
|
5933
6087
|
|
|
5934
6088
|
|
|
5935
6089
|
const visibility_reducer_initialState = {
|
|
5936
|
-
visibility: constants_visibilityStates.initialize
|
|
6090
|
+
visibility: constants_visibilityStates.initialize,
|
|
6091
|
+
showInlineView: false
|
|
5937
6092
|
};
|
|
5938
6093
|
/* harmony default export */ const visibility_reducer = (visibility_utils_createReducer({
|
|
5939
6094
|
[setFromStorage]: (state, {
|
|
@@ -5945,7 +6100,10 @@ const visibility_reducer_initialState = {
|
|
|
5945
6100
|
payload: visibility
|
|
5946
6101
|
}) => visibility ? visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
|
|
5947
6102
|
visibility
|
|
5948
|
-
}) : state
|
|
6103
|
+
}) : state,
|
|
6104
|
+
[setShowInlineView]: state => visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
|
|
6105
|
+
showInlineView: true
|
|
6106
|
+
})
|
|
5949
6107
|
}, visibility_reducer_initialState));
|
|
5950
6108
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/index.js
|
|
5951
6109
|
|
|
@@ -6016,7 +6174,8 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
6016
6174
|
const hasResponded = useUserHasResponded();
|
|
6017
6175
|
const hasConversation = useSeamlyHasConversation();
|
|
6018
6176
|
const {
|
|
6019
|
-
visible: visibility
|
|
6177
|
+
visible: visibility,
|
|
6178
|
+
setVisibility
|
|
6020
6179
|
} = useVisibility();
|
|
6021
6180
|
const unreadMessageCount = useSeamlyUnreadCount();
|
|
6022
6181
|
const emitEvent = useCallback((...args) => {
|
|
@@ -6074,7 +6233,9 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
6074
6233
|
type: use_seamly_commands_ADD_EVENT,
|
|
6075
6234
|
event: {
|
|
6076
6235
|
type: 'message',
|
|
6077
|
-
payload: message
|
|
6236
|
+
payload: use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, message), {}, {
|
|
6237
|
+
optimisticallyInjected: true
|
|
6238
|
+
})
|
|
6078
6239
|
}
|
|
6079
6240
|
});
|
|
6080
6241
|
}, [api, dispatch, emitEvent, getTextMessageBase]);
|
|
@@ -6172,11 +6333,16 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
6172
6333
|
type: use_seamly_commands_SET_INITIAL_STATE,
|
|
6173
6334
|
initialState
|
|
6174
6335
|
});
|
|
6336
|
+
|
|
6337
|
+
if (initialState.userResponded) {
|
|
6338
|
+
dispatch(AppActions.setHasResponded(initialState.userResponded));
|
|
6339
|
+
setVisibility(visibilityStates.open);
|
|
6340
|
+
}
|
|
6175
6341
|
}
|
|
6176
6342
|
}).catch(error => {
|
|
6177
6343
|
dispatch(InterruptActions.set(error));
|
|
6178
6344
|
});
|
|
6179
|
-
}, [api, dispatch]);
|
|
6345
|
+
}, [api, dispatch, setVisibility]);
|
|
6180
6346
|
return {
|
|
6181
6347
|
connect,
|
|
6182
6348
|
start,
|
|
@@ -6189,6 +6355,7 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
6189
6355
|
addMessageBubble,
|
|
6190
6356
|
addUploadBubble,
|
|
6191
6357
|
addDivider,
|
|
6358
|
+
apiConnected: api.connected,
|
|
6192
6359
|
apiConfigReady: api.configReady
|
|
6193
6360
|
};
|
|
6194
6361
|
};
|
|
@@ -6318,11 +6485,12 @@ const useSeamlyEntry = () => {
|
|
|
6318
6485
|
default: defaultEntry,
|
|
6319
6486
|
active,
|
|
6320
6487
|
userSelected,
|
|
6321
|
-
options: entryOptions
|
|
6488
|
+
options: entryOptions,
|
|
6489
|
+
optionsOverride: entryOptionsOverride
|
|
6322
6490
|
} = useSeamlyStateContext().entryMeta;
|
|
6323
6491
|
const dispatch = useSeamlyDispatchContext();
|
|
6324
6492
|
const activeEntry = userSelected || active || defaultEntry;
|
|
6325
|
-
const activeEntryOptions = entryOptions[activeEntry] || {};
|
|
6493
|
+
const activeEntryOptions = entryOptionsOverride[activeEntry] || entryOptions[activeEntry] || {};
|
|
6326
6494
|
const setBlockAutoEntrySwitch = useCallback(value => {
|
|
6327
6495
|
dispatch({
|
|
6328
6496
|
type: seamly_entry_hooks_SET_BLOCK_AUTO_ENTRY_SWITCH,
|
|
@@ -6368,6 +6536,7 @@ const useSeamlyEntry = () => {
|
|
|
6368
6536
|
|
|
6369
6537
|
|
|
6370
6538
|
|
|
6539
|
+
|
|
6371
6540
|
const {
|
|
6372
6541
|
SET_IS_LOADING: use_seamly_chat_SET_IS_LOADING
|
|
6373
6542
|
} = seamly_utils_seamlyActions;
|
|
@@ -6377,28 +6546,31 @@ const useSeamlyChat = () => {
|
|
|
6377
6546
|
t
|
|
6378
6547
|
} = useI18n();
|
|
6379
6548
|
const {
|
|
6380
|
-
|
|
6381
|
-
|
|
6549
|
+
isInline,
|
|
6550
|
+
isWindow
|
|
6551
|
+
} = useSeamlyLayoutMode();
|
|
6382
6552
|
const {
|
|
6383
6553
|
isOpen,
|
|
6384
6554
|
isVisible,
|
|
6385
6555
|
setVisibility
|
|
6386
6556
|
} = useVisibility();
|
|
6557
|
+
const showInlineView = useSelector(selectShowInlineView);
|
|
6387
6558
|
const dispatch = useSeamlyDispatchContext();
|
|
6388
6559
|
const events = useEvents();
|
|
6389
6560
|
const spinnerTimeout = useRef(null);
|
|
6390
6561
|
const {
|
|
6391
6562
|
start,
|
|
6392
6563
|
connect,
|
|
6393
|
-
apiConfigReady
|
|
6564
|
+
apiConfigReady,
|
|
6565
|
+
apiConnected
|
|
6394
6566
|
} = useSeamlyCommands();
|
|
6395
6567
|
const hasConversation = useSeamlyHasConversation();
|
|
6396
6568
|
const prevIsOpen = useRef(null);
|
|
6397
6569
|
const prevIsVisible = useRef(null);
|
|
6570
|
+
const startCalled = useRef(false);
|
|
6398
6571
|
const {
|
|
6399
6572
|
sendAssertive
|
|
6400
6573
|
} = useLiveRegion();
|
|
6401
|
-
const connectCalled = useRef(false);
|
|
6402
6574
|
const hasEvents = events.length > 0;
|
|
6403
6575
|
useEffect(() => {
|
|
6404
6576
|
if (isVisible) {
|
|
@@ -6447,22 +6619,34 @@ const useSeamlyChat = () => {
|
|
|
6447
6619
|
}
|
|
6448
6620
|
}, [hasEvents, dispatch]);
|
|
6449
6621
|
useEffect(() => {
|
|
6450
|
-
// This is needed to reset the ref to allow connect to happen again.
|
|
6622
|
+
// This is needed to reset the ref to allow connect and start to happen again.
|
|
6451
6623
|
// Mostly due to Interrupt situations and a reset being called.
|
|
6452
|
-
if (!
|
|
6453
|
-
|
|
6624
|
+
if (!apiConfigReady || !apiConnected) {
|
|
6625
|
+
startCalled.current = false;
|
|
6626
|
+
}
|
|
6627
|
+
}, [apiConfigReady, apiConnected]);
|
|
6628
|
+
const connectAndStart = useCallback(async () => {
|
|
6629
|
+
// We don't connect if we are already connected to the api to avoid multiple in-flight connection processes.
|
|
6630
|
+
if (!apiConnected) {
|
|
6631
|
+
await connect();
|
|
6632
|
+
} // We only start a conversation when the chat interface is either 'open' or if using the inline view if it's 'open' or 'minimized'.
|
|
6633
|
+
|
|
6634
|
+
|
|
6635
|
+
if (isOpen || isVisible && isInline) {
|
|
6636
|
+
start();
|
|
6637
|
+
startCalled.current = true;
|
|
6454
6638
|
}
|
|
6455
|
-
}, [
|
|
6639
|
+
}, [apiConnected, connect, isInline, isOpen, isVisible, start]);
|
|
6456
6640
|
useEffect(() => {
|
|
6457
|
-
// We
|
|
6458
|
-
//
|
|
6459
|
-
// We
|
|
6460
|
-
//
|
|
6461
|
-
if (
|
|
6641
|
+
// We dont't connect or start when the apiConfig is not ready yet.
|
|
6642
|
+
// We also keep track of whether start has been called to avoid multiple in-flight connection processes.
|
|
6643
|
+
// We check if the window view is not open and no conversation is started yet.
|
|
6644
|
+
// Lastly we check if the inline view is not scrolled in to view.
|
|
6645
|
+
if (!apiConfigReady || startCalled.current || isWindow && !isOpen && !hasConversation || isInline && !showInlineView) {
|
|
6462
6646
|
return;
|
|
6463
6647
|
}
|
|
6464
6648
|
|
|
6465
|
-
if (hasConversation) {
|
|
6649
|
+
if (hasConversation && isOpen) {
|
|
6466
6650
|
// We deactivate the extra startup loading spinner when a conversation is available
|
|
6467
6651
|
// We also stop setting the loading indicator in the first place to avoid a flash.
|
|
6468
6652
|
clearTimeout(spinnerTimeout.current);
|
|
@@ -6472,11 +6656,8 @@ const useSeamlyChat = () => {
|
|
|
6472
6656
|
});
|
|
6473
6657
|
}
|
|
6474
6658
|
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
});
|
|
6478
|
-
connectCalled.current = true;
|
|
6479
|
-
}, [isOpen, hasConversation, apiConfigReady, start, connect, dispatch, layoutMode]);
|
|
6659
|
+
connectAndStart();
|
|
6660
|
+
}, [apiConfigReady, connectAndStart, dispatch, hasConversation, isInline, isOpen, isWindow, showInlineView]);
|
|
6480
6661
|
|
|
6481
6662
|
const openChat = () => {
|
|
6482
6663
|
setVisibility(visibilityStates.open);
|
|
@@ -6793,19 +6974,21 @@ function hooks_useTranslations() {
|
|
|
6793
6974
|
function useTranslatedEventData({
|
|
6794
6975
|
payload
|
|
6795
6976
|
} = {}) {
|
|
6796
|
-
|
|
6977
|
+
var _translatedBody, _translatedBody2, _translatedBody3;
|
|
6978
|
+
|
|
6979
|
+
const payloadId = payload === null || payload === void 0 ? void 0 : payload.id;
|
|
6797
6980
|
let body;
|
|
6798
6981
|
let translatedBody;
|
|
6799
6982
|
|
|
6800
|
-
switch (payload
|
|
6983
|
+
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
6801
6984
|
case 'participant':
|
|
6802
6985
|
body = payload.participant.introduction;
|
|
6803
6986
|
translatedBody = payload.participant.translatedIntroduction;
|
|
6804
6987
|
break;
|
|
6805
6988
|
|
|
6806
6989
|
default:
|
|
6807
|
-
body = payload
|
|
6808
|
-
translatedBody = payload
|
|
6990
|
+
body = payload === null || payload === void 0 ? void 0 : payload.body;
|
|
6991
|
+
translatedBody = payload === null || payload === void 0 ? void 0 : payload.translatedBody;
|
|
6809
6992
|
}
|
|
6810
6993
|
|
|
6811
6994
|
const hasTranslation = !!translatedBody;
|
|
@@ -6820,12 +7003,12 @@ function useTranslatedEventData({
|
|
|
6820
7003
|
dispatch(Actions.enableEvent(payloadId));
|
|
6821
7004
|
}
|
|
6822
7005
|
}, [isTranslated, payloadId, dispatch]);
|
|
6823
|
-
return [hasTranslation && isTranslated ? translatedBody
|
|
7006
|
+
return [hasTranslation && isTranslated ? (_translatedBody = translatedBody) === null || _translatedBody === void 0 ? void 0 : _translatedBody.data : body, {
|
|
6824
7007
|
hasTranslation,
|
|
6825
7008
|
isTranslated: isTranslated && hasTranslation,
|
|
6826
7009
|
toggleTranslation,
|
|
6827
|
-
translatedBy: translatedBody
|
|
6828
|
-
locale: translatedBody
|
|
7010
|
+
translatedBy: (_translatedBody2 = translatedBody) === null || _translatedBody2 === void 0 ? void 0 : _translatedBody2.translatedBy,
|
|
7011
|
+
locale: (_translatedBody3 = translatedBody) === null || _translatedBody3 === void 0 ? void 0 : _translatedBody3.locale
|
|
6829
7012
|
}];
|
|
6830
7013
|
}
|
|
6831
7014
|
function hooks_useTranslationsContainer() {
|
|
@@ -6840,49 +7023,58 @@ function hooks_useLocaleNativeName(locale) {
|
|
|
6840
7023
|
const {
|
|
6841
7024
|
languages
|
|
6842
7025
|
} = hooks_useTranslations();
|
|
6843
|
-
return useMemo(() =>
|
|
7026
|
+
return useMemo(() => {
|
|
7027
|
+
var _languages$find;
|
|
7028
|
+
|
|
7029
|
+
return languages === null || languages === void 0 ? void 0 : (_languages$find = languages.find(lang => lang.locale === locale)) === null || _languages$find === void 0 ? void 0 : _languages$find.nativeName;
|
|
7030
|
+
}, [locale, languages]);
|
|
6844
7031
|
}
|
|
6845
7032
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/middleware.js
|
|
6846
7033
|
|
|
6847
7034
|
|
|
6848
7035
|
|
|
6849
|
-
function middleware_createMiddleware(
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
7036
|
+
function middleware_createMiddleware({
|
|
7037
|
+
dispatch,
|
|
7038
|
+
getState
|
|
7039
|
+
}) {
|
|
7040
|
+
return next => {
|
|
7041
|
+
return action => {
|
|
7042
|
+
var _action$history, _action$history$trans, _action$initialState, _action$initialState$, _action$event, _action$event$payload, _action$event$payload2;
|
|
6855
7043
|
|
|
6856
|
-
|
|
6857
|
-
case String(seamlyActions.SET_HISTORY):
|
|
6858
|
-
if (action.history?.translation?.enabled) {
|
|
6859
|
-
dispatch(Actions.enable(action.history.translation.locale));
|
|
6860
|
-
}
|
|
7044
|
+
const result = next(action);
|
|
6861
7045
|
|
|
6862
|
-
|
|
7046
|
+
switch (action.type) {
|
|
7047
|
+
case String(seamlyActions.SET_HISTORY):
|
|
7048
|
+
if ((_action$history = action.history) !== null && _action$history !== void 0 && (_action$history$trans = _action$history.translation) !== null && _action$history$trans !== void 0 && _action$history$trans.enabled) {
|
|
7049
|
+
dispatch(Actions.enable(action.history.translation.locale));
|
|
7050
|
+
dispatch(I18nActions.setLocale(action.history.translation.locale));
|
|
7051
|
+
}
|
|
6863
7052
|
|
|
6864
|
-
|
|
6865
|
-
if (action.initialState?.translation?.enabled) {
|
|
6866
|
-
dispatch(Actions.enable(action.initialState.translation.locale));
|
|
6867
|
-
dispatch(I18nActions.setLocale(action.locale));
|
|
6868
|
-
}
|
|
7053
|
+
break;
|
|
6869
7054
|
|
|
6870
|
-
|
|
7055
|
+
case String(seamlyActions.SET_INITIAL_STATE):
|
|
7056
|
+
if ((_action$initialState = action.initialState) !== null && _action$initialState !== void 0 && (_action$initialState$ = _action$initialState.translation) !== null && _action$initialState$ !== void 0 && _action$initialState$.enabled) {
|
|
7057
|
+
dispatch(Actions.enable(action.initialState.translation.locale));
|
|
7058
|
+
dispatch(I18nActions.setLocale(action.locale));
|
|
7059
|
+
}
|
|
6871
7060
|
|
|
6872
|
-
|
|
6873
|
-
if (action.event.type === 'info' && action.event?.payload?.body?.subtype === 'new_translation' && action.event.payload.body.translationEnabled) {
|
|
6874
|
-
dispatch(I18nActions.setLocale(action.event.payload.body.translationLocale));
|
|
6875
|
-
}
|
|
7061
|
+
break;
|
|
6876
7062
|
|
|
6877
|
-
|
|
7063
|
+
case String(seamlyActions.ADD_EVENT):
|
|
7064
|
+
if (action.event.type === 'info' && ((_action$event = action.event) === null || _action$event === void 0 ? void 0 : (_action$event$payload = _action$event.payload) === null || _action$event$payload === void 0 ? void 0 : (_action$event$payload2 = _action$event$payload.body) === null || _action$event$payload2 === void 0 ? void 0 : _action$event$payload2.subtype) === 'new_translation' && action.event.payload.body.translationEnabled) {
|
|
7065
|
+
dispatch(I18nActions.setLocale(action.event.payload.body.translationLocale));
|
|
7066
|
+
}
|
|
6878
7067
|
|
|
6879
|
-
|
|
6880
|
-
const initialLocale = I18nSelectors.selectInitialLocale(getState());
|
|
6881
|
-
dispatch(I18nActions.setLocale(initialLocale));
|
|
6882
|
-
break;
|
|
6883
|
-
}
|
|
7068
|
+
break;
|
|
6884
7069
|
|
|
6885
|
-
|
|
7070
|
+
case String(Actions.disable):
|
|
7071
|
+
const initialLocale = I18nSelectors.selectInitialLocale(getState());
|
|
7072
|
+
dispatch(I18nActions.setLocale(initialLocale));
|
|
7073
|
+
break;
|
|
7074
|
+
}
|
|
7075
|
+
|
|
7076
|
+
return result;
|
|
7077
|
+
};
|
|
6886
7078
|
};
|
|
6887
7079
|
}
|
|
6888
7080
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/reducer.js
|
|
@@ -6907,7 +7099,9 @@ const translations_reducer_initialState = {
|
|
|
6907
7099
|
};
|
|
6908
7100
|
/* harmony default export */ const translations_reducer = (translations_utils_createReducer({
|
|
6909
7101
|
[seamly_utils_seamlyActions.SET_FEATURES]: (state, action) => {
|
|
6910
|
-
|
|
7102
|
+
var _action$features;
|
|
7103
|
+
|
|
7104
|
+
const feature = action === null || action === void 0 ? void 0 : (_action$features = action.features) === null || _action$features === void 0 ? void 0 : _action$features.translation;
|
|
6911
7105
|
|
|
6912
7106
|
if (!feature) {
|
|
6913
7107
|
return state;
|
|
@@ -7950,7 +8144,7 @@ const app_reducer_initialState = {
|
|
|
7950
8144
|
userHasResponded: false
|
|
7951
8145
|
};
|
|
7952
8146
|
/* harmony default export */ const app_reducer = (app_utils_createReducer({
|
|
7953
|
-
[
|
|
8147
|
+
[actions_setHasResponded]: (state, {
|
|
7954
8148
|
hasResponded
|
|
7955
8149
|
}) => app_reducer_objectSpread(app_reducer_objectSpread({}, state), {}, {
|
|
7956
8150
|
userHasResponded: hasResponded
|
|
@@ -8298,6 +8492,7 @@ const StyleGuideApp = ({
|
|
|
8298
8492
|
|
|
8299
8493
|
const updatedState = app_objectSpread(app_objectSpread({}, bareState), {}, {
|
|
8300
8494
|
config: app_objectSpread(app_objectSpread(app_objectSpread(app_objectSpread({}, bareState.config), config), {}, {
|
|
8495
|
+
showDisclaimer: bareState.config.showDisclaimer || config.showDisclaimer,
|
|
8301
8496
|
layoutMode: bareState.config.layoutMode
|
|
8302
8497
|
}, overrideMessages ? {
|
|
8303
8498
|
messages: overrideMessages
|
|
@@ -8305,7 +8500,7 @@ const StyleGuideApp = ({
|
|
|
8305
8500
|
showFaq
|
|
8306
8501
|
}),
|
|
8307
8502
|
headerTitles: app_objectSpread(app_objectSpread({}, bareState.headerTitles), {}, {
|
|
8308
|
-
subTitle: agent
|
|
8503
|
+
subTitle: (agent === null || agent === void 0 ? void 0 : agent.name) || bareState.headerTitles.subTitle
|
|
8309
8504
|
})
|
|
8310
8505
|
});
|
|
8311
8506
|
|