@jetbrains/ring-ui 5.0.146 → 5.0.147

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 (70) hide show
  1. package/components/data-list/data-list.css +2 -1
  2. package/components/date-picker/date-picker.css +1 -1
  3. package/components/editable-heading/editable-heading.css +5 -5
  4. package/components/heading/heading.css +5 -5
  5. package/components/input/input-legacy.css +2 -2
  6. package/components/input/input.css +5 -5
  7. package/components/list/list.css +2 -2
  8. package/components/query-assist/query-assist.css +12 -11
  9. package/components/select/select-popup.css +2 -2
  10. package/components/select/select.css +3 -3
  11. package/components/tags-input/tags-input.css +1 -1
  12. package/components/toggle/toggle.css +1 -1
  13. package/dist/_helpers/card.js +5 -5
  14. package/dist/analytics/analytics__custom-plugin.js +6 -2
  15. package/dist/analytics/analytics__ga-plugin.js +2 -1
  16. package/dist/auth/auth__core.js +100 -63
  17. package/dist/auth/iframe-flow.js +2 -1
  18. package/dist/auth/landing.js +2 -1
  19. package/dist/auth/request-builder.js +2 -1
  20. package/dist/auth/token-validator.js +6 -2
  21. package/dist/auth/window-flow.js +4 -2
  22. package/dist/caret/caret.js +16 -13
  23. package/dist/clipboard/clipboard-fallback.js +3 -3
  24. package/dist/data-list/data-list.js +6 -3
  25. package/dist/data-list/item.js +1 -1
  26. package/dist/date-picker/date-input.js +4 -4
  27. package/dist/date-picker/date-picker.js +7 -6
  28. package/dist/date-picker/date-popup.js +3 -2
  29. package/dist/dialog-ng/dialog-ng.js +3 -2
  30. package/dist/dropdown/dropdown.js +4 -2
  31. package/dist/editable-heading/editable-heading.js +2 -2
  32. package/dist/global/focus-sensor-hoc.js +13 -8
  33. package/dist/global/normalize-indent.js +2 -2
  34. package/dist/global/react-render-adapter.js +4 -1
  35. package/dist/global/rerender-hoc.js +2 -1
  36. package/dist/global/schedule-raf.js +2 -1
  37. package/dist/header/profile.js +6 -6
  38. package/dist/header/smart-profile.js +3 -2
  39. package/dist/header/smart-services.js +6 -3
  40. package/dist/http/http.js +13 -7
  41. package/dist/hub-source/hub-source__user.js +3 -2
  42. package/dist/input/input.js +7 -4
  43. package/dist/island/content.js +2 -1
  44. package/dist/list/list__users-groups-source.js +10 -7
  45. package/dist/loader/loader.js +2 -1
  46. package/dist/loader/loader__core.js +2 -1
  47. package/dist/markdown/code.js +3 -2
  48. package/dist/message/message.js +8 -6
  49. package/dist/pager/pager.js +16 -12
  50. package/dist/permissions/permissions__cache.js +1 -1
  51. package/dist/popup/popup.js +2 -1
  52. package/dist/popup/position.js +1 -1
  53. package/dist/query-assist/query-assist.js +46 -34
  54. package/dist/select/select.js +17 -10
  55. package/dist/select/select__popup.js +10 -3
  56. package/dist/select-ng/select-ng.js +2 -1
  57. package/dist/select-ng/select-ng__lazy.js +2 -1
  58. package/dist/shortcuts/core.js +2 -1
  59. package/dist/style.css +1 -1
  60. package/dist/tab-trap/tab-trap.js +4 -2
  61. package/dist/table/header.js +2 -2
  62. package/dist/table/multitable.js +14 -7
  63. package/dist/table/row-with-focus-sensor.js +8 -4
  64. package/dist/table/selection-shortcuts-hoc.js +11 -11
  65. package/dist/tabs/collapsible-tabs.js +1 -1
  66. package/dist/tag/tag.js +2 -1
  67. package/dist/tags-input/tags-input.js +23 -13
  68. package/dist/tooltip/tooltip.js +4 -2
  69. package/dist/user-agreement/user-agreement.js +8 -8
  70. package/package.json +9 -8
@@ -208,8 +208,14 @@ class Auth {
208
208
  }
209
209
  });
210
210
  if (this.config.cacheCurrentUser) {
211
- this.addListener(LOGOUT_EVENT, () => this._storage?.wipeCachedCurrentUser());
212
- this.addListener(USER_CHANGED_EVENT, () => this._storage?.onUserChanged());
211
+ this.addListener(LOGOUT_EVENT, () => {
212
+ var _this$_storage;
213
+ return (_this$_storage = this._storage) === null || _this$_storage === void 0 ? void 0 : _this$_storage.wipeCachedCurrentUser();
214
+ });
215
+ this.addListener(USER_CHANGED_EVENT, () => {
216
+ var _this$_storage2;
217
+ return (_this$_storage2 = this._storage) === null || _this$_storage2 === void 0 ? void 0 : _this$_storage2.onUserChanged();
218
+ });
213
219
  }
214
220
  this._createInitDeferred();
215
221
  this.setUpPreconnect(config.serverUri);
