@seamly/web-ui 22.1.0-beta.1 → 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
@@ -3110,13 +3110,15 @@ const configSlice = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_3__/* .createSl
3110
3110
  preChat,
3111
3111
  agentParticipant,
3112
3112
  userParticipant,
3113
- startChatIcon
3113
+ startChatIcon,
3114
+ locale
3114
3115
  }
3115
3116
  }) => {
3116
3117
  state.preChatEvents = preChat.map(payload => ({
3117
3118
  type: 'message',
3118
3119
  payload
3119
3120
  }));
3121
+ state.context.locale = locale;
3120
3122
  state.agentParticipant = agentParticipant;
3121
3123
  state.userParticipant = userParticipant;
3122
3124
  state.startChatIcon = startChatIcon;
@@ -5502,7 +5504,13 @@ const translationSlice = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_3__/* .cre
5502
5504
  const feature = (_a = payload === null || payload === void 0 ? void 0 : payload.features) === null || _a === void 0 ? void 0 : _a.translation;
5503
5505
  if (!feature) return;
5504
5506
  state.isAvailable = feature.enabled === true;
5505
- state.languages = feature.languages;
5507
+ state.languages = [...feature.languages].sort((a, b) => {
5508
+ if (a.locale === payload.locale) return -1;
5509
+ if (b.locale === payload.locale) return 1;
5510
+ return a.nativeName.localeCompare(b.nativeName, undefined, {
5511
+ sensitivity: 'base'
5512
+ });
5513
+ });
5506
5514
  }).addCase(domains_store_slice__WEBPACK_IMPORTED_MODULE_2__/* .setHistory */ .JB, (state, {
5507
5515
  payload
5508
5516
  }) => {
@@ -8324,15 +8332,52 @@ var compat_module = __webpack_require__(8661);
8324
8332
  var batch = __webpack_require__(9256);
8325
8333
  ;// CONCATENATED MODULE: ./node_modules/react-redux/es/components/Context.js
8326
8334
 
8327
- const Context_ReactReduxContext = /*#__PURE__*/(0,compat_module.createContext)(null);
8335
+ const ContextKey = Symbol.for(`react-redux-context-${compat_module.version}`);
8336
+ const gT = globalThis;
8337
+
8338
+ function getContext() {
8339
+ let realContext = gT[ContextKey];
8340
+
8341
+ if (!realContext) {
8342
+ realContext = (0,compat_module.createContext)(null);
8343
+
8344
+ if (false) {}
8345
+
8346
+ gT[ContextKey] = realContext;
8347
+ }
8348
+
8349
+ return realContext;
8350
+ }
8351
+
8352
+ const Context_ReactReduxContext = /*#__PURE__*/new Proxy({}, /*#__PURE__*/new Proxy({}, {
8353
+ get(_, handler) {
8354
+ const target = getContext(); // @ts-ignore
8328
8355
 
8329
- if (false) {}
8356
+ return (_target, ...args) => Reflect[handler](target, ...args);
8357
+ }
8330
8358
 
8359
+ }));
8331
8360
  /* harmony default export */ const Context = ((/* unused pure expression or super */ null && (Context_ReactReduxContext)));
8332
8361
  ;// CONCATENATED MODULE: ./node_modules/react-redux/es/hooks/useReduxContext.js
8333
8362
 
8334
8363
 
8335
8364
 
8365
+ /**
8366
+ * Hook factory, which creates a `useReduxContext` hook bound to a given context. This is a low-level
8367
+ * hook that you should usually not need to call directly.
8368
+ *
8369
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
8370
+ * @returns {Function} A `useReduxContext` hook bound to the specified context.
8371
+ */
8372
+ function createReduxContextHook(context = Context_ReactReduxContext) {
8373
+ return function useReduxContext() {
8374
+ const contextValue = (0,compat_module.useContext)(context);
8375
+
8376
+ if (false) {}
8377
+
8378
+ return contextValue;
8379
+ };
8380
+ }
8336
8381
  /**
8337
8382
  * A hook to access the value of the `ReactReduxContext`. This is a low-level
8338
8383
  * hook that you should usually not need to call directly.
@@ -8349,13 +8394,8 @@ if (false) {}
8349
8394
  * return <div>{store.getState()}</div>
8350
8395
  * }
8351
8396
  */
8352
- function useReduxContext_useReduxContext() {
8353
- const contextValue = (0,compat_module.useContext)(Context_ReactReduxContext);
8354
-
8355
- if (false) {}
8356
8397
 
8357
- return contextValue;
8358
- }
8398
+ const useReduxContext_useReduxContext = /*#__PURE__*/createReduxContextHook();
8359
8399
  ;// CONCATENATED MODULE: ./node_modules/react-redux/es/utils/useSyncExternalStore.js
8360
8400
  const useSyncExternalStore_notInitialized = () => {
8361
8401
  throw new Error('uSES not initialized!');
@@ -8380,16 +8420,37 @@ const refEquality = (a, b) => a === b;
8380
8420
 
8381
8421
 
8382
8422
  function createSelectorHook(context = Context_ReactReduxContext) {
8383
- const useReduxContext = context === Context_ReactReduxContext ? useReduxContext_useReduxContext : () => (0,compat_module.useContext)(context);
8384
- return function useSelector(selector, equalityFn = refEquality) {
8423
+ const useReduxContext = context === Context_ReactReduxContext ? useReduxContext_useReduxContext : createReduxContextHook(context);
8424
+ return function useSelector(selector, equalityFnOrOptions = {}) {
8425
+ const {
8426
+ equalityFn = refEquality,
8427
+ stabilityCheck = undefined,
8428
+ noopCheck = undefined
8429
+ } = typeof equalityFnOrOptions === 'function' ? {
8430
+ equalityFn: equalityFnOrOptions
8431
+ } : equalityFnOrOptions;
8432
+
8385
8433
  if (false) {}
8386
8434
 
8387
8435
  const {
8388
8436
  store,
8389
8437
  subscription,
8390
- getServerState
8438
+ getServerState,
8439
+ stabilityCheck: globalStabilityCheck,
8440
+ noopCheck: globalNoopCheck
8391
8441
  } = useReduxContext();
8392
- const selectedState = useSyncExternalStoreWithSelector(subscription.addNestedSub, store.getState, getServerState || store.getState, selector, equalityFn);
8442
+ const firstRun = (0,compat_module.useRef)(true);
8443
+ const wrappedSelector = (0,compat_module.useCallback)({
8444
+ [selector.name](state) {
8445
+ const selected = selector(state);
8446
+
8447
+ if (false) {}
8448
+
8449
+ return selected;
8450
+ }
8451
+
8452
+ }[selector.name], [selector, globalStabilityCheck, stabilityCheck]);
8453
+ const selectedState = useSyncExternalStoreWithSelector(subscription.addNestedSub, store.getState, getServerState || store.getState, wrappedSelector, equalityFn);
8393
8454
  (0,compat_module.useDebugValue)(selectedState);
8394
8455
  return selectedState;
8395
8456
  };
@@ -8976,16 +9037,20 @@ function Provider({
8976
9037
  store,
8977
9038
  context,
8978
9039
  children,
8979
- serverState
9040
+ serverState,
9041
+ stabilityCheck = 'once',
9042
+ noopCheck = 'once'
8980
9043
  }) {
8981
9044
  const contextValue = useMemo(() => {
8982
9045
  const subscription = createSubscription(store);
8983
9046
  return {
8984
9047
  store,
8985
9048
  subscription,
8986
- getServerState: serverState ? () => serverState : undefined
9049
+ getServerState: serverState ? () => serverState : undefined,
9050
+ stabilityCheck,
9051
+ noopCheck
8987
9052
  };
8988
- }, [store, serverState]);
9053
+ }, [store, serverState, stabilityCheck, noopCheck]);
8989
9054
  const previousState = useMemo(() => store.getState(), [store]);
8990
9055
  useIsomorphicLayoutEffect(() => {
8991
9056
  const {
@@ -9014,7 +9079,6 @@ function Provider({
9014
9079
  ;// CONCATENATED MODULE: ./node_modules/react-redux/es/hooks/useStore.js
9015
9080
 
9016
9081
 
9017
-
9018
9082
  /**
9019
9083
  * Hook factory, which creates a `useStore` hook bound to a given context.
9020
9084
  *
@@ -9024,7 +9088,8 @@ function Provider({
9024
9088
 
9025
9089
  function createStoreHook(context = Context_ReactReduxContext) {
9026
9090
  const useReduxContext = // @ts-ignore
9027
- context === Context_ReactReduxContext ? useReduxContext_useReduxContext : () => (0,compat_module.useContext)(context);
9091
+ context === Context_ReactReduxContext ? useReduxContext_useReduxContext : // @ts-ignore
9092
+ createReduxContextHook(context);
9028
9093
  return function useStore() {
9029
9094
  const {
9030
9095
  store
@@ -9818,9 +9883,9 @@ var reselect_es = __webpack_require__(573);
9818
9883
  const getState = ({
9819
9884
  forms
9820
9885
  }) => forms;
9821
- const getFormById = (0,reselect_es/* createSelector */.P1)(getState, (_, {
9886
+ const getFormById = (0,reselect_es/* createSelector */.P1)([getState, (_, {
9822
9887
  formId
9823
- }) => formId, (forms, formId) => forms[formId]);
9888
+ }) => formId], (forms, formId) => forms[formId]);
9824
9889
  const getFormControlsByFormId = (0,reselect_es/* createSelector */.P1)(getFormById, form => (form === null || form === void 0 ? void 0 : form.controls) || {});
9825
9890
  const getFormValuesByFormId = (0,reselect_es/* createSelector */.P1)(getFormControlsByFormId, controls => {
9826
9891
  const valuesObj = {};
@@ -9831,15 +9896,15 @@ const getFormValuesByFormId = (0,reselect_es/* createSelector */.P1)(getFormCont
9831
9896
  });
9832
9897
  return valuesObj;
9833
9898
  });
9834
- const getControlValueByName = (0,reselect_es/* createSelector */.P1)(getFormControlsByFormId, (_, {
9899
+ const getControlValueByName = (0,reselect_es/* createSelector */.P1)([getFormControlsByFormId, (_, {
9835
9900
  name
9836
- }) => name, (controls, name) => {
9901
+ }) => name], (controls, name) => {
9837
9902
  var _a;
9838
9903
  return (_a = controls[name]) === null || _a === void 0 ? void 0 : _a.value;
9839
9904
  });
9840
- const getControlTouchedByName = (0,reselect_es/* createSelector */.P1)(getFormControlsByFormId, (_, {
9905
+ const getControlTouchedByName = (0,reselect_es/* createSelector */.P1)([getFormControlsByFormId, (_, {
9841
9906
  name
9842
- }) => name, (controls, name) => {
9907
+ }) => name], (controls, name) => {
9843
9908
  var _a;
9844
9909
  return (_a = controls[name]) === null || _a === void 0 ? void 0 : _a.touched;
9845
9910
  });
@@ -10040,7 +10105,7 @@ const useEntryTextTranslation = controlName => {
10040
10105
  text: (text === null || text === void 0 ? void 0 : text.label) || t('input.inputLabelText'),
10041
10106
  limit: !(text === null || text === void 0 ? void 0 : text.label) && hasCharacterLimit ? characterLimit : null
10042
10107
  }), [t, hasCharacterLimit, characterLimit, text === null || text === void 0 ? void 0 : text.label]);
10043
- 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]);
10108
+ 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]);
10044
10109
  return {
10045
10110
  placeholder,
10046
10111
  label,
@@ -10085,14 +10150,14 @@ function AbortTransactionButton() {
10085
10150
  });
10086
10151
  clearEntryAbortTransaction();
10087
10152
  };
10088
- return ((0,jsx_runtime_.jsx)("li", Object.assign({ className: (0,css/* className */.o)([
10153
+ return ((0,jsx_runtime_.jsx)("li", { className: (0,css/* className */.o)([
10089
10154
  'cvco-conversation__item',
10090
10155
  'cvco-conversation__item--abort-transaction',
10091
- ]) }, { children: (0,jsx_runtime_.jsx)("button", Object.assign({ className: (0,css/* className */.o)([
10156
+ ]), children: (0,jsx_runtime_.jsx)("button", { className: (0,css/* className */.o)([
10092
10157
  'button',
10093
10158
  'button--secondary',
10094
10159
  'abort-transaction__button',
10095
- ]), type: "button", onClick: handleAbortTransaction }, { children: abortTransaction.label })) })));
10160
+ ]), type: "button", onClick: handleAbortTransaction, children: abortTransaction.label }) }));
10096
10161
  }
10097
10162
 
10098
10163
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/component-context.js
@@ -10973,7 +11038,7 @@ const TimeIndicator = ({
10973
11038
  /* harmony default export */ const time_indicator = (TimeIndicator);
10974
11039
  ;// CONCATENATED MODULE: ./node_modules/tabbable/dist/index.esm.js
10975
11040
  /*!
10976
- * tabbable 6.1.2
11041
+ * tabbable 6.2.0
10977
11042
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
10978
11043
  */
10979
11044
  // NOTE: separate `:not()` selectors has broader browser support than the newer
@@ -11153,7 +11218,27 @@ var getCandidatesIteratively = function getCandidatesIteratively(elements, inclu
11153
11218
  }
11154
11219
  return candidates;
11155
11220
  };
11156
- var getTabindex = function getTabindex(node, isScope) {
11221
+
11222
+ /**
11223
+ * @private
11224
+ * Determines if the node has an explicitly specified `tabindex` attribute.
11225
+ * @param {HTMLElement} node
11226
+ * @returns {boolean} True if so; false if not.
11227
+ */
11228
+ var hasTabIndex = function hasTabIndex(node) {
11229
+ return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
11230
+ };
11231
+
11232
+ /**
11233
+ * Determine the tab index of a given node.
11234
+ * @param {HTMLElement} node
11235
+ * @returns {number} Tab order (negative, 0, or positive number).
11236
+ * @throws {Error} If `node` is falsy.
11237
+ */
11238
+ var getTabIndex = function getTabIndex(node) {
11239
+ if (!node) {
11240
+ throw new Error('No node provided');
11241
+ }
11157
11242
  if (node.tabIndex < 0) {
11158
11243
  // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
11159
11244
  // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
@@ -11162,16 +11247,28 @@ var getTabindex = function getTabindex(node, isScope) {
11162
11247
  // order, consider their tab index to be 0.
11163
11248
  // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
11164
11249
  // so if they don't have a tabindex attribute specifically set, assume it's 0.
11165
- //
11166
- // isScope is positive for custom element with shadow root or slot that by default
11167
- // have tabIndex -1, but need to be sorted by document order in order for their
11168
- // content to be inserted in the correct position
11169
- if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) {
11250
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
11170
11251
  return 0;
11171
11252
  }
11172
11253
  }
11173
11254
  return node.tabIndex;
11174
11255
  };
11256
+
11257
+ /**
11258
+ * Determine the tab index of a given node __for sort order purposes__.
11259
+ * @param {HTMLElement} node
11260
+ * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
11261
+ * has tabIndex -1, but needs to be sorted by document order in order for its content to be
11262
+ * inserted into the correct sort position.
11263
+ * @returns {number} Tab order (negative, 0, or positive number).
11264
+ */
11265
+ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
11266
+ var tabIndex = getTabIndex(node);
11267
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
11268
+ return 0;
11269
+ }
11270
+ return tabIndex;
11271
+ };
11175
11272
  var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
11176
11273
  return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
11177
11274
  };
@@ -11414,7 +11511,7 @@ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(o
11414
11511
  return true;
11415
11512
  };
11416
11513
  var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
11417
- if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
11514
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
11418
11515
  return false;
11419
11516
  }
