@seamly/web-ui 23.0.0-alpha.2 → 23.0.0-alpha.3

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 (38) hide show
  1. package/build/dist/lib/components.js +58 -75
  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 +55 -72
  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 +8 -8
  10. package/build/dist/lib/index.debug.min.js +1 -1
  11. package/build/dist/lib/index.debug.min.js.map +1 -1
  12. package/build/dist/lib/index.js +42 -63
  13. package/build/dist/lib/index.js.map +1 -1
  14. package/build/dist/lib/index.min.js +1 -1
  15. package/build/dist/lib/index.min.js.map +1 -1
  16. package/build/dist/lib/standalone.js +52 -74
  17. package/build/dist/lib/standalone.js.map +1 -1
  18. package/build/dist/lib/standalone.min.js +1 -1
  19. package/build/dist/lib/standalone.min.js.map +1 -1
  20. package/build/dist/lib/style-guide.js +51 -68
  21. package/build/dist/lib/style-guide.js.map +1 -1
  22. package/build/dist/lib/style-guide.min.js +1 -1
  23. package/build/dist/lib/style-guide.min.js.map +1 -1
  24. package/build/dist/lib/utils.js +63 -99
  25. package/build/dist/lib/utils.js.map +1 -1
  26. package/build/dist/lib/utils.min.js +1 -1
  27. package/build/dist/lib/utils.min.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/javascripts/api/index.ts +2 -18
  30. package/src/javascripts/domains/config/actions.ts +3 -0
  31. package/src/javascripts/domains/config/slice.ts +3 -0
  32. package/src/javascripts/domains/i18n/slice.ts +1 -1
  33. package/src/javascripts/domains/translations/components/options-dialog/translation-options.tsx +1 -1
  34. package/src/javascripts/domains/translations/hooks.ts +1 -1
  35. package/src/javascripts/domains/translations/middleware.ts +4 -10
  36. package/src/javascripts/domains/translations/slice.ts +2 -2
  37. package/src/javascripts/style-guide/states.js +4 -0
  38. package/src/javascripts/style-guide/style-guide-engine.js +1 -1
@@ -2342,14 +2342,6 @@ var api_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet ||
2342
2342
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2343
2343
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2344
2344
  };
2345
- var __rest = undefined && undefined.__rest || function (s, e) {
2346
- var t = {};
2347
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2348
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2349
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2350
- }
2351
- return t;
2352
- };
2353
2345
  var _API_instances, _API_ready, _API_externalId, _API_conversationAuthToken, _API_layoutMode, _API_config, _API_getAccessToken, _API_setAccessToken, _API_setConversationUrl, _API_getChannelTopic, _API_setChannelTopic, _API_getLocale, _API_getUrlPrefix, _API_updateUrls, _API_createConversation;
2354
2346
 
2355
2347
 
