@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.
@@ -15761,7 +15761,7 @@ function useStoreContext() {
15761
15761
  function useStoreDispatch() {
15762
15762
  return useStoreContext().dispatch;
15763
15763
  }
15764
- function useSelector(selector, deps = []) {
15764
+ function hooks_useSelector(selector, deps = []) {
15765
15765
  const store = useStoreContext(); // we need a force-update because we're manually updating a ref instead of a useState
15766
15766
 
15767
15767
  const [, forceUpdate] = hooks_module_p(x => x + 1, 0); // we're keeping the value to compare against
@@ -15819,7 +15819,7 @@ const useSelectorWithProps = function useSelectorWithProps(selector, props, inpu
15819
15819
  ) {
15820
15820
  // eslint-disable-next-line react-hooks/exhaustive-deps
15821
15821
  const wrappedMapper = hooks_module_A(state => selector(state, props), inputs);
15822
- return useSelector(wrappedMapper, inputs);
15822
+ return hooks_useSelector(wrappedMapper, inputs);
15823
15823
  };
15824
15824
  ;// CONCATENATED MODULE: ./src/javascripts/domains/redux/index.js
15825
15825
 
@@ -15831,13 +15831,13 @@ const useSelectorWithProps = function useSelectorWithProps(selector, props, inpu
15831
15831
 
15832
15832
 
15833
15833
  function useConfig() {
15834
- return useSelector(selectConfig);
15834
+ return hooks_useSelector(selectConfig);
15835
15835
  }
15836
15836
  function useParticipants() {
15837
15837
  const {
15838
15838
  agentParticipant,
15839
15839
  userParticipant
15840
- } = useSelector(selectConfig);
15840
+ } = useSelector(Selectors.selectConfig);
15841
15841
  return {
15842
15842
  agent: agentParticipant,
15843
15843
  user: userParticipant
@@ -15846,7 +15846,7 @@ function useParticipants() {
15846
15846
  function useStartChatIcon() {
15847
15847
  const {
15848
15848
  startChatIcon
15849
- } = useSelector(selectConfig);
15849
+ } = hooks_useSelector(selectConfig);
15850
15850
  return startChatIcon;
15851
15851
  }
15852
15852
  ;// CONCATENATED MODULE: ./src/javascripts/config.js
@@ -17027,6 +17027,12 @@ const calculateVisibility = ({
17027
17027
 
17028
17028
  if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== visibilityStates.open) {
17029
17029
  return hasResponded ? requestedVisibility || previousVisibility || visibilityStates.open : visibilityStates.hidden;
17030
+ } // Allow users to continue a conversation (if they have responded and no visibility is requested)
17031
+ // when switching from the window layout to the inline layout
17032
+
17033
+
17034
+ if (layoutMode === 'inline' && hasResponded && !requestedVisibility) {
17035
+ return previousVisibility || visibilityStates.open;
17030
17036
  }
17031
17037
 
17032
17038
  const baseVisibility = visibilityStates.minimized;
@@ -17059,7 +17065,7 @@ function seamly_state_hooks_objectSpread(target) { for (var i = 1; i < arguments
17059
17065
 
17060
17066
 
17061
17067
  const seamly_state_hooks_selectState = state => state.state;
17062
- const useSeamlyStateContext = () => useSelector(seamly_state_hooks_selectState);
17068
+ const useSeamlyStateContext = () => hooks_useSelector(seamly_state_hooks_selectState);
17063
17069
  const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState, selectConfig, selectUserHasResponded, ({
17064
17070
  events,
17065
17071
  serviceData
@@ -17109,7 +17115,7 @@ const selectEvents = createSelector(selectEventsWithSuggestion, selectConfig, (e
17109
17115
 
17110
17116
  return mappedEvents;
17111
17117
  });
17112
- const useEvents = () => useSelector(selectEvents, []);
17118
+ const useEvents = () => hooks_useSelector(selectEvents, []);
17113
17119
  const useSeamlyIsLoading = () => useSeamlyStateContext().isLoading;
17114
17120
  const useSeamlyHeaderData = () => useSeamlyStateContext().headerTitles;
17115
17121
  const useSeamlyUnreadCount = () => useSeamlyStateContext().unreadEvents;
@@ -17123,7 +17129,7 @@ const selectLastMessageEventId = createSelector(selectEvents, events => {
17123
17129
 
17124
17130
  return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
17125
17131
  });
17126
- const useLastMessageEventId = () => useSelector(selectLastMessageEventId);
17132
+ const useLastMessageEventId = () => hooks_useSelector(selectLastMessageEventId);
17127
17133
  const useSeamlyIsHistoryLoaded = () => useSeamlyStateContext().historyLoaded;
17128
17134
  const useSeamlyCurrentAgent = () => {
17129
17135
  const {
@@ -17338,6 +17344,7 @@ const clear = interrupt_utils_createAction('clear');
17338
17344
 
17339
17345
 
17340
17346
 
17347
+
17341
17348
  const setHasResponded = app_utils_createAction('setHasResponded', hasResponded => ({
17342
17349
  hasResponded
17343
17350
  }));
@@ -17406,6 +17413,13 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
17406
17413
  }
17407
17414
  } else if (config !== null && config !== void 0 && (_config$context2 = config.context) !== null && _config$context2 !== void 0 && _config$context2.translationLocale) {
17408
17415
  locale = config.context.translationLocale;
17416
+ api.send('action', {
17417
+ type: actionTypes.setTranslation,
17418
+ body: {
17419
+ enabled: true,
17420
+ locale
17421
+ }
17422
+ });
17409
17423
  dispatch(enable(locale));
17410
17424
  }
17411
17425
  } catch (e) {
@@ -18286,9 +18300,9 @@ const formatter = new MessageFormatter('en-GB', {
18286
18300
  select: selectTypeHandler
18287
18301
  });
18288
18302
  function useI18n() {
18289
- const translations = useSelector(selectTranslations);
18290
- const locale = useSelector(selectLocale);
18291
- const initialLocale = useSelector(selectInitialLocale);
18303
+ const translations = hooks_useSelector(selectTranslations);
18304
+ const locale = hooks_useSelector(selectLocale);
18305
+ const initialLocale = hooks_useSelector(selectInitialLocale);
18292
18306
  const t = hooks_module_A((key, values = {}) => {
18293
18307
  const translation = translations[key];
18294
18308
 
@@ -18728,7 +18742,7 @@ function useInterrupt() {
18728
18742
  const {
18729
18743
  t
18730
18744
  } = useI18n();
18731
- const error = useSelector(selectError);
18745
+ const error = hooks_useSelector(selectError);
18732
18746
  const hasInterrupt = Boolean(error);
18733
18747
  const meta = hooks_module_d(() => {
18734
18748
  if (!error) return {};
@@ -18876,7 +18890,7 @@ const handleError = (state, {
18876
18890
 
18877
18891
 
18878
18892
  function useUserHasResponded() {
18879
- return useSelector(selectUserHasResponded);
18893
+ return hooks_useSelector(selectUserHasResponded);
18880
18894
  }
18881
18895
  ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/hooks.js
18882
18896
 
@@ -18886,7 +18900,7 @@ function useUserHasResponded() {
18886
18900
 
18887
18901
  const useVisibility = () => {
18888
18902
  const dispatch = useStoreDispatch();
18889
- const visible = useSelector(selectVisibility);
18903
+ const visible = hooks_useSelector(selectVisibility);
18890
18904
  const isVisible = visible ? visible !== visibilityStates.hidden : false;
18891
18905
  const isOpen = visible === visibilityStates.open;
18892
18906
  const isMinimized = visible === visibilityStates.minimized;
@@ -19829,7 +19843,7 @@ function useTranslations() {
19829
19843
  isActive,
19830
19844
  isAvailable,
19831
19845
  currentLocale
19832
- } = useSelector(getState, []);
19846
+ } = hooks_useSelector(getState, []);
19833
19847
  return {
19834
19848
  languages,
19835
19849
  isActive,
@@ -19880,7 +19894,7 @@ function useTranslatedEventData({
19880
19894
  }];
19881
19895
  }
19882
19896
  function useTranslationsContainer() {
19883
- const id = useSelector(getState, []).containerId;
19897
+ const id = hooks_useSelector(getState, []).containerId;
19884
19898
  const focusContainer = useElementFocusingById(id);
19885
19899
  return {
19886
19900
  id,
@@ -27538,13 +27552,9 @@ const Translation = _ref => {
27538
27552
 
27539
27553
 
27540
27554
 
27541
-
27542
27555
  const Participant = ({
27543
27556
  event
27544
27557
  }) => {
27545
- const {
27546
- agent
27547
- } = useParticipants();
27548
27558
  const {
27549
27559
  participant
27550
27560
  } = event.payload;
@@ -27557,11 +27567,10 @@ const Participant = ({
27557
27567
  return null;
27558
27568
  }
27559
27569
 
27560
- const avatar = participant.avatar || (agent === null || agent === void 0 ? void 0 : agent.avatar);
27561
27570
  return jsxRuntime_module_e(EventDivider, {
27562
- graphicSrc: avatar,
27571
+ graphicSrc: participant.avatar,
27563
27572
  graphicType: participant.avatar ? 'avatar' : undefined,
27564
- iconName: !avatar ? 'balloon' : undefined,
27573
+ iconName: !participant.avatar ? 'balloon' : undefined,
27565
27574
  childrenHTML: intro,
27566
27575
  dividerType: "participant"
27567
27576
  });
@@ -33635,7 +33644,6 @@ class API {
33635
33644
  sendContext(context = {}) {
33636
33645
  const {
33637
33646
  locale,
33638
- translationLocale,
33639
33647
  variables
33640
33648
  } = context;
33641
33649
  const payload = {};
@@ -33648,14 +33656,6 @@ class API {
33648
33656
  payload.locale = locale;
33649
33657
  }
33650
33658
 
33651
- if (translationLocale) {
33652
- if (typeof translationLocale !== 'string') {
33653
- throw new Error('Translation locale must be a string');
33654
- }
33655
-
33656
- payload.translationLocale = translationLocale;
33657
- }
33658
-
33659
33659
  if (variables) {
33660
33660
  if (typeof variables !== 'object') {
33661
33661
  throw new Error('Variables must be an object');
@@ -33682,7 +33682,7 @@ class API {
33682
33682
  return {
33683
33683
  clientName: "@seamly/web-ui",
33684
33684
  clientVariant: this.layoutMode,
33685
- clientVersion: "20.2.0-alpha.1",
33685
+ clientVersion: "20.2.0-alpha.4",
33686
33686
  currentUrl: window.location.toString(),
33687
33687
  screenResolution: `${window.screen.width}x${window.screen.height}`,
33688
33688
  timezone: getTimeZone(),
@@ -34028,6 +34028,7 @@ class ExternalApi {
34028
34028
  this._waitingActions = [];
34029
34029
  this._instances = {};
34030
34030
  this.appConfig = appConfig;
34031
+ this.context = {};
34031
34032
  }
34032
34033
 
34033
34034
  push(...actionObjects) {
@@ -34058,7 +34059,8 @@ class ExternalApi {
34058
34059
  break;
34059
34060
 
34060
34061
  default:
34061
- if (!this.handleAction(actionObj)) {
34062
+ if (!this.handleAction(actionObj) && // Store context properties for the next instance that will be created
34063
+ !this.setContext(actionObj.action, ...actionObj.args)) {
34062
34064
  this._waitingActions.push(actionObj);
34063
34065
  }
34064
34066
 
@@ -34067,6 +34069,25 @@ class ExternalApi {
34067
34069
  });
34068
34070
  }
34069
34071
 
34072
+ setContext(action, args) {
34073
+ switch (action) {
34074
+ case 'setTranslation':
34075
+ const {
34076
+ enabled,
34077
+ locale
34078
+ } = args;
34079
+
34080
+ if (!!enabled && locale) {
34081
+ this.context.translationLocale = locale;
34082
+ }
34083
+
34084
+ return true;
34085
+
34086
+ default:
34087
+ return false;
34088
+ }
34089
+ }
34090
+
34070
34091
  handleInit(actionObj) {
34071
34092
  const userConfig = this.getUserConfig(...actionObj.args);
34072
34093
  const config = this.getCombinedConfig(userConfig); // if this.appConfig is a function, it might return an invalid configuration (false, null, undefined)
@@ -34090,7 +34111,9 @@ class ExternalApi {
34090
34111
 
34091
34112
  if (config) {
34092
34113
  const instance = this.createInstance(config);
34093
- this._instances[config.namespace] = instance;
34114
+ this._instances[config.namespace] = instance; // Clear the context after creating the instance, so we do not reuse it for the next
34115
+
34116
+ this.context = {};
34094
34117
  instance.render();
34095
34118
  }
34096
34119
  }
@@ -34158,10 +34181,13 @@ class ExternalApi {
34158
34181
  return this.appConfig(userConfig);
34159
34182
  }
34160
34183
 
34184
+ const context = external_api_objectSpread(external_api_objectSpread({}, userConfig.context || this.appConfig.context), this.context);
34185
+
34161
34186
  const defaults = external_api_objectSpread(external_api_objectSpread({}, this.appConfig.defaults), userConfig.defaults);
34162
34187
 
34163
34188
  return external_api_objectSpread(external_api_objectSpread(external_api_objectSpread({}, this.appConfig), userConfig), {}, {
34164
34189
  api: external_api_objectSpread(external_api_objectSpread({}, this.appConfig.api), userConfig.api),
34190
+ context: keys_default()(context).length ? context : undefined,
34165
34191
  defaults: keys_default()(defaults).length ? defaults : undefined
34166
34192
  });
34167
34193
  }