11420
11517
  return true;
@@ -11439,7 +11536,7 @@ var sortByOrder = function sortByOrder(candidates) {
11439
11536
  candidates.forEach(function (item, i) {
11440
11537
  var isScope = !!item.scopeParent;
11441
11538
  var element = isScope ? item.scopeParent : item;
11442
- var candidateTabindex = getTabindex(element, isScope);
11539
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
11443
11540
  var elements = isScope ? sortByOrder(item.candidates) : element;
11444
11541
  if (candidateTabindex === 0) {
11445
11542
  isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
@@ -11458,32 +11555,32 @@ var sortByOrder = function sortByOrder(candidates) {
11458
11555
  return acc;
11459
11556
  }, []).concat(regularTabbables);
11460
11557
  };
11461
- var tabbable = function tabbable(el, options) {
11558
+ var tabbable = function tabbable(container, options) {
11462
11559
  options = options || {};
11463
11560
  var candidates;
11464
11561
  if (options.getShadowRoot) {
11465
- candidates = getCandidatesIteratively([el], options.includeContainer, {
11562
+ candidates = getCandidatesIteratively([container], options.includeContainer, {
11466
11563
  filter: isNodeMatchingSelectorTabbable.bind(null, options),
11467
11564
  flatten: false,
11468
11565
  getShadowRoot: options.getShadowRoot,
11469
11566
  shadowRootFilter: isValidShadowRootTabbable
11470
11567
  });
11471
11568
  } else {
11472
- candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
11569
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
11473
11570
  }
11474
11571
  return sortByOrder(candidates);
11475
11572
  };
11476
- var focusable = function focusable(el, options) {
11573
+ var focusable = function focusable(container, options) {
11477
11574
  options = options || {};
11478
11575
  var candidates;
11479
11576
  if (options.getShadowRoot) {
11480
- candidates = getCandidatesIteratively([el], options.includeContainer, {
11577
+ candidates = getCandidatesIteratively([container], options.includeContainer, {
11481
11578
  filter: isNodeMatchingSelectorFocusable.bind(null, options),
11482
11579
  flatten: true,
11483
11580
  getShadowRoot: options.getShadowRoot
11484
11581
  });
11485
11582
  } else {
11486
- candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
11583
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
11487
11584
  }
11488
11585
  return candidates;
11489
11586
  };
@@ -11514,7 +11611,7 @@ var isFocusable = function isFocusable(node, options) {
11514
11611
 
11515
11612
  ;// CONCATENATED MODULE: ./node_modules/focus-trap/dist/focus-trap.esm.js
11516
11613
  /*!
11517
- * focus-trap 7.4.3
11614
+ * focus-trap 7.5.2
11518
11615
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
11519
11616
  */
11520
11617
 
@@ -11600,10 +11697,10 @@ var isSelectableInput = function isSelectableInput(node) {
11600
11697
  return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
11601
11698
  };
11602
11699
  var isEscapeEvent = function isEscapeEvent(e) {
11603
- return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
11700
+ 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;
11604
11701
  };
11605
11702
  var isTabEvent = function isTabEvent(e) {
11606
- return e.key === 'Tab' || e.keyCode === 9;
11703
+ return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
11607
11704
  };
11608
11705
 
11609
11706
  // checks for TAB by default
@@ -11687,8 +11784,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11687
11784
  // container: HTMLElement,
11688
11785
  // tabbableNodes: Array<HTMLElement>, // empty if none
11689
11786
  // focusableNodes: Array<HTMLElement>, // empty if none
11690
- // firstTabbableNode: HTMLElement|null,
11691
- // lastTabbableNode: HTMLElement|null,
11787
+ // posTabIndexesFound: boolean,
11788
+ // firstTabbableNode: HTMLElement|undefined,
11789
+ // lastTabbableNode: HTMLElement|undefined,
11790
+ // firstDomTabbableNode: HTMLElement|undefined,
11791
+ // lastDomTabbableNode: HTMLElement|undefined,
11692
11792
  // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
11693
11793
  // }>}
11694
11794
  containerGroups: [],
@@ -11705,7 +11805,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11705
11805
  paused: false,
11706
11806
  // timer ID for when delayInitialFocus is true and initial focus in this trap
11707
11807
  // has been delayed during activation
11708
- delayInitialFocusTimer: undefined
11808
+ delayInitialFocusTimer: undefined,
11809
+ // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
11810
+ recentNavEvent: undefined
11709
11811
  };
11710
11812
  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
11711
11813
 
@@ -11724,7 +11826,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11724
11826
  /**
11725
11827
  * Finds the index of the container that contains the element.
11726
11828
  * @param {HTMLElement} element
11727
- * @param {Event} [event]
11829
+ * @param {Event} [event] If available, and `element` isn't directly found in any container,
11830
+ * the event's composed path is used to see if includes any known trap containers in the
11831
+ * case where the element is inside a Shadow DOM.
11728
11832
  * @returns {number} Index of the container in either `state.containers` or
11729
11833
  * `state.containerGroups` (the order/length of these lists are the same); -1
11730
11834
  * if the element isn't found.
@@ -11819,14 +11923,41 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11819
11923
  var tabbableNodes = tabbable(container, config.tabbableOptions);
11820
11924
 
11821
11925
  // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
11822
- // are a superset of tabbable nodes
11926
+ // are a superset of tabbable nodes since nodes with negative `tabindex` attributes
11927
+ // are focusable but not tabbable
11823
11928
  var focusableNodes = focusable(container, config.tabbableOptions);
11929
+ var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
11930
+ var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
11931
+ var firstDomTabbableNode = focusableNodes.find(function (node) {
11932
+ return isTabbable(node);
11933
+ });
11934
+ var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
11935
+ return isTabbable(node);
11936
+ });
11937
+ var posTabIndexesFound = !!tabbableNodes.find(function (node) {
11938
+ return getTabIndex(node) > 0;
11939
+ });
11824
11940
  return {
11825
11941
  container: container,
11826
11942
  tabbableNodes: tabbableNodes,
11827
11943
  focusableNodes: focusableNodes,
11828
- firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
11829
- lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
11944
+ /** True if at least one node with positive `tabindex` was found in this container. */
11945
+ posTabIndexesFound: posTabIndexesFound,
11946
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
11947
+ firstTabbableNode: firstTabbableNode,
11948
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
11949
+ lastTabbableNode: lastTabbableNode,
11950
+ // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
11951
+ // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
11952
+ // because that API doesn't work with Shadow DOM as well as it should (@see
11953
+ // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
11954
+ // to address an edge case related to positive tabindex support, this seems like a much easier,
11955
+ // "close enough most of the time" alternative for positive tabindexes which should generally
11956
+ // be avoided anyway...
11957
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
11958
+ firstDomTabbableNode: firstDomTabbableNode,
11959
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
11960
+ lastDomTabbableNode: lastDomTabbableNode,
11830
11961
  /**
11831
11962
  * Finds the __tabbable__ node that follows the given node in the specified direction,
11832
11963
  * in this container, if any.
@@ -11837,30 +11968,24 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11837
11968
  */
11838
11969
  nextTabbableNode: function nextTabbableNode(node) {
11839
11970
  var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
11840
- // NOTE: If tabindex is positive (in order to manipulate the tab order separate
11841
- // from the DOM order), this __will not work__ because the list of focusableNodes,
11842
- // while it contains tabbable nodes, does not sort its nodes in any order other
11843
- // than DOM order, because it can't: Where would you place focusable (but not
11844
- // tabbable) nodes in that order? They have no order, because they aren't tabbale...
11845
- // Support for positive tabindex is already broken and hard to manage (possibly
11846
- // not supportable, TBD), so this isn't going to make things worse than they
11847
- // already are, and at least makes things better for the majority of cases where
11848
- // tabindex is either 0/unset or negative.
11849
- // FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
11850
- var nodeIdx = focusableNodes.findIndex(function (n) {
11851
- return n === node;
11852
- });
11971
+ var nodeIdx = tabbableNodes.indexOf(node);
11853
11972
  if (nodeIdx < 0) {
11854
- return undefined;
11855
- }
11856
- if (forward) {
11857
- return focusableNodes.slice(nodeIdx + 1).find(function (n) {
11858
- return isTabbable(n, config.tabbableOptions);
11973
+ // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):
11974
+ // since `node` should at least have been focusable, we assume that's the case and mimic
11975
+ // what browsers do, which is set focus to the next node in __document position order__,
11976
+ // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE
11977
+ // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to
11978
+ // basic DOM order
11979
+ if (forward) {
11980
+ return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
11981
+ return isTabbable(el);
11982
+ });
11983
+ }
11984
+ return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
11985
+ return isTabbable(el);
11859
11986
  });
11860
11987
  }
11861
- return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
11862
- return isTabbable(n, config.tabbableOptions);
11863
- });
11988
+ return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
11864
11989
  }
11865
11990
  };
11866
11991
  });
@@ -11873,6 +11998,19 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11873
11998
  ) {
11874
11999
  throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
11875
12000
  }
