@seamly/web-ui 22.1.0 → 22.2.0

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 (50) hide show
  1. package/build/dist/lib/components.js +429 -180
  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.LICENSE.txt +2 -2
  5. package/build/dist/lib/components.min.js.map +1 -1
  6. package/build/dist/lib/hooks.js +84 -19
  7. package/build/dist/lib/hooks.js.map +1 -1
  8. package/build/dist/lib/hooks.min.js +1 -1
  9. package/build/dist/lib/hooks.min.js.map +1 -1
  10. package/build/dist/lib/index.debug.js +38 -38
  11. package/build/dist/lib/index.debug.min.js +1 -1
  12. package/build/dist/lib/index.debug.min.js.map +1 -1
  13. package/build/dist/lib/index.js +462 -193
  14. package/build/dist/lib/index.js.map +1 -1
  15. package/build/dist/lib/index.min.js +1 -1
  16. package/build/dist/lib/index.min.js.LICENSE.txt +2 -2
  17. package/build/dist/lib/index.min.js.map +1 -1
  18. package/build/dist/lib/standalone.js +539 -216
  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.LICENSE.txt +1 -1
  22. package/build/dist/lib/standalone.min.js.map +1 -1
  23. package/build/dist/lib/style-guide.js +557 -190
  24. package/build/dist/lib/style-guide.js.map +1 -1
  25. package/build/dist/lib/style-guide.min.js +1 -1
  26. package/build/dist/lib/style-guide.min.js.LICENSE.txt +2 -2
  27. package/build/dist/lib/style-guide.min.js.map +1 -1
  28. package/build/dist/lib/styles-default-implementation.js +1 -1
  29. package/build/dist/lib/styles.css +1 -1
  30. package/build/dist/lib/styles.js +1 -1
  31. package/build/dist/lib/utils.js +459 -190
  32. package/build/dist/lib/utils.js.map +1 -1
  33. package/build/dist/lib/utils.min.js +1 -1
  34. package/build/dist/lib/utils.min.js.LICENSE.txt +1 -1
  35. package/build/dist/lib/utils.min.js.map +1 -1
  36. package/package.json +28 -28
  37. package/src/javascripts/api/index.ts +13 -1
  38. package/src/javascripts/domains/config/slice.ts +2 -1
  39. package/src/javascripts/domains/forms/selectors.ts +6 -8
  40. package/src/javascripts/domains/forms/slice.ts +1 -1
  41. package/src/javascripts/domains/translations/components/options-dialog/translation-option.tsx +3 -1
  42. package/src/javascripts/domains/translations/components/options-dialog/translation-options.tsx +62 -35
  43. package/src/javascripts/domains/translations/slice.ts +8 -1
  44. package/src/javascripts/lib/engine/index.tsx +3 -1
  45. package/src/javascripts/style-guide/states.js +47 -0
  46. package/src/javascripts/ui/components/entry/text-entry/hooks.ts +2 -2
  47. package/src/javascripts/ui/components/form-controls/wrapper.tsx +13 -3
  48. package/src/stylesheets/5-components/_input.scss +0 -5
  49. package/src/stylesheets/5-components/_options.scss +2 -2
  50. package/src/stylesheets/5-components/_translation-options.scss +23 -3
