@seamly/web-ui 21.0.7 → 21.0.9

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.
Files changed (44) hide show
  1. package/build/dist/lib/components.js +224 -231
  2. package/build/dist/lib/components.min.js +1 -1
  3. package/build/dist/lib/hooks.js +116 -16
  4. package/build/dist/lib/hooks.min.js +1 -1
  5. package/build/dist/lib/index.debug.js +50 -39
  6. package/build/dist/lib/index.debug.min.js +1 -1
  7. package/build/dist/lib/index.debug.min.js.LICENSE.txt +5 -1
  8. package/build/dist/lib/index.js +208 -220
  9. package/build/dist/lib/index.min.js +1 -1
  10. package/build/dist/lib/standalone.js +215 -251
  11. package/build/dist/lib/standalone.min.js +1 -1
  12. package/build/dist/lib/style-guide.js +194 -191
  13. package/build/dist/lib/style-guide.min.js +1 -1
  14. package/build/dist/lib/utils.js +192 -189
  15. package/build/dist/lib/utils.min.js +1 -1
  16. package/package.json +1 -1
  17. package/src/javascripts/domains/forms/provider.tsx +1 -1
  18. package/src/javascripts/domains/i18n/slice.ts +2 -0
  19. package/src/javascripts/domains/interrupt/hooks.ts +15 -7
  20. package/src/javascripts/domains/interrupt/middleware.ts +7 -14
  21. package/src/javascripts/domains/interrupt/selectors.ts +4 -0
  22. package/src/javascripts/domains/interrupt/slice.ts +2 -2
  23. package/src/javascripts/domains/translations/components/translation-status.tsx +4 -3
  24. package/src/javascripts/domains/translations/slice.ts +2 -0
  25. package/src/javascripts/ui/components/app-options/index.js +4 -3
  26. package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +9 -13
  27. package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +5 -5
  28. package/src/javascripts/ui/components/entry/deprecated-toggle-button.js +4 -3
  29. package/src/javascripts/ui/components/faq/faq.js +5 -4
  30. package/src/javascripts/ui/components/layout/agent-info.js +4 -3
  31. package/src/javascripts/ui/components/layout/chat-frame.js +7 -8
  32. package/src/javascripts/ui/components/layout/deprecated-chat-frame.js +7 -8
  33. package/src/javascripts/ui/components/layout/interrupt.js +6 -15
  34. package/src/javascripts/ui/components/layout/pre-chat-messages.js +4 -3
  35. package/src/javascripts/ui/components/suggestions/index.js +5 -4
  36. package/src/javascripts/ui/components/translation-chat-status/index.tsx +4 -3
  37. package/src/javascripts/ui/components/view/app-view.js +1 -2
  38. package/src/javascripts/ui/components/view/deprecated-view.js +1 -2
  39. package/src/javascripts/ui/components/view/inline-view.js +1 -11
  40. package/src/javascripts/ui/components/view/window-view/index.js +1 -9
  41. package/src/javascripts/ui/components/view/window-view/window-open-button.js +4 -3
  42. package/src/javascripts/ui/hooks/{use-seamly-chat.js → use-seamly-chat.ts} +5 -1
  43. package/src/javascripts/ui/hooks/use-session-expired-command.ts +17 -0
  44. package/src/.DS_Store +0 -0