12001
+
12002
+ // NOTE: Positive tabindexes are only properly supported in single-container traps because
12003
+ // doing it across multiple containers where tabindexes could be all over the place
12004
+ // would require Tabbable to support multiple containers, would require additional
12005
+ // specialized Shadow DOM support, and would require Tabbable's multi-container support
12006
+ // to look at those containers in document position order rather than user-provided
12007
+ // order (as they are treated in Focus-trap, for legacy reasons). See discussion on
12008
+ // https://github.com/focus-trap/focus-trap/issues/375 for more details.
12009
+ if (state.containerGroups.find(function (g) {
12010
+ return g.posTabIndexesFound;
12011
+ }) && state.containerGroups.length > 1) {
12012
+ 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.");
12013
+ }
11876
12014
  };
11877
12015
  var tryFocus = function tryFocus(node) {
11878
12016
  if (node === false) {
@@ -11888,6 +12026,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11888
12026
  node.focus({
11889
12027
  preventScroll: !!config.preventScroll
11890
12028
  });
12029
+ // NOTE: focus() API does not trigger focusIn event so set MRU node manually
11891
12030
  state.mostRecentlyFocusedNode = node;
11892
12031
  if (isSelectableInput(node)) {
11893
12032
  node.select();
@@ -11898,64 +12037,23 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11898
12037
  return node ? node : node === false ? false : previousActiveElement;
11899
12038
  };
11900
12039
 
11901
- // This needs to be done on mousedown and touchstart instead of click
11902
- // so that it precedes the focus event.
11903
- var checkPointerDown = function checkPointerDown(e) {
11904
- var target = getActualTarget(e);
11905
- if (findContainerIndex(target, e) >= 0) {
11906
- // allow the click since it ocurred inside the trap
11907
- return;
11908
- }
11909
- if (valueOrHandler(config.clickOutsideDeactivates, e)) {
11910
- // immediately deactivate the trap
11911
- trap.deactivate({
11912
- // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
11913
- // which will result in the outside click setting focus to the node
11914
- // that was clicked (and if not focusable, to "nothing"); by setting
11915
- // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
11916
- // on activation (or the configured `setReturnFocus` node), whether the
11917
- // outside click was on a focusable node or not
11918
- returnFocus: config.returnFocusOnDeactivate
11919
- });
11920
- return;
11921
- }
11922
-
11923
- // This is needed for mobile devices.
11924
- // (If we'll only let `click` events through,
11925
- // then on mobile they will be blocked anyways if `touchstart` is blocked.)
11926
- if (valueOrHandler(config.allowOutsideClick, e)) {
11927
- // allow the click outside the trap to take place
11928
- return;
11929
- }
11930
-
11931
- // otherwise, prevent the click
11932
- e.preventDefault();
11933
- };
11934
-
11935
- // In case focus escapes the trap for some strange reason, pull it back in.
11936
- var checkFocusIn = function checkFocusIn(e) {
11937
- var target = getActualTarget(e);
11938
- var targetContained = findContainerIndex(target, e) >= 0;
11939
-
11940
- // In Firefox when you Tab out of an iframe the Document is briefly focused.
11941
- if (targetContained || target instanceof Document) {
11942
- if (targetContained) {
11943
- state.mostRecentlyFocusedNode = target;
11944
- }
11945
- } else {
11946
- // escaped! pull it back in to where it just left
11947
- e.stopImmediatePropagation();
11948
- tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
11949
- }
11950
- };
11951
-
11952
- // Hijack key nav events on the first and last focusable nodes of the trap,
11953
- // in order to prevent focus from escaping. If it escapes for even a
11954
- // moment it can end up scrolling the page and causing confusion so we
11955
- // kind of need to capture the action at the keydown phase.
11956
- var checkKeyNav = function checkKeyNav(event) {
11957
- var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
11958
- var target = getActualTarget(event);
12040
+ /**
12041
+ * Finds the next node (in either direction) where focus should move according to a
12042
+ * keyboard focus-in event.
12043
+ * @param {Object} params
12044
+ * @param {Node} [params.target] Known target __from which__ to navigate, if any.
12045
+ * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
12046
+ * will be used to determine the `target`). Ignored if `target` is specified.
12047
+ * @param {boolean} [params.isBackward] True if focus should move backward.
12048
+ * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
12049
+ * determined given the current state of the trap.
12050
+ */
12051
+ var findNextNavNode = function findNextNavNode(_ref2) {
12052
+ var target = _ref2.target,
12053
+ event = _ref2.event,
12054
+ _ref2$isBackward = _ref2.isBackward,
12055
+ isBackward = _ref2$isBackward === void 0 ? false : _ref2$isBackward;
12056
+ target = target || getActualTarget(event);
11959
12057
  updateTabbableNodes();
11960
12058
  var destinationNode = null;
11961
12059
  if (state.tabbableGroups.length > 0) {
@@ -11978,8 +12076,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11978
12076
  // REVERSE
11979
12077
 
11980
12078
  // is the target the first tabbable node in a group?
11981
- var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
11982
- var firstTabbableNode = _ref2.firstTabbableNode;
12079
+ var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
12080
+ var firstTabbableNode = _ref3.firstTabbableNode;
11983
12081
  return target === firstTabbableNode;
11984
12082
  });
11985
12083
  if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
@@ -11997,7 +12095,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
11997
12095
  // the LAST group if it's the first tabbable node of the FIRST group)
11998
12096
  var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
11999
12097
  var destinationGroup = state.tabbableGroups[destinationGroupIndex];
12000
- destinationNode = destinationGroup.lastTabbableNode;
12098
+ destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
12001
12099
  } else if (!isTabEvent(event)) {
12002
12100
  // user must have customized the nav keys so we have to move focus manually _within_
12003
12101
  // the active group: do this based on the order determined by tabbable()
@@ -12007,8 +12105,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
12007
12105
  // FORWARD
12008
12106
 
12009
12107
  // is the target the last tabbable node in a group?
12010
- var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
12011
- var lastTabbableNode = _ref3.lastTabbableNode;
12108
+ var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
12109
+ var lastTabbableNode = _ref4.lastTabbableNode;
12012
12110
  return target === lastTabbableNode;
12013
12111
  });
12014
12112
  if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
@@ -12026,7 +12124,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
12026
12124
  // group if it's the last tabbable node of the LAST group)
12027
12125
  var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
12028
12126
  var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
12029
- destinationNode = _destinationGroup.firstTabbableNode;
12127
+ destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
12030
12128
  } else if (!isTabEvent(event)) {
12031
12129
  // user must have customized the nav keys so we have to move focus manually _within_
12032
12130
  // the active group: do this based on the order determined by tabbable()
@@ -12038,6 +12136,153 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
12038
12136
  // NOTE: the fallbackFocus option does not support returning false to opt-out
12039
12137
  destinationNode = getNodeForOption('fallbackFocus');
12040
12138
  }