@@ -3132,13 +3132,15 @@ const configSlice = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_3__/* .createSl
3132
3132
  preChat,
3133
3133
  agentParticipant,
3134
3134
  userParticipant,
3135
- startChatIcon
3135
+ startChatIcon,
3136
+ locale
3136
3137
  }
3137
3138
  }) => {
3138
3139
  state.preChatEvents = preChat.map(payload => ({
3139
3140
  type: 'message',
3140
3141
  payload
3141
3142
  }));
3143
+ state.context.locale = locale;
3142
3144
  state.agentParticipant = agentParticipant;
3143
3145
  state.userParticipant = userParticipant;
3144
3146
  state.startChatIcon = startChatIcon;
@@ -5564,7 +5566,13 @@ const translationSlice = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_3__/* .cre
5564
5566
  const feature = (_a = payload === null || payload === void 0 ? void 0 : payload.features) === null || _a === void 0 ? void 0 : _a.translation;
5565
5567
  if (!feature) return;
5566
5568
  state.isAvailable = feature.enabled === true;
5567
- state.languages = feature.languages;
5569
+ state.languages = [...feature.languages].sort((a, b) => {
5570
+ if (a.locale === payload.locale) return -1;
5571
+ if (b.locale === payload.locale) return 1;
5572
+ return a.nativeName.localeCompare(b.nativeName, undefined, {
5573
+ sensitivity: 'base'
5574
+ });
5575
+ });
5568
5576
  }).addCase(domains_store_slice__WEBPACK_IMPORTED_MODULE_2__/* .setHistory */ .JB, (state, {
5569
5577
  payload
5570
5578
  }) => {
@@ -8455,15 +8463,52 @@ var compat_module = __webpack_require__(8661);
8455
8463
  var utils_batch = __webpack_require__(9256);
8456
8464
  ;// CONCATENATED MODULE: ./node_modules/react-redux/es/components/Context.js
8457
8465
 
8458
- const Context_ReactReduxContext = /*#__PURE__*/(0,compat_module.createContext)(null);
8466
+ const ContextKey = Symbol.for(`react-redux-context-${compat_module.version}`);
8467
+ const gT = globalThis;
8468
+
8469
+ function getContext() {
8470
+ let realContext = gT[ContextKey];
8471
+
8472
+ if (!realContext) {
8473
+ realContext = (0,compat_module.createContext)(null);
8459
8474
 
8460
- if (false) {}
8475
+ if (false) {}
8476
+
8477
+ gT[ContextKey] = realContext;
8478
+ }
8461
8479
 
8480
+ return realContext;
8481
+ }
8482
+
8483
+ const Context_ReactReduxContext = /*#__PURE__*/new Proxy({}, /*#__PURE__*/new Proxy({}, {
8484
+ get(_, handler) {
8485
+ const target = getContext(); // @ts-ignore
8486
+
8487
+ return (_target, ...args) => Reflect[handler](target, ...args);
8488
+ }
8489
+
8490
+ }));
8462
8491
  /* harmony default export */ const Context = ((/* unused pure expression or super */ null && (Context_ReactReduxContext)));
8463
8492
  ;// CONCATENATED MODULE: ./node_modules/react-redux/es/hooks/useReduxContext.js
8464
8493
 
8465
8494
 
8466
8495
 
8496
+ /**
8497
+ * Hook factory, which creates a `useReduxContext` hook bound to a given context. This is a low-level
8498
+ * hook that you should usually not need to call directly.
8499
+ *
8500
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
8501
+ * @returns {Function} A `useReduxContext` hook bound to the specified context.
8502
+ */
8503
+ function createReduxContextHook(context = Context_ReactReduxContext) {
8504
+ return function useReduxContext() {
8505
+ const contextValue = (0,compat_module.useContext)(context);
8506
+
8507
+ if (false) {}
8508
+
8509
+ return contextValue;
8510
+ };
8511
+ }
8467
8512
  /**
8468
8513
  * A hook to access the value of the `ReactReduxContext`. This is a low-level
8469
8514
  * hook that you should usually not need to call directly.
@@ -8480,13 +8525,8 @@ if (false) {}
8480
8525
  * return <div>{store.getState()}</div>
8481
8526
  * }
8482
8527
  */
8483
- function useReduxContext_useReduxContext() {
8484
- const contextValue = (0,compat_module.useContext)(Context_ReactReduxContext);
8485
8528
 
8486
- if (false) {}
8487
-
8488
- return contextValue;
8489
- }
8529
+ const useReduxContext_useReduxContext = /*#__PURE__*/createReduxContextHook();
8490
8530
  ;// CONCATENATED MODULE: ./node_modules/react-redux/es/utils/useSyncExternalStore.js
8491
8531
  const useSyncExternalStore_notInitialized = () => {
8492
8532
  throw new Error('uSES not initialized!');
@@ -8511,16 +8551,37 @@ const refEquality = (a, b) => a === b;
8511
8551
 
8512
8552
 
8513
8553
  function createSelectorHook(context = Context_ReactReduxContext) {
8514
- const useReduxContext = context === Context_ReactReduxContext ? useReduxContext_useReduxContext : () => (0,compat_module.useContext)(context);
8515
- return function useSelector(selector, equalityFn = refEquality) {
8554
+ const useReduxContext = context === Context_ReactReduxContext ? useReduxContext_useReduxContext : createReduxContextHook(context);
8555
+ return function useSelector(selector, equalityFnOrOptions = {}) {
8556
+ const {
8557
+ equalityFn = refEquality,
8558
+ stabilityCheck = undefined,
8559
+ noopCheck = undefined
8560
+ } = typeof equalityFnOrOptions === 'function' ? {
8561
+ equalityFn: equalityFnOrOptions
8562
+ } : equalityFnOrOptions;
8563
+
8516
8564
  if (false) {}
8517
8565
 
8518
8566
  const {
8519
8567
  store,
8520
8568
  subscription,
8521
- getServerState
8569
+ getServerState,
8570
+ stabilityCheck: globalStabilityCheck,
8571
+ noopCheck: globalNoopCheck
8522
8572
  } = useReduxContext();
8523
- const selectedState = useSyncExternalStoreWithSelector(subscription.addNestedSub, store.getState, getServerState || store.getState, selector, equalityFn);
8573
+ const firstRun = (0,compat_module.useRef)(true);
8574
+ const wrappedSelector = (0,compat_module.useCallback)({
8575
+ [selector.name](state) {
8576
+ const selected = selector(state);
8577
+
8578
+ if (false) {}
8579
+
8580
+ return selected;
8581
+ }
8582
+
8583
+ }[selector.name], [selector, globalStabilityCheck, stabilityCheck]);
8584
+ const selectedState = useSyncExternalStoreWithSelector(subscription.addNestedSub, store.getState, getServerState || store.getState, wrappedSelector, equalityFn);
8524
8585
  (0,compat_module.useDebugValue)(selectedState);
8525
8586
  return selectedState;
8526
8587
  };
@@ -9107,16 +9168,20 @@ function Provider({
9107
9168
  store,
9108
9169
  context,
9109
9170
  children,
9110
- serverState
9171
+ serverState,
9172
+ stabilityCheck = 'once',
9173
+ noopCheck = 'once'
9111
9174
  }) {
9112
9175
  const contextValue = (0,compat_module.useMemo)(() => {
9113
9176
  const subscription = Subscription_createSubscription(store);
9114
9177
  return {
9115
9178
  store,
9116
9179
  subscription,
9117
- getServerState: serverState ? () => serverState : undefined
9180
+ getServerState: serverState ? () => serverState : undefined,
9181
+ stabilityCheck,
9182
+ noopCheck
9118
9183
  };
9119
- }, [store, serverState]);
9184
+ }, [store, serverState, stabilityCheck, noopCheck]);
9120
9185
  const previousState = (0,compat_module.useMemo)(() => store.getState(), [store]);
9121
9186
  useIsomorphicLayoutEffect_useIsomorphicLayoutEffect(() => {
9122
9187
  const {
@@ -9145,7 +9210,6 @@ function Provider({
9145
9210
  ;// CONCATENATED MODULE: ./node_modules/react-redux/es/hooks/useStore.js
9146
9211
 
9147
9212
 
9148
-
9149
9213
  /**
9150
9214
  * Hook factory, which creates a `useStore` hook bound to a given context.
9151
9215
  *
@@ -9155,7 +9219,8 @@ function Provider({
9155
9219
 
9156
9220
  function createStoreHook(context = Context_ReactReduxContext) {
9157
9221
  const useReduxContext = // @ts-ignore
9158
- context === Context_ReactReduxContext ? useReduxContext_useReduxContext : () => (0,compat_module.useContext)(context);
9222
+ context === Context_ReactReduxContext ? useReduxContext_useReduxContext : // @ts-ignore
9223
+ createReduxContextHook(context);
9159
9224
  return function useStore() {
9160
9225
  const {
9161
9226
  store
@@ -11379,6 +11444,7 @@ _ConversationConnector_connectionListeners = new WeakMap(), _ConversationConnect
11379
11444
  return !complete;
11380
11445
  }), "f");
11381
11446
  };
11447
+ /* harmony default export */ const conversation_connector = (ConversationConnector);
11382
11448
  ;// CONCATENATED MODULE: ./src/javascripts/api/index.ts
11383
11449
  var api_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
11384
11450
  function adopt(value) {
@@ -11418,6 +11484,14 @@ var api_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet ||
11418
11484
  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");
11419
11485
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11420
11486
  };
11487
+ var __rest = undefined && undefined.__rest || function (s, e) {
11488
+ var t = {};
11489
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
11490
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11491
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
11492
+ }
11493
+ return t;
11494
+ };
11421
11495
  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, _API_getEnvironment;
11422
11496
 
11423
11497
 
@@ -11505,7 +11579,7 @@ class API {
11505
11579
  _API_conversationAuthToken.set(this, void 0);
11506
11580
  _API_layoutMode.set(this, void 0);
11507
11581
  _API_config.set(this, void 0);
11508
- this.conversation = new ConversationConnector();
11582
+ this.conversation = new conversation_connector();
11509
11583
  _API_getLocale.set(this, locale => locale || this.locale);
11510
11584
  this.store = objectStore(`${namespace}.connection${context.locale ? `.${context.locale}` : ''}`, config.storageProvider || store);
11511
11585
  this.connectionInfo = {
@@ -11778,6 +11852,7 @@ class API {
11778
11852
  this.conversation.pushToChannel(command, buildPayload(command, payload), 10000);
11779
11853
  }
11780
11854
  sendContext(context) {
11855
+ var _a;
11781
11856
  const {
11782
11857
  locale,
11783
11858
  variables
@@ -11799,7 +11874,15 @@ class API {
11799
11874
  if (Object.keys(payload).length === 0 && payload.constructor === Object) {
11800
11875
  return;
11801
11876
  }
11802
- this.send('context', payload, false);
11877
+ // Destructure the server locale from the payload
11878
+ const {
11879
+ locale: _
11880
+ } = payload,
11881
+ restPayload = __rest(payload, ["locale"]);
11882
+ const configLocale = (_a = api_classPrivateFieldGet(this, _API_config, "f").context) === null || _a === void 0 ? void 0 : _a.locale;
11883
+ this.send('context', Object.assign(Object.assign({}, configLocale ? {
11884
+ locale: configLocale
11885
+ } : {}), restPayload), false);
11803
11886
  }
11804
11887
  }
11805
11888
  _API_ready = new WeakMap(), _API_externalId = new WeakMap(), _API_conversationAuthToken = new WeakMap(), _API_layoutMode = new WeakMap(), _API_config = new WeakMap(), _API_getLocale = new WeakMap(), _API_instances = new WeakSet(), _API_getAccessToken = function _API_getAccessToken() {
@@ -11876,7 +11959,7 @@ _API_ready = new WeakMap(), _API_externalId = new WeakMap(), _API_conversationAu
11876
11959
  return {
11877
11960
  clientName: "@seamly/web-ui",
11878
11961
  clientVariant: api_classPrivateFieldGet(this, _API_layoutMode, "f"),
11879
- clientVersion: "22.1.0",
11962
+ clientVersion: "22.2.0",
11880
11963
  currentUrl: window.location.toString(),
11881
11964
  screenResolution: `${window.screen.width}x${window.screen.height}`,
11882
11965
  timezone: getTimeZone(),
@@ -12794,7 +12877,7 @@ const TimeIndicator = ({
12794
12877
  var store_slice = __webpack_require__(8801);
12795
12878
  ;// CONCATENATED MODULE: ./node_modules/tabbable/dist/index.esm.js
12796
12879
  /*!
12797
- * tabbable 6.1.2
12880
+ * tabbable 6.2.0
12798
12881
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
12799
12882
  */
12800
12883
  // NOTE: separate `:not()` selectors has broader browser support than the newer
@@ -12974,7 +13057,27 @@ var getCandidatesIteratively = function getCandidatesIteratively(elements, inclu
12974
13057
  }
12975
13058
  return candidates;
12976
13059
  };
12977
- var getTabindex = function getTabindex(node, isScope) {
13060
+
13061
+ /**
13062
+ * @private
13063
+ * Determines if the node has an explicitly specified `tabindex` attribute.
13064
+ * @param {HTMLElement} node
13065
+ * @returns {boolean} True if so; false if not.
13066
+ */
13067
+ var hasTabIndex = function hasTabIndex(node) {
13068
+ return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
13069
+ };
13070
+
13071
+ /**
13072
+ * Determine the tab index of a given node.
13073
+ * @param {HTMLElement} node
13074
+ * @returns {number} Tab order (negative, 0, or positive number).
13075
+ * @throws {Error} If `node` is falsy.
13076
+ */
13077
+ var getTabIndex = function getTabIndex(node) {
13078
+ if (!node) {
13079
+ throw new Error('No node provided');
13080
+ }
12978
13081
  if (node.tabIndex < 0) {
12979
13082
  // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
12980
13083
  // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
@@ -12983,16 +13086,28 @@ var getTabindex = function getTabindex(node, isScope) {
12983
13086
  // order, consider their tab index to be 0.
12984
13087
  // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
12985
13088
  // so if they don't have a tabindex attribute specifically set, assume it's 0.
12986
- //
12987
- // isScope is positive for custom element with shadow root or slot that by default
12988
- // have tabIndex -1, but need to be sorted by document order in order for their
12989
- // content to be inserted in the correct position
12990
- if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) {
13089
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
12991
13090
  return 0;
12992
13091
  }
12993
13092
  }
12994
13093
  return node.tabIndex;
12995
13094
  };
13095
+
13096
+ /**
13097
+ * Determine the tab index of a given node __for sort order purposes__.
13098
+ * @param {HTMLElement} node
13099
+ * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
13100
+ * has tabIndex -1, but needs to be sorted by document order in order for its content to be
13101
+ * inserted into the correct sort position.
13102
+ * @returns {number} Tab order (negative, 0, or positive number).
13103
+ */
13104
+ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
13105
+ var tabIndex = getTabIndex(node);
13106
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
13107
+ return 0;
13108
+ }
13109
+ return tabIndex;
13110
+ };
12996
13111
  var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
12997
13112
  return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
12998
13113
  };
@@ -13235,7 +13350,7 @@ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(o
13235
13350
  return true;
13236
13351
  };
13237
13352
  var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
13238
- if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
13353
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
13239
13354
  return false;
13240
13355
  }
13241
13356
  return true;
@@ -13260,7 +13375,7 @@ var sortByOrder = function sortByOrder(candidates) {
13260
13375
  candidates.forEach(function (item, i) {
13261
13376
  var isScope = !!item.scopeParent;
13262
13377
  var element = isScope ? item.scopeParent : item;
13263
- var candidateTabindex = getTabindex(element, isScope);
13378
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
13264
13379
  var elements = isScope ? sortByOrder(item.candidates) : element;
13265
13380
  if (candidateTabindex === 0) {
13266
13381
  isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
@@ -13279,32 +13394,32 @@ var sortByOrder = function sortByOrder(candidates) {
13279
13394
  return acc;
13280
13395
  }, []).concat(regularTabbables);
13281
13396
  };
13282
- var tabbable = function tabbable(el, options) {
13397
+ var tabbable = function tabbable(container, options) {
13283
13398
  options = options || {};
13284
13399
  var candidates;
13285
13400
  if (options.getShadowRoot) {
13286
- candidates = getCandidatesIteratively([el], options.includeContainer, {
13401
+ candidates = getCandidatesIteratively([container], options.includeContainer, {
13287
13402
  filter: isNodeMatchingSelectorTabbable.bind(null, options),
13288
13403
  flatten: false,
13289
13404
  getShadowRoot: options.getShadowRoot,
13290
13405
  shadowRootFilter: isValidShadowRootTabbable
13291
13406
  });
13292
13407
  } else {
13293
- candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
13408
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
13294
13409
  }
13295
13410
  return sortByOrder(candidates);
13296
13411
  };
13297
- var focusable = function focusable(el, options) {
13412
+ var focusable = function focusable(container, options) {
13298
13413
  options = options || {};
13299
13414
  var candidates;
13300
13415
  if (options.getShadowRoot) {
13301
- candidates = getCandidatesIteratively([el], options.includeContainer, {
13416
+ candidates = getCandidatesIteratively([container], options.includeContainer, {
13302
13417
  filter: isNodeMatchingSelectorFocusable.bind(null, options),
13303
13418
  flatten: true,
13304
13419
  getShadowRoot: options.getShadowRoot
13305
13420
  });
13306
13421
  } else {
13307
- candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
13422
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
13308
13423
  }
13309
13424
  return candidates;
13310
13425
  };
@@ -13335,7 +13450,7 @@ var isFocusable = function isFocusable(node, options) {
13335
13450
 
13336
13451
  ;// CONCATENATED MODULE: ./node_modules/focus-trap/dist/focus-trap.esm.js
13337
13452
  /*!
13338
- * focus-trap 7.4.3
13453
+ * focus-trap 7.5.2
13339
13454
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
13340
13455
  */
13341
13456
 
@@ -13421,10 +13536,10 @@ var isSelectableInput = function isSelectableInput(node) {
13421
13536
  return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
13422
13537
  };
13423
13538
  var isEscapeEvent = function isEscapeEvent(e) {
13424
- return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
13539
+ return (e === null || e === void 0 ? void 0 : e.key) === 'Escape' || (e === null || e === void 0 ? void 0 : e.key) === 'Esc' || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
13425
13540
  };
13426
13541
  var isTabEvent = function isTabEvent(e) {
13427
- return e.key === 'Tab' || e.keyCode === 9;
13542
+ return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
13428
13543
  };
13429
13544
 
13430
13545
  // checks for TAB by default
@@ -13508,8 +13623,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13508
13623
  // container: HTMLElement,
13509
13624
  // tabbableNodes: Array<HTMLElement>, // empty if none
13510
13625
  // focusableNodes: Array<HTMLElement>, // empty if none
13511
- // firstTabbableNode: HTMLElement|null,
13512
- // lastTabbableNode: HTMLElement|null,
13626
+ // posTabIndexesFound: boolean,
13627
+ // firstTabbableNode: HTMLElement|undefined,
13628
+ // lastTabbableNode: HTMLElement|undefined,
13629
+ // firstDomTabbableNode: HTMLElement|undefined,
13630
+ // lastDomTabbableNode: HTMLElement|undefined,
13513
13631
  // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
13514
13632
  // }>}
13515
13633
  containerGroups: [],
@@ -13526,7 +13644,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13526
13644
  paused: false,
13527
13645
  // timer ID for when delayInitialFocus is true and initial focus in this trap
13528
13646
  // has been delayed during activation
13529
- delayInitialFocusTimer: undefined
13647
+ delayInitialFocusTimer: undefined,
13648
+ // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
13649
+ recentNavEvent: undefined
13530
13650
  };
13531
13651
  var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later
13532
13652
 
@@ -13545,7 +13665,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13545
13665
  /**
13546
13666
  * Finds the index of the container that contains the element.
13547
13667
  * @param {HTMLElement} element
13548
- * @param {Event} [event]
13668
+ * @param {Event} [event] If available, and `element` isn't directly found in any container,
13669
+ * the event's composed path is used to see if includes any known trap containers in the
13670
+ * case where the element is inside a Shadow DOM.
13549
13671
  * @returns {number} Index of the container in either `state.containers` or
13550
13672
  * `state.containerGroups` (the order/length of these lists are the same); -1
13551
13673
  * if the element isn't found.
@@ -13640,14 +13762,41 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13640
13762
  var tabbableNodes = tabbable(container, config.tabbableOptions);
13641
13763
 
13642
13764
  // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
13643
- // are a superset of tabbable nodes
13765
+ // are a superset of tabbable nodes since nodes with negative `tabindex` attributes
13766
+ // are focusable but not tabbable
13644
13767
  var focusableNodes = focusable(container, config.tabbableOptions);
13768
+ var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
13769
+ var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
13770
+ var firstDomTabbableNode = focusableNodes.find(function (node) {
13771
+ return isTabbable(node);
13772
+ });
13773
+ var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
13774
+ return isTabbable(node);
13775
+ });
13776
+ var posTabIndexesFound = !!tabbableNodes.find(function (node) {
13777
+ return getTabIndex(node) > 0;
13778
+ });
13645
13779
  return {
13646
13780
  container: container,
13647
13781
  tabbableNodes: tabbableNodes,
13648
13782
  focusableNodes: focusableNodes,
13649
- firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
13650
- lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
13783
+ /** True if at least one node with positive `tabindex` was found in this container. */
13784
+ posTabIndexesFound: posTabIndexesFound,
13785
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
13786
+ firstTabbableNode: firstTabbableNode,
13787
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
13788
+ lastTabbableNode: lastTabbableNode,
13789
+ // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
13790
+ // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
13791
+ // because that API doesn't work with Shadow DOM as well as it should (@see
13792
+ // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
13793
+ // to address an edge case related to positive tabindex support, this seems like a much easier,
13794
+ // "close enough most of the time" alternative for positive tabindexes which should generally
13795
+ // be avoided anyway...
13796
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
13797
+ firstDomTabbableNode: firstDomTabbableNode,
13798
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
13799
+ lastDomTabbableNode: lastDomTabbableNode,
13651
13800
  /**
13652
13801
  * Finds the __tabbable__ node that follows the given node in the specified direction,
13653
13802
  * in this container, if any.
@@ -13658,30 +13807,24 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13658
13807
  */
13659
13808
  nextTabbableNode: function nextTabbableNode(node) {
13660
13809
  var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
13661
- // NOTE: If tabindex is positive (in order to manipulate the tab order separate
13662
- // from the DOM order), this __will not work__ because the list of focusableNodes,
13663
- // while it contains tabbable nodes, does not sort its nodes in any order other
13664
- // than DOM order, because it can't: Where would you place focusable (but not
13665
- // tabbable) nodes in that order? They have no order, because they aren't tabbale...
13666
- // Support for positive tabindex is already broken and hard to manage (possibly
13667
- // not supportable, TBD), so this isn't going to make things worse than they
13668
- // already are, and at least makes things better for the majority of cases where
13669
- // tabindex is either 0/unset or negative.
13670
- // FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
13671
- var nodeIdx = focusableNodes.findIndex(function (n) {
13672
- return n === node;
13673
- });
13810
+ var nodeIdx = tabbableNodes.indexOf(node);
13674
13811
  if (nodeIdx < 0) {
13675
- return undefined;
13676
- }
13677
- if (forward) {
13678
- return focusableNodes.slice(nodeIdx + 1).find(function (n) {
13679
- return isTabbable(n, config.tabbableOptions);
13812
+ // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):
13813
+ // since `node` should at least have been focusable, we assume that's the case and mimic
13814
+ // what browsers do, which is set focus to the next node in __document position order__,
13815
+ // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE
13816
+ // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to
13817
+ // basic DOM order
13818
+ if (forward) {
13819
+ return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
13820
+ return isTabbable(el);
13821
+ });
13822
+ }
13823
+ return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
13824
+ return isTabbable(el);
13680
13825
  });
13681
13826
  }
13682
- return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
13683
- return isTabbable(n, config.tabbableOptions);
13684
- });
13827
+ return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
13685
13828
  }
13686
13829
  };
13687
13830
  });
@@ -13694,6 +13837,19 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13694
13837
  ) {
13695
13838
  throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
13696
13839
  }
13840
+
13841
+ // NOTE: Positive tabindexes are only properly supported in single-container traps because
13842
+ // doing it across multiple containers where tabindexes could be all over the place
13843
+ // would require Tabbable to support multiple containers, would require additional
13844
+ // specialized Shadow DOM support, and would require Tabbable's multi-container support
13845
+ // to look at those containers in document position order rather than user-provided
13846
+ // order (as they are treated in Focus-trap, for legacy reasons). See discussion on
13847
+ // https://github.com/focus-trap/focus-trap/issues/375 for more details.
13848
+ if (state.containerGroups.find(function (g) {
13849
+ return g.posTabIndexesFound;
13850
+ }) && state.containerGroups.length > 1) {
13851
+ throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
13852
+ }
13697
13853
  };
13698
13854
  var tryFocus = function tryFocus(node) {
13699
13855
  if (node === false) {
@@ -13709,6 +13865,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13709
13865
  node.focus({
13710
13866
  preventScroll: !!config.preventScroll
13711
13867
  });
13868
+ // NOTE: focus() API does not trigger focusIn event so set MRU node manually
13712
13869
  state.mostRecentlyFocusedNode = node;
13713
13870
  if (isSelectableInput(node)) {
13714
13871
  node.select();
@@ -13719,64 +13876,23 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13719
13876
  return node ? node : node === false ? false : previousActiveElement;
13720
13877
  };
13721
13878
 
13722
- // This needs to be done on mousedown and touchstart instead of click
13723
- // so that it precedes the focus event.
13724
- var checkPointerDown = function checkPointerDown(e) {
13725
- var target = getActualTarget(e);
13726
- if (findContainerIndex(target, e) >= 0) {
13727
- // allow the click since it ocurred inside the trap
13728
- return;
13729
- }
13730
- if (valueOrHandler(config.clickOutsideDeactivates, e)) {
13731
- // immediately deactivate the trap
13732
- trap.deactivate({
13733
- // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
13734
- // which will result in the outside click setting focus to the node
13735
- // that was clicked (and if not focusable, to "nothing"); by setting
13736
- // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
13737
- // on activation (or the configured `setReturnFocus` node), whether the
13738
- // outside click was on a focusable node or not
13739
- returnFocus: config.returnFocusOnDeactivate
13740
- });
13741
- return;
13742
- }
13743
-
13744
- // This is needed for mobile devices.
13745
- // (If we'll only let `click` events through,
13746
- // then on mobile they will be blocked anyways if `touchstart` is blocked.)
13747
- if (valueOrHandler(config.allowOutsideClick, e)) {
13748
- // allow the click outside the trap to take place
13749
- return;
13750
- }
13751
-
13752
- // otherwise, prevent the click
13753
- e.preventDefault();
13754
- };
13755
-
13756
- // In case focus escapes the trap for some strange reason, pull it back in.
13757
- var checkFocusIn = function checkFocusIn(e) {
13758
- var target = getActualTarget(e);
13759
- var targetContained = findContainerIndex(target, e) >= 0;
13760
-
13761
- // In Firefox when you Tab out of an iframe the Document is briefly focused.
13762
- if (targetContained || target instanceof Document) {
13763
- if (targetContained) {
13764
- state.mostRecentlyFocusedNode = target;
13765
- }
13766
- } else {
13767
- // escaped! pull it back in to where it just left
13768
- e.stopImmediatePropagation();
13769
- tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
13770
- }
13771
- };
13772
-
13773
- // Hijack key nav events on the first and last focusable nodes of the trap,
13774
- // in order to prevent focus from escaping. If it escapes for even a
13775
- // moment it can end up scrolling the page and causing confusion so we
13776
- // kind of need to capture the action at the keydown phase.
13777
- var checkKeyNav = function checkKeyNav(event) {
13778
- var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
13779
- var target = getActualTarget(event);
13879
+ /**
13880
+ * Finds the next node (in either direction) where focus should move according to a
13881
+ * keyboard focus-in event.
13882
+ * @param {Object} params
13883
+ * @param {Node} [params.target] Known target __from which__ to navigate, if any.
13884
+ * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
13885
+ * will be used to determine the `target`). Ignored if `target` is specified.
13886
+ * @param {boolean} [params.isBackward] True if focus should move backward.
13887
+ * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
13888
+ * determined given the current state of the trap.
13889
+ */
13890
+ var findNextNavNode = function findNextNavNode(_ref2) {
13891
+ var target = _ref2.target,
13892
+ event = _ref2.event,
13893
+ _ref2$isBackward = _ref2.isBackward,
13894
+ isBackward = _ref2$isBackward === void 0 ? false : _ref2$isBackward;
13895
+ target = target || getActualTarget(event);
13780
13896
  updateTabbableNodes();
13781
13897
  var destinationNode = null;
13782
13898
  if (state.tabbableGroups.length > 0) {
@@ -13799,8 +13915,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13799
13915
  // REVERSE
13800
13916
 
13801
13917
  // is the target the first tabbable node in a group?
13802
- var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
13803
- var firstTabbableNode = _ref2.firstTabbableNode;
13918
+ var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
13919
+ var firstTabbableNode = _ref3.firstTabbableNode;
13804
13920
  return target === firstTabbableNode;
13805
13921
  });
13806
13922
  if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
@@ -13818,7 +13934,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13818
13934
  // the LAST group if it's the first tabbable node of the FIRST group)
13819
13935
  var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
13820
13936
  var destinationGroup = state.tabbableGroups[destinationGroupIndex];
13821
- destinationNode = destinationGroup.lastTabbableNode;
13937
+ destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
13822
13938
  } else if (!isTabEvent(event)) {
13823
13939
  // user must have customized the nav keys so we have to move focus manually _within_
13824
13940
  // the active group: do this based on the order determined by tabbable()
@@ -13828,8 +13944,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13828
13944
  // FORWARD
13829
13945
 
13830
13946
  // is the target the last tabbable node in a group?
13831
- var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
13832
- var lastTabbableNode = _ref3.lastTabbableNode;
13947
+ var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
13948
+ var lastTabbableNode = _ref4.lastTabbableNode;
13833
13949
  return target === lastTabbableNode;
13834
13950
  });
13835
13951
  if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
@@ -13847,7 +13963,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13847
13963
  // group if it's the last tabbable node of the LAST group)
13848
13964
  var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
13849
13965
  var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
13850
- destinationNode = _destinationGroup.firstTabbableNode;
13966
+ destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
13851
13967
  } else if (!isTabEvent(event)) {
13852
13968
  // user must have customized the nav keys so we have to move focus manually _within_
13853
13969
  // the active group: do this based on the order determined by tabbable()
@@ -13859,6 +13975,153 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
13859
13975
  // NOTE: the fallbackFocus option does not support returning false to opt-out
13860
13976
  destinationNode = getNodeForOption('fallbackFocus');
13861
13977
  }
13978
+ return destinationNode;
13979
+ };
13980
+
13981
+ // This needs to be done on mousedown and touchstart instead of click
13982
+ // so that it precedes the focus event.
13983
+ var checkPointerDown = function checkPointerDown(e) {
13984
+ var target = getActualTarget(e);
13985
+ if (findContainerIndex(target, e) >= 0) {
13986
+ // allow the click since it ocurred inside the trap
13987
+ return;
13988
+ }
13989
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
13990
+ // immediately deactivate the trap
13991
+ trap.deactivate({
13992
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
13993
+ // which will result in the outside click setting focus to the node
13994
+ // that was clicked (and if not focusable, to "nothing"); by setting
13995
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
13996
+ // on activation (or the configured `setReturnFocus` node), whether the
13997
+ // outside click was on a focusable node or not
13998
+ returnFocus: config.returnFocusOnDeactivate
13999
+ });
14000
+ return;
14001
+ }
14002
+
14003
+ // This is needed for mobile devices.
14004
+ // (If we'll only let `click` events through,
14005
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
14006
+ if (valueOrHandler(config.allowOutsideClick, e)) {
14007
+ // allow the click outside the trap to take place
14008
+ return;
14009
+ }
14010
+
14011
+ // otherwise, prevent the click
14012
+ e.preventDefault();
14013
+ };
14014
+
14015
+ // In case focus escapes the trap for some strange reason, pull it back in.
14016
+ // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected
14017
+ // scrolling if the node that got focused was out of view; there's nothing we can do to
14018
+ // prevent that from happening by the time we discover that focus escaped
14019
+ var checkFocusIn = function checkFocusIn(event) {
14020
+ var target = getActualTarget(event);
14021
+ var targetContained = findContainerIndex(target, event) >= 0;
14022
+
14023
+ // In Firefox when you Tab out of an iframe the Document is briefly focused.
14024
+ if (targetContained || target instanceof Document) {
14025
+ if (targetContained) {
14026
+ state.mostRecentlyFocusedNode = target;
14027
+ }
14028
+ } else {
14029
+ // escaped! pull it back in to where it just left
14030
+ event.stopImmediatePropagation();
14031
+
14032
+ // focus will escape if the MRU node had a positive tab index and user tried to nav forward;
14033
+ // it will also escape if the MRU node had a 0 tab index and user tried to nav backward
14034
+ // toward a node with a positive tab index
14035
+ var nextNode; // next node to focus, if we find one
14036
+ var navAcrossContainers = true;
14037
+ if (state.mostRecentlyFocusedNode) {
14038
+ if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
14039
+ // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
14040
+ var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
14041
+ // there MAY not be any tabbable nodes in the container if there are at least 2 containers
14042
+ // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container
14043
+ // with at least one tabbable node in order to function, so this could be the other container
14044
+ // with nothing tabbable in it)
14045
+ var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
14046
+ if (tabbableNodes.length > 0) {
14047
+ // MRU tab index MAY not be found if the MRU node is focusable but not tabbable
14048
+ var mruTabIdx = tabbableNodes.findIndex(function (node) {
14049
+ return node === state.mostRecentlyFocusedNode;
14050
+ });
14051
+ if (mruTabIdx >= 0) {
14052
+ if (config.isKeyForward(state.recentNavEvent)) {
14053
+ if (mruTabIdx + 1 < tabbableNodes.length) {
14054
+ nextNode = tabbableNodes[mruTabIdx + 1];
14055
+ navAcrossContainers = false;
14056
+ }
14057
+ // else, don't wrap within the container as focus should move to next/previous
14058
+ // container
14059
+ } else {
14060
+ if (mruTabIdx - 1 >= 0) {
14061
+ nextNode = tabbableNodes[mruTabIdx - 1];
14062
+ navAcrossContainers = false;
14063
+ }
14064
+ // else, don't wrap within the container as focus should move to next/previous
14065
+ // container
14066
+ }
14067
+ // else, don't find in container order without considering direction too
14068
+ }
14069
+ }
14070
+ // else, no tabbable nodes in that container (which means we must have at least one other
14071
+ // container with at least one tabbable node in it, otherwise focus-trap would've thrown
14072
+ // an error the last time updateTabbableNodes() was run): find next node among all known
14073
+ // containers
14074
+ } else {
14075
+ // check to see if there's at least one tabbable node with a positive tab index inside
14076
+ // the trap because focus seems to escape when navigating backward from a tabbable node
14077
+ // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with
14078
+ // the greatest positive tab index like it should)
14079
+ if (!state.containerGroups.some(function (g) {
14080
+ return g.tabbableNodes.some(function (n) {
14081
+ return getTabIndex(n) > 0;
14082
+ });
14083
+ })) {
14084
+ // no containers with tabbable nodes with positive tab indexes which means the focus
14085
+ // escaped for some other reason and we should just execute the fallback to the
14086
+ // MRU node or initial focus node, if any
14087
+ navAcrossContainers = false;
14088
+ }
14089
+ }
14090
+ } else {
14091
+ // no MRU node means we're likely in some initial condition when the trap has just
14092
+ // been activated and initial focus hasn't been given yet, in which case we should
14093
+ // fall through to trying to focus the initial focus node, which is what should
14094
+ // happen below at this point in the logic
14095
+ navAcrossContainers = false;
14096
+ }
14097
+ if (navAcrossContainers) {
14098
+ nextNode = findNextNavNode({
14099
+ // move FROM the MRU node, not event-related node (which will be the node that is
14100
+ // outside the trap causing the focus escape we're trying to fix)
14101
+ target: state.mostRecentlyFocusedNode,
14102
+ isBackward: config.isKeyBackward(state.recentNavEvent)
14103
+ });
14104
+ }
14105
+ if (nextNode) {
14106
+ tryFocus(nextNode);
14107
+ } else {
14108
+ tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
14109
+ }
14110
+ }
14111
+ state.recentNavEvent = undefined; // clear
14112
+ };
14113
+
14114
+ // Hijack key nav events on the first and last focusable nodes of the trap,
14115
+ // in order to prevent focus from escaping. If it escapes for even a
14116
+ // moment it can end up scrolling the page and causing confusion so we
14117
+ // kind of need to capture the action at the keydown phase.
14118
+ var checkKeyNav = function checkKeyNav(event) {
14119
+ var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
14120
+ state.recentNavEvent = event;
14121
+ var destinationNode = findNextNavNode({
14122
+ event: event,
14123
+ isBackward: isBackward
14124
+ });
13862
14125
  if (destinationNode) {
13863
14126
  if (isTabEvent(event)) {
13864
14127
  // since tab natively moves focus, we wouldn't have a destination node unless we
@@ -14749,7 +15012,7 @@ const SeamlyActivityMonitor = ({ children }) => {
14749
15012
  // It is important to use keyUp here as focus may be set from outside the
14750
15013
  // chat container via keyboard. In this case the keyDown handler would not
14751
15014
  // be fired inside the container on the initial focus event.
14752
- return ((0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('activity-monitor'), tabIndex: -1, onMouseDown: onActivityHandler, onKeyUp: onActivityHandler, onTouchStart: onActivityHandler, onMouseMove: onActivityHandler, onWheel: onActivityHandler, onPointerDown: onActivityHandler, onPointerMove: onActivityHandler }, { children: (0,jsx_runtime_.jsx)(seamly_activity_event_context/* default */.Z.Provider, Object.assign({ value: onActivityHandler }, { children: children })) })));
15015
+ return ((0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('activity-monitor'), tabIndex: -1, onMouseDown: onActivityHandler, onKeyUp: onActivityHandler, onTouchStart: onActivityHandler, onMouseMove: onActivityHandler, onWheel: onActivityHandler, onPointerDown: onActivityHandler, onPointerMove: onActivityHandler, children: (0,jsx_runtime_.jsx)(seamly_activity_event_context/* default */.Z.Provider, { value: onActivityHandler, children: children }) }));
14753
15016
  };
14754
15017
  /* harmony default export */ const seamly_activity_monitor = (SeamlyActivityMonitor);
14755
15018
 
@@ -14760,7 +15023,7 @@ var seamly_offline_error = __webpack_require__(3243);
14760
15023
  // EXTERNAL MODULE: ./src/javascripts/domains/interrupt/slice.ts
14761
15024
  var interrupt_slice = __webpack_require__(6160);
14762
15025
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/core/seamly-event-subscriber.ts
14763
- var __rest = undefined && undefined.__rest || function (s, e) {
15026
+ var seamly_event_subscriber_rest = undefined && undefined.__rest || function (s, e) {
14764
15027
  var t = {};
14765
15028
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
14766
15029
  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
@@ -14934,7 +15197,7 @@ const SeamlyEventSubscriber = () => {
14934
15197
  const {
14935
15198
  serviceSettings
14936
15199
  } = payload,
14937
- eventPayload = __rest(payload, ["serviceSettings"]);
15200
+ eventPayload = seamly_event_subscriber_rest(payload, ["serviceSettings"]);
14938
15201
  const {
14939
15202
  entry,
14940
15203
  proactiveMessages
@@ -15164,7 +15427,7 @@ const SeamlyFileUpload = ({ children }) => {
15164
15427
  uploadHandle,
15165
15428
  }));
15166
15429
  }, [addImageToSessionStorage, addUploadBubble, api, dispatch, t]);
15167
- return ((0,jsx_runtime_.jsx)(seamly_file_upload_context/* default */.Z.Provider, Object.assign({ value: onUploadFileHandler }, { children: children })));
15430
+ return ((0,jsx_runtime_.jsx)(seamly_file_upload_context/* default */.Z.Provider, { value: onUploadFileHandler, children: children }));
15168
15431
  };
15169
15432
  /* harmony default export */ const seamly_file_upload = (SeamlyFileUpload);
15170
15433
 
@@ -15565,7 +15828,7 @@ const SeamlyCore = ({ store, children, eventBus, api }) => {
15565
15828
  (0,hooks_.useErrorBoundary)((error) => {
15566
15829
  store.dispatch((0,errors/* catchError */.K)(error));
15567
15830
  });
15568
- return ((0,jsx_runtime_.jsx)(es/* Provider */.zt, Object.assign({ store: store }, { children: (0,jsx_runtime_.jsx)(seamly_api_context/* SeamlyEventBusContext */.T.Provider, Object.assign({ value: eventBus }, { children: (0,jsx_runtime_.jsx)(seamly_api_context/* SeamlyApiContext */.a.Provider, Object.assign({ value: api }, { children: (0,jsx_runtime_.jsx)(seamly_live_region, { children: (0,jsx_runtime_.jsx)(seamly_chat, { children: (0,jsx_runtime_.jsxs)(component_filter, { children: [(0,jsx_runtime_.jsx)(seamly_initializer, {}), (0,jsx_runtime_.jsx)(seamly_event_subscriber, {}), (0,jsx_runtime_.jsx)(seamly_read_state, {}), (0,jsx_runtime_.jsx)(seamly_new_notifications, {}), (0,jsx_runtime_.jsx)(seamly_idle_detach_counter, {}), (0,jsx_runtime_.jsxs)(seamly_activity_monitor, { children: [(0,jsx_runtime_.jsx)(seamly_instance_functions_loader, {}), (0,jsx_runtime_.jsx)(seamly_file_upload, { children: children })] })] }) }) }) })) })) })));
15831
+ return ((0,jsx_runtime_.jsx)(es/* Provider */.zt, { store: store, children: (0,jsx_runtime_.jsx)(seamly_api_context/* SeamlyEventBusContext */.T.Provider, { value: eventBus, children: (0,jsx_runtime_.jsx)(seamly_api_context/* SeamlyApiContext */.a.Provider, { value: api, children: (0,jsx_runtime_.jsx)(seamly_live_region, { children: (0,jsx_runtime_.jsx)(seamly_chat, { children: (0,jsx_runtime_.jsxs)(component_filter, { children: [(0,jsx_runtime_.jsx)(seamly_initializer, {}), (0,jsx_runtime_.jsx)(seamly_event_subscriber, {}), (0,jsx_runtime_.jsx)(seamly_read_state, {}), (0,jsx_runtime_.jsx)(seamly_new_notifications, {}), (0,jsx_runtime_.jsx)(seamly_idle_detach_counter, {}), (0,jsx_runtime_.jsxs)(seamly_activity_monitor, { children: [(0,jsx_runtime_.jsx)(seamly_instance_functions_loader, {}), (0,jsx_runtime_.jsx)(seamly_file_upload, { children: children })] })] }) }) }) }) }) }));
15569
15832
  };
15570
15833
  /* harmony default export */ const seamly_core = (SeamlyCore);
15571
15834
 
@@ -15624,9 +15887,9 @@ var reselect_es = __webpack_require__(573);
15624
15887
  const getState = ({
15625
15888
  forms
15626
15889
  }) => forms;
15627
- const getFormById = (0,reselect_es/* createSelector */.P1)(getState, (_, {
15890
+ const getFormById = (0,reselect_es/* createSelector */.P1)([getState, (_, {
15628
15891
  formId
15629
- }) => formId, (forms, formId) => forms[formId]);
15892
+ }) => formId], (forms, formId) => forms[formId]);
15630
15893
  const getFormControlsByFormId = (0,reselect_es/* createSelector */.P1)(getFormById, form => (form === null || form === void 0 ? void 0 : form.controls) || {});
15631
15894
  const getFormValuesByFormId = (0,reselect_es/* createSelector */.P1)(getFormControlsByFormId, controls => {
15632
15895
  const valuesObj = {};
@@ -15637,15 +15900,15 @@ const getFormValuesByFormId = (0,reselect_es/* createSelector */.P1)(getFormCont
15637
15900
  });
15638
15901
  return valuesObj;
15639
15902
  });
15640
- const getControlValueByName = (0,reselect_es/* createSelector */.P1)(getFormControlsByFormId, (_, {
15903
+ const getControlValueByName = (0,reselect_es/* createSelector */.P1)([getFormControlsByFormId, (_, {
15641
15904
  name
15642
- }) => name, (controls, name) => {
15905
+ }) => name], (controls, name) => {
15643
15906
  var _a;
15644
15907
  return (_a = controls[name]) === null || _a === void 0 ? void 0 : _a.value;
15645
15908
  });
15646
- const getControlTouchedByName = (0,reselect_es/* createSelector */.P1)(getFormControlsByFormId, (_, {
15909
+ const getControlTouchedByName = (0,reselect_es/* createSelector */.P1)([getFormControlsByFormId, (_, {
15647
15910
  name
15648
- }) => name, (controls, name) => {
15911
+ }) => name], (controls, name) => {
15649
15912
  var _a;
15650
15913
  return (_a = controls[name]) === null || _a === void 0 ? void 0 : _a.touched;
15651
15914
  });
@@ -15842,7 +16105,7 @@ const useEntryTextTranslation = controlName => {
15842
16105
  text: (text === null || text === void 0 ? void 0 : text.label) || t('input.inputLabelText'),
15843
16106
  limit: !(text === null || text === void 0 ? void 0 : text.label) && hasCharacterLimit ? characterLimit : null
15844
16107
  }), [t, hasCharacterLimit, characterLimit, text === null || text === void 0 ? void 0 : text.label]);
15845
- const labelClass = (0,hooks_.useMemo)(() => (text === null || text === void 0 ? void 0 : text.label) ? 'input__label' : 'visually-hidden', [text === null || text === void 0 ? void 0 : text.label]);
16108
+ const labelClass = (0,hooks_.useMemo)(() => (text === null || text === void 0 ? void 0 : text.label) ? 'label' : 'visually-hidden', [text === null || text === void 0 ? void 0 : text.label]);
15846
16109
  return {
15847
16110
  placeholder,
15848
16111
  label,
@@ -15887,14 +16150,14 @@ function AbortTransactionButton() {
15887
16150
  });
15888
16151
  clearEntryAbortTransaction();
15889
16152
  };
15890
- return ((0,jsx_runtime_.jsx)("li", Object.assign({ className: (0,css/* className */.o)([
16153
+ return ((0,jsx_runtime_.jsx)("li", { className: (0,css/* className */.o)([
15891
16154
  'cvco-conversation__item',
15892
16155
  'cvco-conversation__item--abort-transaction',
15893
- ]) }, { children: (0,jsx_runtime_.jsx)("button", Object.assign({ className: (0,css/* className */.o)([
16156
+ ]), children: (0,jsx_runtime_.jsx)("button", { className: (0,css/* className */.o)([
15894
16157
  'button',
15895
16158
  'button--secondary',
15896
16159
  'abort-transaction__button',
15897
- ]), type: "button", onClick: handleAbortTransaction }, { children: abortTransaction.label })) })));
16160
+ ]), type: "button", onClick: handleAbortTransaction, children: abortTransaction.label }) }));
15898
16161
  }
15899
16162
 
15900
16163
  ;// CONCATENATED MODULE: external "preact/compat"
@@ -15969,7 +16232,7 @@ const Event = ({ event, newParticipant }) => {
15969
16232
  if (newParticipant) {
15970
16233
  classNames.push('conversation__item--new-participant');
15971
16234
  }
15972
- return ((0,jsx_runtime_.jsxs)("li", Object.assign({ className: (0,css/* className */.o)(classNames), ref: containerRef }, { children: [event.timeIndicator && (0,jsx_runtime_.jsx)(time_indicator, { event: event }), (0,jsx_runtime_.jsx)(Component, Object.assign({ event: event }, { children: (0,jsx_runtime_.jsx)(SubComponent, { event: event }) }))] })));
16235
+ return ((0,jsx_runtime_.jsxs)("li", { className: (0,css/* className */.o)(classNames), ref: containerRef, children: [event.timeIndicator && (0,jsx_runtime_.jsx)(time_indicator, { event: event }), (0,jsx_runtime_.jsx)(Component, { event: event, children: (0,jsx_runtime_.jsx)(SubComponent, { event: event }) })] }));
15973
16236
  };
15974
16237
  /* harmony default export */ const event_event = (Event);
15975
16238
 
@@ -16056,7 +16319,7 @@ const Conversation = () => {
16056
16319
  e.preventDefault();
16057
16320
  focusSkiplinkTarget();
16058
16321
  };
16059
- return ((0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, { children: [isOpen && ((0,jsx_runtime_.jsx)("a", Object.assign({ className: (0,css/* className */.o)('skip-link'), href: `#${skiplinkTargetId}`, onClick: onClickHandler }, { children: t('skiplinkText') }))), (0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('chat__body') }, { children: (0,jsx_runtime_.jsxs)("div", Object.assign({ className: (0,css/* className */.o)('conversation__container') }, { children: [(0,jsx_runtime_.jsx)(privacy_disclaimer, {}), (0,jsx_runtime_.jsxs)("ol", Object.assign({ className: (0,css/* className */.o)('conversation') }, { children: [(0,jsx_runtime_.jsx)(component_filter, { children: (0,jsx_runtime_.jsx)(Events, {}) }), debouncedIsLoading ? (0,jsx_runtime_.jsx)(loader, {}) : null, (0,jsx_runtime_.jsx)(AbortTransactionButton, {})] }))] })) }))] }));
16322
+ return ((0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, { children: [isOpen && ((0,jsx_runtime_.jsx)("a", { className: (0,css/* className */.o)('skip-link'), href: `#${skiplinkTargetId}`, onClick: onClickHandler, children: t('skiplinkText') })), (0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('chat__body'), children: (0,jsx_runtime_.jsxs)("div", { className: (0,css/* className */.o)('conversation__container'), children: [(0,jsx_runtime_.jsx)(privacy_disclaimer, {}), (0,jsx_runtime_.jsxs)("ol", { className: (0,css/* className */.o)('conversation'), children: [(0,jsx_runtime_.jsx)(component_filter, { children: (0,jsx_runtime_.jsx)(Events, {}) }), debouncedIsLoading ? (0,jsx_runtime_.jsx)(loader, {}) : null, (0,jsx_runtime_.jsx)(AbortTransactionButton, {})] })] }) })] }));
16060
16323
  };