@@ -2439,7 +2431,7 @@ class API {
2439
2431
  _API_config.set(this, void 0);
2440
2432
  this.conversation = new conversation_connector();
2441
2433
  _API_getLocale.set(this, locale => locale || this.locale);
2442
- this.store = objectStore(`${namespace}.connection${context.contentLocale ? `.${context.contentLocale}` : ''}`, config.storageProvider || store);
2434
+ this.store = objectStore(`${namespace}.connection${context.userLocale ? `.${context.userLocale}` : ''}`, config.storageProvider || store);
2443
2435
  this.connectionInfo = {
2444
2436
  apiKey: config.key,
2445
2437
  domain: config.domain || DOMAIN,
@@ -2705,7 +2697,6 @@ class API {
2705
2697
  this.conversation.pushToChannel(command, buildPayload(command, payload), 10000);
2706
2698
  }
2707
2699
  sendContext(context) {
2708
- var _a, _b;
2709
2700
  const {
2710
2701
  contentLocale,
2711
2702
  userLocale,
@@ -2738,23 +2729,13 @@ class API {
2738
2729
  if (Object.keys(payload).length === 0 && payload.constructor === Object) {
2739
2730
  return;
2740
2731
  }
2741
- // Destructure the server locale from the payload
2742
- const {
2743
- contentLocale: _
2744
- } = payload,
2745
- restPayload = __rest(payload, ["contentLocale"]);
2746
- const localContentLocale = (_a = api_classPrivateFieldGet(this, _API_config, "f").context) === null || _a === void 0 ? void 0 : _a.contentLocale;
2747
- const localUserLocale = (_b = api_classPrivateFieldGet(this, _API_config, "f").context) === null || _b === void 0 ? void 0 : _b.userLocale;
2748
- this.send('context', Object.assign(Object.assign({}, localContentLocale ? {
2749
- contentLocale: localContentLocale,
2750
- userLocale: localUserLocale
2751
- } : {}), restPayload), false);
2732
+ this.send('context', payload, false);
2752
2733
  }
2753
2734
  getEnvironment() {
2754
2735
  return {
2755
2736
  clientName: "@seamly/web-ui",
2756
2737
  clientVariant: api_classPrivateFieldGet(this, _API_layoutMode, "f"),
2757
- clientVersion: "23.0.0-alpha.2",
2738
+ clientVersion: "22.3.6",
2758
2739
  currentUrl: window.location.toString(),
2759
2740
  screenResolution: `${window.screen.width}x${window.screen.height}`,
2760
2741
  timezone: getTimeZone(),
@@ -7209,7 +7190,7 @@ const initializeConfig = createAsyncThunk('initializeConfig', (_, {
7209
7190
  },
7210
7191
  rejectWithValue
7211
7192
  }) => actions_awaiter(void 0, void 0, void 0, function* () {
7212
- var _a;
7193
+ var _a, _b;
7213
7194
  try {
7214
7195
  const {
7215
7196
  features,
@@ -7219,7 +7200,8 @@ const initializeConfig = createAsyncThunk('initializeConfig', (_, {
7219
7200
  userParticipant,
7220
7201
  startChatIcon
7221
7202
  } = yield api.getConfig();
7222
- const defaultContentLocale = ((_a = config === null || config === void 0 ? void 0 : config.context) === null || _a === void 0 ? void 0 : _a.contentLocale) || defaultLocale;
7203
+ const defaultUserLocale = ((_a = config === null || config === void 0 ? void 0 : config.context) === null || _a === void 0 ? void 0 : _a.userLocale) || defaultLocale;
7204
+ const defaultContentLocale = ((_b = config === null || config === void 0 ? void 0 : config.context) === null || _b === void 0 ? void 0 : _b.contentLocale) || defaultLocale;
7223
7205
  const {
7224
7206
  connectWhenInView
7225
7207
  } = config;
@@ -7230,6 +7212,7 @@ const initializeConfig = createAsyncThunk('initializeConfig', (_, {
7230
7212
  agentParticipant,
7231
7213
  userParticipant,
7232
7214
  startChatIcon,
7215
+ defaultUserLocale,
7233
7216
  defaultContentLocale,
7234
7217
  connectWhenInView
7235
7218
  };
@@ -8813,7 +8796,7 @@ const resetApp = create_debounced_async_thunk('resetApp', (_, {
8813
8796
  leading: true
8814
8797
  });
8815
8798
  ;// CONCATENATED MODULE: ./src/javascripts/domains/config/slice.ts
8816
- var slice_rest = undefined && undefined.__rest || function (s, e) {
8799
+ var __rest = undefined && undefined.__rest || function (s, e) {
8817
8800
  var t = {};
8818
8801
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
8819
8802
  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
@@ -8857,7 +8840,7 @@ const updateState = (state, config) => {
8857
8840
  {
8858
8841
  messages
8859
8842
  } = _a,
8860
- partialConfig = slice_rest(_a, ["messages"]);
8843
+ partialConfig = __rest(_a, ["messages"]);
8861
8844
  let newState = state;
8862
8845
  if (Object.keys(partialConfig).length > 0) {
8863
8846
  newState = Object.assign(Object.assign({}, newState), partialConfig);
@@ -8892,6 +8875,7 @@ const configSlice = createSlice({
8892
8875
  agentParticipant,
8893
8876
  userParticipant,
8894
8877
  startChatIcon,
8878
+ defaultUserLocale,
8895
8879
  defaultContentLocale
8896
8880
  }
8897
8881
  }) => {
@@ -8900,6 +8884,7 @@ const configSlice = createSlice({
8900
8884
  type: 'message',
8901
8885
  payload
8902
8886
  }));
8887
+ state.context.userLocale = defaultUserLocale;
8903
8888
  state.context.contentLocale = defaultContentLocale;
8904
8889
  state.agentParticipant = agentParticipant;
8905
8890
  state.userParticipant = userParticipant;
@@ -9240,7 +9225,7 @@ const i18nSlice = createSlice({
9240
9225
  builder.addCase(resetApp.pending, () => i18n_slice_initialState).addCase(initializeConfig.fulfilled, (state, {
9241
9226
  payload
9242
9227
  }) => {
9243
- state.initialLocale = payload.defaultContentLocale;
9228
+ state.initialLocale = payload.defaultUserLocale;
9244
9229
  }).addCase(setLocale.pending, state => {
9245
9230
  state.isLoading = true;
9246
9231
  }).addCase(setLocale.rejected, state => {
@@ -10028,28 +10013,6 @@ function createOptionsMiddleware({
10028
10013
  return result;
10029
10014
  };
10030
10015
  }
10031
- ;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/selectors.ts
10032
-
10033
- const selectTranslations = createSelector(({
10034
- i18n
10035
- }) => i18n, ({
10036
- translations
10037
- }) => translations);
10038
- const selectInitialLocale = createSelector(({
10039
- i18n
10040
- }) => i18n, ({
10041
- initialLocale
10042
- }) => initialLocale);
10043
- const selectLocale = createSelector(({
10044
- i18n
10045
- }) => i18n, ({
10046
- userLocale
10047
- }) => userLocale);
10048
- const selectIsLoading = createSelector(({
10049
- i18n
10050
- }) => i18n, ({
10051
- isLoading
10052
- }) => isLoading);
10053
10016
  ;// CONCATENATED MODULE: ./src/javascripts/domains/translations/slice.ts
10054
10017
 
10055
10018
 
@@ -10154,8 +10117,8 @@ const translationSlice = createSlice({
10154
10117
  if (!feature) return;
10155
10118
  state.isAvailable = feature.enabled === true;
10156
10119
  state.languages = [...feature.languages].sort((a, b) => {
10157
- if (a.locale === payload.defaultContentLocale) return -1;
10158
- if (b.locale === payload.defaultContentLocale) return 1;
10120
+ if (a.locale === payload.defaultUserLocale) return -1;
10121
+ if (b.locale === payload.defaultUserLocale) return 1;
10159
10122
  return a.nativeName.localeCompare(b.nativeName, undefined, {
10160
10123
  sensitivity: 'base'
10161
10124
  });
@@ -10192,7 +10155,6 @@ const {
10192
10155
 
10193
10156
 
10194
10157
 
10195
-
10196
10158
  const createI18nMiddleware = ({
10197
10159
  dispatch,
10198
10160
  getState
@@ -10209,14 +10171,14 @@ const createI18nMiddleware = ({
10209
10171
  }
10210
10172
  }
10211
10173
  if (initializeConfig.fulfilled.match(action)) {
10212
- if (action.payload.defaultContentLocale) {
10213
- dispatch(setLocale(action.payload.defaultContentLocale));
10174
+ if (action.payload.defaultUserLocale) {
10175
+ dispatch(setLocale(action.payload.defaultUserLocale));
10214
10176
  return result;
10215
10177
  }
10216
10178
  }
10217
10179
  if (initializeApp.fulfilled.match(action)) {
10218
- if (action.payload.contentLocale) {
10219
- dispatch(setLocale(action.payload.contentLocale));
10180
+ if (action.payload.userLocale) {
10181
+ dispatch(setLocale(action.payload.userLocale));
10220
10182
  }
10221
10183
  return result;
10222
10184
  }
@@ -10226,11 +10188,6 @@ const createI18nMiddleware = ({
10226
10188
  return result;
10227
10189
  }
10228
10190
  }
10229
- if (disableTranslation.match(action)) {
10230
- const initialLocale = selectInitialLocale(getState());
10231
- dispatch(setLocale(initialLocale));
10232
- return result;
10233
- }
10234
10191
  return result;
10235
10192
  };
10236
10193
  };
@@ -11029,6 +10986,28 @@ function selectTypeHandler(value) {
11029
10986
 
11030
10987
  //# sourceMappingURL=icu-message-formatter.es.js.map
11031
10988
 
10989
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/selectors.ts
10990
+
10991
+ const selectTranslations = createSelector(({
10992
+ i18n
10993
+ }) => i18n, ({
10994
+ translations
10995
+ }) => translations);
10996
+ const selectInitialLocale = createSelector(({
10997
+ i18n
10998
+ }) => i18n, ({
10999
+ initialLocale
11000
+ }) => initialLocale);
11001
+ const selectLocale = createSelector(({
11002
+ i18n
11003
+ }) => i18n, ({
11004
+ userLocale
11005
+ }) => userLocale);
11006
+ const selectIsLoading = createSelector(({
11007
+ i18n
11008
+ }) => i18n, ({
11009
+ isLoading
11010
+ }) => isLoading);
11032
11011
  ;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/hooks.ts
11033
11012
 
11034
11013
 
@@ -12142,7 +12121,7 @@ function useTranslations() {
12142
12121
  }, [sendContext]);
12143
12122
  const disableTranslations = (0,hooks_.useCallback)(() => {
12144
12123
  sendContext({
12145
- userLocale: config.context.userLocale
12124
+ userLocale: config.context.contentLocale
12146
12125
  });
12147
12126
  dispatch(disableTranslation());
12148
12127
  }, [config.context, dispatch, sendContext]);
@@ -17381,7 +17360,7 @@ const TranslationOptions = ({ onChange, describedById, }) => {
17381
17360
  const { languages, currentLocale, enableTranslations, disableTranslations } = useTranslations();
17382
17361
  const focusSkiplinkTarget = useSkiplinkTargetFocusing();
17383
17362
  const handleChange = (locale) => () => {
17384
- if (locale === currentLocale || userLocale === locale) {
17363
+ if (locale === currentLocale || contentLocale === locale) {
17385
17364
  disableTranslations();
17386
17365
  }
17387
17366
  else {
@@ -21867,7 +21846,8 @@ const standardState = {
21867
21846
  ...baseState.config,
21868
21847
  context: {
21869
21848
  ...baseState.context,
21870
- contentLocale: 'nl'
21849
+ contentLocale: 'nl',
21850
+ userLocale: 'en'
21871
21851
  }
21872
21852
  },
21873
21853
  translations: {
@@ -21982,7 +21962,8 @@ const standardState = {
21982
21962
  ...baseState.config,
21983
21963
  context: {
21984
21964
  ...baseState.context,
21985
- contentLocale: 'nl'
21965
+ contentLocale: 'nl',
21966
+ userLocale: 'en'
21986
21967
  }
21987
21968
  },
21988
21969
  translations: {
@@ -22121,7 +22102,8 @@ const standardState = {
22121
22102
  ...baseState.config,
22122
22103
  showDisclaimer: true,
22123
22104
  context: {
22124
- contentLocale: 'nl-informal'
22105
+ contentLocale: 'nl-informal',
22106
+ userLocale: 'en-GB'
22125
22107
  }
22126
22108
  },
22127
22109
  translations: {
@@ -22153,7 +22135,8 @@ const standardState = {
22153
22135
  ...baseState.config,
22154
22136
  showDisclaimer: true,
22155
22137
  context: {
22156
- contentLocale: 'nl-informal'
22138
+ contentLocale: 'nl-informal',
22139
+ userLocale: 'en-GB'
22157
22140
  }
22158
22141
  },
22159
22142
  translations: {
@@ -22948,7 +22931,7 @@ class SeamlyStyleGuideInstance extends Engine {
22948
22931
  api.URLS = {
22949
22932
  translations: `/client/${this.config.api.key}/translations/{version}/{locale}.json`
22950
22933
  };
22951
- const translations = await api.getTranslations(this.config.context.contentLocale || 'en-GB');
22934
+ const translations = await api.getTranslations(this.config.context.userLocale || 'en-GB');
22952
22935
  const {
22953
22936
  agentParticipant,
22954
22937
  userParticipant