12139
+ return destinationNode;
12140
+ };
12141
+
12142
+ // This needs to be done on mousedown and touchstart instead of click
12143
+ // so that it precedes the focus event.
12144
+ var checkPointerDown = function checkPointerDown(e) {
12145
+ var target = getActualTarget(e);
12146
+ if (findContainerIndex(target, e) >= 0) {
12147
+ // allow the click since it ocurred inside the trap
12148
+ return;
12149
+ }
12150
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
12151
+ // immediately deactivate the trap
12152
+ trap.deactivate({
12153
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
12154
+ // which will result in the outside click setting focus to the node
12155
+ // that was clicked (and if not focusable, to "nothing"); by setting
12156
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
12157
+ // on activation (or the configured `setReturnFocus` node), whether the
12158
+ // outside click was on a focusable node or not
12159
+ returnFocus: config.returnFocusOnDeactivate
12160
+ });
12161
+ return;
12162
+ }
12163
+
12164
+ // This is needed for mobile devices.
12165
+ // (If we'll only let `click` events through,
12166
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
12167
+ if (valueOrHandler(config.allowOutsideClick, e)) {
12168
+ // allow the click outside the trap to take place
12169
+ return;
12170
+ }
12171
+
12172
+ // otherwise, prevent the click
12173
+ e.preventDefault();
12174
+ };
12175
+
12176
+ // In case focus escapes the trap for some strange reason, pull it back in.
12177
+ // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected
12178
+ // scrolling if the node that got focused was out of view; there's nothing we can do to
12179
+ // prevent that from happening by the time we discover that focus escaped
12180
+ var checkFocusIn = function checkFocusIn(event) {
12181
+ var target = getActualTarget(event);
12182
+ var targetContained = findContainerIndex(target, event) >= 0;
12183
+
12184
+ // In Firefox when you Tab out of an iframe the Document is briefly focused.
12185
+ if (targetContained || target instanceof Document) {
12186
+ if (targetContained) {
12187
+ state.mostRecentlyFocusedNode = target;
12188
+ }
12189
+ } else {
12190
+ // escaped! pull it back in to where it just left
12191
+ event.stopImmediatePropagation();
12192
+
12193
+ // focus will escape if the MRU node had a positive tab index and user tried to nav forward;
12194
+ // it will also escape if the MRU node had a 0 tab index and user tried to nav backward
12195
+ // toward a node with a positive tab index
12196
+ var nextNode; // next node to focus, if we find one
12197
+ var navAcrossContainers = true;
12198
+ if (state.mostRecentlyFocusedNode) {
12199
+ if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
12200
+ // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
12201
+ var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
12202
+ // there MAY not be any tabbable nodes in the container if there are at least 2 containers
12203
+ // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container
12204
+ // with at least one tabbable node in order to function, so this could be the other container
12205
+ // with nothing tabbable in it)
12206
+ var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
12207
+ if (tabbableNodes.length > 0) {
12208
+ // MRU tab index MAY not be found if the MRU node is focusable but not tabbable
12209
+ var mruTabIdx = tabbableNodes.findIndex(function (node) {
12210
+ return node === state.mostRecentlyFocusedNode;
12211
+ });
12212
+ if (mruTabIdx >= 0) {
12213
+ if (config.isKeyForward(state.recentNavEvent)) {
12214
+ if (mruTabIdx + 1 < tabbableNodes.length) {
12215
+ nextNode = tabbableNodes[mruTabIdx + 1];
12216
+ navAcrossContainers = false;
12217
+ }
12218
+ // else, don't wrap within the container as focus should move to next/previous
12219
+ // container
12220
+ } else {
12221
+ if (mruTabIdx - 1 >= 0) {
12222
+ nextNode = tabbableNodes[mruTabIdx - 1];
12223
+ navAcrossContainers = false;
12224
+ }
12225
+ // else, don't wrap within the container as focus should move to next/previous
12226
+ // container
12227
+ }
12228
+ // else, don't find in container order without considering direction too
12229
+ }
12230
+ }
12231
+ // else, no tabbable nodes in that container (which means we must have at least one other
12232
+ // container with at least one tabbable node in it, otherwise focus-trap would've thrown
12233
+ // an error the last time updateTabbableNodes() was run): find next node among all known
12234
+ // containers
12235
+ } else {
12236
+ // check to see if there's at least one tabbable node with a positive tab index inside
12237
+ // the trap because focus seems to escape when navigating backward from a tabbable node
12238
+ // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with
12239
+ // the greatest positive tab index like it should)
12240
+ if (!state.containerGroups.some(function (g) {
12241
+ return g.tabbableNodes.some(function (n) {
12242
+ return getTabIndex(n) > 0;
12243
+ });
12244
+ })) {
12245
+ // no containers with tabbable nodes with positive tab indexes which means the focus
12246
+ // escaped for some other reason and we should just execute the fallback to the
12247
+ // MRU node or initial focus node, if any
12248
+ navAcrossContainers = false;
12249
+ }
12250
+ }
12251
+ } else {
12252
+ // no MRU node means we're likely in some initial condition when the trap has just
12253
+ // been activated and initial focus hasn't been given yet, in which case we should
12254
+ // fall through to trying to focus the initial focus node, which is what should
12255
+ // happen below at this point in the logic
12256
+ navAcrossContainers = false;
12257
+ }
12258
+ if (navAcrossContainers) {
12259
+ nextNode = findNextNavNode({
12260
+ // move FROM the MRU node, not event-related node (which will be the node that is
12261
+ // outside the trap causing the focus escape we're trying to fix)
12262
+ target: state.mostRecentlyFocusedNode,
12263
+ isBackward: config.isKeyBackward(state.recentNavEvent)
12264
+ });
12265
+ }
12266
+ if (nextNode) {
12267
+ tryFocus(nextNode);
12268
+ } else {
12269
+ tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
12270
+ }
12271
+ }
12272
+ state.recentNavEvent = undefined; // clear
12273
+ };
12274
+
12275
+ // Hijack key nav events on the first and last focusable nodes of the trap,
12276
+ // in order to prevent focus from escaping. If it escapes for even a
12277
+ // moment it can end up scrolling the page and causing confusion so we
12278
+ // kind of need to capture the action at the keydown phase.
12279
+ var checkKeyNav = function checkKeyNav(event) {
12280
+ var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
12281
+ state.recentNavEvent = event;
12282
+ var destinationNode = findNextNavNode({
12283
+ event: event,
12284
+ isBackward: isBackward
12285
+ });
12041
12286
  if (destinationNode) {
12042
12287
  if (isTabEvent(event)) {
12043
12288
  // since tab natively moves focus, we wouldn't have a destination node unless we
@@ -12962,7 +13207,7 @@ const Event = ({ event, newParticipant }) => {
12962
13207
  if (newParticipant) {
12963
13208
  classNames.push('conversation__item--new-participant');
12964
13209
  }
12965
- 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 }) }))] })));
13210
+ 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 }) })] }));
12966
13211
  };