16061
16324
  /* harmony default export */ const conversation = (Conversation);
16062
16325
 
@@ -16459,16 +16722,16 @@ const OptionsFrame = ({ className: givenClassName, children, onCancel, headingTe
16459
16722
  (0,hooks_.useEffect)(() => {
16460
16723
  (0,general_utils/* focusElement */.C5)(container.current);
16461
16724
  }, [container]);
16462
- return ((0,jsx_runtime_.jsx)("section", Object.assign({ className: (0,css/* className */.o)('options', {
16725
+ return ((0,jsx_runtime_.jsx)("section", { className: (0,css/* className */.o)('options', {
16463
16726
  'options--right': position.horizontal === 'right',
16464
16727
  'options--left': position.horizontal === 'left',
16465
16728
  'options--top': position.vertical === 'top',
16466
16729
  'options--bottom': position.vertical === 'bottom',
16467
- }, givenClassName), "aria-labelledby": mainHeadingId, tabIndex: -1, ref: container }, { children: (0,jsx_runtime_.jsxs)("div", Object.assign({ className: (0,css/* className */.o)('options__body') }, { children: [(0,jsx_runtime_.jsx)("h2", Object.assign({ id: mainHeadingId, className: (0,css/* className */.o)('options__title') }, { children: headingText })), (0,jsx_runtime_.jsxs)("button", Object.assign({ type: "button", onClick: onCancelHandler, "aria-describedby": mainHeadingId, className: (0,css/* className */.o)('button', 'options__close'), ref: (btn) => {
16730
+ }, givenClassName), "aria-labelledby": mainHeadingId, tabIndex: -1, ref: container, children: (0,jsx_runtime_.jsxs)("div", { className: (0,css/* className */.o)('options__body'), children: [(0,jsx_runtime_.jsx)("h2", { id: mainHeadingId, className: (0,css/* className */.o)('options__title'), children: headingText }), (0,jsx_runtime_.jsxs)("button", { type: "button", onClick: onCancelHandler, "aria-describedby": mainHeadingId, className: (0,css/* className */.o)('button', 'options__close'), ref: (btn) => {
16468
16731
  if (cancelButtonRef) {
16469
16732
  cancelButtonRef.current = btn;
16470
16733
  }
16471
- } }, { children: [(0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: "close", size: "16", alt: "" }), (0,jsx_runtime_.jsx)("span", { children: cancelButtonText })] })), description ? ((0,jsx_runtime_.jsx)("p", Object.assign({ className: (0,css/* className */.o)('options__description'), id: descriptionId }, { children: description }))) : null, (0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('options__wrapper') }, { children: children }))] })) })));
16734
+ }, children: [(0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: "close", size: "16", alt: "" }), (0,jsx_runtime_.jsx)("span", { children: cancelButtonText })] }), description ? ((0,jsx_runtime_.jsx)("p", { className: (0,css/* className */.o)('options__description'), id: descriptionId, children: description })) : null, (0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('options__wrapper'), children: children })] }) }));
16472
16735
  };