@@ -6608,7 +6608,7 @@ const interruptSlice = createSlice({
6608
6608
  clearInterrupt: () => slice_initialState
6609
6609
  },
6610
6610
  extraReducers: builder => {
6611
- builder.addCase(resetApp.fulfilled, () => slice_initialState).addMatcher(isAnyOf(initializeApp.rejected, actions_initializeConfig.rejected, actions_setLocale.rejected, setVisibility.rejected, initializeVisibility.rejected), (state, {
6611
+ builder.addCase(actions_initializeConfig.pending, () => slice_initialState).addMatcher(isAnyOf(initializeApp.rejected, actions_initializeConfig.rejected, actions_setLocale.rejected, setVisibility.rejected, initializeVisibility.rejected), (state, {
6612
6612
  payload
6613
6613
  }) => {
6614
6614
  state.error = payload;
@@ -6933,6 +6933,7 @@ const {
6933
6933
 
6934
6934
 
6935
6935
 
6936
+
6936
6937
  const i18n_slice_initialState = {
6937
6938
  translations: {
6938
6939
  'errors.configError.message': 'We are sorry this happened, please retry at a later time.',
@@ -6969,7 +6970,7 @@ const i18nSlice = createSlice({
6969
6970
  },
6970
6971
  extraReducers: builder => {
6971
6972
  // Add reducers for additional action types here, and handle loading state as needed
6972
- builder.addCase(actions_initializeConfig.fulfilled, (state, {
6973
+ builder.addCase(resetApp.pending, () => i18n_slice_initialState).addCase(actions_initializeConfig.fulfilled, (state, {
6973
6974
  payload
6974
6975
  }) => {
6975
6976
  state.initialLocale = payload.locale;
@@ -6999,12 +7000,7 @@ const {
6999
7000
  ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/middleware.ts
7000
7001
 
7001
7002
 
7002
-
7003
-
7004
-
7005
-
7006
-
7007
- const handledErrorTypes = [seamly_general_error_SeamlyGeneralError, SeamlyConfigurationError, SeamlySessionExpiredError, SeamlyOfflineError, SeamlyUnauthorizedError, SeamlyUnavailableError];
7003
+ const handledErrorTypes = (/* unused pure expression or super */ null && (['SeamlyGeneralError', 'SeamlyConfigurationError', 'SeamlySessionExpiredError', 'SeamlyOfflineError', 'SeamlyUnauthorizedError', 'SeamlyUnavailableError']));
7008
7004
  function middleware_createInterruptMiddleware({
7009
7005
  api
7010
7006
  }) {
@@ -7014,7 +7010,7 @@ function middleware_createInterruptMiddleware({
7014
7010
  type
7015
7011
  } = action;
7016
7012
  if (type === setInterrupt.type) {
7017
- if (!handledErrorTypes.some(ErrorType => payload.name === ErrorType.name)) {
7013
+ if (!handledErrorTypes.includes(payload.name)) {
7018
7014
  throw new SeamlyGeneralError(payload);
7019
7015
  } else if (payload.action === 'reset') {
7020
7016
  // [SMLY-942] We clear the store before a reset to force a new conversation if the page is refreshed before the conversation is reset
@@ -7055,6 +7051,7 @@ function middleware_createOptionsMiddleware({
7055
7051
 
7056
7052
 
7057
7053
 
7054
+
7058
7055
  const translationsInitialState = {
7059
7056
  isActive: false,
7060
7057
  currentLocale: undefined,
@@ -7145,7 +7142,7 @@ const translationSlice = createSlice({
7145
7142
  }
7146
7143
  },
7147
7144
  extraReducers: builder => {
7148
- builder.addCase(actions_initializeConfig.fulfilled, (state, {
7145
+ builder.addCase(resetApp.pending, () => translationsInitialState).addCase(actions_initializeConfig.fulfilled, (state, {
7149
7146
  payload
7150
7147
  }) => {
7151
7148
  var _a;
@@ -7590,7 +7587,109 @@ const use_seamly_commands_useSeamlyCommands = () => {
7590
7587
  };
7591
7588
  };
7592
7589
  /* harmony default export */ const use_seamly_commands = (use_seamly_commands_useSeamlyCommands);
7593
- ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.js
7590
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/selectors.ts
7591
+
7592
+ const selectError = es_createSelector(({
7593
+ interrupt
7594
+ }) => interrupt, ({
7595
+ error
7596
+ }) => error);
7597
+ const selectHasError = es_createSelector(selectError, error => Boolean(error));
7598
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/hooks.ts
7599
+
7600
+
7601
+
7602
+
7603
+ function useInterrupt() {
7604
+ const {
7605
+ t
7606
+ } = hooks_useI18n();
7607
+ const error = useSelector_useSelector(selectError);
7608
+ const hasError = useSelector_useSelector(selectHasError);
7609
+ const meta = (0,hooks_.useMemo)(() => {
7610
+ if (!hasError) {
7611
+ return {
7612
+ title: undefined,
7613
+ message: undefined,
7614
+ srText: undefined,
7615
+ buttonText: undefined,
7616
+ originalError: undefined
7617
+ };
7618
+ }
7619
+ const {
7620
+ langKey,
7621
+ action
7622
+ } = error;
7623
+ const title = t(`${langKey}.title`);
7624
+ const message = t(`${langKey}.message`);
7625
+ const srText = t(`${langKey}.srText`);
7626
+ const buttonText = t(`${langKey}.buttonText`);
7627
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, langKey ? {
7628
+ title,
7629
+ message,
7630
+ srText
7631
+ } : {}), action ? {
7632
+ action
7633
+ } : {}), action && langKey ? {
7634
+ buttonText
7635
+ } : {}), {
7636
+ originalError: error
7637
+ });
7638
+ }, [hasError, error, t]);
7639
+ return {
7640
+ hasError,
7641
+ meta,
7642
+ error
7643
+ };
7644
+ }
7645
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-session-expired-command.ts
7646
+
7647
+
7648
+
7649
+ function useSessionExpiredCommand() {
7650
+ const {
7651
+ meta: {
7652
+ originalError,
7653
+ action
7654
+ }
7655
+ } = useInterrupt();
7656
+ const seamlyCommands = use_seamly_commands();
7657
+ const isExpiredError = (originalError === null || originalError === void 0 ? void 0 : originalError.name) === 'SeamlySessionExpiredError';
7658
+ (0,hooks_.useEffect)(() => {
7659
+ if (isExpiredError && seamlyCommands[action]) {
7660
+ seamlyCommands[action]();
7661
+ }
7662
+ }, [action, seamlyCommands, isExpiredError]);
7663
+ }
7664
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.ts
7665
+ var use_seamly_chat_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
7666
+ function adopt(value) {
7667
+ return value instanceof P ? value : new P(function (resolve) {
7668
+ resolve(value);
7669
+ });
7670
+ }
7671
+ return new (P || (P = Promise))(function (resolve, reject) {
7672
+ function fulfilled(value) {
7673
+ try {
7674
+ step(generator.next(value));
7675
+ } catch (e) {
7676
+ reject(e);
7677
+ }
7678
+ }
7679
+ function rejected(value) {
7680
+ try {
7681
+ step(generator["throw"](value));
7682
+ } catch (e) {
7683
+ reject(e);
7684
+ }
7685
+ }
7686
+ function step(result) {
7687
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
7688
+ }
7689
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
7690
+ });
7691
+ };
7692
+
7594
7693
 
7595
7694
 
7596
7695
 
@@ -7629,6 +7728,8 @@ const useSeamlyChat = () => {
7629
7728
  const {
7630
7729
  sendAssertive
7631
7730
  } = live_region_hooks_useLiveRegion();
7731
+ // Automatically reset conversation if the session has expired
7732
+ useSessionExpiredCommand();
7632
7733
  (0,hooks_.useEffect)(() => {
7633
7734
  if (isVisible) {
7634
7735
  // Wait for the live containers to stabilise in the DOM before injecting
@@ -7675,24 +7776,23 @@ const useSeamlyChat = () => {
7675
7776
  connectCalled.current = false;
7676
7777
  }
7677
7778
  }, [apiConfigReady, apiConnected]);
7678
- const connectAndStart = (0,hooks_.useCallback)(async () => {
7779
+ const connectAndStart = (0,hooks_.useCallback)(() => use_seamly_chat_awaiter(void 0, void 0, void 0, function* () {
7679
7780
  // We don't connect if we are already connected to the api to avoid multiple in-flight connection processes.
7680
7781
  if (!apiConnected) {
7681
7782
  connectCalled.current = true;
7682
- await connect();
7783
+ yield connect();
7683
7784
  }
7684
-
7685
7785
  // We only start a conversation when the chat interface is either app, 'open' or if using the inline view if it's 'open' or 'minimized'.
7686
7786
  if (isApp || isOpen || isVisible && isInline) {
7687
7787
  start();
7688
7788
  }
7689
- }, [apiConnected, connect, isApp, isInline, isOpen, isVisible, start]);
7789
+ }), [apiConnected, connect, isApp, isInline, isOpen, isVisible, start]);
7690
7790
  (0,hooks_.useEffect)(() => {
7691
7791
  // We dont't connect or start when the apiConfig is not ready yet.
7692
7792
  // We also keep track of whether start has been called to avoid multiple in-flight connection processes.
7693
7793
  // We check if the window view is not open and no conversation is started yet.
7694
7794
  // Lastly we check if the inline view is not scrolled in to view.
7695
- if (!apiConfigReady || connectCalled.current || isWindow && !isOpen && !hasConversation() || isInline && (!isVisible || !showInlineView)) {
7795
+ if (!apiConfigReady || connectCalled.current || isWindow && !isOpen || isInline && (!isVisible || !showInlineView)) {
7696
7796
  return;
7697
7797
  }
7698
7798
  if (hasConversation() && isOpen) {