12967
13212
  /* harmony default export */ const event_event = (Event);
12968
13213
 
@@ -13049,7 +13294,7 @@ const Conversation = () => {
13049
13294
  e.preventDefault();
13050
13295
  focusSkiplinkTarget();
13051
13296
  };
13052
- 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, {})] }))] })) }))] }));
13297
+ 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, {})] })] }) })] }));
13053
13298
  };
13054
13299
  /* harmony default export */ const conversation = (Conversation);
13055
13300
 
@@ -13415,7 +13660,7 @@ function FormProvider(_a) {
13415
13660
  console.error('"onSubmit" is required.');
13416
13661
  return null;
13417
13662
  }
13418
- return ((0,jsx_runtime_.jsx)(Provider, Object.assign({}, props, { value: contextValue }, { children: children })));
13663
+ return ((0,jsx_runtime_.jsx)(Provider, Object.assign({}, props, { value: contextValue, children: children })));
13419
13664
  }
13420
13665
 
13421
13666
  // EXTERNAL MODULE: ./src/javascripts/domains/visibility/constants.ts
@@ -13483,8 +13728,8 @@ function error_Error({
13483
13728
 
13484
13729
 
13485
13730
 
13486
- const FormControlWrapper = ({ contentHint, id, labelText, labelClass = (0,css/* className */.o)('label'), validity, errorText, children, }) => {
13487
- 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] }))] }));
13731
+ const FormControlWrapper = ({ contentHint, id, labelText, labelClass, validity, errorText, children, }) => {
13732
+ 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] })] }));
13488
13733
  };