16473
16736
  /* harmony default export */ const options_frame = (OptionsFrame);
16474
16737
 
@@ -16605,7 +16868,7 @@ function FormProvider(_a) {
16605
16868
  console.error('"onSubmit" is required.');
16606
16869
  return null;
16607
16870
  }
16608
- return ((0,jsx_runtime_.jsx)(Provider, Object.assign({}, props, { value: contextValue }, { children: children })));
16871
+ return ((0,jsx_runtime_.jsx)(Provider, Object.assign({}, props, { value: contextValue, children: children })));
16609
16872
  }
16610
16873
 
16611
16874
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/form-controls/form.js
@@ -16671,8 +16934,8 @@ function error_Error({
16671
16934
 
16672
16935
 
16673
16936
 
16674
- const FormControlWrapper = ({ contentHint, id, labelText, labelClass = (0,css/* className */.o)('label'), validity, errorText, children, }) => {
16675
- return ((0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, { children: [contentHint && ((0,jsx_runtime_.jsx)("span", Object.assign({ id: `${id}-content-hint`, className: (0,css/* className */.o)('input__content-hint') }, { children: contentHint }))), (0,jsx_runtime_.jsx)(error_Error, { id: `${id}-error`, error: !validity && errorText }), (0,jsx_runtime_.jsxs)("div", Object.assign({ className: (0,css/* className */.o)('form-control__wrapper') }, { children: [(0,jsx_runtime_.jsx)("label", Object.assign({ htmlFor: id, className: labelClass }, { children: labelText })), children] }))] }));
16937
+ const FormControlWrapper = ({ contentHint, id, labelText, labelClass, validity, errorText, children, }) => {
16938
+ return ((0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, { children: [contentHint && ((0,jsx_runtime_.jsx)("span", { id: `${id}-content-hint`, className: (0,css/* className */.o)('input__content-hint'), children: contentHint })), (0,jsx_runtime_.jsx)(error_Error, { id: `${id}-error`, error: !validity && errorText }), (0,jsx_runtime_.jsxs)("div", { className: (0,css/* className */.o)('form-control__wrapper'), children: [(0,jsx_runtime_.jsx)("label", { htmlFor: id, className: (0,css/* className */.o)(labelClass), children: labelText }), children] })] }));
16676
16939
  };
16677
16940
  /* harmony default export */ const wrapper = (FormControlWrapper);
16678
16941
 
@@ -16707,7 +16970,7 @@ function Input(_a) {
16707
16970
  describedByIds.push(`${id}-error`);
16708
16971
  }
16709
16972
  // todo: destructure Field
16710
- return ((0,jsx_runtime_.jsx)(wrapper, Object.assign({ id: id, contentHint: contentHint, validity: !hasError, errorText: error, labelText: labelText, labelClass: labelClass }, { children: (0,jsx_runtime_.jsx)("input", Object.assign({ id: id, name: name, type: type, "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": describedByIds.join(' ') || null }, field, props)) })));
16973
+ return ((0,jsx_runtime_.jsx)(wrapper, { id: id, contentHint: contentHint, validity: !hasError, errorText: error, labelText: labelText, labelClass: labelClass, children: (0,jsx_runtime_.jsx)("input", Object.assign({ id: id, name: name, type: type, "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": describedByIds.join(' ') || null }, field, props)) }));
16711
16974
  }
16712
16975
  /* harmony default export */ const input = (Input);
16713
16976
 
@@ -17055,14 +17318,14 @@ const OptionsButton = () => {
17055
17318
 
17056
17319
 
17057
17320
 
17058
- const TranslationOption = ({ label, checked, description, onChange, id, }) => {
17321
+ const TranslationOption = ({ label, checked, description, onChange, id, itemClassName, }) => {
17059
17322
  const onKeyDown = (e) => {
17060
17323
  if (e.code === 'Space' || e.code === 'Enter') {
17061
17324
  e.preventDefault();
17062
17325
  onChange();
17063
17326
  }
17064
17327
  };
17065
- return ((0,jsx_runtime_.jsxs)("li", Object.assign({ className: (0,css/* className */.o)('translation-options__item'), "aria-selected": checked, role: "option", tabIndex: 0, onClick: onChange, onKeyDown: onKeyDown, id: id }, { children: [(0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { alt: "", name: "check", size: "16" }), label, " ", description && (0,jsx_runtime_.jsxs)("span", { children: ["(", description, ")"] })] })));
17328
+ return ((0,jsx_runtime_.jsxs)("li", { className: (0,css/* className */.o)([itemClassName, 'translation-options__item']), "aria-selected": checked, role: "option", tabIndex: 0, onClick: onChange, onKeyDown: onKeyDown, id: id, children: [(0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { alt: "", name: "check", size: "16" }), label, " ", description && (0,jsx_runtime_.jsxs)("span", { children: ["(", description, ")"] })] }));
17066
17329
  };
17067
17330
  /* harmony default export */ const translation_option = (TranslationOption);
17068
17331
 
@@ -17074,12 +17337,13 @@ const TranslationOption = ({ label, checked, description, onChange, id, }) => {
17074
17337
 
17075
17338
 
17076
17339
 
17340
+ const isChecked = (language, currentLocale, isOriginal) => currentLocale === language.locale || (!currentLocale && isOriginal);
17077
17341
  const TranslationOptions = ({ onChange, describedById, }) => {
17078
17342
  const { context: { locale: defaultLocale }, } = (0,hooks/* useConfig */.ZR)();
17079
17343
  const { t } = (0,i18n_hooks/* useI18n */.Q)();
17080
17344
  const { focusContainer } = (0,translations_hooks/* useTranslationsContainer */.a5)();
17081
17345
  const { languages, currentLocale, enableTranslations, disableTranslations } = (0,translations_hooks/* useTranslations */.T_)();
17082
- const handleChange = ({ locale }) => () => {
17346
+ const handleChange = (locale) => () => {
17083
17347
  if (locale === currentLocale || defaultLocale === locale) {
17084
17348
  disableTranslations();
17085
17349
  }
@@ -17089,22 +17353,25 @@ const TranslationOptions = ({ onChange, describedById, }) => {
17089
17353
  onChange();
17090
17354
  focusContainer();
17091
17355
  };
17092
- const sortedLanguages = (0,hooks_.useMemo)(() => {
17093
- return [...languages].sort((a, b) => {
17094
- if (a.locale === defaultLocale)
17095
- return -1;
17096
- if (b.locale === defaultLocale)
17097
- return 1;
17098
- return a.nativeName.localeCompare(b.nativeName, undefined, {
17099
- sensitivity: 'base',
17100
- });
17101
- });
17102
- }, [languages, defaultLocale]);
17103
- return ((0,jsx_runtime_.jsx)("ul", Object.assign({ "aria-describedby": describedById, role: "listbox", tabIndex: -1, className: (0,css/* className */.o)('translation-options') }, { children: sortedLanguages.map((language, idx) => {
17104
- const isOriginal = idx === 0;
17105
- const checked = currentLocale === language.locale || (!currentLocale && isOriginal);
17106
- return ((0,jsx_runtime_.jsx)(translation_option, { id: language.locale, label: language.nativeName, checked: checked, description: isOriginal && t('translations.settings.original'), onChange: handleChange(language) }, language.locale));
17107
- }) })));
17356
+ const { primaryLanguages, remainingLanguages } = (0,compat_namespaceObject.useMemo)(() => languages.reduce((acc, language) => {
17357
+ const isOriginal = language.locale === defaultLocale;
17358
+ const checked = isChecked(language, currentLocale, isOriginal);
17359
+ if (language.locale !== defaultLocale) {
17360
+ acc.remainingLanguages.push(Object.assign(Object.assign({}, language), { checked, isOriginal }));
17361
+ }
17362
+ const selectedIdx = acc.remainingLanguages.findIndex((l) => l.locale === currentLocale);
17363
+ if (isOriginal || (checked && selectedIdx > 4)) {
17364
+ acc.primaryLanguages.push(Object.assign(Object.assign({}, language), { checked, isOriginal }));
17365
+ }
17366
+ return acc;
17367
+ }, {
17368
+ primaryLanguages: [],
17369
+ remainingLanguages: [],
17370
+ }), [currentLocale, defaultLocale, languages]);
17371
+ return ((0,jsx_runtime_.jsxs)("ul", { "aria-describedby": describedById, role: "listbox", tabIndex: -1, className: (0,css/* className */.o)('translation-options'), children: [primaryLanguages.map(({ locale, nativeName, checked, isOriginal }, idx) => ((0,jsx_runtime_.jsx)(translation_option, { id: locale, label: nativeName, checked: checked, description: isOriginal && t('translations.settings.original'), onChange: handleChange(locale), itemClassName: (0,css/* className */.o)({
17372
+ 'translation-options__item--original': isOriginal,
17373
+ 'translation-options__item--selected': checked && idx !== 0,
17374
+ }) }, locale))), remainingLanguages.map(({ locale, nativeName, checked, isOriginal }) => ((0,jsx_runtime_.jsx)(translation_option, { id: locale, label: nativeName, checked: checked, description: isOriginal && t('translations.settings.original'), onChange: handleChange(locale) }, locale)))] }));
17108
17375
  };
17109
17376
  /* harmony default export */ const translation_options = (TranslationOptions);
17110
17377
 
@@ -17117,7 +17384,7 @@ const TranslationOptions = ({ onChange, describedById, }) => {
17117
17384
  function TranslationsOptionsDialog({ onClose, position, }) {
17118
17385
  const { t } = (0,i18n_hooks/* useI18n */.Q)();
17119
17386
  const descriptionId = (0,seamly_hooks/* useGeneratedId */.I8)();
17120
- return ((0,jsx_runtime_.jsx)(options_frame, Object.assign({ onCancel: onClose, headingText: t('translations.menu.title'), cancelButtonText: t('translations.settings.cancelButtonText'), description: t('translations.menu.description'), descriptionId: descriptionId, position: position, disableButtonFocusing: true }, { children: (0,jsx_runtime_.jsx)(translation_options, { describedById: descriptionId, onChange: onClose }) })));
17387
+ return ((0,jsx_runtime_.jsx)(options_frame, { onCancel: onClose, headingText: t('translations.menu.title'), cancelButtonText: t('translations.settings.cancelButtonText'), description: t('translations.menu.description'), descriptionId: descriptionId, position: position, disableButtonFocusing: true, children: (0,jsx_runtime_.jsx)(translation_options, { describedById: descriptionId, onChange: onClose }) }));
17121
17388
  }
17122
17389
  /* harmony default export */ const options_dialog = (TranslationsOptionsDialog);
17123
17390
 
@@ -17157,11 +17424,11 @@ function TranslationsOptionsButton({ children, position = {
17157
17424
  e.preventDefault();
17158
17425
  }
17159
17426
  };
17160
- return ((0,jsx_runtime_.jsxs)("div", Object.assign({ className: (0,css/* className */.o)('translations__container'), onKeyDown: onMainKeyDownHandler }, { children: [(0,jsx_runtime_.jsx)(in_out_transition, Object.assign({ transitionStartState: transitionStartStates.notRendered, isActive: menuIsOpen }, { children: (0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('options__dialog'), role: "dialog" }, { children: (0,jsx_runtime_.jsx)(options_dialog, { onClose: handleDialogClose, position: position }) })) })), (0,jsx_runtime_.jsx)("button", Object.assign({ type: "button", className: (0,css/* className */.o)([
17427
+ return ((0,jsx_runtime_.jsxs)("div", { className: (0,css/* className */.o)('translations__container'), onKeyDown: onMainKeyDownHandler, children: [(0,jsx_runtime_.jsx)(in_out_transition, { transitionStartState: transitionStartStates.notRendered, isActive: menuIsOpen, children: (0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('options__dialog'), role: "dialog", children: (0,jsx_runtime_.jsx)(options_dialog, { onClose: handleDialogClose, position: position }) }) }), (0,jsx_runtime_.jsx)("button", { type: "button", className: (0,css/* className */.o)([
17161
17428
  'button',
17162
17429
  'chat__options__button',
17163
17430
  ...classNames,
17164
- ]), id: toggleButtonId, onClick: handleToggleClick, onKeyDown: handleToggleKeyDown, ref: toggleButton, "aria-haspopup": "dialog", "aria-expanded": menuIsOpen }, { children: children }))] })));
17431
+ ]), id: toggleButtonId, onClick: handleToggleClick, onKeyDown: handleToggleKeyDown, ref: toggleButton, "aria-haspopup": "dialog", "aria-expanded": menuIsOpen, children: children })] }));
17165
17432
  }
17166
17433
 
17167
17434
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/app-options/index.js
@@ -17231,7 +17498,7 @@ const UnreadMessagesButton = () => {
17231
17498
  const { scrollToRef, unreadIds } = (0,hooks_.useContext)(chat_scroll_context);
17232
17499
  const { isMinimized } = (0,visibility_hooks/* useVisibility */.iJ)();
17233
17500
  const { t } = (0,i18n_hooks/* useI18n */.Q)();
17234
- return ((0,jsx_runtime_.jsx)(in_out_transition, Object.assign({ isActive: !!unreadIds.length && !isMinimized }, { children: (0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('unread-messages') }, { children: (0,jsx_runtime_.jsxs)("button", Object.assign({ type: "button", className: (0,css/* className */.o)('button', 'button--primary'), onClick: scrollToRef }, { children: [t('message.unreadMessagesCount', { unreadCount: unreadIds.length }), (0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: "chevronDown", size: "32", alt: "" })] })) })) })));
17501
+ return ((0,jsx_runtime_.jsx)(in_out_transition, { isActive: !!unreadIds.length && !isMinimized, children: (0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('unread-messages'), children: (0,jsx_runtime_.jsxs)("button", { type: "button", className: (0,css/* className */.o)('button', 'button--primary'), onClick: scrollToRef, children: [t('message.unreadMessagesCount', { unreadCount: unreadIds.length }), (0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: "chevronDown", size: "32", alt: "" })] }) }) }));
17235
17502
  };
