@seamly/web-ui 22.2.0 → 22.3.0-beta.2

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 (61) hide show
  1. package/build/dist/lib/components.js +449 -291
  2. package/build/dist/lib/components.js.map +1 -1
  3. package/build/dist/lib/components.min.js +1 -1
  4. package/build/dist/lib/components.min.js.map +1 -1
  5. package/build/dist/lib/hooks.js +367 -177
  6. package/build/dist/lib/hooks.js.map +1 -1
  7. package/build/dist/lib/hooks.min.js +1 -1
  8. package/build/dist/lib/hooks.min.js.map +1 -1
  9. package/build/dist/lib/index.debug.js +76 -54
  10. package/build/dist/lib/index.debug.js.map +1 -1
  11. package/build/dist/lib/index.debug.min.js +1 -1
  12. package/build/dist/lib/index.debug.min.js.LICENSE.txt +16 -8
  13. package/build/dist/lib/index.debug.min.js.map +1 -1
  14. package/build/dist/lib/index.js +342 -193
  15. package/build/dist/lib/index.js.map +1 -1
  16. package/build/dist/lib/index.min.js +1 -1
  17. package/build/dist/lib/index.min.js.map +1 -1
  18. package/build/dist/lib/standalone.js +350 -194
  19. package/build/dist/lib/standalone.js.map +1 -1
  20. package/build/dist/lib/standalone.min.js +1 -1
  21. package/build/dist/lib/standalone.min.js.map +1 -1
  22. package/build/dist/lib/style-guide.js +365 -194
  23. package/build/dist/lib/style-guide.js.map +1 -1
  24. package/build/dist/lib/style-guide.min.js +1 -1
  25. package/build/dist/lib/style-guide.min.js.map +1 -1
  26. package/build/dist/lib/styles.css +1 -1
  27. package/build/dist/lib/utils.js +504 -324
  28. package/build/dist/lib/utils.js.map +1 -1
  29. package/build/dist/lib/utils.min.js +1 -1
  30. package/build/dist/lib/utils.min.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/javascripts/api/errors/seamly-api-error.ts +0 -1
  33. package/src/javascripts/api/index.ts +16 -8
  34. package/src/javascripts/domains/app/actions.ts +8 -3
  35. package/src/javascripts/domains/interrupt/selectors.ts +3 -2
  36. package/src/javascripts/domains/interrupt/slice.ts +2 -0
  37. package/src/javascripts/domains/redux/create-debounced-async-thunk.ts +109 -0
  38. package/src/javascripts/domains/redux/redux.types.ts +2 -1
  39. package/src/javascripts/domains/store/actions.ts +38 -0
  40. package/src/javascripts/domains/translations/components/options-dialog/translation-option.tsx +1 -1
  41. package/src/javascripts/domains/visibility/actions.ts +4 -1
  42. package/src/javascripts/style-guide/states.js +26 -1
  43. package/src/javascripts/ui/components/chat-status/chat-status-action.tsx +2 -2
  44. package/src/javascripts/ui/components/conversation/event/{card-component.js → card-component.tsx} +6 -4
  45. package/src/javascripts/ui/components/conversation/event/carousel-component/components/controls.js +2 -2
  46. package/src/javascripts/ui/components/conversation/event/choice-prompt.js +1 -1
  47. package/src/javascripts/ui/components/conversation/event/event-participant.js +1 -1
  48. package/src/javascripts/ui/components/conversation/event/image-lightbox.js +1 -1
  49. package/src/javascripts/ui/components/conversation/event-divider.js +6 -1
  50. package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +14 -30
  51. package/src/javascripts/ui/components/form-controls/error.js +1 -1
  52. package/src/javascripts/ui/components/form-controls/file-input.js +1 -1
  53. package/src/javascripts/ui/components/layout/agent-info.js +1 -1
  54. package/src/javascripts/ui/components/layout/{icon.js → icon.tsx} +74 -37
  55. package/src/javascripts/ui/components/options/options-button.js +1 -1
  56. package/src/javascripts/ui/components/suggestions/suggestions-item.js +1 -1
  57. package/src/javascripts/ui/components/view/window-view/window-open-button.js +9 -4
  58. package/src/javascripts/ui/components/widgets/lightbox.js +1 -1
  59. package/src/javascripts/ui/hooks/use-session-expired-command.ts +31 -2
  60. package/src/stylesheets/5-components/_message-card.scss +4 -3
  61. package/src/stylesheets/5-components/_message-count.scss +11 -9
@@ -12499,7 +12499,8 @@ class API {
12499
12499
  });
12500
12500
  }
12501
12501
  getConversationUrl() {
12502
- return this.store.get('conversationUrl');
12502
+ const conversationUrl = this.store.get('conversationUrl');
12503
+ return conversationUrl;
12503
12504
  }
12504
12505
  hasConversation() {
12505
12506
  return !!this.getConversationUrl();
@@ -12608,7 +12609,7 @@ class API {
12608
12609
  if (error.status >= 500) {
12609
12610
  throw new SeamlyGeneralError(error);
12610
12611
  }
12611
- throw error;
12612
+ throw new ApiError(error);
12612
12613
  }
12613
12614
  });
12614
12615
  }
@@ -12718,7 +12719,7 @@ class API {
12718
12719
  if (error.status >= 500) {
12719
12720
  throw new SeamlyGeneralError(error);
12720
12721
  }
12721
- throw error;
12722
+ throw new ApiError(error);
12722
12723
  }
12723
12724
  });
12724
12725
  }
@@ -12780,15 +12781,17 @@ class API {
12780
12781
  }
12781
12782
  }