@@ -249,7 +255,8 @@ class Auth {
249
255
  * that should be restored after returning back from auth server.
250
256
  */
251
257
  async init() {
252
- this._storage?.onTokenChange(async token => {
258
+ var _this$_storage3;
259
+ (_this$_storage3 = this._storage) === null || _this$_storage3 === void 0 ? void 0 : _this$_storage3.onTokenChange(async token => {
253
260
  const isGuest = this.user ? this.user.guest : false;
254
261
  if (isGuest && !token) {
255
262
  return;
@@ -297,16 +304,18 @@ class Auth {
297
304
  return new Promise(noop);
298
305
  }
299
306
  try {
307
+ var _this$_tokenValidator, _this$_initDeferred, _this$_initDeferred$r, _state;
300
308
  // Check if there is a valid token
301
- await this._tokenValidator?.validateToken();
309
+ await ((_this$_tokenValidator = this._tokenValidator) === null || _this$_tokenValidator === void 0 ? void 0 : _this$_tokenValidator.validateToken());
302
310
  // Checking if there is a message left by another app on this domain
303
311
  const message = await this._domainStorage._messagesStorage.get(`domain-message-${DOMAIN_USER_CHANGED_EVENT}`);
304
312
  if (message) {
313
+ var _this$user;
305
314
  const {
306
315
  userID,
307
316
  serviceID
308
317
  } = message;
309
- if (serviceID !== this.config.clientId && (!userID || this.user?.id !== userID)) {
318
+ if (serviceID !== this.config.clientId && (!userID || ((_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user.id) !== userID)) {
310
319
  this.forceTokenUpdate();
311
320
  }
312
321
  }
@@ -316,11 +325,12 @@ class Auth {
316
325
  // Check if we have requested to restore state anyway
317
326
  state = await this._checkForStateRestoration();
318
327
  }
319
- this._initDeferred?.resolve?.(state && state.restoreLocation);
320
- return state?.restoreLocation;
328
+ (_this$_initDeferred = this._initDeferred) === null || _this$_initDeferred === void 0 ? void 0 : (_this$_initDeferred$r = _this$_initDeferred.resolve) === null || _this$_initDeferred$r === void 0 ? void 0 : _this$_initDeferred$r.call(_this$_initDeferred, state && state.restoreLocation);
329
+ return (_state = state) === null || _state === void 0 ? void 0 : _state.restoreLocation;
321
330
  } catch (error) {
322
331
  if (Auth.storageIsUnavailable) {
323
- this._initDeferred?.resolve?.(); // No way to handle if cookies are disabled
332
+ var _this$_initDeferred2, _this$_initDeferred2$;
333
+ (_this$_initDeferred2 = this._initDeferred) === null || _this$_initDeferred2 === void 0 ? void 0 : (_this$_initDeferred2$ = _this$_initDeferred2.resolve) === null || _this$_initDeferred2$ === void 0 ? void 0 : _this$_initDeferred2$.call(_this$_initDeferred2); // No way to handle if cookies are disabled
324
334
  await this.requestUser(); // Someone may expect user to be loaded as a part of token validation
325
335
  return null;
326
336
  }
@@ -328,7 +338,8 @@ class Auth {
328
338
  }
329
339
  }
330
340
  async sendRedirect(error) {
331
- const authRequest = await this._requestBuilder?.prepareAuthRequest();
341
+ var _this$_requestBuilder;
342
+ const authRequest = await ((_this$_requestBuilder = this._requestBuilder) === null || _this$_requestBuilder === void 0 ? void 0 : _this$_requestBuilder.prepareAuthRequest());
332
343
  if (authRequest != null) {
333
344
  this._redirectCurrentPage(authRequest.url);
334
345
  }
@@ -341,10 +352,12 @@ class Auth {
341
352
  async handleInitError(error) {
342
353
  if ('stateId' in error && error.stateId) {
343
354
  try {
344
- const state = await this._storage?.getState(error.stateId);
355
+ var _this$_storage4;
356
+ const state = await ((_this$_storage4 = this._storage) === null || _this$_storage4 === void 0 ? void 0 : _this$_storage4.getState(error.stateId));
345
357
  if (state && state.nonRedirect) {
358
+ var _this$_storage5;
346
359
  state.error = error;
347
- this._storage?.saveState(error.stateId, state);
360
+ (_this$_storage5 = this._storage) === null || _this$_storage5 === void 0 ? void 0 : _this$_storage5.saveState(error.stateId, state);
348
361
  // Return endless promise in the background to avoid service start
349
362
  return new Promise(noop);
350
363
  }
@@ -355,7 +368,8 @@ class Auth {
355
368
  throw error;
356
369
  }
357
370
  async handleInitValidationError(error) {
358
- if ('cause' in error && error.cause instanceof Error && error.cause?.message === 'invalid_client') {
371
+ var _error$cause, _this$_initDeferred4, _this$_initDeferred4$;
372
+ if ('cause' in error && error.cause instanceof Error && ((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.message) === 'invalid_client') {
359
373
  // eslint-disable-next-line no-console
360
374
  console.error('RingUI Auth: invalid client detected. Logging out', error);
361
375
  await this.logout();
@@ -368,16 +382,17 @@ class Auth {
368
382
  // Background flow
369
383
  if ('authRedirect' in error && error.authRedirect && !this.config.redirect) {
370
384
  try {
371
- await this._backgroundFlow?.authorize();
372
- await this._tokenValidator?.validateToken();
373
- this._initDeferred?.resolve?.();
385
+ var _this$_backgroundFlow, _this$_tokenValidator2, _this$_initDeferred3, _this$_initDeferred3$;
386
+ await ((_this$_backgroundFlow = this._backgroundFlow) === null || _this$_backgroundFlow === void 0 ? void 0 : _this$_backgroundFlow.authorize());
387
+ await ((_this$_tokenValidator2 = this._tokenValidator) === null || _this$_tokenValidator2 === void 0 ? void 0 : _this$_tokenValidator2.validateToken());
388
+ (_this$_initDeferred3 = this._initDeferred) === null || _this$_initDeferred3 === void 0 ? void 0 : (_this$_initDeferred3$ = _this$_initDeferred3.resolve) === null || _this$_initDeferred3$ === void 0 ? void 0 : _this$_initDeferred3$.call(_this$_initDeferred3);
374
389
  return undefined;
375
390
  } catch (validationError) {
376
391
  // Fallback to redirect flow
377
392
  return validationError instanceof Error ? this.sendRedirect(validationError) : undefined;
378
393
  }
379
394
  }
380
- this._initDeferred?.reject?.(error);
395
+ (_this$_initDeferred4 = this._initDeferred) === null || _this$_initDeferred4 === void 0 ? void 0 : (_this$_initDeferred4$ = _this$_initDeferred4.reject) === null || _this$_initDeferred4$ === void 0 ? void 0 : _this$_initDeferred4$.call(_this$_initDeferred4, error);
381
396
  throw error;
382
397
  }
383
398
  /**
@@ -390,13 +405,13 @@ class Auth {
390
405
  throw new Error('You should log in to be able to make requests');
391
406
  }
392
407
  try {
393
- var _await$this$_tokenVal;
394
- await this._initDeferred?.promise;
408
+ var _this$_initDeferred5, _await$this$_tokenVal, _this$_tokenValidator3;
409
+ await ((_this$_initDeferred5 = this._initDeferred) === null || _this$_initDeferred5 === void 0 ? void 0 : _this$_initDeferred5.promise);
395
410
  if (Auth.storageIsUnavailable) {
396
411
  return null; // Forever guest if storage is unavailable
397
412
  }
398
413
 
399
- return (_await$this$_tokenVal = await this._tokenValidator?.validateTokenLocally()) !== null && _await$this$_tokenVal !== void 0 ? _await$this$_tokenVal : null;
414
+ return (_await$this$_tokenVal = await ((_this$_tokenValidator3 = this._tokenValidator) === null || _this$_tokenValidator3 === void 0 ? void 0 : _this$_tokenValidator3.validateTokenLocally())) !== null && _await$this$_tokenVal !== void 0 ? _await$this$_tokenVal : null;
400
415
  } catch (e) {
401
416
  return this.forceTokenUpdate();
402
417
  }
@@ -417,8 +432,8 @@ class Auth {
417
432
  this._backendCheckPromise = null;
418
433
  }
419
434
  try {
420
- var _await$this$_backgrou;
421
- return (_await$this$_backgrou = await this._backgroundFlow?.authorize()) !== null && _await$this$_backgrou !== void 0 ? _await$this$_backgrou : null;
435
+ var _await$this$_backgrou, _this$_backgroundFlow2;
436
+ return (_await$this$_backgrou = await ((_this$_backgroundFlow2 = this._backgroundFlow) === null || _this$_backgroundFlow2 === void 0 ? void 0 : _this$_backgroundFlow2.authorize())) !== null && _await$this$_backgrou !== void 0 ? _await$this$_backgrou : null;
422
437
  } catch (error) {
423
438
  if (!(error instanceof Error)) {
424
439
  return null;
@@ -427,7 +442,8 @@ class Auth {
427
442
  return new Promise(resolve => {
428
443
  const onTryAgain = async () => {
429
444
  try {
430
- const result = await this._backgroundFlow?.authorize();
445
+ var _this$_backgroundFlow3;
446
+ const result = await ((_this$_backgroundFlow3 = this._backgroundFlow) === null || _this$_backgroundFlow3 === void 0 ? void 0 : _this$_backgroundFlow3.authorize());
431
447
  resolve(result !== null && result !== void 0 ? result : null);
432
448
  } catch (retryError) {
433
449
  if (retryError instanceof Error) {
@@ -447,7 +463,8 @@ class Auth {
447
463
  });
448
464
  });
449
465
  } else {
450
- const authRequest = await this._requestBuilder?.prepareAuthRequest();
466
+ var _this$_requestBuilder2;
467
+ const authRequest = await ((_this$_requestBuilder2 = this._requestBuilder) === null || _this$_requestBuilder2 === void 0 ? void 0 : _this$_requestBuilder2.prepareAuthRequest());
451
468
  if (authRequest != null) {
452
469
  this._redirectCurrentPage(authRequest.url);
453
470
  }
@@ -480,7 +497,8 @@ class Auth {
480
497
  */
481
498
  getUser(accessToken) {
482
499
  if (this.config.cacheCurrentUser) {
483
- return this._storage?.getCachedUser(() => this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams));
500
+ var _this$_storage6;
501
+ return (_this$_storage6 = this._storage) === null || _this$_storage6 === void 0 ? void 0 : _this$_storage6.getCachedUser(() => this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams));
484
502
  } else {
485
503
  return this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams);
486
504
  }
@@ -502,9 +520,10 @@ class Auth {
502
520
  return user;
503
521
  }
504
522
  async updateUser() {
523
+ var _this$_storage7;
505
524
  this._setPostponed(false);
506
525
  const accessToken = await this.requestToken();
507
- this._storage?.wipeCachedCurrentUser();
526
+ (_this$_storage7 = this._storage) === null || _this$_storage7 === void 0 ? void 0 : _this$_storage7.wipeCachedCurrentUser();
508
527
  const user = await this.getUser(accessToken);
509
528
  this.user = user;
510
529
  this.listeners.trigger(USER_CHANGED_EVENT, user);
@@ -545,6 +564,7 @@ class Auth {
545
564
  this.logout();
546
565
  }
547
566
  _showAuthDialog() {
567
+ var _this$user2, _this$_authDialogServ, _this$_storage9, _this$_storage10;
548
568
  let {
549
569
  nonInteractive,
550
570
  error,
@@ -556,14 +576,14 @@ class Auth {
556
576
  onPostponeLogout,
557
577
  translations
558
578
  } = this.config;
559
- const cancelable = this.user?.guest || canCancel;
579
+ const cancelable = ((_this$user2 = this.user) === null || _this$user2 === void 0 ? void 0 : _this$user2.guest) || canCancel;
560
580
  const actualTranslations = translations !== null && translations !== void 0 ? translations : getTranslations();
561
581
  this._createInitDeferred();
562
582
  const closeDialog = () => {
563
583
  /* eslint-disable @typescript-eslint/no-use-before-define */
564
- stopTokenListening?.();
565
- stopMessageListening?.();
566
- hide?.();
584
+ stopTokenListening === null || stopTokenListening === void 0 ? void 0 : stopTokenListening();
585
+ stopMessageListening === null || stopMessageListening === void 0 ? void 0 : stopMessageListening();
586
+ hide === null || hide === void 0 ? void 0 : hide();
567
587
  /* eslint-enable @typescript-eslint/no-use-before-define */
568
588
  };
569
589
 
@@ -576,26 +596,29 @@ class Auth {
576
596
  this._runEmbeddedLogin();
577
597
  };
578
598
  const onCancel = () => {
579
- this._embeddedFlow?.stop();
580
- this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
599
+ var _this$_embeddedFlow, _this$_storage8, _this$user3;
600
+ (_this$_embeddedFlow = this._embeddedFlow) === null || _this$_embeddedFlow === void 0 ? void 0 : _this$_embeddedFlow.stop();
601
+ (_this$_storage8 = this._storage) === null || _this$_storage8 === void 0 ? void 0 : _this$_storage8.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
581
602
  closeDialog();
582
603
  if (!cancelable) {
583
- this._initDeferred?.resolve?.();
604
+ var _this$_initDeferred6, _this$_initDeferred6$;
605
+ (_this$_initDeferred6 = this._initDeferred) === null || _this$_initDeferred6 === void 0 ? void 0 : (_this$_initDeferred6$ = _this$_initDeferred6.resolve) === null || _this$_initDeferred6$ === void 0 ? void 0 : _this$_initDeferred6$.call(_this$_initDeferred6);
584
606
  this.listeners.trigger(LOGOUT_POSTPONED_EVENT);
585
607
  onPostponeLogout();
586
608
  return;
587
609
  }
588
- if (this.user?.guest && nonInteractive) {
610
+ if ((_this$user3 = this.user) !== null && _this$user3 !== void 0 && _this$user3.guest && nonInteractive) {
589
611
  this.forceTokenUpdate();
590
612
  } else {
591
- this._initDeferred?.resolve?.();
613
+ var _this$_initDeferred7, _this$_initDeferred7$;
614
+ (_this$_initDeferred7 = this._initDeferred) === null || _this$_initDeferred7 === void 0 ? void 0 : (_this$_initDeferred7$ = _this$_initDeferred7.resolve) === null || _this$_initDeferred7$ === void 0 ? void 0 : _this$_initDeferred7$.call(_this$_initDeferred7);
592
615
  }
593
616
  };
594
617
  const onTryAgainClick = async () => {
595
- await onTryAgain?.();
618
+ await (onTryAgain === null || onTryAgain === void 0 ? void 0 : onTryAgain());
596
619
  closeDialog();
597
620
  };
598
- const hide = this._authDialogService?.({
621
+ const hide = (_this$_authDialogServ = this._authDialogService) === null || _this$_authDialogServ === void 0 ? void 0 : _this$_authDialogServ.call(this, {
599
622
  ...this._service,
600
623
  loginCaption: actualTranslations.login,
601
624
  loginToCaption: actualTranslations.loginTo,
@@ -607,16 +630,20 @@ class Auth {
607
630
  onCancel,
608
631
  onTryAgain: onTryAgain ? onTryAgainClick : undefined
609
632
  });
610
- const stopTokenListening = this._storage?.onTokenChange(token => {
633
+ const stopTokenListening = (_this$_storage9 = this._storage) === null || _this$_storage9 === void 0 ? void 0 : _this$_storage9.onTokenChange(token => {
611
634
  if (token) {
635
+ var _this$_initDeferred8, _this$_initDeferred8$;
612
636
  closeDialog();
613
- this._initDeferred?.resolve?.();
637
+ (_this$_initDeferred8 = this._initDeferred) === null || _this$_initDeferred8 === void 0 ? void 0 : (_this$_initDeferred8$ = _this$_initDeferred8.resolve) === null || _this$_initDeferred8$ === void 0 ? void 0 : _this$_initDeferred8$.call(_this$_initDeferred8);
614
638
  }
615
639
  });
616
- const stopMessageListening = this._storage?.onMessage(Auth.CLOSE_WINDOW_MESSAGE, () => this._embeddedFlow?.stop());
640
+ const stopMessageListening = (_this$_storage10 = this._storage) === null || _this$_storage10 === void 0 ? void 0 : _this$_storage10.onMessage(Auth.CLOSE_WINDOW_MESSAGE, () => {
641
+ var _this$_embeddedFlow2;
642
+ return (_this$_embeddedFlow2 = this._embeddedFlow) === null || _this$_embeddedFlow2 === void 0 ? void 0 : _this$_embeddedFlow2.stop();
643
+ });
617
644
  }
618
645
  _showUserChangedDialog(_ref) {
619
- var _translations$youHave, _newUser$name, _newUser$name2, _translations$login, _translations$loginTo, _translations$applyCh, _translations$tryAgai, _translations$postpon;
646
+ var _this$_authDialogServ2, _translations$youHave, _newUser$name, _newUser$name2, _translations$login, _translations$loginTo, _translations$applyCh, _translations$tryAgai, _translations$postpon;
620
647
  let {
621
648
  newUser,
622
649
  onApply,
@@ -627,18 +654,19 @@ class Auth {
627
654
  } = this.config;
628
655
  this._createInitDeferred();
629
656
  const done = () => {
630
- this._initDeferred?.resolve?.();
657
+ var _this$_initDeferred9, _this$_initDeferred9$;
658
+ (_this$_initDeferred9 = this._initDeferred) === null || _this$_initDeferred9 === void 0 ? void 0 : (_this$_initDeferred9$ = _this$_initDeferred9.resolve) === null || _this$_initDeferred9$ === void 0 ? void 0 : _this$_initDeferred9$.call(_this$_initDeferred9);
631
659
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
632
- hide?.();
660
+ hide === null || hide === void 0 ? void 0 : hide();
633
661
  };
634
- const hide = this._authDialogService?.({
662
+ const hide = (_this$_authDialogServ2 = this._authDialogService) === null || _this$_authDialogServ2 === void 0 ? void 0 : _this$_authDialogServ2.call(this, {
635
663
  ...this._service,
636
- title: (_translations$youHave = translations?.youHaveLoggedInAs) !== null && _translations$youHave !== void 0 ? _translations$youHave : translate('youHaveLoggedInAs').replace('%userName%', (_newUser$name = newUser.name) !== null && _newUser$name !== void 0 ? _newUser$name : '').replace('{{userName}}', (_newUser$name2 = newUser.name) !== null && _newUser$name2 !== void 0 ? _newUser$name2 : ''),
637
- loginCaption: (_translations$login = translations?.login) !== null && _translations$login !== void 0 ? _translations$login : translate('login'),
638
- loginToCaption: (_translations$loginTo = translations?.loginTo) !== null && _translations$loginTo !== void 0 ? _translations$loginTo : translate('loginTo'),
639
- confirmLabel: (_translations$applyCh = translations?.applyChange) !== null && _translations$applyCh !== void 0 ? _translations$applyCh : translate('applyChange'),
640
- tryAgainLabel: (_translations$tryAgai = translations?.tryAgainLabel) !== null && _translations$tryAgai !== void 0 ? _translations$tryAgai : translate('tryAgainLabel'),
641
- cancelLabel: (_translations$postpon = translations?.postpone) !== null && _translations$postpon !== void 0 ? _translations$postpon : translate('postpone'),
664
+ title: (_translations$youHave = translations === null || translations === void 0 ? void 0 : translations.youHaveLoggedInAs) !== null && _translations$youHave !== void 0 ? _translations$youHave : translate('youHaveLoggedInAs').replace('%userName%', (_newUser$name = newUser.name) !== null && _newUser$name !== void 0 ? _newUser$name : '').replace('{{userName}}', (_newUser$name2 = newUser.name) !== null && _newUser$name2 !== void 0 ? _newUser$name2 : ''),
665
+ loginCaption: (_translations$login = translations === null || translations === void 0 ? void 0 : translations.login) !== null && _translations$login !== void 0 ? _translations$login : translate('login'),
666
+ loginToCaption: (_translations$loginTo = translations === null || translations === void 0 ? void 0 : translations.loginTo) !== null && _translations$loginTo !== void 0 ? _translations$loginTo : translate('loginTo'),
667
+ confirmLabel: (_translations$applyCh = translations === null || translations === void 0 ? void 0 : translations.applyChange) !== null && _translations$applyCh !== void 0 ? _translations$applyCh : translate('applyChange'),
668
+ tryAgainLabel: (_translations$tryAgai = translations === null || translations === void 0 ? void 0 : translations.tryAgainLabel) !== null && _translations$tryAgai !== void 0 ? _translations$tryAgai : translate('tryAgainLabel'),
669
+ cancelLabel: (_translations$postpon = translations === null || translations === void 0 ? void 0 : translations.postpone) !== null && _translations$postpon !== void 0 ? _translations$postpon : translate('postpone'),
642
670
  onConfirm: () => {
643
671
  done();
644
672
  onApply();
@@ -678,17 +706,19 @@ class Auth {
678
706
  const REPEAT_TIMEOUT = 5000;
679
707
  let timerId;
680
708
  return new Promise((resolve, reject) => {
709
+ var _this$_storage12;
681
710
  const done = () => {
711
+ var _this$_storage11;
682
712
  /* eslint-disable @typescript-eslint/no-use-before-define */
683
713
  hide();
684
714
  window.removeEventListener('online', onCheckAgain);
685
- stopListeningCloseMessage?.();
715
+ stopListeningCloseMessage === null || stopListeningCloseMessage === void 0 ? void 0 : stopListeningCloseMessage();
686
716
  /* eslint-enable @typescript-eslint/no-use-before-define */
687
- this._storage?.sendMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, Date.now());
717
+ (_this$_storage11 = this._storage) === null || _this$_storage11 === void 0 ? void 0 : _this$_storage11.sendMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, Date.now());
688
718
  clearTimeout(timerId);
689
719
  };
690
- const stopListeningCloseMessage = this._storage?.onMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, () => {
691
- stopListeningCloseMessage?.();
720
+ const stopListeningCloseMessage = (_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.onMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, () => {
721
+ stopListeningCloseMessage === null || stopListeningCloseMessage === void 0 ? void 0 : stopListeningCloseMessage();
692
722
  done();
693
723
  resolve();
694
724
  });
@@ -721,6 +751,7 @@ class Auth {
721
751
  * Wipe accessToken and redirect to auth page with required authorization
722
752
  */
723
753
  async logout(extraParams) {
754
+ var _this$_storage13, _this$_requestBuilder3;
724
755
  const requestParams = {
725
756
  // eslint-disable-next-line camelcase
726
757
  request_credentials: 'required',
@@ -729,17 +760,19 @@ class Auth {
729
760
  await this._checkBackendsStatusesIfEnabled();
730
761
  await this.listeners.trigger('logout');
731
762
  this._updateDomainUser(null);
732
- await this._storage?.wipeToken();
733
- const authRequest = await this._requestBuilder?.prepareAuthRequest(requestParams);
763
+ await ((_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.wipeToken());
764
+ const authRequest = await ((_this$_requestBuilder3 = this._requestBuilder) === null || _this$_requestBuilder3 === void 0 ? void 0 : _this$_requestBuilder3.prepareAuthRequest(requestParams));
734
765
  if (authRequest != null) {
735
766
  this._redirectCurrentPage(authRequest.url);
736
767
  }
737
768
  }
738
769
  async _runEmbeddedLogin() {
739
- this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
770
+ var _this$_storage14;
771
+ (_this$_storage14 = this._storage) === null || _this$_storage14 === void 0 ? void 0 : _this$_storage14.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
740
772
  try {
773
+ var _this$_embeddedFlow3;
741
774
  this._isLoginWindowOpen = true;
742
- return await this._embeddedFlow?.authorize();
775
+ return await ((_this$_embeddedFlow3 = this._embeddedFlow) === null || _this$_embeddedFlow3 === void 0 ? void 0 : _this$_embeddedFlow3.authorize());
743
776
  } catch (e) {
744
777
  throw e;
745
778
  } finally {
@@ -757,7 +790,8 @@ class Auth {
757
790
  }
758
791
  await this._checkBackendsStatusesIfEnabled();
759
792
  try {
760
- const accessToken = await this._backgroundFlow?.authorize();
793
+ var _this$_backgroundFlow4;
794
+ const accessToken = await ((_this$_backgroundFlow4 = this._backgroundFlow) === null || _this$_backgroundFlow4 === void 0 ? void 0 : _this$_backgroundFlow4.authorize());
761
795
  const user = await this.getUser(accessToken);
762
796
  if (user.guest) {
763
797
  this._beforeLogout();
@@ -784,6 +818,7 @@ class Auth {
784
818
  * @private
785
819
  */
786
820
  async _checkForAuthResponse() {
821
+ var _this$_storage15;
787
822
  // getAuthResponseURL may throw an exception
788
823
  const authResponse = this._responseParser.getAuthResponseFromURL();
789
824
  const {
@@ -803,27 +838,29 @@ class Auth {
803
838
  expiresIn,
804
839
  accessToken
805
840
  } = authResponse;
806
- const newState = (await (stateId && this._storage?.getState(stateId))) || {};
841
+ const newState = (await (stateId && ((_this$_storage15 = this._storage) === null || _this$_storage15 === void 0 ? void 0 : _this$_storage15.getState(stateId)))) || {};
807
842
  const scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
808
843
  const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
809
844
  const expires = TokenValidator._epoch() + effectiveExpiresIn;
810
845
  if (accessToken != null) {
811
- await this._storage?.saveToken({
846
+ var _this$_storage16;
847
+ await ((_this$_storage16 = this._storage) === null || _this$_storage16 === void 0 ? void 0 : _this$_storage16.saveToken({
812
848
  accessToken,
813
849
  scopes,
814
850
  expires,
815
851
  lifeTime: effectiveExpiresIn
816
- });
852
+ }));
817
853
  }
818
854
  return newState;
819
855
  }
820
856
  async _checkForStateRestoration() {
857
+ var _this$_storage17;
821
858
  const authResponse = this._responseParser._authResponse;
822
859
  if (authResponse && this.config.cleanHash) {
823
860
  this.setHash('');
824
861
  }
825
- const stateId = authResponse?.restoreAuthState;
826
- return (await (stateId && this._storage?.getState(stateId))) || {};
862
+ const stateId = authResponse === null || authResponse === void 0 ? void 0 : authResponse.restoreAuthState;
863
+ return (await (stateId && ((_this$_storage17 = this._storage) === null || _this$_storage17 === void 0 ? void 0 : _this$_storage17.getState(stateId)))) || {};
827
864
  }
828
865
  _checkBackendsAreUp() {
829
866
  const abortCtrl = new AbortController();
@@ -107,7 +107,8 @@ class IFrameFlow {
107
107
  }
108
108
  });
109
109
  const cleanUp = () => {
110
- this.hideDialog?.();
110
+ var _this$hideDialog;
111
+ (_this$hideDialog = this.hideDialog) === null || _this$hideDialog === void 0 ? void 0 : _this$hideDialog.call(this);
111
112
  removeStateListener();
112
113
  removeTokenListener();
113
114
  };
@@ -68,6 +68,7 @@ const parser = new AuthResponseParser();
68
68
  const authResponse = parser.getAuthResponseFromURL();
69
69
  // eslint-disable-next-line consistent-this
70
70
  async function parseAndStoreResponse(clientId) {
71
+ var _this$_storage;
71
72
  const storage = new AuthStorage({
72
73
  messagePrefix: `${clientId}-message-`,
73
74
  stateKeyPrefix: `${clientId}-states-`,
@@ -83,7 +84,7 @@ async function parseAndStoreResponse(clientId) {
83
84
  expiresIn,
84
85
  accessToken
85
86
  } = authResponse;
86
- const newState = (await (stateId && this._storage?.getState(stateId))) || {};
87
+ const newState = (await (stateId && ((_this$_storage = this._storage) === null || _this$_storage === void 0 ? void 0 : _this$_storage.getState(stateId)))) || {};
87
88
  const scopes = scope ? scope.split(' ') : newState.scopes || [];
88
89
  const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : DEFAULT_EXPIRES_TIMEOUT;
89
90
  const expires = TokenValidator._epoch() + effectiveExpiresIn;
@@ -60,7 +60,8 @@ class AuthRequestBuilder {
60
60
  * @private
61
61
  */
62
62
  _saveState(id, storedState) {
63
- return this.storage?.saveState(id, storedState);
63
+ var _this$storage;
64
+ return (_this$storage = this.storage) === null || _this$storage === void 0 ? void 0 : _this$storage.saveState(id, storedState);
64
65
  }
65
66
  }
66
67
 
@@ -96,7 +96,10 @@ class TokenValidator {
96
96
  optionalScopes
97
97
  } = this._config;
98
98
  const requiredScopes = optionalScopes ? scope.filter(scopeId => !optionalScopes.includes(scopeId)) : scope;
99
- const hasAllScopes = requiredScopes.every(scopeId => storedToken.scopes?.includes(scopeId));
99
+ const hasAllScopes = requiredScopes.every(scopeId => {
100
+ var _storedToken$scopes;
101
+ return (_storedToken$scopes = storedToken.scopes) === null || _storedToken$scopes === void 0 ? void 0 : _storedToken$scopes.includes(scopeId);
102
+ });
100
103
  if (!hasAllScopes) {
101
104
  throw new TokenValidator.TokenValidationError('Token doesn\'t match required scopes');
102
105
  }
@@ -127,8 +130,9 @@ class TokenValidator {
127
130
  // Skip JSON parsing errors
128
131
  }
129
132
  if (errorResponse.status === CODE.UNAUTHORIZED || TokenValidator.shouldRefreshToken(response.error)) {
133
+ var _errorResponse$data, _errorResponse$data2;
130
134
  // Token expired
131
- throw new TokenValidator.TokenValidationError(response.error || errorResponse.message, errorResponse.data?.error ? new Error(errorResponse.data?.error) : undefined);
135
+ throw new TokenValidator.TokenValidationError(response.error || errorResponse.message, (_errorResponse$data = errorResponse.data) !== null && _errorResponse$data !== void 0 && _errorResponse$data.error ? new Error((_errorResponse$data2 = errorResponse.data) === null || _errorResponse$data2 === void 0 ? void 0 : _errorResponse$data2.error) : undefined);
132
136
  }
133
137
  // Request unexpectedly failed
134
138
  throw errorResponse;
@@ -45,6 +45,7 @@ class WindowFlow {
45
45
  this.reject = reject;
46
46
  let cleanRun;
47
47
  const cleanUp = () => {
48
+ var _this$_loginWindow;
48
49
  if (cleanRun) {
49
50
  return;
50
51
  }
@@ -53,7 +54,7 @@ class WindowFlow {
53
54
  removeStateListener();
54
55
  removeTokenListener();
55
56
  /* eslint-enable @typescript-eslint/no-use-before-define */
56
- this._loginWindow?.close();
57
+ (_this$_loginWindow = this._loginWindow) === null || _this$_loginWindow === void 0 ? void 0 : _this$_loginWindow.close();
57
58
  clearTimeout(this._timeoutId);
58
59
  };
59
60
  const removeTokenListener = this._storage.onTokenChange(token => {
@@ -77,7 +78,8 @@ class WindowFlow {
77
78
  });
78
79
  }
79
80
  checkIsClosed = () => {
80
- if (this._loginWindow?.closed) {
81
+ var _this$_loginWindow2;
82
+ if ((_this$_loginWindow2 = this._loginWindow) !== null && _this$_loginWindow2 !== void 0 && _this$_loginWindow2.closed) {
81
83
  this.stop();
82
84
  return;
83
85
  }
@@ -43,8 +43,8 @@ class Caret {
43
43
  let curPos = 0;
44
44
  while (_curNode != null && _curNode !== this.target) {
45
45
  while (_curNode.previousSibling) {
46
- var _curNode$previousSibl;
47
- curPos += (_curNode$previousSibl = _curNode.previousSibling.textContent?.length) !== null && _curNode$previousSibl !== void 0 ? _curNode$previousSibl : 0;
46
+ var _curNode$previousSibl, _curNode$previousSibl2;
47
+ curPos += (_curNode$previousSibl = (_curNode$previousSibl2 = _curNode.previousSibling.textContent) === null || _curNode$previousSibl2 === void 0 ? void 0 : _curNode$previousSibl2.length) !== null && _curNode$previousSibl !== void 0 ? _curNode$previousSibl : 0;
48
48
  _curNode = _curNode.previousSibling;
49
49
  }
50
50
  _curNode = _curNode.parentNode;
@@ -64,7 +64,7 @@ class Caret {
64
64
  this.focus();
65
65
  }
66
66
  const selection = window.getSelection();
67
- if (!selection?.rangeCount) {
67
+ if (!(selection !== null && selection !== void 0 && selection.rangeCount)) {
68
68
  return 0;
69
69
  }
70
70
  const range1 = selection.getRangeAt(0);
@@ -134,12 +134,12 @@ class Caret {
134
134
  while (curPos < position && _curNode.nodeType !== nodeTypeText) {
135
135
  i++;
136
136
  if (_curNode.childNodes[i] != null) {
137
- var _curNode$childNodes$i;
138
- curPos += (_curNode$childNodes$i = _curNode.childNodes[i].textContent?.length) !== null && _curNode$childNodes$i !== void 0 ? _curNode$childNodes$i : 0;
137
+ var _curNode$childNodes$i, _curNode$childNodes$i2;
138
+ curPos += (_curNode$childNodes$i = (_curNode$childNodes$i2 = _curNode.childNodes[i].textContent) === null || _curNode$childNodes$i2 === void 0 ? void 0 : _curNode$childNodes$i2.length) !== null && _curNode$childNodes$i !== void 0 ? _curNode$childNodes$i : 0;
139
139
  if (curPos >= position) {
140
- var _curNode$textContent$;
140
+ var _curNode$textContent$, _curNode$textContent;
141
141
  _curNode = _curNode.childNodes[i];
142
- curPos -= (_curNode$textContent$ = _curNode.textContent?.length) !== null && _curNode$textContent$ !== void 0 ? _curNode$textContent$ : 0;
142
+ curPos -= (_curNode$textContent$ = (_curNode$textContent = _curNode.textContent) === null || _curNode$textContent === void 0 ? void 0 : _curNode$textContent.length) !== null && _curNode$textContent$ !== void 0 ? _curNode$textContent$ : 0;
143
143
  i = -1;
144
144
  }
145
145
  } else {
@@ -173,7 +173,7 @@ class Caret {
173
173
  } else if (position === -1) {
174
174
  var _value$length;
175
175
  const value = isContentEditable ? this.target.textContent : Caret.normalizeNewlines('value' in this.target ? this.target.value : undefined);
176
- correctedPosition = (_value$length = value?.length) !== null && _value$length !== void 0 ? _value$length : 0;
176
+ correctedPosition = (_value$length = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length !== void 0 ? _value$length : 0;
177
177
  } else {
178
178
  const {
179
179
  _curNode,
@@ -187,10 +187,12 @@ class Caret {
187
187
  this.focus();
188
188
  try {
189
189
  if (correctedPosition instanceof Range) {
190
- window.getSelection()?.removeAllRanges();
191
- window.getSelection()?.addRange(correctedPosition);
190
+ var _window$getSelection, _window$getSelection2;
191
+ (_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.removeAllRanges();
192
+ (_window$getSelection2 = window.getSelection()) === null || _window$getSelection2 === void 0 ? void 0 : _window$getSelection2.addRange(correctedPosition);
192
193
  } else {
193
- window.getSelection()?.collapse(curNode || this.target, correctedPosition);
194
+ var _window$getSelection3;
195
+ (_window$getSelection3 = window.getSelection()) === null || _window$getSelection3 === void 0 ? void 0 : _window$getSelection3.collapse(curNode || this.target, correctedPosition);
194
196
  }
195
197
  } catch (e) {
196
198
  // Do nothing
@@ -208,9 +210,10 @@ class Caret {
208
210
  let offset = 0;
209
211
  let range;
210
212
  try {
213
+ var _window$getSelection4, _range;
211
214
  // Both statements may throw
212
- range = window.getSelection()?.getRangeAt(0).cloneRange();
213
- range?.setStart(range.startContainer, range.startOffset - 1);
215
+ range = (_window$getSelection4 = window.getSelection()) === null || _window$getSelection4 === void 0 ? void 0 : _window$getSelection4.getRangeAt(0).cloneRange();
216
+ (_range = range) === null || _range === void 0 ? void 0 : _range.setStart(range.startContainer, range.startOffset - 1);
214
217
  } catch (e) {
215
218
  return offset;
216
219
  }
@@ -26,12 +26,12 @@ function copyHTMLToClipboard(str) {
26
26
  const selection = document.getSelection();
27
27
  // Should restore previous selection
28
28
  const selected = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : false;
29
- selection?.removeAllRanges();
29
+ selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
30
30
  const range = document.createRange();
31
31
  range.selectNode(el);
32
- selection?.addRange(range);
32
+ selection === null || selection === void 0 ? void 0 : selection.addRange(range);
33
33
  document.execCommand('copy');
34
- selection?.removeAllRanges();
34
+ selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
35
35
  document.execCommand('copy');
36
36
  document.body.removeChild(el);
37
37
  if (selected && selection) {
@@ -97,9 +97,11 @@ class DataList extends PureComponent {
97
97
  }
98
98
  const item = itemFormatter(focused);
99
99
  if (item.collapsed) {
100
- item.onExpand?.();
100
+ var _item$onExpand;
101
+ (_item$onExpand = item.onExpand) === null || _item$onExpand === void 0 ? void 0 : _item$onExpand.call(item);
101
102
  } else {
102
- item.onCollapse?.();
103
+ var _item$onCollapse;
104
+ (_item$onCollapse = item.onCollapse) === null || _item$onCollapse === void 0 ? void 0 : _item$onCollapse.call(item);
103
105
  }
104
106
  };
105
107
  shortcutsMap = {
@@ -135,6 +137,7 @@ class DataList extends PureComponent {
135
137
  }), /*#__PURE__*/React.createElement("ul", {
136
138
  className: classes
137
139
  }, data.map(model => {
140
+ var _this$props$itemMoreL, _this$props;
138
141
  const item = itemFormatter(model);
139
142
  const {
140
143
  id,
@@ -142,7 +145,7 @@ class DataList extends PureComponent {
142
145
  title,
143
146
  items
144
147
  } = item;
145
- const showMoreLessButton = this.props.itemMoreLessState?.(item);
148
+ const showMoreLessButton = (_this$props$itemMoreL = (_this$props = this.props).itemMoreLessState) === null || _this$props$itemMoreL === void 0 ? void 0 : _this$props$itemMoreL.call(_this$props, item);
146
149
  return /*#__PURE__*/React.createElement(Item, {
147
150
  key: key || id,
148
151
  item: model,
@@ -163,7 +163,7 @@ class Item extends PureComponent {
163
163
  });
164
164
  }
165
165
  }
166
- const itemIsEmpty = !items?.length || collapsible && collapsed;
166
+ const itemIsEmpty = !(items !== null && items !== void 0 && items.length) || collapsible && collapsed;
167
167
  const offset = level * LIST_LEFT_OFFSET + ITEM_LEFT_OFFSET + parentShift;
168
168
  return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement(Title, {
169
169
  title: title,