17236
17503
  /* harmony default export */ const unread_messages_button = (UnreadMessagesButton);
17237
17504
 
@@ -17379,13 +17646,13 @@ const ChatScrollProvider = ({ children }) => {
17379
17646
  return acc;
17380
17647
  }, {}), [events]);
17381
17648
  const { scrollToRef, scrollToBottom, containerRef, unreadIds } = use_chat_scroll(eventRefs);
17382
- return ((0,jsx_runtime_.jsx)(chat_scroll_context.Provider, Object.assign({ value: {
17649
+ return ((0,jsx_runtime_.jsx)(chat_scroll_context.Provider, { value: {
17383
17650
  eventRefs,
17384
17651
  unreadIds,
17385
17652
  scrollToRef,
17386
17653
  scrollToBottom,
17387
17654
  containerRef,
17388
- } }, { children: (0,jsx_runtime_.jsxs)("div", Object.assign({ className: (0,css/* className */.o)('chat__container') }, { children: [(0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('chat__container__scroll-area'), ref: containerRef }, { children: children })), (0,jsx_runtime_.jsx)(unread_messages_button, {})] })) })));
17655
+ }, children: (0,jsx_runtime_.jsxs)("div", { className: (0,css/* className */.o)('chat__container'), children: [(0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('chat__container__scroll-area'), ref: containerRef, children: children }), (0,jsx_runtime_.jsx)(unread_messages_button, {})] }) }));
17389
17656
  };
