@seamly/web-ui 21.0.8 → 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 (43) hide show
  1. package/build/dist/lib/components.js +222 -224
  2. package/build/dist/lib/components.min.js +1 -1
  3. package/build/dist/lib/hooks.js +114 -9
  4. package/build/dist/lib/hooks.min.js +1 -1
  5. package/build/dist/lib/index.debug.js +49 -38
  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 +206 -213
  9. package/build/dist/lib/index.min.js +1 -1
  10. package/build/dist/lib/standalone.js +213 -244
  11. package/build/dist/lib/standalone.min.js +1 -1
  12. package/build/dist/lib/style-guide.js +192 -184
  13. package/build/dist/lib/style-guide.min.js +1 -1
  14. package/build/dist/lib/utils.js +190 -182
  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/selectors.ts +4 -0
  21. package/src/javascripts/domains/interrupt/slice.ts +2 -2
  22. package/src/javascripts/domains/translations/components/translation-status.tsx +4 -3
  23. package/src/javascripts/domains/translations/slice.ts +2 -0
  24. package/src/javascripts/ui/components/app-options/index.js +4 -3
  25. package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +9 -13
  26. package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +5 -5
  27. package/src/javascripts/ui/components/entry/deprecated-toggle-button.js +4 -3
  28. package/src/javascripts/ui/components/faq/faq.js +5 -4
  29. package/src/javascripts/ui/components/layout/agent-info.js +4 -3
  30. package/src/javascripts/ui/components/layout/chat-frame.js +7 -8
  31. package/src/javascripts/ui/components/layout/deprecated-chat-frame.js +7 -8
  32. package/src/javascripts/ui/components/layout/interrupt.js +6 -15
  33. package/src/javascripts/ui/components/layout/pre-chat-messages.js +4 -3
  34. package/src/javascripts/ui/components/suggestions/index.js +5 -4
  35. package/src/javascripts/ui/components/translation-chat-status/index.tsx +4 -3
  36. package/src/javascripts/ui/components/view/app-view.js +1 -2
  37. package/src/javascripts/ui/components/view/deprecated-view.js +1 -2
  38. package/src/javascripts/ui/components/view/inline-view.js +1 -11
  39. package/src/javascripts/ui/components/view/window-view/index.js +1 -9
  40. package/src/javascripts/ui/components/view/window-view/window-open-button.js +4 -3
  41. package/src/javascripts/ui/hooks/{use-seamly-chat.js → use-seamly-chat.ts} +5 -1
  42. package/src/javascripts/ui/hooks/use-session-expired-command.ts +17 -0
  43. package/src/.DS_Store +0 -0