12782
12783
  _API_ready = new (weak_map_default())(), _API_externalId = new (weak_map_default())(), _API_conversationAuthToken = new (weak_map_default())(), _API_layoutMode = new (weak_map_default())(), _API_config = new (weak_map_default())(), _API_getLocale = new (weak_map_default())(), _API_instances = new (weak_set_default())(), _API_getAccessToken = function _API_getAccessToken() {
12783
- return this.store.get('accessToken');
12784
+ const accessToken = this.store.get('accessToken');
12785
+ return accessToken;
12784
12786
  }, _API_setAccessToken = function _API_setAccessToken(accessToken) {
12785
12787
  this.store.set('accessToken', accessToken);
12786
12788
  }, _API_setConversationUrl = function _API_setConversationUrl(url) {
12787
12789
  this.store.set('conversationUrl', url);
12788
12790
  }, _API_getChannelTopic = function _API_getChannelTopic() {
12791
+ const channelTopic = this.store.get('channelTopic') || this.store.get('channelName');
12789
12792
  // The `channelName` fallback is needed for seamless client upgrades.
12790
12793
  // TODO: Remove when all clients have been upgraded past v20.
12791
- return this.store.get('channelTopic') || this.store.get('channelName');
12794
+ return channelTopic;
12792
12795
  }, _API_setChannelTopic = function _API_setChannelTopic(topic) {
12793
12796
  this.store.set('channelTopic', topic);
12794
12797
  }, _API_getUrlPrefix = function _API_getUrlPrefix(protocol) {
@@ -12859,7 +12862,7 @@ _API_ready = new (weak_map_default())(), _API_externalId = new (weak_map_default
12859
12862
  return {
12860
12863
  clientName: "@seamly/web-ui",
12861
12864
  clientVariant: api_classPrivateFieldGet(this, _API_layoutMode, "f"),
12862
- clientVersion: "22.2.0",
12865
+ clientVersion: "22.3.0-beta.2",
12863
12866
  currentUrl: window.location.toString(),
12864
12867
  screenResolution: `${window.screen.width}x${window.screen.height}`,
12865
12868
  timezone: getTimeZone(),
@@ -16709,6 +16712,64 @@ const setLocale = createAsyncThunk('setLocale', (locale, _ref) => {
16709
16712
  return true;
16710
16713
  }
16711
16714
  });
16715
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/redux/create-debounced-async-thunk.ts
16716
+
16717
+
16718
+
16719
+ /**
16720
+ * A debounced analogue of the `createAsyncThunk` from `@reduxjs/toolkit`
16721
+ * @param typePrefix - a string action type value
16722
+ * @param payloadCreator - a callback function that should return a promise containing the result of some asynchronous logic
16723
+ * @param debounceOptions - the debounce options object
16724
+ */
16725
+ const createDebouncedAsyncThunk = (typePrefix, payloadCreator, debounceOptions) => {
16726
+ const {
16727
+ wait = 300,
16728
+ maxWait = 0,
16729
+ leading = false
16730
+ } = debounceOptions !== null && debounceOptions !== void 0 ? debounceOptions : {};
16731
+ let debounceTimer = null;
16732
+ let maxWaitTimer = null;
16733
+ let resolve;
16734
+ const cancel = () => {
16735
+ if (resolve) {
16736
+ resolve(false);
16737
+ resolve = undefined;
16738
+ }
16739
+ };
16740
+ const invoke = () => {
16741
+ clearTimeout(maxWaitTimer);
16742
+ maxWaitTimer = undefined;
16743
+ if (resolve) {
16744
+ resolve(true);
16745
+ resolve = undefined;
16746
+ }
16747
+ };
16748
+ const debounceExecutionCondition = () => {
16749
+ const immediate = leading && !debounceTimer;
16750
+ // Start debounced condition resolution
16751
+ clearTimeout(debounceTimer);
16752
+ debounceTimer = set_timeout_default()(() => {
16753
+ invoke();
16754
+ debounceTimer = null;
16755
+ }, wait);
16756
+ if (immediate) {
16757
+ return true;
16758
+ }
16759
+ cancel();
16760
+ // Start max wait condition resolution
16761
+ if (maxWait && !maxWaitTimer) {
16762
+ maxWaitTimer = set_timeout_default()(invoke, maxWait);
16763
+ }
16764
+ return new (promise_default())(res => {
16765
+ resolve = res;
16766
+ });
16767
+ };
16768
+ return createAsyncThunk(typePrefix, payloadCreator, {
16769
+ condition: debounceExecutionCondition
16770
+ });
16771
+ };
16772
+ /* harmony default export */ var create_debounced_async_thunk = (createDebouncedAsyncThunk);
16712
16773
  ;// CONCATENATED MODULE: ./node_modules/reselect/es/defaultMemoize.js
16713
16774
  // Cache implementation based on Erik Rasmussen's `lru-memoize`:
16714
16775
  // https://github.com/erikras/lru-memoize
@@ -17294,8 +17355,9 @@ const setVisibility = createAsyncThunk('setVisibility', (requestedVisibility, _r
17294
17355
  if (previousVisibility === calculatedVisibility) {
17295
17356
  return undefined;
17296
17357
  }
17358
+ const visibility = api.store.get(StoreKey);
17297
17359
  // Store the user-requested visibility in order to reinitialize after refresh
17298
- api.store.set(StoreKey, assign_default()(assign_default()({}, api.store.get(StoreKey) || {}), {
17360
+ api.store.set(StoreKey, assign_default()(assign_default()({}, visibility || {}), {
17299
17361
  [layoutMode]: requestedVisibility
17300
17362
  }));
17301
17363
  if (requestedVisibility) {
@@ -17363,6 +17425,7 @@ var app_actions_awaiter = undefined && undefined.__awaiter || function (thisArg,
17363
17425
 
17364
17426
 
17365
17427
 
17428
+
17366
17429
  const initializeApp = createAsyncThunk('initializeApp', (_, _ref) => {
17367
17430
  let {
17368
17431
  extra: {
@@ -17431,7 +17494,7 @@ const initializeApp = createAsyncThunk('initializeApp', (_, _ref) => {
17431
17494
  }
17432
17495
  });
17433
17496
  });
17434
- const resetApp = createAsyncThunk('resetApp', (_, _ref2) => {
17497
+ const resetApp = create_debounced_async_thunk('resetApp', (_, _ref2) => {
17435
17498
  let {
17436
17499
  dispatch,
17437
17500
  extra: {
@@ -17440,7 +17503,7 @@ const resetApp = createAsyncThunk('resetApp', (_, _ref2) => {
17440
17503
  } = _ref2;
17441
17504
  return app_actions_awaiter(void 0, void 0, void 0, function* () {
17442
17505
  yield api.disconnect();
17443
- yield api.clearStore();
17506
+ api.clearStore();
17444
17507
  dispatch(resetConfig());
17445
17508
  yield dispatch(initializeConfig());
17446
17509
  try {
@@ -17448,11 +17511,14 @@ const resetApp = createAsyncThunk('resetApp', (_, _ref2) => {
17448
17511
  locale
17449
17512
  } = yield dispatch(initializeApp()).unwrap();
17450
17513
  yield dispatch(setLocale(locale));
17451
- } catch (rejectedValueOrSerializedError) {
17514
+ } catch (e) {
17452
17515
  // nothing to do
17453
17516
  }
17454
17517
  dispatch(initializeVisibility());
17455
17518
  });
17519
+ }, {
17520
+ wait: 2000,
17521
+ leading: true
17456
17522
  });
17457
17523
  ;// CONCATENATED MODULE: ./src/javascripts/domains/app/hooks.js
17458
17524
 
@@ -17491,12 +17557,80 @@ const {
17491
17557
  setHasResponded
17492
17558
  } = appSlice.actions;
17493
17559
  /* harmony default export */ var app_slice = (appSlice.reducer);
17560
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/store/actions.ts
17561
+
17562
+ var store_actions_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
17563
+ function adopt(value) {
17564
+ return value instanceof P ? value : new P(function (resolve) {
17565
+ resolve(value);
17566
+ });
17567
+ }
17568
+ return new (P || (P = (promise_default())))(function (resolve, reject) {
17569
+ function fulfilled(value) {
17570
+ try {
17571
+ step(generator.next(value));
17572
+ } catch (e) {
17573
+ reject(e);
17574
+ }
17575
+ }
17576
+ function rejected(value) {
17577
+ try {
17578
+ step(generator["throw"](value));
17579
+ } catch (e) {
17580
+ reject(e);
17581
+ }
17582
+ }
17583
+ function step(result) {
17584
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
17585
+ }
17586
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
17587
+ });
17588
+ };
17589
+
17590
+ const getConversation = createAsyncThunk('getConversation', (_, _ref) => {
17591
+ let {
17592
+ extra: {
17593
+ api
17594
+ },
17595
+ rejectWithValue
17596
+ } = _ref;
17597
+ return store_actions_awaiter(void 0, void 0, void 0, function* () {
17598
+ try {
17599
+ return api.getConversation();
17600
+ } catch (error) {
17601
+ return rejectWithValue({
17602
+ name: error === null || error === void 0 ? void 0 : error.name,
17603
+ message: error === null || error === void 0 ? void 0 : error.message,
17604
+ langKey: error === null || error === void 0 ? void 0 : error.langKey,
17605
+ action: error === null || error === void 0 ? void 0 : error.action,
17606
+ originalEvent: error === null || error === void 0 ? void 0 : error.originalEvent,
17607
+ originalError: error === null || error === void 0 ? void 0 : error.originalError
17608
+ });
17609
+ }
17610
+ });
17611
+ }, {
17612
+ condition(payload, _ref2) {
17613
+ let {
17614
+ getState
17615
+ } = _ref2;
17616
+ var _a;
17617
+ const {
17618
+ state: {
17619
+ events
17620
+ }
17621
+ } = getState();
17622
+ const lastEvent = events[events.length - 1];
17623
+ const payloadLastEventId = (_a = payload === null || payload === void 0 ? void 0 : payload.lastEvent) === null || _a === void 0 ? void 0 : _a.id;
17624
+ return lastEvent && payloadLastEventId !== lastEvent.payload.id;
17625
+ }
17626
+ });
17494
17627
  ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/slice.ts
17495
17628
 
17496
17629
 
17497
17630
 
17498
17631
 
17499
17632
 
17633
+
17500
17634
  const slice_initialState = {
17501
17635
  error: undefined
17502
17636
  };
@@ -17510,7 +17644,7 @@ const interruptSlice = createSlice({
17510
17644
  clearInterrupt: () => slice_initialState
17511
17645
  },
17512
17646
  extraReducers: builder => {
17513
- builder.addCase(initializeConfig.pending, () => slice_initialState).addMatcher(isAnyOf(initializeApp.rejected, initializeConfig.rejected, setLocale.rejected, setVisibility.rejected, initializeVisibility.rejected), (state, _ref) => {
17647
+ builder.addCase(initializeConfig.pending, () => slice_initialState).addMatcher(isAnyOf(initializeApp.rejected, initializeConfig.rejected, setLocale.rejected, setVisibility.rejected, initializeVisibility.rejected, getConversation.rejected), (state, _ref) => {
17514
17648
  let {
17515
17649
  payload
17516
17650
  } = _ref;
@@ -20093,6 +20227,10 @@ function useInterrupt() {
20093
20227
 
20094
20228
 
20095
20229
 
20230
+
20231
+
20232
+
20233
+
20096
20234
  function useSessionExpiredCommand() {
20097
20235
  const {
20098
20236
  meta: {
@@ -20100,13 +20238,35 @@ function useSessionExpiredCommand() {
20100
20238
  action
20101
20239
  }
20102
20240
  } = useInterrupt();
20241
+ const dispatch = useAppDispatch();
20103
20242
  const seamlyCommands = use_seamly_commands();
20104
20243
  const isExpiredError = (originalError === null || originalError === void 0 ? void 0 : originalError.name) === 'SeamlySessionExpiredError';
20244
+ const limit = (0,hooks_module/* useRef */.sO)(0);
20245
+ const limitTimer = (0,hooks_module/* useRef */.sO)(null);
20105
20246
  (0,hooks_module/* useEffect */.d4)(() => {
20106
20247
  if (isExpiredError && seamlyCommands[action]) {
20248
+ if (limit.current >= 10) {
20249
+ limitTimer.current = set_timeout_default()(() => {
20250
+ limit.current = 0;
20251
+ }, 10000);
20252
+ const error = new SeamlyGeneralError();
20253
+ dispatch(setInterrupt({
20254
+ name: error.name,
20255
+ message: error.message,
20256
+ langKey: error.langKey,
20257
+ originalEvent: error.originalEvent,
20258
+ originalError: error.originalError,
20259
+ action: error.action
20260
+ }));
20261
+ return () => {};
20262
+ }
20263
+ limit.current += 1;
20107
20264
  seamlyCommands[action]();
20108
20265
  }
20109
- }, [action, seamlyCommands, isExpiredError]);
20266
+ return () => {
20267
+ if (limitTimer.current) clearTimeout(limitTimer.current);
20268
+ };
20269
+ }, [action, seamlyCommands, isExpiredError, dispatch]);
20110
20270
  }
20111
20271
  ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.ts
20112
20272
 
@@ -20987,7 +21147,7 @@ const EventParticipant = _ref => {
20987
21147
  })
20988
21148
  }));
20989
21149
  }
20990
- if (showName) {
21150
+ if (showName && participantName) {
20991
21151
  authorInfo.push(o("span", {
20992
21152
  className: css_className('message__author-name'),
20993
21153
  children: participantName
@@ -21071,109 +21231,61 @@ function MessageContainer(_ref) {
21071
21231
  });
21072
21232
  }
21073
21233
  /* harmony default export */ var message_container = (MessageContainer);
21074
- ;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/card-component.js
21075
-
21234
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/card-component.tsx
21076
21235
 
21077
21236
 
21078
21237
 
21079
21238
 
21080
21239
 
21081
- const CardComponent = _ref => {
21082
- let {
21083
- id,
21084
- action,
21085
- buttonText,
21086
- description,
21087
- hasFocus,
21088
- image,
21089
- title,
21090
- isCarouselItem
21091
- } = _ref;
21092
- const cardRef = (0,hooks_module/* useRef */.sO)(null);
21093
- const {
21094
- sendMessage,
21095
- sendAction,
21096
- emitEvent
21097
- } = use_seamly_commands();
21098
- const descriptionId = useGeneratedId();
21099
- const isMounted = (0,hooks_module/* useRef */.sO)();
21100
- const CardActionComponent = action.type === cardTypes.navigate ? 'a' : 'button';
21101
- const emitCardEvent = (0,hooks_module/* useCallback */.I4)(() => emitEvent(`action.${actionTypes.clickCard}`, {
21102
- type: actionTypes.clickCta,
21103
- originMessage: id,
21104
- action
21105
- }), [emitEvent, id, action]);
21106
- const handleClick = (0,hooks_module/* useCallback */.I4)(() => {
21107
- emitCardEvent();
21108
- if (action.type === cardTypes.ask) {
21109
- sendMessage({
21110
- body: action.ask
21111
- });
21112
- } else if (action.type === cardTypes.topic) {
21113
- const {
21114
- topic: name,
21115
- fallbackMessage
21116
- } = action;
21117
- sendAction({
21118
- type: actionTypes.setTopic,
21119
- body: {
21120
- name,
21121
- fallbackMessage
21240
+ const CardComponent = ({ id, action, buttonText, description, hasFocus, image, title, isCarouselItem, }) => {
21241
+ const cardRef = (0,hooks_module/* useRef */.sO)(null);
21242
+ const { sendMessage, sendAction, emitEvent } = use_seamly_commands();
21243
+ const descriptionId = useGeneratedId();
21244
+ const isMounted = (0,hooks_module/* useRef */.sO)(false);
21245
+ const CardActionComponent = action.type === cardTypes.navigate ? 'a' : 'button';
21246
+ const emitCardEvent = (0,hooks_module/* useCallback */.I4)(() => emitEvent(`action.${actionTypes.clickCard}`, {
21247
+ type: actionTypes.clickCta,
21248
+ originMessage: id,
21249
+ action,
21250
+ }), [emitEvent, id, action]);
21251
+ const handleClick = (0,hooks_module/* useCallback */.I4)(() => {
21252
+ emitCardEvent();
21253
+ if (action.type === cardTypes.ask) {
21254
+ sendMessage({ body: action.ask });
21122
21255
  }
21123
- });
21124
- }
21125
- }, [sendMessage, action, sendAction, emitCardEvent]);
21126
- const actionProps = (0,hooks_module/* useMemo */.Ye)(() => action.type === cardTypes.navigate ? {
21127
- href: action.link,
21128
- rel: 'noopener noreferrer',
21129
- target: action.newTab ? '_blank' : '_self',
21130
- onClick: emitCardEvent
21131
- } : {
21132
- onClick: handleClick
21133
- }, [action, handleClick, emitCardEvent]);
21134
- (0,hooks_module/* useEffect */.d4)(() => {
21135
- if (isCarouselItem) {
21136
- if (hasFocus && isMounted.current) {
21137
- window.requestAnimationFrame(() => cardRef.current.focus());
21138
- } else {
21139
- cardRef.current.blur();
21140
- }
21141
- }
21142
- isMounted.current = true;
21143
- }, [hasFocus, isCarouselItem]);
21144
- return o("div", {
21145
- className: css_className('card__wrapper'),
21146
- id: id,
21147
- tabIndex: "-1" // set tabIndex of -1 so card can be focussed
21148
- ,
21149
- ref: cardRef,
21150
- children: [o("img", {
21151
- className: css_className('card__image'),
21152
- src: image,
21153
- alt: ""
21154
- }), o("div", {
21155
- className: css_className('card__content'),
21156
- id: id,
21157
- children: [title && o("h2", {
21158
- className: css_className('card__title'),
21159
- children: title
21160
- }), description && o("div", {
21161
- className: css_className('card__description'),
21162
- dangerouslySetInnerHTML: {
21163
- __html: description
21256
+ else if (action.type === cardTypes.topic) {
21257
+ const { topic: name, fallbackMessage } = action;
21258
+ sendAction({
21259
+ type: actionTypes.setTopic,
21260
+ body: { name, fallbackMessage },
21261
+ });
21164
21262
  }
21165
- }), o(CardActionComponent, {
21166
- tabIndex: isCarouselItem && !hasFocus ? '-1' : undefined // disable to prevent tabbing through cards
21167
- ,
21168
- className: css_className('button', 'button--primary'),
21169
- "aria-describedby": descriptionId,
21170
- ...actionProps,
21171
- children: buttonText
21172
- })]
21173
- })]
21174
- });
21263
+ }, [sendMessage, action, sendAction, emitCardEvent]);
21264
+ const actionProps = (0,hooks_module/* useMemo */.Ye)(() => action.type === cardTypes.navigate
21265
+ ? {
21266
+ href: action.link,
21267
+ rel: 'noopener noreferrer',
21268
+ target: action.newTab ? '_blank' : '_self',
21269
+ onClick: emitCardEvent,
21270
+ }
21271
+ : {
21272
+ onClick: handleClick,
21273
+ }, [action, handleClick, emitCardEvent]);
21274
+ (0,hooks_module/* useEffect */.d4)(() => {
21275
+ if (isCarouselItem) {
21276
+ if (hasFocus && isMounted.current) {
21277
+ window.requestAnimationFrame(() => cardRef.current.focus());
21278
+ }
21279
+ else {
21280
+ cardRef.current.blur();
21281
+ }
21282
+ }
21283
+ isMounted.current = true;
21284
+ }, [hasFocus, isCarouselItem]);
21285
+ return (o("div", { className: css_className('card__wrapper'), id: id, tabIndex: -1, ref: cardRef, children: [image ? (o("img", { className: css_className('card__image'), src: image, alt: "" })) : null, o("div", { className: css_className('card__content'), id: id, children: [title && o("h2", { className: css_className('card__title'), children: title }), description && (o("div", { className: css_className('card__description'), dangerouslySetInnerHTML: { __html: description } })), o(CardActionComponent, Object.assign({ tabIndex: isCarouselItem && !hasFocus ? -1 : undefined, className: css_className('button', 'button--primary'), "aria-describedby": descriptionId }, actionProps, { children: buttonText }))] })] }));
21175
21286
  };
21176
21287
  /* harmony default export */ var card_component = (CardComponent);
21288
+
21177
21289
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/card-message.js
21178
21290
 
21179
21291
 
@@ -21275,7 +21387,8 @@ function CarouselMessageSlide(_ref) {
21275
21387
  /* harmony default export */ var icon_send_32 = ("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32px\" height=\"32px\" x=\"0px\" y=\"0px\" viewBox=\"0 0 32 32\"><defs/><path fill=\"#4A48C1\" d=\"M6.714,14.985l17.837-7.906c0.681-0.302,1.414,0.301,1.25,1.027L22.273,23.59\tc-0.13,0.566-0.751,0.865-1.275,0.613l-3.623-1.752l-2.334,2.287c-0.572,0.562-1.538,0.156-1.538-0.645V21.01\tc0-0.217,0.078-0.43,0.222-0.594l7.676-8.841l-10.414,7.472l-4.351-2.445C5.987,16.236,6.033,15.287,6.714,14.985L6.714,14.985z\"/></svg>");
21276
21388
  ;// CONCATENATED MODULE: ./node_modules/raw-loader/dist/cjs.js!./src/icons/icon_upload-32.svg
21277
21389
  /* harmony default export */ var icon_upload_32 = ("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32px\" height=\"32px\" x=\"0px\" y=\"0px\" viewBox=\"0 0 32 32\"><defs/><path fill=\"#4A48C1\" d=\"M9.488,13.481c-0.391-0.391-0.391-1.023,0-1.414l5.805-5.805c0.026-0.026,0.06-0.036,0.088-0.058\tc0.073-0.06,0.146-0.119,0.235-0.156c0.246-0.103,0.522-0.103,0.769,0c0.093,0.039,0.171,0.101,0.249,0.165\tc0.023,0.02,0.053,0.027,0.074,0.049l5.805,5.805c0.391,0.391,0.391,1.023,0,1.414c-0.195,0.195-0.451,0.293-0.707,0.293\ts-0.512-0.098-0.707-0.293L17,9.383V20.33c0,0.553-0.447,1-1,1c-0.552,0-1-0.447-1-1V9.383l-4.098,4.098\tC10.512,13.872,9.879,13.872,9.488,13.481z M22.819,24.031H9.181c-0.552,0-1,0.447-1,1s0.448,1,1,1h13.639c0.553,0,1-0.447,1-1\tS23.372,24.031,22.819,24.031z\"/></svg>");
21278
- ;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/icon.js
21390
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/icon.tsx
21391
+
21279
21392
  /* eslint-disable import/no-webpack-loader-syntax */
21280
21393
  // The eslint rules are disabled for this as otherwsise we'd need to include the loader rule in all implementations
21281
21394
  // this can again be changed when we can import pre-built packages in implementations
@@ -21300,59 +21413,70 @@ function CarouselMessageSlide(_ref) {
21300
21413
 
21301
21414
 
21302
21415
 
21303
-
21304
21416
 
21305
21417
 
21306
21418
  /* eslint-enable import/no-webpack-loader-syntax */
21307
-
21308
-
21309
-
21310
21419
  const ICONS = {
21311
- send32: icon_send_32,
21312
- balloon32: icon_balloon_32,
21313
- newTopic32: icon_newtopic_32,
21314
- newTranslation16: icon_newtranslation_16,
21315
- newTranslation32: icon_newtranslation_32,
21316
- avatar32: avatar_bot_32,
21317
- chevronDown8: icon_chevron_down_8,
21318
- chevronDown32: icon_chevron_down_32,
21319
- chevronRight8: icon_chevron_right_8,
21320
- chevronRight16: icon_chevron_right_16,
21321
- close8: icon_close_8,
21322
- close16: icon_close_16,
21323
- enlarge32: icon_enlarge_32,
21324
- options32: icon_options_32,
21325
- file32: icon_file_32,
21326
- upload32: icon_upload_32,
21327
- download16: icon_download_16,
21328
- error16: icon_error_16,
21329
- arrowLeft16: icon_arrow_left_16,
21330
- arrowRight16: icon_arrow_right_16,
21331
- check32: icon_check_32,
21332
- check16: icon_check_16
21333
- };
21334
- const Icon = _ref => {
21335
- let {
21336
- name,
21337
- size = '32',
21338
- className = undefined,
21339
- alt
21340
- } = _ref;
21341
- const iconName = `${name}${size}`;
21342
- return o(preact_module/* Fragment */.HY, {
21343
- children: [o("div", {
21344
- "aria-hidden": "true",
21345
- className: className || css_className('icon'),
21346
- dangerouslySetInnerHTML: {
21347
- __html: ICONS[iconName]
21348
- }
21349
- }), alt && o("span", {
21350
- className: css_className('visually-hidden'),
21351
- children: alt
21352
- })]
21353
- });
21420
+ send: {
21421
+ 32: icon_send_32,
21422
+ },
21423
+ balloon: {
21424
+ 32: icon_balloon_32,
21425
+ },
21426
+ newTopic: {
21427
+ 32: icon_newtopic_32,
21428
+ },
21429
+ newTranslation: {
21430
+ 16: icon_newtranslation_16,
21431
+ 32: icon_newtranslation_32,
21432
+ },
21433
+ avatar: {
21434
+ 32: avatar_bot_32,
21435
+ },
21436
+ chevronDown: {
21437
+ 8: icon_chevron_down_8,
21438
+ 32: icon_chevron_down_32,
21439
+ },
21440
+ chevronRight: {
21441
+ 8: icon_chevron_right_8,
21442
+ 16: icon_chevron_right_16,
21443
+ },
21444
+ close: {
21445
+ 8: icon_close_8,
21446
+ 16: icon_close_16,
21447
+ },
21448
+ enlarge: {
21449
+ 32: icon_enlarge_32,
21450
+ },
21451
+ options: {
21452
+ 32: icon_options_32,
21453
+ },
21454
+ file: {
21455
+ 32: icon_file_32,
21456
+ },
21457
+ upload: {
21458
+ 32: icon_upload_32,
21459
+ },
21460
+ download: {
21461
+ 16: icon_download_16,
21462
+ },
21463
+ error: {
21464
+ 16: icon_error_16,
21465
+ },
21466
+ arrowLeft: {
21467
+ 16: icon_arrow_left_16,
21468
+ },
21469
+ arrowRight: {
21470
+ 16: icon_arrow_right_16,
21471
+ },
21472
+ check: {
21473
+ 16: icon_check_16,
21474
+ 32: icon_check_32,
21475
+ },
21354
21476
  };
21477
+ const Icon = ({ name, size = '32', className, alt }) => (o(preact_module/* Fragment */.HY, { children: [o("div", { "aria-hidden": "true", className: className || css_className('icon'), dangerouslySetInnerHTML: { __html: ICONS[name][size] } }), alt && o("span", { className: css_className('visually-hidden'), children: alt })] }));
21355
21478
  /* harmony default export */ var layout_icon = (Icon);
21479
+
21356
21480
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/carousel-component/components/controls.js
21357
21481
 
21358
21482
 
@@ -21384,7 +21508,8 @@ function CarouselControls(_ref) {
21384
21508
  onClick: handlePrevious,
21385
21509
  children: o(layout_icon, {
21386
21510
  name: "arrowLeft",
21387
- size: "16"
21511
+ size: "16",
21512
+ alt: ""
21388
21513
  })
21389
21514
  }), children, o("button", {
21390
21515
  className: css_className('button', 'button--next'),
@@ -21392,7 +21517,8 @@ function CarouselControls(_ref) {
21392
21517
  onClick: handleNext,
21393
21518
  children: o(layout_icon, {
21394
21519
  name: "arrowRight",
21395
- size: "16"
21520
+ size: "16",
21521
+ alt: ""
21396
21522
  })
21397
21523
  })]
21398
21524
  });
@@ -21693,7 +21819,8 @@ const ChoicePrompt = _ref => {
21693
21819
  "aria-describedby": descriptorId,
21694
21820
  children: [showOptions ? t('message.choicePrompts.cancelChooseAgain') : t('message.choicePrompts.chooseAgain'), o(layout_icon, {
21695
21821
  name: "chevronDown",
21696
- size: "8"
21822
+ size: "8",
21823
+ alt: ""
21697
21824
  })]
21698
21825
  }), showOptions && o(message_container, {
21699
21826
  type: "choice-prompt",
@@ -21755,7 +21882,8 @@ const SuggestionsItem = _ref => {
21755
21882
  className: css_className('button', 'button--primary'),
21756
21883
  children: [hasIcon && o(layout_icon, {
21757
21884
  name: "chevronRight",
21758
- size: "8"
21885
+ size: "8",
21886
+ alt: ""
21759
21887
  }), question]
21760
21888
  })
21761
21889
  });
@@ -21997,7 +22125,8 @@ function EventDivider(_ref) {
21997
22125
  children: iconName ? o(layout_icon, {
21998
22126
  name: iconName,
21999
22127
  size: iconSize,
22000
- className: iconClassName
22128
+ className: iconClassName,
22129
+ alt: ""
22001
22130
  }) : o("img", {
22002
22131
  src: graphicSrc,
22003
22132
  className: css_className({
@@ -23893,7 +24022,8 @@ const Lightbox = _ref => {
23893
24022
  onClick: onClose,
23894
24023
  children: [o(layout_icon, {
23895
24024
  name: "close",
23896
- size: "16"
24025
+ size: "16",
24026
+ alt: ""
23897
24027
  }), t('lightbox.closeLabel')]
23898
24028
  })]
23899
24029
  })
@@ -23945,7 +24075,8 @@ const ImageLightbox = _ref => {
23945
24075
  description
23946
24076
  }), o(layout_icon, {
23947
24077
  name: "enlarge",
23948
- size: "32"
24078
+ size: "32",
24079
+ alt: ""
23949
24080
  })]
23950
24081
  }), showLightBox && o(lightbox, {
23951
24082
  url: url,
@@ -24398,6 +24529,34 @@ const SeamlyActivityMonitor = ({ children }) => {
24398
24529
 
24399
24530
 
24400
24531
 
24532
+
24533
+ var seamly_event_subscriber_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
24534
+ function adopt(value) {
24535
+ return value instanceof P ? value : new P(function (resolve) {
24536
+ resolve(value);
24537
+ });
24538
+ }
24539
+ return new (P || (P = (promise_default())))(function (resolve, reject) {
24540
+ function fulfilled(value) {
24541
+ try {
24542
+ step(generator.next(value));
24543
+ } catch (e) {
24544
+ reject(e);
24545
+ }
24546
+ }
24547
+ function rejected(value) {
24548
+ try {
24549
+ step(generator["throw"](value));
24550
+ } catch (e) {
24551
+ reject(e);
24552
+ }
24553
+ }
24554
+ function step(result) {
24555
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
24556
+ }
24557
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24558
+ });
24559
+ };
24401
24560
  var seamly_event_subscriber_rest = undefined && undefined.__rest || function (s, e) {
24402
24561
  var t = {};
24403
24562
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && index_of_default()(e).call(e, p) < 0) t[p] = s[p];
@@ -24418,13 +24577,13 @@ var seamly_event_subscriber_rest = undefined && undefined.__rest || function (s,
24418
24577
 
24419
24578
 
24420
24579
 
24580
+
24421
24581
  const EMITTABLE_MESSAGE_TYPES = ['text', 'choice_prompt', 'image', 'video'];
24422
24582
  const SeamlyEventSubscriber = () => {
24423
24583
  const api = useSeamlyApiContext();
24424
24584
  const syncChannelRef = (0,hooks_module/* useRef */.sO)();
24425
24585
  const messageChannelRef = (0,hooks_module/* useRef */.sO)();
24426
- const dispatch = useDispatch();
24427
- const events = useEvents();
24586
+ const dispatch = useAppDispatch();
24428
24587
  const eventBus = (0,hooks_module/* useContext */.qp)(SeamlyEventBusContext);
24429
24588
  const prevEmittedEventId = (0,hooks_module/* useRef */.sO)(null);
24430
24589
  const {
@@ -24673,31 +24832,19 @@ const SeamlyEventSubscriber = () => {
24673
24832
  if (syncChannelRef.current) {
24674
24833
  (_a = api.conversation.channel) === null || _a === void 0 ? void 0 : _a.off('sync', syncChannelRef.current);
24675
24834
  }
24676
- syncChannelRef.current = api.conversation.channel.on('sync', payload => {
24677
- var _a;
24678
- const lastEvent = events[events.length - 1];
24679
- const payloadLastEventId = (_a = payload === null || payload === void 0 ? void 0 : payload.lastEvent) === null || _a === void 0 ? void 0 : _a.id;
24680
- if (lastEvent && payloadLastEventId === lastEvent.payload.id) {
24681
- return payload;
24682
- }
24683
- return api.getConversation().then(history => {
24835
+ syncChannelRef.current = api.conversation.channel.on('sync', payload => seamly_event_subscriber_awaiter(void 0, void 0, void 0, function* () {
24836
+ try {
24837
+ const history = yield dispatch(getConversation(payload)).unwrap();
24684
24838
  if (!history) return;
24685
24839
  dispatch(setHistory(history));
24686
- }).catch(error => {
24687
- dispatch(setInterrupt({
24688
- name: error === null || error === void 0 ? void 0 : error.name,
24689
- message: error === null || error === void 0 ? void 0 : error.message,
24690
- langKey: error === null || error === void 0 ? void 0 : error.langKey,
24691
- action: error === null || error === void 0 ? void 0 : error.action,
24692
- originalEvent: error === null || error === void 0 ? void 0 : error.originalEvent,
24693
- originalError: error === null || error === void 0 ? void 0 : error.originalError
24694
- }));
24695
- });
24696
- });
24840
+ } catch (_e) {
24841
+ // nothing to do, the error is handled in the thunk
24842
+ }
24843
+ }));
24697
24844
  return true;
24698
24845
  });
24699
24846
  }
24700
- }, [api, api.connectionInfo, api.conversation.channel, events, dispatch]);
24847
+ }, [api, api.connectionInfo, api.conversation.channel, dispatch]);
24701
24848
  return null;
24702
24849
  };
24703
24850
  /* harmony default export */ var seamly_event_subscriber = (SeamlyEventSubscriber);
@@ -26346,7 +26493,8 @@ function error_Error(_ref) {
26346
26493
  className: css_className('error__message'),
26347
26494
  children: [o(layout_icon, {
26348
26495
  name: "error",
26349
- size: "16"
26496
+ size: "16",
26497
+ alt: ""
26350
26498
  }), error]
26351
26499
  })
26352
26500
  });
@@ -26734,7 +26882,8 @@ const OptionsButton = () => {
26734
26882
  "aria-disabled": !multiMenu && !firstOption.available ? 'true' : null,
26735
26883
  children: [multiMenu && o(layout_icon, {
26736
26884
  name: "options",
26737
- size: "32"
26885
+ size: "32",
26886
+ alt: ""
26738
26887
  }), o("span", {
26739
26888
  className: css_className('button__text'),
26740
26889
  children: multiMenu ? t('options.openButtonText') : `${firstOption.title}${!firstOption.available ? ' ' : ''}`
@@ -26757,7 +26906,7 @@ const TranslationOption = ({ label, checked, description, onChange, id, itemClas
26757
26906
  onChange();
26758
26907
  }
26759
26908
  };
26760
- return (o("li", { className: css_className([itemClassName, 'translation-options__item']), "aria-selected": checked, role: "option", tabIndex: 0, onClick: onChange, onKeyDown: onKeyDown, id: id, children: [o(layout_icon, { alt: "", name: "check", size: "16" }), label, " ", description && o("span", { children: ["(", description, ")"] })] }));
26909
+ return (o("li", { className: css_className([itemClassName, 'translation-options__item']), "aria-selected": checked, role: "option", tabIndex: 0, onClick: onChange, onKeyDown: onKeyDown, id: id, children: [o(layout_icon, { name: "check", size: "16", alt: "" }), label, " ", description && o("span", { children: ["(", description, ")"] })] }));
26761
26910
  };
26762
26911
  /* harmony default export */ var translation_option = (TranslationOption);
26763
26912
 
@@ -27601,7 +27750,8 @@ function FileInput(_ref) {
27601
27750
  className: css_className('upload__label'),
27602
27751
  children: [o(layout_icon, {
27603
27752
  name: "upload",
27604
- size: "32"
27753
+ size: "32",
27754
+ alt: ""
27605
27755
  }), o("div", {
27606
27756
  children: [o("span", {
27607
27757
  className: css_className(['upload__label--text']),
@@ -28351,7 +28501,8 @@ const ButtonIcon = () => {
28351
28501
  alt: ""
28352
28502
  }) : o(layout_icon, {
28353
28503
  name: "avatar",
28354
- size: "32"
28504
+ size: "32",
28505
+ alt: ""
28355
28506
  });
28356
28507
  };
28357
28508
  const WindowOpenButton = _ref => {
@@ -28380,10 +28531,14 @@ const WindowOpenButton = _ref => {
28380
28531
  "aria-label": ariaLabel,
28381
28532
  "aria-hidden": isOpen,
28382
28533
  onClick: handleClick,
28383
- children: [o("span", {
28384
- className: css_className('message-count'),
28385
- "aria-hidden": "true",
28386
- children: !!count && count
28534
+ children: [o(in_out_transition, {
28535
+ isActive: !!count,
28536
+ transitionStartState: transitionStartStates.notRendered,
28537
+ children: o("span", {
28538
+ className: css_className('message-count'),
28539
+ "aria-hidden": "true",
28540
+ children: count
28541
+ })
28387
28542
  }), o(ButtonIcon, {})]
28388
28543
  })
28389
28544
  });
@@ -29048,7 +29203,8 @@ const AgentInfo = () => {
29048
29203
  alt: ""
29049
29204
  }) : o(layout_icon, {
29050
29205
  name: "avatar",
29051
- size: "32"
29206
+ size: "32",
29207
+ alt: ""
29052
29208
  }), o("span", {
29053
29209
  className: css_className(classNames),
29054
29210
  "aria-hidden": "true",