17390
17657
  /* harmony default export */ const chat_scroll_provider = (ChatScrollProvider);
17391
17658
 
@@ -17678,13 +17945,13 @@ function TextEntryForm({ controlName, skipLinkId }) {
17678
17945
  // When a message is submitted, the keyboard should be prevented from closing on mobile devices
17679
17946
  event.preventDefault();
17680
17947
  };
17681
- return ((0,jsx_runtime_.jsxs)(form_controls_form, Object.assign({ className: (0,css/* className */.o)('entry-form'), disableValidationClasses: true, noValidate: "true" }, { children: [(0,jsx_runtime_.jsxs)("div", Object.assign({ className: (0,css/* className */.o)([
17948
+ return ((0,jsx_runtime_.jsxs)(form_controls_form, { className: (0,css/* className */.o)('entry-form'), disableValidationClasses: true, noValidate: "true", children: [(0,jsx_runtime_.jsxs)("div", { className: (0,css/* className */.o)([
17682
17949
  'input--text__container',
17683
17950
  ...(reachedCharacterWarning && !reachedCharacterLimit
17684
17951
  ? ['character-warning']
17685
17952
  : []),
17686
17953
  ...(reachedCharacterLimit ? ['character-exceeded'] : []),
17687
- ]) }, { children: [(0,jsx_runtime_.jsx)(input, { id: skipLinkId, type: "text", name: controlName, className: (0,css/* className */.o)('input__text'), autocomplete: "off", placeholder: placeholder, labelText: label, labelClass: (0,css/* className */.o)(labelClass), "aria-invalid": hasCharacterLimit ? reachedCharacterLimit : null, onKeyUp: handleKeyUp, onFocus: handleFocus }), (0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('character-count') }, { children: reachedCharacterWarning && (0,jsx_runtime_.jsx)("span", { children: remainingChars }) }))] })), (0,jsx_runtime_.jsx)("button", Object.assign({ className: (0,css/* className */.o)('button', 'input__submit'), type: "submit", onPointerDown: handlePointerDown, "aria-disabled": !hasValue || reachedCharacterLimit ? 'true' : null }, { children: (0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: "send", size: "32", alt: t('input.sendMessage') }) }))] })));
17954
+ ]), children: [(0,jsx_runtime_.jsx)(input, { id: skipLinkId, type: "text", name: controlName, className: (0,css/* className */.o)('input__text'), autocomplete: "off", placeholder: placeholder, labelText: label, labelClass: (0,css/* className */.o)(labelClass), "aria-invalid": hasCharacterLimit ? reachedCharacterLimit : null, onKeyUp: handleKeyUp, onFocus: handleFocus }), (0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('character-count'), children: reachedCharacterWarning && (0,jsx_runtime_.jsx)("span", { children: remainingChars }) })] }), (0,jsx_runtime_.jsx)("button", { className: (0,css/* className */.o)('button', 'input__submit'), type: "submit", onPointerDown: handlePointerDown, "aria-disabled": !hasValue || reachedCharacterLimit ? 'true' : null, children: (0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: "send", size: "32", alt: t('input.sendMessage') }) })] }));
17688
17955
  }
