@seamly/web-ui 20.2.0-alpha.1 → 20.2.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8098,7 +8098,7 @@ function useStoreContext() {
8098
8098
  function useStoreDispatch() {
8099
8099
  return useStoreContext().dispatch;
8100
8100
  }
8101
- function useSelector(selector, deps = []) {
8101
+ function hooks_useSelector(selector, deps = []) {
8102
8102
  const store = useStoreContext(); // we need a force-update because we're manually updating a ref instead of a useState
8103
8103
 
8104
8104
  const [, forceUpdate] = (0,hooks_namespaceObject.useReducer)(x => x + 1, 0); // we're keeping the value to compare against
@@ -8156,7 +8156,7 @@ const useSelectorWithProps = function useSelectorWithProps(selector, props, inpu
8156
8156
  ) {
8157
8157
  // eslint-disable-next-line react-hooks/exhaustive-deps
8158
8158
  const wrappedMapper = (0,hooks_namespaceObject.useCallback)(state => selector(state, props), inputs);
8159
- return useSelector(wrappedMapper, inputs);
8159
+ return hooks_useSelector(wrappedMapper, inputs);
8160
8160
  };
8161
8161
  ;// CONCATENATED MODULE: ./src/javascripts/domains/redux/index.js
8162
8162
 
@@ -8168,13 +8168,13 @@ const useSelectorWithProps = function useSelectorWithProps(selector, props, inpu
8168
8168
 
8169
8169
 
8170
8170
  function useConfig() {
8171
- return useSelector(selectConfig);
8171
+ return hooks_useSelector(selectConfig);
8172
8172
  }
8173
8173
  function useParticipants() {
8174
8174
  const {
8175
8175
  agentParticipant,
8176
8176
  userParticipant
8177
- } = useSelector(selectConfig);
8177
+ } = useSelector(Selectors.selectConfig);
8178
8178
  return {
8179
8179
  agent: agentParticipant,
8180
8180
  user: userParticipant
@@ -8183,7 +8183,7 @@ function useParticipants() {
8183
8183
  function useStartChatIcon() {
8184
8184
  const {
8185
8185
  startChatIcon
8186
- } = useSelector(selectConfig);
8186
+ } = hooks_useSelector(selectConfig);
8187
8187
  return startChatIcon;
8188
8188
  }
8189
8189
  ;// CONCATENATED MODULE: ./src/javascripts/config.js
@@ -9288,6 +9288,12 @@ const calculateVisibility = ({
9288
9288
 
9289
9289
  if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== visibilityStates.open) {
9290
9290
  return hasResponded ? requestedVisibility || previousVisibility || visibilityStates.open : visibilityStates.hidden;
9291
+ } // Allow users to continue a conversation (if they have responded and no visibility is requested)
9292
+ // when switching from the window layout to the inline layout
9293
+
9294
+
9295
+ if (layoutMode === 'inline' && hasResponded && !requestedVisibility) {
9296
+ return previousVisibility || visibilityStates.open;
9291
9297
  }
9292
9298
 
9293
9299
  const baseVisibility = visibilityStates.minimized;
@@ -9312,7 +9318,7 @@ function seamly_state_hooks_defineProperty(obj, key, value) { if (key in obj) {
9312
9318
 
9313
9319
 
9314
9320
  const seamly_state_hooks_selectState = state => state.state;
9315
- const useSeamlyStateContext = () => useSelector(seamly_state_hooks_selectState);
9321
+ const useSeamlyStateContext = () => hooks_useSelector(seamly_state_hooks_selectState);
9316
9322
  const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState, selectConfig, selectUserHasResponded, ({
9317
9323
  events,
9318
9324
  serviceData
@@ -9360,7 +9366,7 @@ const selectEvents = createSelector(selectEventsWithSuggestion, selectConfig, (e
9360
9366
  });
9361
9367
  return mappedEvents;
9362
9368
  });
9363
- const useEvents = () => useSelector(selectEvents, []);
9369
+ const useEvents = () => hooks_useSelector(selectEvents, []);
9364
9370
  const useSeamlyIsLoading = () => useSeamlyStateContext().isLoading;
9365
9371
  const useSeamlyHeaderData = () => useSeamlyStateContext().headerTitles;
9366
9372
  const useSeamlyUnreadCount = () => useSeamlyStateContext().unreadEvents;
@@ -9373,7 +9379,7 @@ const selectLastMessageEventId = createSelector(selectEvents, events => {
9373
9379
  const filteredEvents = events.filter(event => event.type === 'message');
9374
9380
  return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
9375
9381
  });
9376
- const useLastMessageEventId = () => useSelector(selectLastMessageEventId);
9382
+ const useLastMessageEventId = () => hooks_useSelector(selectLastMessageEventId);
9377
9383
  const useSeamlyIsHistoryLoaded = () => useSeamlyStateContext().historyLoaded;
9378
9384
  const useSeamlyCurrentAgent = () => {
9379
9385
  const {
@@ -9574,6 +9580,7 @@ const clear = interrupt_utils_createAction('clear');
9574
9580
 
9575
9581
 
9576
9582
 
9583
+
9577
9584
  const setHasResponded = app_utils_createAction('setHasResponded', hasResponded => ({
9578
9585
  hasResponded
9579
9586
  }));
@@ -9642,6 +9649,13 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
9642
9649
  }
9643
9650
  } else if (config !== null && config !== void 0 && (_config$context2 = config.context) !== null && _config$context2 !== void 0 && _config$context2.translationLocale) {
9644
9651
  locale = config.context.translationLocale;
9652
+ api.send('action', {
9653
+ type: actionTypes.setTranslation,
9654
+ body: {
9655
+ enabled: true,
9656
+ locale
9657
+ }
9658
+ });
9645
9659
  dispatch(enable(locale));
9646
9660
  }
9647
9661
  } catch (e) {
@@ -10504,9 +10518,9 @@ const formatter = new MessageFormatter('en-GB', {
10504
10518
  select: selectTypeHandler
10505
10519
  });
10506
10520
  function useI18n() {
10507
- const translations = useSelector(selectTranslations);
10508
- const locale = useSelector(selectLocale);
10509
- const initialLocale = useSelector(selectInitialLocale);
10521
+ const translations = hooks_useSelector(selectTranslations);
10522
+ const locale = hooks_useSelector(selectLocale);
10523
+ const initialLocale = hooks_useSelector(selectInitialLocale);
10510
10524
  const t = (0,hooks_namespaceObject.useCallback)((key, values = {}) => {
10511
10525
  const translation = translations[key];
10512
10526
 
@@ -10896,7 +10910,7 @@ function useInterrupt() {
10896
10910
  const {
10897
10911
  t
10898
10912
  } = useI18n();
10899
- const error = useSelector(selectError);
10913
+ const error = hooks_useSelector(selectError);
10900
10914
  const hasInterrupt = Boolean(error);
10901
10915
  const meta = (0,hooks_namespaceObject.useMemo)(() => {
10902
10916
  if (!error) return {};
@@ -11035,7 +11049,7 @@ const handleError = (state, {
11035
11049
 
11036
11050
 
11037
11051
  function useUserHasResponded() {
11038
- return useSelector(selectUserHasResponded);
11052
+ return hooks_useSelector(selectUserHasResponded);
11039
11053
  }
11040
11054
  ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/hooks.js
11041
11055
 
@@ -11045,7 +11059,7 @@ function useUserHasResponded() {
11045
11059
 
11046
11060
  const useVisibility = () => {
11047
11061
  const dispatch = useStoreDispatch();
11048
- const visible = useSelector(selectVisibility);
11062
+ const visible = hooks_useSelector(selectVisibility);
11049
11063
  const isVisible = visible ? visible !== visibilityStates.hidden : false;
11050
11064
  const isOpen = visible === visibilityStates.open;
11051
11065
  const isMinimized = visible === visibilityStates.minimized;
@@ -11933,7 +11947,7 @@ function useTranslations() {
11933
11947
  isActive,
11934
11948
  isAvailable,
11935
11949
  currentLocale
11936
- } = useSelector(getState, []);
11950
+ } = hooks_useSelector(getState, []);
11937
11951
  return {
11938
11952
  languages,
11939
11953
  isActive,
@@ -11984,7 +11998,7 @@ function useTranslatedEventData({
11984
11998
  }];
11985
11999
  }
11986
12000
  function useTranslationsContainer() {
11987
- const id = useSelector(getState, []).containerId;
12001
+ const id = hooks_useSelector(getState, []).containerId;
11988
12002
  const focusContainer = useElementFocusingById(id);
11989
12003
  return {
11990
12004
  id,
@@ -19481,13 +19495,9 @@ const Translation = _ref => {
19481
19495
 
19482
19496
 
19483
19497
 
19484
-
19485
19498
  const Participant = ({
19486
19499
  event
19487
19500
  }) => {
19488
- const {
19489
- agent
19490
- } = useParticipants();
19491
19501
  const {
19492
19502
  participant
19493
19503
  } = event.payload;
@@ -19500,11 +19510,10 @@ const Participant = ({
19500
19510
  return null;
19501
19511
  }
19502
19512
 
19503
- const avatar = participant.avatar || (agent === null || agent === void 0 ? void 0 : agent.avatar);
19504
19513
  return (0,jsx_runtime_namespaceObject.jsx)(EventDivider, {
19505
- graphicSrc: avatar,
19514
+ graphicSrc: participant.avatar,
19506
19515
  graphicType: participant.avatar ? 'avatar' : undefined,
19507
- iconName: !avatar ? 'balloon' : undefined,
19516
+ iconName: !participant.avatar ? 'balloon' : undefined,
19508
19517
  childrenHTML: intro,
19509
19518
  dividerType: "participant"
19510
19519
  });
@@ -25276,7 +25285,6 @@ class API {
25276
25285
  sendContext(context = {}) {
25277
25286
  const {
25278
25287
  locale,
25279
- translationLocale,
25280
25288
  variables
25281
25289
  } = context;
25282
25290
  const payload = {};
@@ -25289,14 +25297,6 @@ class API {
25289
25297
  payload.locale = locale;
25290
25298
  }
25291
25299
 
25292
- if (translationLocale) {
25293
- if (typeof translationLocale !== 'string') {
25294
- throw new Error('Translation locale must be a string');
25295
- }
25296
-
25297
- payload.translationLocale = translationLocale;
25298
- }
25299
-
25300
25300
  if (variables) {
25301
25301
  if (typeof variables !== 'object') {
25302
25302
  throw new Error('Variables must be an object');
@@ -25321,7 +25321,7 @@ class API {
25321
25321
  return {
25322
25322
  clientName: "@seamly/web-ui",
25323
25323
  clientVariant: this.layoutMode,
25324
- clientVersion: "20.2.0-alpha.1",
25324
+ clientVersion: "20.2.0-alpha.4",
25325
25325
  currentUrl: window.location.toString(),
25326
25326
  screenResolution: `${window.screen.width}x${window.screen.height}`,
25327
25327
  timezone: getTimeZone(),
@@ -25638,6 +25638,7 @@ class ExternalApi {
25638
25638
  this._waitingActions = [];
25639
25639
  this._instances = {};
25640
25640
  this.appConfig = appConfig;
25641
+ this.context = {};
25641
25642
  }
25642
25643
 
25643
25644
  push(...actionObjects) {
@@ -25665,7 +25666,8 @@ class ExternalApi {
25665
25666
  break;
25666
25667
 
25667
25668
  default:
25668
- if (!this.handleAction(actionObj)) {
25669
+ if (!this.handleAction(actionObj) && // Store context properties for the next instance that will be created
25670
+ !this.setContext(actionObj.action, ...actionObj.args)) {
25669
25671
  this._waitingActions.push(actionObj);
25670
25672
  }
25671
25673
 
@@ -25674,6 +25676,25 @@ class ExternalApi {
25674
25676
  });
25675
25677
  }
25676
25678
 
25679
+ setContext(action, args) {
25680
+ switch (action) {
25681
+ case 'setTranslation':
25682
+ const {
25683
+ enabled,
25684
+ locale
25685
+ } = args;
25686
+
25687
+ if (!!enabled && locale) {
25688
+ this.context.translationLocale = locale;
25689
+ }
25690
+
25691
+ return true;
25692
+
25693
+ default:
25694
+ return false;
25695
+ }
25696
+ }
25697
+
25677
25698
  handleInit(actionObj) {
25678
25699
  const userConfig = this.getUserConfig(...actionObj.args);
25679
25700
  const config = this.getCombinedConfig(userConfig); // if this.appConfig is a function, it might return an invalid configuration (false, null, undefined)
@@ -25695,7 +25716,9 @@ class ExternalApi {
25695
25716
 
25696
25717
  if (config) {
25697
25718
  const instance = this.createInstance(config);
25698
- this._instances[config.namespace] = instance;
25719
+ this._instances[config.namespace] = instance; // Clear the context after creating the instance, so we do not reuse it for the next
25720
+
25721
+ this.context = {};
25699
25722
  instance.render();
25700
25723
  }
25701
25724
  }
@@ -25759,10 +25782,13 @@ class ExternalApi {
25759
25782
  return this.appConfig(userConfig);
25760
25783
  }
25761
25784
 
25785
+ const context = external_api_objectSpread(external_api_objectSpread({}, userConfig.context || this.appConfig.context), this.context);
25786
+
25762
25787
  const defaults = external_api_objectSpread(external_api_objectSpread({}, this.appConfig.defaults), userConfig.defaults);
25763
25788
 
25764
25789
  return external_api_objectSpread(external_api_objectSpread(external_api_objectSpread({}, this.appConfig), userConfig), {}, {
25765
25790
  api: external_api_objectSpread(external_api_objectSpread({}, this.appConfig.api), userConfig.api),
25791
+ context: Object.keys(context).length ? context : undefined,
25766
25792
  defaults: Object.keys(defaults).length ? defaults : undefined
25767
25793
  });
25768
25794
  }