13489
13734
  /* harmony default export */ const wrapper = (FormControlWrapper);
13490
13735
 
@@ -13519,7 +13764,7 @@ function Input(_a) {
13519
13764
  describedByIds.push(`${id}-error`);
13520
13765
  }
13521
13766
  // todo: destructure Field
13522
- 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)) })));
13767
+ 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)) }));
13523
13768
  }
13524
13769
  /* harmony default export */ const input = (Input);
13525
13770
 
@@ -13564,13 +13809,13 @@ function TextEntryForm({ controlName, skipLinkId }) {
13564
13809
  // When a message is submitted, the keyboard should be prevented from closing on mobile devices
13565
13810
  event.preventDefault();
13566
13811
  };
13567
- 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)([
13812
+ 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)([
13568
13813
  'input--text__container',
13569
13814
  ...(reachedCharacterWarning && !reachedCharacterLimit
13570
13815
  ? ['character-warning']
13571
13816
  : []),
13572
13817
  ...(reachedCharacterLimit ? ['character-exceeded'] : []),
13573
- ]) }, { 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') }) }))] })));
13818
+ ]), 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') }) })] }));
13574
13819
  }
13575
13820
 
13576
13821
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/entry/text-entry/index.js
@@ -14677,16 +14922,16 @@ const OptionsFrame = ({ className: givenClassName, children, onCancel, headingTe
14677
14922
  (0,hooks_.useEffect)(() => {
14678
14923
  (0,general_utils/* focusElement */.C5)(container.current);
14679
14924
  }, [container]);
14680
- return ((0,jsx_runtime_.jsx)("section", Object.assign({ className: (0,css/* className */.o)('options', {
14925
+ return ((0,jsx_runtime_.jsx)("section", { className: (0,css/* className */.o)('options', {
14681
14926
  'options--right': position.horizontal === 'right',
14682
14927
  'options--left': position.horizontal === 'left',
14683
14928
  'options--top': position.vertical === 'top',
14684
14929
  'options--bottom': position.vertical === 'bottom',
14685
- }, 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) => {
14930
+ }, 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) => {
14686
14931
  if (cancelButtonRef) {
14687
14932
  cancelButtonRef.current = btn;
14688
14933
  }
14689
- } }, { 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 }))] })) })));
14934
+ }, 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 })] }) }));
14690
14935
  };