17689
17956
 
17690
17957
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/entry/text-entry/index.js
@@ -18342,7 +18609,7 @@ const CollapseButton = () => {
18342
18609
 
18343
18610
  const ChatStatus = ({ children, handleClose, title, closeButtonText, srCloseButtonText, id, }) => {
18344
18611
  const headingId = (0,utility_hooks/* useGeneratedId */.I8)();
18345
- return ((0,jsx_runtime_.jsxs)("section", Object.assign({ tabIndex: -1, id: id, "aria-labelledby": title ? headingId : undefined, className: (0,css/* className */.o)('chat-status', !title && 'chat-status--condensed') }, { children: [(0,jsx_runtime_.jsxs)("div", Object.assign({ className: (0,css/* className */.o)('chat-status__body') }, { children: [title ? ((0,jsx_runtime_.jsx)("h2", Object.assign({ className: (0,css/* className */.o)('chat-status__title'), id: headingId }, { children: title }))) : null, children] })), typeof handleClose === 'function' && ((0,jsx_runtime_.jsxs)("button", Object.assign({ type: "button", onClick: handleClose, className: (0,css/* className */.o)('button', 'button--tertiary', 'chat-status__close') }, { children: [closeButtonText || (0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: "close", size: "16", alt: "" }), srCloseButtonText && ((0,jsx_runtime_.jsx)("span", Object.assign({ className: (0,css/* className */.o)('visually-hidden') }, { children: srCloseButtonText })))] })))] })));
18612
+ return ((0,jsx_runtime_.jsxs)("section", { tabIndex: -1, id: id, "aria-labelledby": title ? headingId : undefined, className: (0,css/* className */.o)('chat-status', !title && 'chat-status--condensed'), children: [(0,jsx_runtime_.jsxs)("div", { className: (0,css/* className */.o)('chat-status__body'), children: [title ? ((0,jsx_runtime_.jsx)("h2", { className: (0,css/* className */.o)('chat-status__title'), id: headingId, children: title })) : null, children] }), typeof handleClose === 'function' && ((0,jsx_runtime_.jsxs)("button", { type: "button", onClick: handleClose, className: (0,css/* className */.o)('button', 'button--tertiary', 'chat-status__close'), children: [closeButtonText || (0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: "close", size: "16", alt: "" }), srCloseButtonText && ((0,jsx_runtime_.jsx)("span", { className: (0,css/* className */.o)('visually-hidden'), children: srCloseButtonText }))] }))] }));
18346
18613
  };