@@ -6660,7 +6660,7 @@ const interruptSlice = createSlice({
6660
6660
  clearInterrupt: () => slice_initialState
6661
6661
  },
6662
6662
  extraReducers: builder => {
6663
- builder.addCase(resetApp.fulfilled, () => slice_initialState).addMatcher(isAnyOf(initializeApp.rejected, actions_initializeConfig.rejected, actions_setLocale.rejected, setVisibility.rejected, initializeVisibility.rejected), (state, {
6663
+ builder.addCase(actions_initializeConfig.pending, () => slice_initialState).addMatcher(isAnyOf(initializeApp.rejected, actions_initializeConfig.rejected, actions_setLocale.rejected, setVisibility.rejected, initializeVisibility.rejected), (state, {
6664
6664
  payload
6665
6665
  }) => {
6666
6666
  state.error = payload;
@@ -6985,6 +6985,7 @@ const {
6985
6985
 
6986
6986
 
6987
6987
 
6988
+
6988
6989
  const i18n_slice_initialState = {
6989
6990
  translations: {
6990
6991
  'errors.configError.message': 'We are sorry this happened, please retry at a later time.',
@@ -7021,7 +7022,7 @@ const i18nSlice = createSlice({
7021
7022
  },
7022
7023
  extraReducers: builder => {
7023
7024
  // Add reducers for additional action types here, and handle loading state as needed
7024
- builder.addCase(actions_initializeConfig.fulfilled, (state, {
7025
+ builder.addCase(resetApp.pending, () => i18n_slice_initialState).addCase(actions_initializeConfig.fulfilled, (state, {
7025
7026
  payload
7026
7027
  }) => {
7027
7028
  state.initialLocale = payload.locale;
@@ -7102,6 +7103,7 @@ function middleware_createOptionsMiddleware({
7102
7103
 
7103
7104
 
7104
7105
 
7106
+
7105
7107
  const translationsInitialState = {
7106
7108
  isActive: false,
7107
7109
  currentLocale: undefined,
@@ -7192,7 +7194,7 @@ const translationSlice = createSlice({
7192
7194
  }
7193
7195
  },
7194
7196
  extraReducers: builder => {
7195
- builder.addCase(actions_initializeConfig.fulfilled, (state, {
7197
+ builder.addCase(resetApp.pending, () => translationsInitialState).addCase(actions_initializeConfig.fulfilled, (state, {
7196
7198
  payload
7197
7199
  }) => {
7198
7200
  var _a;
@@ -7637,7 +7639,109 @@ const use_seamly_commands_useSeamlyCommands = () => {
7637
7639
  };
7638
7640
  };
7639
7641
  /* harmony default export */ const use_seamly_commands = (use_seamly_commands_useSeamlyCommands);
7640
- ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.js
7642
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/selectors.ts
7643
+
7644
+ const selectError = es_createSelector(({
7645
+ interrupt
7646
+ }) => interrupt, ({
7647
+ error
7648
+ }) => error);
7649
+ const selectHasError = es_createSelector(selectError, error => Boolean(error));
7650
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/hooks.ts
7651
+
7652
+
7653
+
7654
+
7655
+ function hooks_useInterrupt() {
7656
+ const {
7657
+ t
7658
+ } = hooks_useI18n();
7659
+ const error = useSelector_useSelector(selectError);
7660
+ const hasError = useSelector_useSelector(selectHasError);
7661
+ const meta = (0,hooks_.useMemo)(() => {
7662
+ if (!hasError) {
7663
+ return {
7664
+ title: undefined,
7665
+ message: undefined,
7666
+ srText: undefined,
7667
+ buttonText: undefined,
7668
+ originalError: undefined
7669
+ };
7670
+ }
7671
+ const {
7672
+ langKey,
7673
+ action
7674
+ } = error;
7675
+ const title = t(`${langKey}.title`);
7676
+ const message = t(`${langKey}.message`);
7677
+ const srText = t(`${langKey}.srText`);
7678
+ const buttonText = t(`${langKey}.buttonText`);
7679
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, langKey ? {
7680
+ title,
7681
+ message,
7682
+ srText
7683
+ } : {}), action ? {
7684
+ action
7685
+ } : {}), action && langKey ? {
7686
+ buttonText
7687
+ } : {}), {
7688
+ originalError: error
7689
+ });
7690
+ }, [hasError, error, t]);
7691
+ return {
7692
+ hasError,
7693
+ meta,
7694
+ error
7695
+ };
7696
+ }
7697
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-session-expired-command.ts
7698
+
7699
+
7700
+
7701
+ function use_session_expired_command_useSessionExpiredCommand() {
7702
+ const {
7703
+ meta: {
7704
+ originalError,
7705
+ action
7706
+ }
7707
+ } = useInterrupt();
7708
+ const seamlyCommands = useSeamlyCommands();
7709
+ const isExpiredError = (originalError === null || originalError === void 0 ? void 0 : originalError.name) === 'SeamlySessionExpiredError';
7710
+ useEffect(() => {
7711
+ if (isExpiredError && seamlyCommands[action]) {
7712
+ seamlyCommands[action]();
7713
+ }
7714
+ }, [action, seamlyCommands, isExpiredError]);
7715
+ }
7716
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.ts
7717
+ var use_seamly_chat_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
7718
+ function adopt(value) {
7719
+ return value instanceof P ? value : new P(function (resolve) {
7720
+ resolve(value);
7721
+ });
7722
+ }
7723
+ return new (P || (P = Promise))(function (resolve, reject) {
7724
+ function fulfilled(value) {
7725
+ try {
7726
+ step(generator.next(value));
7727
+ } catch (e) {
7728
+ reject(e);
7729
+ }
7730
+ }
7731
+ function rejected(value) {
7732
+ try {
7733
+ step(generator["throw"](value));
7734
+ } catch (e) {
7735
+ reject(e);
7736
+ }
7737
+ }
7738
+ function step(result) {
7739
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
7740
+ }
7741
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
7742
+ });
7743
+ };
7744
+
7641
7745
 
7642
7746
 
7643
7747
 
@@ -7676,6 +7780,8 @@ const useSeamlyChat = () => {
7676
7780
  const {
7677
7781
  sendAssertive
7678
7782
  } = useLiveRegion();
7783
+ // Automatically reset conversation if the session has expired
7784
+ useSessionExpiredCommand();
7679
7785
  useEffect(() => {
7680
7786
  if (isVisible) {
7681
7787
  // Wait for the live containers to stabilise in the DOM before injecting
@@ -7722,24 +7828,23 @@ const useSeamlyChat = () => {
7722
7828
  connectCalled.current = false;
7723
7829
  }
7724
7830
  }, [apiConfigReady, apiConnected]);
7725
- const connectAndStart = useCallback(async () => {
7831
+ const connectAndStart = useCallback(() => use_seamly_chat_awaiter(void 0, void 0, void 0, function* () {
7726
7832
  // We don't connect if we are already connected to the api to avoid multiple in-flight connection processes.
7727
7833
  if (!apiConnected) {
7728
7834
  connectCalled.current = true;
7729
- await connect();
7835
+ yield connect();
7730
7836
  }
7731
-
7732
7837
  // 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'.
7733
7838
  if (isApp || isOpen || isVisible && isInline) {
7734
7839
  start();
7735
7840
  }
7736
- }, [apiConnected, connect, isApp, isInline, isOpen, isVisible, start]);
7841
+ }), [apiConnected, connect, isApp, isInline, isOpen, isVisible, start]);
7737
7842
  useEffect(() => {
7738
7843
  // We dont't connect or start when the apiConfig is not ready yet.
7739
7844
  // We also keep track of whether start has been called to avoid multiple in-flight connection processes.
7740
7845
  // We check if the window view is not open and no conversation is started yet.
7741
7846
  // Lastly we check if the inline view is not scrolled in to view.
7742
- if (!apiConfigReady || connectCalled.current || isWindow && !isOpen && !hasConversation() || isInline && (!isVisible || !showInlineView)) {
7847
+ if (!apiConfigReady || connectCalled.current || isWindow && !isOpen || isInline && (!isVisible || !showInlineView)) {
7743
7848
  return;
7744
7849
  }
7745
7850
  if (hasConversation() && isOpen) {
@@ -11411,52 +11516,6 @@ const Conversation = () => {
11411
11516
  };
11412
11517
  /* harmony default export */ const conversation = (Conversation);
11413
11518
 
11414
- ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/selectors.ts
11415
-
11416
- const selectError = es_createSelector(({
11417
- interrupt
11418
- }) => interrupt, ({
11419
- error
11420
- }) => error);
11421
- ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/hooks.ts
11422
-
11423
-
11424
-
11425
-
11426
- function useInterrupt() {
11427
- const {
11428
- t
11429
- } = hooks_useI18n();
11430
- const error = useSelector_useSelector(selectError);
11431
- const hasInterrupt = Boolean(error);
11432
- const meta = (0,hooks_.useMemo)(() => {
11433
- if (!error) return {};
11434
- const {
11435
- langKey,
11436
- action
11437
- } = error;
11438
- const title = t(`${langKey}.title`);
11439
- const message = t(`${langKey}.message`);
11440
- const srText = t(`${langKey}.srText`);
11441
- const buttonText = t(`${langKey}.buttonText`);
11442
- return Object.assign(Object.assign(Object.assign(Object.assign({}, langKey ? {
11443
- title,
11444
- message,
11445
- srText
11446
- } : {}), action ? {
11447
- action
11448
- } : {}), action && langKey ? {
11449
- buttonText
11450
- } : {}), {
11451
- originalError: error
11452
- });
11453
- }, [t, error]);
11454
- return {
11455
- hasInterrupt,
11456
- meta,
11457
- error
11458
- };
11459
- }
11460
11519
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/entry/deprecated-toggle-button.js
11461
11520
 
11462
11521
 
@@ -11465,6 +11524,7 @@ function useInterrupt() {
11465
11524
 
11466
11525
 
11467
11526
 
11527
+
11468
11528
  // Deprecated Toggle Button, should be removed once it is removed from clients
11469
11529
 
11470
11530
 
@@ -11485,13 +11545,11 @@ const DeprecatedToggleButton = ({
11485
11545
  const focusIfContained = useFocusIfSeamlyContainedFocus();
11486
11546
  const currentAgent = useSeamlyCurrentAgent();
11487
11547
  const agentSubtitle = useSeamlyHeaderData().subTitle;
11488
- const {
11489
- hasInterrupt
11490
- } = useInterrupt();
11548
+ const hasError = useSelector_useSelector(selectHasError);
11491
11549
  const {
11492
11550
  headerCollapseButtonId
11493
11551
  } = useSeamlyStateContext();
11494
- const showAgentInfo = currentAgent && !hasInterrupt;
11552
+ const showAgentInfo = currentAgent && !hasError;
11495
11553
  (0,hooks_.useLayoutEffect)(() => {
11496
11554
  // Because we can close the app from the external API we
11497
11555
  // need to determine if current keyboard focus resides inside
@@ -11992,10 +12050,9 @@ function FormProvider(_a) {
11992
12050
  });
11993
12051
  }, [setExternalErrors]);
11994
12052
  const handleSubmit = (0,hooks_.useCallback)((e) => {
11995
- var _a;
11996
12053
  e.preventDefault();
11997
12054
  // If the submitter is set to being aria-disabled, block the submit action
11998
- const ariaDisabled = ((_a = e.submitter) === null || _a === void 0 ? void 0 : _a.ariaDisabled) === 'true';
12055
+ const ariaDisabled = e.submitter.getAttribute('aria-disabled') === 'true';
11999
12056
  setIsSubmitted(!ariaDisabled);
12000
12057
  if (!ariaDisabled && validationIsValid) {
12001
12058
  dispatch(setHasResponded(true));
@@ -13104,6 +13161,7 @@ const EntryContainer = () => {
13104
13161
 
13105
13162
 
13106
13163
 
13164
+
13107
13165
  const AgentInfo = () => {
13108
13166
  const {
13109
13167
  t
@@ -13117,12 +13175,10 @@ const AgentInfo = () => {
13117
13175
  isOpen
13118
13176
  } = hooks_useVisibility();
13119
13177
  const currentAgent = useSeamlyCurrentAgent();
13120
- const {
13121
- hasInterrupt
13122
- } = useInterrupt();
13178
+ const hasError = useSelector_useSelector(selectHasError);
13123
13179
  const startChatIcon = useStartChatIcon();
13124
13180
  const src = currentAgent?.avatar ?? startChatIcon;
13125
- const displaySubtitle = hasInterrupt ? '' : subTitle;
13181
+ const displaySubtitle = hasError ? '' : subTitle;
13126
13182
  const classNames = ['message-count'];
13127
13183
  if (isOpen) {
13128
13184
  classNames.push('message-count__hide');
@@ -13180,6 +13236,7 @@ const AgentInfo = () => {
13180
13236
 
13181
13237
 
13182
13238
 
13239
+
13183
13240
 
13184
13241
 
13185
13242
  const Suggestions = ({
@@ -13211,9 +13268,7 @@ const Suggestions = ({
13211
13268
  sendPolite
13212
13269
  } = live_region_hooks_useLiveRegion();
13213
13270
  // interrupt & countdown hooks
13214
- const {
13215
- hasInterrupt
13216
- } = useInterrupt();
13271
+ const hasError = useSelector_useSelector(selectHasError);
13217
13272
  const {
13218
13273
  hasCountdown,
13219
13274
  endCountdown
@@ -13230,7 +13285,7 @@ const Suggestions = ({
13230
13285
  } = useTranslatedEventData({
13231
13286
  payload
13232
13287
  });
13233
- const suggestions = (0,hooks_.useMemo)(() => payload && !hasInterrupt ? eventBody : [], [payload, hasInterrupt, eventBody]);
13288
+ const suggestions = (0,hooks_.useMemo)(() => payload && !hasError ? eventBody : [], [payload, hasError, eventBody]);
13234
13289
  const prevSuggestions = (0,hooks_.useRef)(null);
13235
13290
  const prevHasSuggestions = (0,hooks_.useRef)(false);
13236
13291
  const previousRenderedSuggestions = (0,hooks_.useRef)([]);
@@ -13918,6 +13973,7 @@ function TranslationsOptionsButton({ children, position = {
13918
13973
 
13919
13974
 
13920
13975
 
13976
+
13921
13977
  function AppOptions() {
13922
13978
  const {
13923
13979
  menuOptions,
@@ -13926,15 +13982,13 @@ function AppOptions() {
13926
13982
  const {
13927
13983
  isAvailable: isTranslationsAvailable
13928
13984
  } = useTranslations();
13929
- const {
13930
- hasInterrupt
13931
- } = useInterrupt();
13985
+ const hasError = useSelector_useSelector(selectHasError);
13932
13986
  const {
13933
13987
  t,
13934
13988
  locale
13935
13989
  } = hooks_useI18n();
13936
13990
  const localeNativeName = useLocaleNativeName(locale);
13937
- if (!isTranslationsAvailable && (!allowOptionSelection || !menuOptions.length) || hasInterrupt) {
13991
+ if (!isTranslationsAvailable && (!allowOptionSelection || !menuOptions.length) || hasError) {
13938
13992
  return null;
13939
13993
  }
13940
13994
  const openButtonText = t('translations.settings.openButtonText', {
@@ -14167,10 +14221,11 @@ const ChatStatus = ({ children, handleClose, title, closeButtonText, srCloseButt
14167
14221
 
14168
14222
 
14169
14223
 
14224
+
14170
14225
  function TranslationChatStatus() {
14171
14226
  const { t } = hooks_useI18n();
14172
14227
  const { id } = useTranslationsContainer();
14173
- const { hasInterrupt } = useInterrupt();
14228
+ const hasError = useSelector_useSelector(selectHasError);
14174
14229
  const { disableTranslations, currentLocale } = useTranslations();
14175
14230
  const localeNativeName = useLocaleNativeName(currentLocale);
14176
14231
  const focusSkiplinkTarget = useSkiplinkTargetFocusing();
@@ -14179,7 +14234,7 @@ function TranslationChatStatus() {
14179
14234
  disableTranslations();
14180
14235
  focusSkiplinkTarget();
14181
14236
  }, [disableTranslations, focusSkiplinkTarget]);
14182
- if (hasInterrupt) {
14237
+ if (hasError) {
14183
14238
  return null;
14184
14239
  }
14185
14240
  return ((0,jsx_runtime_namespaceObject.jsx)(chat_status, { handleClose: handleClickStop, title: label, id: id, closeButtonText: t('translations.status.stopText'), srCloseButtonText: t('translations.status.srStopText') }));
@@ -14212,21 +14267,86 @@ function TranslationProposal() {
14212
14267
 
14213
14268
 
14214
14269
 
14270
+
14215
14271
  function TranslationStatus() {
14216
- const { hasInterrupt } = useInterrupt();
14272
+ const hasError = useSelector_useSelector(selectHasError);
14217
14273
  const { isActive } = useTranslations();
14218
- if (hasInterrupt) {
14274
+ if (hasError) {
14219
14275
  return null;
14220
14276
  }
14221
14277
  return !isActive ? (0,jsx_runtime_namespaceObject.jsx)(TranslationProposal, {}) : (0,jsx_runtime_namespaceObject.jsx)(TranslationChatStatus, {});
14222
14278
  }
14223
14279
 
14280
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/interrupt.js
14281
+
14282
+
14283
+
14284
+
14285
+
14286
+
14287
+
14288
+
14289
+ const Interrupt = () => {
14290
+ const {
14291
+ meta: {
14292
+ originalError,
14293
+ title,
14294
+ message,
14295
+ buttonText,
14296
+ action,
14297
+ srText
14298
+ }
14299
+ } = hooks_useInterrupt();
14300
+ const seamlyCommands = use_seamly_commands();
14301
+ const headingId = useGeneratedId();
14302
+ const {
14303
+ sendPolite
14304
+ } = live_region_hooks_useLiveRegion();
14305
+ const focusSkiplinkTarget = useSkiplinkTargetFocusing();
14306
+ const isExpiredError = originalError?.name === 'SeamlySessionExpiredError';
14307
+ (0,hooks_.useEffect)(() => {
14308
+ if (!isExpiredError && srText) {
14309
+ // Wait for live regions to stabilise in case this occurs
14310
+ // at an initial render
14311
+ setTimeout(() => {
14312
+ sendPolite(srText);
14313
+ }, 200);
14314
+ }
14315
+ }, [sendPolite, srText, isExpiredError]);
14316
+ const onClickHandler = () => {
14317
+ if (seamlyCommands[action]) {
14318
+ seamlyCommands[action]();
14319
+ }
14320
+ focusSkiplinkTarget();
14321
+ };
14322
+ return !isExpiredError ? (0,jsx_runtime_namespaceObject.jsxs)("section", {
14323
+ className: css_className('interrupt'),
14324
+ "aria-labelledby": headingId,
14325
+ children: [(0,jsx_runtime_namespaceObject.jsx)(collapse_button, {}), (0,jsx_runtime_namespaceObject.jsxs)("div", {
14326
+ className: css_className('interrupt__body'),
14327
+ children: [(0,jsx_runtime_namespaceObject.jsx)("h2", {
14328
+ id: headingId,
14329
+ className: css_className('interrupt__title'),
14330
+ children: title
14331
+ }), (0,jsx_runtime_namespaceObject.jsx)("p", {
14332
+ className: css_className('interrupt__message'),
14333
+ children: message
14334
+ }), buttonText && action && (0,jsx_runtime_namespaceObject.jsx)("div", {
14335
+ className: css_className('interrupt__actions'),
14336
+ children: (0,jsx_runtime_namespaceObject.jsx)("button", {
14337
+ type: "button",
14338
+ className: css_className('button', 'button--primary'),
14339
+ onClick: onClickHandler,
14340
+ children: buttonText
14341
+ })
14342
+ })]
14343
+ })]
14344
+ }) : (0,jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {});
14345
+ };
14346
+ /* harmony default export */ const interrupt = (Interrupt);
14224
14347
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/chat-frame.js
14225
- function chat_frame_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; }
14226
- function chat_frame_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? chat_frame_ownKeys(Object(source), !0).forEach(function (key) { chat_frame_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : chat_frame_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14227
- function chat_frame_defineProperty(obj, key, value) { key = chat_frame_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14228
- function chat_frame_toPropertyKey(arg) { var key = chat_frame_toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14229
- function chat_frame_toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14348
+
14349
+
14230
14350
 
14231
14351
 
14232
14352
 
@@ -14239,21 +14359,14 @@ function chat_frame_toPrimitive(input, hint) { if (typeof input !== "object" ||
14239
14359
 
14240
14360
 
14241
14361
  function ChatFrame({
14242
- children,
14243
- interruptComponent: InterruptComponent
14362
+ children
14244
14363
  }) {
14245
- const {
14246
- hasInterrupt,
14247
- meta
14248
- } = useInterrupt();
14364
+ const hasError = useSelector_useSelector(selectHasError);
14249
14365
  const {
14250
14366
  isOpen
14251
14367
  } = hooks_useVisibility();
14252
- if (hasInterrupt) {
14253
- if (isOpen) {
14254
- return (0,jsx_runtime_namespaceObject.jsx)(InterruptComponent, chat_frame_objectSpread({}, meta));
14255
- }
14256
- return null;
14368
+ if (hasError) {
14369
+ return (0,jsx_runtime_namespaceObject.jsx)(interrupt, {});
14257
14370
  }
14258
14371
  return (0,jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
14259
14372
  children: [(0,jsx_runtime_namespaceObject.jsxs)(chat_scroll_provider, {
@@ -14304,84 +14417,14 @@ const Header = ({
14304
14417
  });
14305
14418
  };
14306
14419
  /* harmony default export */ const header = (Header);
14307
- ;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/interrupt.js
14308
-
14309
-
14310
-
14311
-
14312
-
14313
-
14314
-
14315
- const Interrupt = ({
14316
- originalError,
14317
- title,
14318
- message,
14319
- buttonText,
14320
- action,
14321
- srText
14322
- }) => {
14323
- const seamlyCommands = use_seamly_commands();
14324
- const headingId = useGeneratedId();
14325
- const {
14326
- sendPolite
14327
- } = live_region_hooks_useLiveRegion();
14328
- const focusSkiplinkTarget = useSkiplinkTargetFocusing();
14329
- const isExpiredError = originalError.name === 'SeamlySessionExpiredError';
14330
- (0,hooks_.useEffect)(() => {
14331
- if (isExpiredError && seamlyCommands[action]) {
14332
- seamlyCommands[action]();
14333
- }
14334
- }, [action, seamlyCommands, isExpiredError]);
14335
- (0,hooks_.useEffect)(() => {
14336
- if (!isExpiredError && srText) {
14337
- // Wait for live regions to stabilise in case this occurs
14338
- // at an initial render
14339
- setTimeout(() => {
14340
- sendPolite(srText);
14341
- }, 200);
14342
- }
14343
- }, [sendPolite, srText, isExpiredError]);
14344
- const onClickHandler = () => {
14345
- if (seamlyCommands[action]) {
14346
- seamlyCommands[action]();
14347
- }
14348
- focusSkiplinkTarget();
14349
- };
14350
- return !isExpiredError ? (0,jsx_runtime_namespaceObject.jsxs)("section", {
14351
- className: css_className('interrupt'),
14352
- "aria-labelledby": headingId,
14353
- children: [(0,jsx_runtime_namespaceObject.jsx)(collapse_button, {}), (0,jsx_runtime_namespaceObject.jsxs)("div", {
14354
- className: css_className('interrupt__body'),
14355
- children: [(0,jsx_runtime_namespaceObject.jsx)("h2", {
14356
- id: headingId,
14357
- className: css_className('interrupt__title'),
14358
- children: title
14359
- }), (0,jsx_runtime_namespaceObject.jsx)("p", {
14360
- className: css_className('interrupt__message'),
14361
- children: message
14362
- }), buttonText && action && (0,jsx_runtime_namespaceObject.jsx)("div", {
14363
- className: css_className('interrupt__actions'),
14364
- children: (0,jsx_runtime_namespaceObject.jsx)("button", {
14365
- type: "button",
14366
- className: css_className('button', 'button--primary'),
14367
- onClick: onClickHandler,
14368
- children: buttonText
14369
- })
14370
- })]
14371
- })]
14372
- }) : (0,jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {});
14373
- };
14374
- /* harmony default export */ const interrupt = (Interrupt);
14375
14420
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/view/app-view.js
14376
14421
 
14377
14422
 
14378
14423
 
14379
14424
 
14380
-
14381
14425
  const AppView = () => {
14382
14426
  return (0,jsx_runtime_namespaceObject.jsx)(chat, {
14383
14427
  children: (0,jsx_runtime_namespaceObject.jsx)(chat_frame, {
14384
- interruptComponent: interrupt,
14385
14428
  children: (0,jsx_runtime_namespaceObject.jsx)(conversation, {})
14386
14429
  })
14387
14430
  });
@@ -14394,6 +14437,7 @@ const AppView = () => {
14394
14437
 
14395
14438
 
14396
14439
 
14440
+
14397
14441
  function PreChatMessageEvent({
14398
14442
  event
14399
14443
  }) {
@@ -14407,13 +14451,11 @@ function PreChatMessages() {
14407
14451
  preChatEvents,
14408
14452
  layoutMode
14409
14453
  } = useConfig();
14410
- const {
14411
- hasInterrupt
14412
- } = useInterrupt();
14454
+ const hasError = useSelector_useSelector(selectHasError);
14413
14455
  const {
14414
14456
  isOpen
14415
14457
  } = hooks_useVisibility();
14416
- const isVisible = !(hasInterrupt || !preChatEvents?.length || isOpen);
14458
+ const isVisible = !(hasError || !preChatEvents?.length || isOpen);
14417
14459
  return isVisible && (0,jsx_runtime_namespaceObject.jsx)("ul", {
14418
14460
  className: css_className('pre-chat-messages', `pre-chat-messages--${layoutMode}`),
14419
14461
  "aria-hidden": !isVisible,
@@ -14426,13 +14468,6 @@ function PreChatMessages() {
14426
14468
  });
14427
14469
  }
14428
14470
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/view/inline-view.js
14429
- function inline_view_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; }
14430
- function inline_view_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? inline_view_ownKeys(Object(source), !0).forEach(function (key) { inline_view_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : inline_view_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14431
- function inline_view_defineProperty(obj, key, value) { key = inline_view_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14432
- function inline_view_toPropertyKey(arg) { var key = inline_view_toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14433
- function inline_view_toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14434
-
14435
-
14436
14471
 
14437
14472
 
14438
14473
 
@@ -14452,13 +14487,6 @@ const InlineView = () => {
14452
14487
  const {
14453
14488
  isOpen
14454
14489
  } = hooks_useVisibility();
14455
- const {
14456
- hasInterrupt,
14457
- meta
14458
- } = useInterrupt();
14459
- if (hasInterrupt && !isOpen) {
14460
- return (0,jsx_runtime_namespaceObject.jsx)(interrupt, inline_view_objectSpread({}, meta));
14461
- }
14462
14490
  return (0,jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
14463
14491
  children: [(0,jsx_runtime_namespaceObject.jsx)(in_out_transition, {
14464
14492
  isActive: !isOpen,
@@ -14474,7 +14502,6 @@ const InlineView = () => {
14474
14502
  children: (0,jsx_runtime_namespaceObject.jsx)(chat, {
14475
14503
  ref: containerRef,
14476
14504
  children: showInlineView && (0,jsx_runtime_namespaceObject.jsx)(chat_frame, {
14477
- interruptComponent: interrupt,
14478
14505
  children: isOpen && (0,jsx_runtime_namespaceObject.jsx)(conversation, {})
14479
14506
  })
14480
14507
  })
@@ -14496,13 +14523,12 @@ const InlineView = () => {
14496
14523
 
14497
14524
 
14498
14525
 
14526
+
14499
14527
  const ButtonIcon = () => {
14500
14528
  const startChatIcon = useStartChatIcon();
14501
14529
  const currentAgent = useSeamlyCurrentAgent();
14502
- const {
14503
- hasInterrupt
14504
- } = useInterrupt();
14505
- const isActiveConversation = currentAgent && !hasInterrupt;
14530
+ const hasError = useSelector_useSelector(selectHasError);
14531
+ const isActiveConversation = currentAgent && !hasError;
14506
14532
  const src = isActiveConversation ? currentAgent.avatar : startChatIcon;
14507
14533
  return src ? (0,jsx_runtime_namespaceObject.jsx)("img", {
14508
14534
  className: css_className(isActiveConversation ? 'avatar' : 'icon'),
@@ -14548,13 +14574,6 @@ const WindowOpenButton = ({
14548
14574
  };
14549
14575
  /* harmony default export */ const window_open_button = (WindowOpenButton);
14550
14576
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/view/window-view/index.js
14551
- function window_view_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; }
14552
- function window_view_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? window_view_ownKeys(Object(source), !0).forEach(function (key) { window_view_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : window_view_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14553
- function window_view_defineProperty(obj, key, value) { key = window_view_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14554
- function window_view_toPropertyKey(arg) { var key = window_view_toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14555
- function window_view_toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14556
-
14557
-
14558
14577
 
14559
14578
 
14560
14579
 
@@ -14576,10 +14595,6 @@ const WindowView = () => {
14576
14595
  openChat
14577
14596
  } = hooks_useVisibility();
14578
14597
  const userHasResponded = useUserHasResponded();
14579
- const {
14580
- hasInterrupt,
14581
- meta
14582
- } = useInterrupt();
14583
14598
  const {
14584
14599
  t
14585
14600
  } = hooks_useI18n();
@@ -14591,9 +14606,6 @@ const WindowView = () => {
14591
14606
  }
14592
14607
  }
14593
14608
  }), [continueChatText]);
14594
- if (hasInterrupt && !isOpen) {
14595
- return (0,jsx_runtime_namespaceObject.jsx)(interrupt, window_view_objectSpread({}, meta));
14596
- }
14597
14609
  return (0,jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
14598
14610
  children: [(0,jsx_runtime_namespaceObject.jsx)(window_open_button, {
14599
14611
  onClick: openChat
@@ -14618,7 +14630,6 @@ const WindowView = () => {
14618
14630
  transitionStartState: transitionStartStates.notRendered,
14619
14631
  children: (0,jsx_runtime_namespaceObject.jsx)(chat, {
14620
14632
  children: (0,jsx_runtime_namespaceObject.jsx)(chat_frame, {
14621
- interruptComponent: interrupt,
14622
14633
  children: (0,jsx_runtime_namespaceObject.jsx)(conversation, {})
14623
14634
  })
14624
14635
  })
@@ -14701,11 +14712,8 @@ const View = ({
14701
14712
  };
14702
14713
  /* harmony default export */ const view = (View);
14703
14714
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/deprecated-chat-frame.js
14704
- function deprecated_chat_frame_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; }
14705
- function deprecated_chat_frame_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? deprecated_chat_frame_ownKeys(Object(source), !0).forEach(function (key) { deprecated_chat_frame_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : deprecated_chat_frame_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14706
- function deprecated_chat_frame_defineProperty(obj, key, value) { key = deprecated_chat_frame_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14707
- function deprecated_chat_frame_toPropertyKey(arg) { var key = deprecated_chat_frame_toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14708
- function deprecated_chat_frame_toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14715
+
14716
+
14709
14717
 
14710
14718
 
14711
14719
 
@@ -14717,21 +14725,14 @@ function deprecated_chat_frame_toPrimitive(input, hint) { if (typeof input !== "
14717
14725
 
14718
14726
 
14719
14727
  function deprecated_chat_frame_ChatFrame({
14720
- children,
14721
- interruptComponent: InterruptComponent
14728
+ children
14722
14729
  }) {
14723
- const {
14724
- hasInterrupt,
14725
- meta
14726
- } = useInterrupt();
14727
14730
  const {
14728
14731
  isOpen
14729
14732
  } = hooks_useVisibility();
14730
- if (hasInterrupt) {
14731
- if (isOpen) {
14732
- return (0,jsx_runtime_namespaceObject.jsx)(InterruptComponent, deprecated_chat_frame_objectSpread({}, meta));
14733
- }
14734
- return null;
14733
+ const hasError = useSelector_useSelector(selectHasError);
14734
+ if (hasError) {
14735
+ return (0,jsx_runtime_namespaceObject.jsx)(interrupt, {});
14735
14736
  }
14736
14737
  return (0,jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
14737
14738
  children: [(0,jsx_runtime_namespaceObject.jsxs)(chat_scroll_provider, {
@@ -14771,6 +14772,7 @@ function faq_objectWithoutPropertiesLoose(source, excluded) { if (source == null
14771
14772
 
14772
14773
 
14773
14774
 
14775
+
14774
14776
  const Faq = () => {
14775
14777
  const {
14776
14778
  t
@@ -14784,9 +14786,7 @@ const Faq = () => {
14784
14786
  const {
14785
14787
  sendPolite
14786
14788
  } = live_region_hooks_useLiveRegion();
14787
- const {
14788
- hasInterrupt
14789
- } = useInterrupt();
14789
+ const hasError = useSelector_useSelector(selectHasError);
14790
14790
  const {
14791
14791
  hasCountdown,
14792
14792
  endCountdown
@@ -14802,7 +14802,7 @@ const Faq = () => {
14802
14802
  payload: lastFaqEventPayload
14803
14803
  });
14804
14804
  const faqs = (0,hooks_.useMemo)(() => {
14805
- const newFaqs = lastFaqEventPayload && !hasInterrupt ? eventBody : [];
14805
+ const newFaqs = lastFaqEventPayload && !hasError ? eventBody : [];
14806
14806
  const itemBaseClass = `faqs__item`;
14807
14807
  return newFaqs.map(_ref => {
14808
14808
  let {
@@ -14814,7 +14814,7 @@ const Faq = () => {
14814
14814
  classNames: [itemBaseClass, ...categories.map(cat => `faqs__item--${String(cat).toLowerCase().replace(/[^a-z0-9_\\-]/, '')}`)]
14815
14815
  });
14816
14816
  });
14817
- }, [lastFaqEventPayload, hasInterrupt, eventBody]);
14817
+ }, [lastFaqEventPayload, hasError, eventBody]);
14818
14818
  const prevFaqs = (0,hooks_.useRef)(null);
14819
14819
  const prevHasFaqs = (0,hooks_.useRef)(false);
14820
14820
  const {
@@ -14994,7 +14994,6 @@ const DeprecatedAppFrame = ({
14994
14994
 
14995
14995
 
14996
14996
 
14997
-
14998
14997
  const ShowInlineView = ({
14999
14998
  children
15000
14999
  }) => {
@@ -15021,7 +15020,6 @@ const DeprecatedView = () => {
15021
15020
  onCloseChat: closeChat,
15022
15021
  children: (0,jsx_runtime_namespaceObject.jsx)(agent_info, {})
15023
15022
  }), (0,jsx_runtime_namespaceObject.jsx)(deprecated_chat_frame, {
15024
- interruptComponent: interrupt,
15025
15023
  children: (0,jsx_runtime_namespaceObject.jsx)(conversation, {})
15026
15024
  })]
15027
15025
  })