14691
14936
  /* harmony default export */ const options_frame = (OptionsFrame);
14692
14937
 
@@ -15034,14 +15279,14 @@ const OptionsButton = () => {
15034
15279
 
15035
15280
 
15036
15281
 
15037
- const TranslationOption = ({ label, checked, description, onChange, id, }) => {
15282
+ const TranslationOption = ({ label, checked, description, onChange, id, itemClassName, }) => {
15038
15283
  const onKeyDown = (e) => {
15039
15284
  if (e.code === 'Space' || e.code === 'Enter') {
15040
15285
  e.preventDefault();
15041
15286
  onChange();
15042
15287
  }
15043
15288
  };
15044
- 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, ")"] })] })));
15289
+ 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, ")"] })] }));
15045
15290
  };
15046
15291
  /* harmony default export */ const translation_option = (TranslationOption);
15047
15292
 
@@ -15053,12 +15298,13 @@ const TranslationOption = ({ label, checked, description, onChange, id, }) => {
15053
15298
 
15054
15299
 
15055
15300
 
15301
+ const isChecked = (language, currentLocale, isOriginal) => currentLocale === language.locale || (!currentLocale && isOriginal);
15056
15302
  const TranslationOptions = ({ onChange, describedById, }) => {
15057
15303
  const { context: { locale: defaultLocale }, } = (0,hooks/* useConfig */.ZR)();
15058
15304
  const { t } = (0,i18n_hooks/* useI18n */.Q)();
15059
15305
  const { focusContainer } = (0,translations_hooks/* useTranslationsContainer */.a5)();
15060
15306
  const { languages, currentLocale, enableTranslations, disableTranslations } = (0,translations_hooks/* useTranslations */.T_)();
15061
- const handleChange = ({ locale }) => () => {
15307
+ const handleChange = (locale) => () => {
15062
15308
  if (locale === currentLocale || defaultLocale === locale) {
15063
15309
  disableTranslations();
15064
15310
  }
@@ -15068,22 +15314,25 @@ const TranslationOptions = ({ onChange, describedById, }) => {
15068
15314
  onChange();
15069
15315
  focusContainer();
15070
15316
  };
15071
- const sortedLanguages = (0,hooks_.useMemo)(() => {
15072
- return [...languages].sort((a, b) => {
15073
- if (a.locale === defaultLocale)
15074
- return -1;
15075
- if (b.locale === defaultLocale)
15076
- return 1;
15077
- return a.nativeName.localeCompare(b.nativeName, undefined, {
15078
- sensitivity: 'base',
15079
- });
15080
- });
15081
- }, [languages, defaultLocale]);
15082
- 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) => {
15083
- const isOriginal = idx === 0;
15084
- const checked = currentLocale === language.locale || (!currentLocale && isOriginal);
15085
- 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));
15086
- }) })));
15317
+ const { primaryLanguages, remainingLanguages } = (0,compat_namespaceObject.useMemo)(() => languages.reduce((acc, language) => {
15318
+ const isOriginal = language.locale === defaultLocale;
15319
+ const checked = isChecked(language, currentLocale, isOriginal);
15320
+ if (language.locale !== defaultLocale) {
15321
+ acc.remainingLanguages.push(Object.assign(Object.assign({}, language), { checked, isOriginal }));
15322
+ }
15323
+ const selectedIdx = acc.remainingLanguages.findIndex((l) => l.locale === currentLocale);
15324
+ if (isOriginal || (checked && selectedIdx > 4)) {
15325
+ acc.primaryLanguages.push(Object.assign(Object.assign({}, language), { checked, isOriginal }));
15326
+ }
15327
+ return acc;
15328
+ }, {
15329
+ primaryLanguages: [],
15330
+ remainingLanguages: [],
15331
+ }), [currentLocale, defaultLocale, languages]);
15332
+ 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)({
15333
+ 'translation-options__item--original': isOriginal,
15334
+ 'translation-options__item--selected': checked && idx !== 0,
15335
+ }) }, 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)))] }));
15087
15336
  };