18347
18614
  /* harmony default export */ const chat_status = (ChatStatus);
18348
18615
 
@@ -18377,7 +18644,7 @@ function TranslationChatStatus() {
18377
18644
 
18378
18645
 
18379
18646
 
18380
- const ChatStatusAction = ({ handleClick, icon, title, srButtonText, }) => ((0,jsx_runtime_.jsxs)("button", Object.assign({ type: "button", onClick: handleClick, className: (0,css/* className */.o)('button', 'button--primary', 'chat-status__button') }, { children: [(0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: icon, size: "16", alt: "" }), title, srButtonText && ((0,jsx_runtime_.jsx)("span", Object.assign({ className: (0,css/* className */.o)('visually-hidden') }, { children: srButtonText })))] })));
18647
+ const ChatStatusAction = ({ handleClick, icon, title, srButtonText, }) => ((0,jsx_runtime_.jsxs)("button", { type: "button", onClick: handleClick, className: (0,css/* className */.o)('button', 'button--primary', 'chat-status__button'), children: [(0,jsx_runtime_.jsx)(layout_icon/* default */.Z, { name: icon, size: "16", alt: "" }), title, srButtonText && ((0,jsx_runtime_.jsx)("span", { className: (0,css/* className */.o)('visually-hidden'), children: srButtonText }))] }));
18381
18648
  /* harmony default export */ const chat_status_action = (ChatStatusAction);
18382
18649
 
18383
18650
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/translation-proposal/index.tsx
@@ -18391,7 +18658,7 @@ function TranslationProposal() {
18391
18658
  if (!showProposal) {
18392
18659
  return null;
18393
18660
  }
18394
- return ((0,jsx_runtime_.jsx)(chat_status, Object.assign({ handleClose: dismissTranslationProposal, srCloseButtonText: translationProposal.srDismissButtonText, id: id, title: translationProposal.titleLabel }, { children: (0,jsx_runtime_.jsx)(chat_status_action, { handleClick: activateTranslationProposal, icon: "newTranslation", title: translationProposal.buttonLabel }) })));
18661
+ return ((0,jsx_runtime_.jsx)(chat_status, { handleClose: dismissTranslationProposal, srCloseButtonText: translationProposal.srDismissButtonText, id: id, title: translationProposal.titleLabel, children: (0,jsx_runtime_.jsx)(chat_status_action, { handleClick: activateTranslationProposal, icon: "newTranslation", title: translationProposal.buttonLabel }) }));
18395
18662
  }
18396
18663
 
18397
18664
  ;// CONCATENATED MODULE: ./src/javascripts/domains/translations/components/translation-status.tsx
@@ -18698,7 +18965,7 @@ const WindowView = () => {
18698
18965
  },
18699
18966
  },
18700
18967
  }), [continueChatText]);
18701
- return ((0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, { children: [(0,jsx_runtime_.jsx)(window_open_button, { onClick: openChat }), (0,jsx_runtime_.jsx)(in_out_transition, Object.assign({ isActive: preChat && !isOpen && !userHasResponded, exitAfter: getDelay(preChat, 'exitAfter'), enterDelay: getDelay(preChat, 'enterDelay'), transitionStartState: transitionStartStates.rendered }, { children: (0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('unstarted-wrapper', 'unstarted-wrapper--window') }, { children: (0,jsx_runtime_.jsx)(PreChatMessages, {}) })) })), (0,jsx_runtime_.jsx)(in_out_transition, Object.assign({ isActive: continueChat && !isOpen && userHasResponded, exitAfter: getDelay(continueChat, 'exitAfter'), enterDelay: getDelay(continueChat, 'enterDelay'), transitionStartState: transitionStartStates.notRendered }, { children: (0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)('unstarted-wrapper', 'unstarted-wrapper--window', 'unstarted-wrapper--continue') }, { children: (0,jsx_runtime_.jsx)(event_text, { event: continueChatEvent }) })) })), (0,jsx_runtime_.jsx)(in_out_transition, Object.assign({ isActive: isOpen, transitionStartState: transitionStartStates.notRendered }, { children: (0,jsx_runtime_.jsx)(chat, { children: (0,jsx_runtime_.jsx)(chat_frame, { children: (0,jsx_runtime_.jsx)(conversation, {}) }) }) }))] }));
18968
+ return ((0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, { children: [(0,jsx_runtime_.jsx)(window_open_button, { onClick: openChat }), (0,jsx_runtime_.jsx)(in_out_transition, { isActive: preChat && !isOpen && !userHasResponded, exitAfter: getDelay(preChat, 'exitAfter'), enterDelay: getDelay(preChat, 'enterDelay'), transitionStartState: transitionStartStates.rendered, children: (0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('unstarted-wrapper', 'unstarted-wrapper--window'), children: (0,jsx_runtime_.jsx)(PreChatMessages, {}) }) }), (0,jsx_runtime_.jsx)(in_out_transition, { isActive: continueChat && !isOpen && userHasResponded, exitAfter: getDelay(continueChat, 'exitAfter'), enterDelay: getDelay(continueChat, 'enterDelay'), transitionStartState: transitionStartStates.notRendered, children: (0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)('unstarted-wrapper', 'unstarted-wrapper--window', 'unstarted-wrapper--continue'), children: (0,jsx_runtime_.jsx)(event_text, { event: continueChatEvent }) }) }), (0,jsx_runtime_.jsx)(in_out_transition, { isActive: isOpen, transitionStartState: transitionStartStates.notRendered, children: (0,jsx_runtime_.jsx)(chat, { children: (0,jsx_runtime_.jsx)(chat_frame, { children: (0,jsx_runtime_.jsx)(conversation, {}) }) }) })] }));
18702
18969
  };
18703
18970
  /* harmony default export */ const window_view = (WindowView);
18704
18971
 
@@ -18913,7 +19180,7 @@ const View = ({ children }) => {
18913
19180
  if (userHasResponded) {
18914
19181
  classNames.push('app--user-responded');
18915
19182
  }
18916
- return (isVisible && ((0,jsx_runtime_.jsx)("div", Object.assign({ className: (0,css/* className */.o)(classNames), lang: blockLang, tabIndex: -1, "data-nosnippet": true, style: { zIndex }, ref: containerElementRef }, { children: children || (0,jsx_runtime_.jsx)(ViewComponent, {}) }))));
19183
+ return (isVisible && ((0,jsx_runtime_.jsx)("div", { className: (0,css/* className */.o)(classNames), lang: blockLang, tabIndex: -1, "data-nosnippet": true, style: { zIndex }, ref: containerElementRef, children: children || (0,jsx_runtime_.jsx)(ViewComponent, {}) })));
18917
19184
  };
18918
19185
  /* harmony default export */ const view = (View);
18919
19186
 
@@ -19013,14 +19280,16 @@ class Engine {
19013
19280
  yield store.dispatch((0,config_actions/* initializeConfig */.t)());
19014
19281
  try {
19015
19282
  const { locale } = yield store.dispatch((0,actions/* initializeApp */.Z)()).unwrap();
19016
- yield store.dispatch((0,i18n_actions/* setLocale */.i)(locale));
19283
+ if (locale) {
19284
+ yield store.dispatch((0,i18n_actions/* setLocale */.i)(locale));
19285
+ }
19017
19286
  }
19018
19287
  catch (rejectedValueOrSerializedError) {
19019
19288
  // nothing to do
19020
19289
  }
19021
19290
  store.dispatch((0,visibility_actions/* initializeVisibility */.Z)());
19022
19291
  if (View) {
19023
- (0,external_preact_.render)((0,jsx_runtime_.jsx)(seamly_core, Object.assign({ eventBus: this.eventBus, store: store, api: this.api }, { children: (0,jsx_runtime_.jsx)(View, {}) })), this.parentElement);
19292
+ (0,external_preact_.render)((0,jsx_runtime_.jsx)(seamly_core, { eventBus: this.eventBus, store: store, api: this.api, children: (0,jsx_runtime_.jsx)(View, {}) }), this.parentElement);
19024
19293
  }
19025
19294
  else {
19026
19295
  (0,external_preact_.render)((0,jsx_runtime_.jsx)(chat_app, { config: renderConfig, eventBus: this.eventBus, store: store, api: this.api }), this.parentElement);