15088
15337
  /* harmony default export */ const translation_options = (TranslationOptions);
15089
15338
 
@@ -15096,7 +15345,7 @@ const TranslationOptions = ({ onChange, describedById, }) => {
15096
15345
  function TranslationsOptionsDialog({ onClose, position, }) {
15097
15346
  const { t } = (0,i18n_hooks/* useI18n */.Q)();
15098
15347
  const descriptionId = (0,seamly_hooks/* useGeneratedId */.I8)();
15099
- 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 }) })));
15348
+ 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 }) }));
15100
15349
  }
15101
15350
  /* harmony default export */ const options_dialog = (TranslationsOptionsDialog);
15102
15351
 
@@ -15136,11 +15385,11 @@ function TranslationsOptionsButton({ children, position = {
15136
15385
  e.preventDefault();
15137
15386
  }
15138
15387
  };
15139
- 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)([
15388
+ 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)([
15140
15389
  'button',
15141
15390
  'chat__options__button',
15142
15391
  ...classNames,
15143
- ]), id: toggleButtonId, onClick: handleToggleClick, onKeyDown: handleToggleKeyDown, ref: toggleButton, "aria-haspopup": "dialog", "aria-expanded": menuIsOpen }, { children: children }))] })));
15392
+ ]), id: toggleButtonId, onClick: handleToggleClick, onKeyDown: handleToggleKeyDown, ref: toggleButton, "aria-haspopup": "dialog", "aria-expanded": menuIsOpen, children: children })] }));
15144
15393
  }
15145
15394
 
15146
15395
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/app-options/index.js
@@ -15210,7 +15459,7 @@ const UnreadMessagesButton = () => {
15210
15459
  const { scrollToRef, unreadIds } = (0,hooks_.useContext)(chat_scroll_context);
15211
15460
  const { isMinimized } = (0,visibility_hooks/* useVisibility */.iJ)();
15212
15461
  const { t } = (0,i18n_hooks/* useI18n */.Q)();
15213
- 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: "" })] })) })) })));
15462
+ 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: "" })] }) }) }));
15214
15463
  };
15215
15464
  /* harmony default export */ const unread_messages_button = (UnreadMessagesButton);
15216
15465
 
@@ -15358,13 +15607,13 @@ const ChatScrollProvider = ({ children }) => {
15358
15607
  return acc;
15359
15608
  }, {}), [events]);
15360
15609
  const { scrollToRef, scrollToBottom, containerRef, unreadIds } = use_chat_scroll(eventRefs);
15361
- return ((0,jsx_runtime_.jsx)(chat_scroll_context.Provider, Object.assign({ value: {
15610
+ return ((0,jsx_runtime_.jsx)(chat_scroll_context.Provider, { value: {
15362
15611
  eventRefs,
15363
15612
  unreadIds,
15364
15613
  scrollToRef,
15365
15614
  scrollToBottom,
15366
15615
  containerRef,
15367
- } }, { 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, {})] })) })));
15616
+ }, 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, {})] }) }));
15368
15617
  };
15369
15618
  /* harmony default export */ const chat_scroll_provider = (ChatScrollProvider);
15370
15619
 
@@ -15405,7 +15654,7 @@ const CollapseButton = () => {
15405
15654
 
15406
15655
  const ChatStatus = ({ children, handleClose, title, closeButtonText, srCloseButtonText, id, }) => {
15407
15656
  const headingId = (0,utility_hooks/* useGeneratedId */.I8)();
15408
- 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 })))] })))] })));
15657
+ 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 }))] }))] }));
15409
15658
  };
15410
15659
  /* harmony default export */ const chat_status = (ChatStatus);
15411
15660
 
@@ -15440,7 +15689,7 @@ function TranslationChatStatus() {
15440
15689
 
15441
15690
 
15442
15691
 
15443
- 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 })))] })));
15692
+ 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 }))] }));
15444
15693
  /* harmony default export */ const chat_status_action = (ChatStatusAction);
15445
15694
 
15446
15695
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/translation-proposal/index.tsx
@@ -15454,7 +15703,7 @@ function TranslationProposal() {
15454
15703
  if (!showProposal) {
15455
15704
  return null;
15456
15705
  }
15457
- 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 }) })));
15706
+ 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 }) }));
15458
15707
  }
15459
15708
 
15460
15709
  ;// CONCATENATED MODULE: ./src/javascripts/domains/translations/components/translation-status.tsx
@@ -15802,7 +16051,7 @@ const WindowView = () => {
15802
16051
  },
15803
16052
  },
15804
16053
  }), [continueChatText]);
15805
- 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, {}) }) }) }))] }));
16054
+ 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, {}) }) }) })] }));
15806
16055
  };
15807
16056
  /* harmony default export */ const window_view = (WindowView);
15808
16057
 
@@ -16017,7 +16266,7 @@ const View = ({ children }) => {
16017
16266
  if (userHasResponded) {
16018
16267
  classNames.push('app--user-responded');
16019
16268
  }
16020
- 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, {}) }))));
16269
+ 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, {}) })));
16021
16270
  };
16022
16271
  /* harmony default export */ const view = (View);
16023
16272