@jetbrains/ring-ui 5.0.84 → 5.0.86

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 (67) hide show
  1. package/components/date-picker/date-picker.js +3 -8
  2. package/components/dropdown/dropdown.d.ts +3 -0
  3. package/components/dropdown/dropdown.js +12 -1
  4. package/components/global/get-uid.js +1 -1
  5. package/components/radio/radio.css +7 -5
  6. package/components/shortcuts/core.js +1 -1
  7. package/dist/analytics/analytics__custom-plugin.js +2 -4
  8. package/dist/analytics/analytics__fus-plugin.js +2 -4
  9. package/dist/analytics/analytics__ga-plugin.js +1 -2
  10. package/dist/auth/auth.js +3 -1
  11. package/dist/auth/auth__core.js +57 -94
  12. package/dist/auth/iframe-flow.js +1 -2
  13. package/dist/auth/landing.js +1 -2
  14. package/dist/auth/request-builder.js +1 -2
  15. package/dist/auth/token-validator.js +2 -6
  16. package/dist/auth/window-flow.js +2 -4
  17. package/dist/button/button.js +1 -2
  18. package/dist/caret/caret.js +13 -16
  19. package/dist/content-layout/content-layout.js +1 -2
  20. package/dist/data-list/data-list.js +3 -6
  21. package/dist/data-list/item.js +1 -1
  22. package/dist/date-picker/date-picker.js +8 -13
  23. package/dist/date-picker/date-popup.js +1 -2
  24. package/dist/dialog-ng/dialog-ng.js +2 -3
  25. package/dist/dropdown/dropdown.d.ts +3 -0
  26. package/dist/dropdown/dropdown.js +15 -6
  27. package/dist/editable-heading/editable-heading.js +1 -3
  28. package/dist/global/focus-sensor-hoc.js +8 -13
  29. package/dist/global/get-uid.js +1 -1
  30. package/dist/global/normalize-indent.js +2 -2
  31. package/dist/global/react-render-adapter.js +1 -4
  32. package/dist/global/rerender-hoc.js +1 -2
  33. package/dist/global/schedule-raf.js +1 -2
  34. package/dist/header/smart-profile.js +2 -3
  35. package/dist/header/smart-services.js +3 -6
  36. package/dist/http/http.js +7 -13
  37. package/dist/hub-source/hub-source__user.js +2 -3
  38. package/dist/icon/icon.js +1 -2
  39. package/dist/input/input.js +3 -6
  40. package/dist/island/content.js +1 -2
  41. package/dist/list/list__users-groups-source.js +7 -10
  42. package/dist/loader/loader.js +1 -2
  43. package/dist/loader/loader__core.js +1 -2
  44. package/dist/markdown/code.js +2 -3
  45. package/dist/message/message.js +4 -6
  46. package/dist/pager/pager.js +4 -8
  47. package/dist/permissions/permissions__cache.js +1 -1
  48. package/dist/popup/popup.js +2 -4
  49. package/dist/popup/position.js +2 -3
  50. package/dist/query-assist/query-assist.js +29 -41
  51. package/dist/select/select.js +10 -17
  52. package/dist/select/select__popup.js +3 -10
  53. package/dist/select-ng/select-ng.js +1 -2
  54. package/dist/select-ng/select-ng__lazy.js +1 -2
  55. package/dist/shortcuts/core.js +2 -3
  56. package/dist/style.css +1 -1
  57. package/dist/tab-trap/tab-trap.js +2 -4
  58. package/dist/table/header.js +2 -2
  59. package/dist/table/multitable.js +7 -14
  60. package/dist/table/row-with-focus-sensor.js +4 -8
  61. package/dist/table/selection-shortcuts-hoc.js +11 -11
  62. package/dist/tabs/collapsible-tabs.js +1 -1
  63. package/dist/tabs/dumb-tabs.js +1 -2
  64. package/dist/tag/tag.js +1 -2
  65. package/dist/tags-input/tags-input.js +13 -23
  66. package/dist/tooltip/tooltip.js +2 -4
  67. package/package.json +15 -17
@@ -199,20 +199,15 @@ export default class DatePicker extends PureComponent {
199
199
  {this.getAnchorText()}
200
200
  <Icon glyph={chevronDownIcon} className={styles.chevronDownIcon}/>
201
201
  </div>);
202
- if (this.props.disabled) {
203
- return (<Button data-test-ring-dropdown-anchor className={styles.anchor} disabled text={false}>
204
- {anchorContent}
205
- </Button>);
206
- }
207
202
  const { className, popupClassName, clear, inline, dropdownProps, translations, ...datePopupProps } = this.props;
208
203
  const classes = classNames(styles.datePicker, className, styles[`size${this.props.size}`], {
209
204
  [styles.inline]: inline
210
205
  });
211
- return (<Dropdown className={classes} anchor={inline
212
- ? (<Link data-test-ring-dropdown-anchor className={styles.anchor} pseudo>
206
+ return (<Dropdown className={classes} disabled={this.props.disabled} anchor={inline
207
+ ? (<Link data-test-ring-dropdown-anchor className={styles.anchor} disabled={this.props.disabled ?? false} pseudo>
213
208
  {this.getAnchorText()}
214
209
  </Link>)
215
- : (<Button data-test-ring-dropdown-anchor className={styles.anchor} text={false}>
210
+ : (<Button data-test-ring-dropdown-anchor className={styles.anchor} text={false} disabled={this.props.disabled ?? false}>
216
211
  {anchorContent}
217
212
  </Button>)} {...dropdownProps}>
218
213
  <PopupComponent className={popupClassName} popupRef={this.popupRef} onClear={clear ? this.clear : null} datePopupProps={{
@@ -10,6 +10,7 @@ export interface DropdownProps extends Omit<HTMLAttributes<HTMLElement>, 'childr
10
10
  anchor: ReactElement | readonly ReactElement[] | string | ((props: AnchorProps) => ReactNode);
11
11
  children: ReactElement<PopupAttrs> | ((props: Omit<PopupAttrs, 'children'>) => ReactNode);
12
12
  initShown: boolean;
13
+ disabled?: boolean | null | undefined;
13
14
  clickMode: boolean;
14
15
  hoverMode: boolean;
15
16
  hoverShowTimeOut: number;
@@ -41,6 +42,7 @@ export default class Dropdown extends Component<DropdownProps, DropdownState> {
41
42
  hoverMode: PropTypes.Requireable<boolean>;
42
43
  hoverShowTimeOut: PropTypes.Requireable<number>;
43
44
  hoverHideTimeOut: PropTypes.Requireable<number>;
45
+ disabled: PropTypes.Requireable<boolean>;
44
46
  onShow: PropTypes.Requireable<(...args: any[]) => any>;
45
47
  onHide: PropTypes.Requireable<(...args: any[]) => any>;
46
48
  onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
@@ -53,6 +55,7 @@ export default class Dropdown extends Component<DropdownProps, DropdownState> {
53
55
  hoverMode: boolean;
54
56
  hoverShowTimeOut: number;
55
57
  hoverHideTimeOut: number;
58
+ disabled: boolean;
56
59
  onShow: () => void;
57
60
  onHide: () => void;
58
61
  onMouseEnter: () => void;
@@ -23,6 +23,7 @@ export default class Dropdown extends Component {
23
23
  hoverMode: PropTypes.bool,
24
24
  hoverShowTimeOut: PropTypes.number,
25
25
  hoverHideTimeOut: PropTypes.number,
26
+ disabled: PropTypes.bool,
26
27
  onShow: PropTypes.func,
27
28
  onHide: PropTypes.func,
28
29
  onMouseEnter: PropTypes.func,
@@ -35,6 +36,7 @@ export default class Dropdown extends Component {
35
36
  hoverMode: false,
36
37
  hoverShowTimeOut: 300,
37
38
  hoverHideTimeOut: 600,
39
+ disabled: false,
38
40
  onShow: () => { },
39
41
  onHide: () => { },
40
42
  onMouseEnter: () => { },
@@ -45,6 +47,9 @@ export default class Dropdown extends Component {
45
47
  pinned: false
46
48
  };
47
49
  onClick = () => {
50
+ if (this.props.disabled) {
51
+ return;
52
+ }
48
53
  const { show, pinned } = this.state;
49
54
  let nextPinned = pinned;
50
55
  if (this.props.hoverMode) {
@@ -70,6 +75,9 @@ export default class Dropdown extends Component {
70
75
  };
71
76
  hoverTimer;
72
77
  onMouseEnter = (event) => {
78
+ if (this.props.disabled) {
79
+ return;
80
+ }
73
81
  this._clearTimer();
74
82
  this.props.onMouseEnter?.(event);
75
83
  this.hoverTimer = window.setTimeout(() => {
@@ -79,6 +87,9 @@ export default class Dropdown extends Component {
79
87
  }, this.props.hoverShowTimeOut);
80
88
  };
81
89
  onMouseLeave = (event) => {
90
+ if (this.props.disabled) {
91
+ return;
92
+ }
82
93
  this.props.onMouseLeave?.(event);
83
94
  if (this.state.pinned) {
84
95
  return;
@@ -107,7 +118,7 @@ export default class Dropdown extends Component {
107
118
  }
108
119
  render() {
109
120
  const { show, pinned } = this.state;
110
- const { initShown, onShow, onHide, hoverShowTimeOut, hoverHideTimeOut, children, anchor, className, activeClassName, hoverMode, clickMode, 'data-test': dataTest, ...restProps } = this.props;
121
+ const { initShown, onShow, onHide, hoverShowTimeOut, hoverHideTimeOut, children, anchor, className, activeClassName, hoverMode, clickMode, 'data-test': dataTest, disabled, ...restProps } = this.props;
111
122
  const classes = classNames(styles.dropdown, className, {
112
123
  [activeClassName ?? '']: activeClassName != null && show
113
124
  });
@@ -1,7 +1,7 @@
1
1
  const idCounters = {};
2
2
  function generateSalt() {
3
3
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
4
- return (Number(new Date()) * Math.random()).toString(36).substring(0, 4);
4
+ return (Date.now() * Math.random()).toString(36).substring(0, 4);
5
5
  }
6
6
  const salt = generateSalt();
7
7
  export default function getUID(name) {
@@ -6,7 +6,10 @@
6
6
  .radio {
7
7
  position: relative;
8
8
 
9
- display: block;
9
+ display: flex;
10
+ flex-direction: row;
11
+
12
+ padding: 6px 0;
10
13
 
11
14
  text-align: left;
12
15
 
@@ -22,9 +25,9 @@
22
25
 
23
26
  .circle {
24
27
  position: relative;
25
- top: -2px;
28
+ top: 2px;
26
29
 
27
- display: inline-block;
30
+ flex-shrink: 0;
28
31
 
29
32
  box-sizing: border-box;
30
33
  width: radio-size;
@@ -32,7 +35,6 @@
32
35
 
33
36
  user-select: none;
34
37
  transition: border-color var(--ring-ease), box-shadow var(--ring-ease);
35
- vertical-align: middle;
36
38
  pointer-events: none;
37
39
 
38
40
  border: 1px solid var(--ring-borders-color);
@@ -119,5 +121,5 @@
119
121
  .label {
120
122
  margin-left: unit;
121
123
 
122
- line-height: calc(unit * 4);
124
+ line-height: var(--ring-line-height);
123
125
  }
@@ -162,7 +162,7 @@ class Shortcuts {
162
162
  return false;
163
163
  }
164
164
  // stop for input, select, and textarea
165
- return element.matches('input,select,textarea') || (element.contentEditable === 'true');
165
+ return element.matches('input:not([type=checkbox]),select,textarea') || (element.contentEditable === 'true');
166
166
  };
167
167
  _getKeyboardEventType(params) {
168
168
  if (!params.type && sniffr.os.name === 'windows') {
@@ -60,9 +60,8 @@ class AnalyticsCustomPlugin {
60
60
  }
61
61
  _initSendSchedule() {
62
62
  window.addEventListener('beforeunload', () => {
63
- var _this$_flush;
64
63
  this._trackPageViewAdditionalInfo();
65
- return (_this$_flush = this._flush) === null || _this$_flush === void 0 ? void 0 : _this$_flush.call(this);
64
+ return this._flush?.();
66
65
  });
67
66
  if (this._flush != null) {
68
67
  setInterval(this._flush, this._flushInterval);
@@ -98,8 +97,7 @@ class AnalyticsCustomPlugin {
98
97
  _addDataToFlushingPack(sendingData) {
99
98
  this._data.push(sendingData);
100
99
  if (this._flushMaxPackSize != null && this._data.length >= this._flushMaxPackSize) {
101
- var _this$_flush2;
102
- (_this$_flush2 = this._flush) === null || _this$_flush2 === void 0 ? void 0 : _this$_flush2.call(this);
100
+ this._flush?.();
103
101
  }
104
102
  }
105
103
  get serializeAdditionalInfo() {
@@ -17,7 +17,6 @@ import 'sniffr';
17
17
  */
18
18
  class AnalyticsFUSPlugin {
19
19
  constructor(_ref) {
20
- var _window$fusra, _window;
21
20
  let {
22
21
  productId,
23
22
  productBuild,
@@ -32,7 +31,6 @@ class AnalyticsFUSPlugin {
32
31
  return;
33
32
  }
34
33
  ((i, s, o, g, r) => {
35
- var _firstScript$parentNo;
36
34
  i[r] = i[r] || function addArgumentsToQueueForWaitingTheScriptLoading() {
37
35
  const fn = i[r];
38
36
  if (fn != null) {
@@ -46,9 +44,9 @@ class AnalyticsFUSPlugin {
46
44
  script.async = true;
47
45
  script.src = g;
48
46
  const firstScript = document.getElementsByTagName(o)[0];
49
- (_firstScript$parentNo = firstScript.parentNode) === null || _firstScript$parentNo === void 0 ? void 0 : _firstScript$parentNo.insertBefore(script, firstScript);
47
+ firstScript.parentNode?.insertBefore(script, firstScript);
50
48
  })(window, document, 'script', '//resources.jetbrains.com/storage/fus/api/fus-reporting-api.js', 'fusra');
51
- (_window$fusra = (_window = window).fusra) === null || _window$fusra === void 0 ? void 0 : _window$fusra.call(_window, 'init', {
49
+ window.fusra?.('init', {
52
50
  recorderCode: productId,
53
51
  recorderVersion,
54
52
  productCode: productId,
@@ -9,7 +9,6 @@ class AnalyticsGAPlugin {
9
9
  return;
10
10
  }
11
11
  ((i, s, o, g, r) => {
12
- var _m$parentNode;
13
12
  i.GoogleAnalyticsObject = r;
14
13
  i[r] = i[r] || function addArgumentsToQueueForWaitingTheScriptLoading() {
15
14
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -22,7 +21,7 @@ class AnalyticsGAPlugin {
22
21
  const m = s.getElementsByTagName(o)[0];
23
22
  a.async = true;
24
23
  a.src = g;
25
- (_m$parentNode = m.parentNode) === null || _m$parentNode === void 0 ? void 0 : _m$parentNode.insertBefore(a, m);
24
+ m.parentNode?.insertBefore(a, m);
26
25
  })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
27
26
  /**
28
27
  * UA-57284711-1 - ga key for development purpose
package/dist/auth/auth.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import WindowFlow from './window-flow.js';
2
2
  import onBackendDown from './down-notification.js';
3
3
  import Auth from './auth__core.js';
4
- export { DEFAULT_BACKGROUND_TIMEOUT, DEFAULT_EXPIRES_TIMEOUT, DOMAIN_USER_CHANGED_EVENT, LOGOUT_EVENT, LOGOUT_POSTPONED_EVENT, USER_CHANGED_EVENT, USER_CHANGE_POSTPONED_EVENT, default } from './auth__core.js';
4
+ export { DEFAULT_BACKGROUND_TIMEOUT, DEFAULT_EXPIRES_TIMEOUT, DOMAIN_USER_CHANGED_EVENT, LOGOUT_EVENT, LOGOUT_POSTPONED_EVENT, USER_CHANGED_EVENT, USER_CHANGE_POSTPONED_EVENT } from './auth__core.js';
5
5
  import '../_helpers/_rollupPluginBabelHelpers.js';
6
6
  import './response-parser.js';
7
7
  import 'es6-error';
@@ -101,3 +101,5 @@ Auth.DEFAULT_CONFIG = {
101
101
  EmbeddedLoginFlow: WindowFlow,
102
102
  onBackendDown: onBackendDown
103
103
  };
104
+
105
+ export { Auth as default };
@@ -211,14 +211,8 @@ class Auth {
211
211
  }
212
212
  });
213
213
  if (this.config.cacheCurrentUser) {
214
- this.addListener(LOGOUT_EVENT, () => {
215
- var _this$_storage;
216
- return (_this$_storage = this._storage) === null || _this$_storage === void 0 ? void 0 : _this$_storage.wipeCachedCurrentUser();
217
- });
218
- this.addListener(USER_CHANGED_EVENT, () => {
219
- var _this$_storage2;
220
- return (_this$_storage2 = this._storage) === null || _this$_storage2 === void 0 ? void 0 : _this$_storage2.onUserChanged();
221
- });
214
+ this.addListener(LOGOUT_EVENT, () => this._storage?.wipeCachedCurrentUser());
215
+ this.addListener(USER_CHANGED_EVENT, () => this._storage?.onUserChanged());
222
216
  }
223
217
  this._createInitDeferred();
224
218
  this.setUpPreconnect(config.serverUri);
@@ -258,8 +252,7 @@ class Auth {
258
252
  * that should be restored after returning back from auth server.
259
253
  */
260
254
  async init() {
261
- var _this$_storage3;
262
- (_this$_storage3 = this._storage) === null || _this$_storage3 === void 0 ? void 0 : _this$_storage3.onTokenChange(async token => {
255
+ this._storage?.onTokenChange(async token => {
263
256
  const isGuest = this.user ? this.user.guest : false;
264
257
  if (isGuest && !token) {
265
258
  return;
@@ -307,18 +300,16 @@ class Auth {
307
300
  return new Promise(noop);
308
301
  }
309
302
  try {
310
- var _this$_tokenValidator, _this$_initDeferred, _this$_initDeferred$r, _state;
311
303
  // Check if there is a valid token
312
- await ((_this$_tokenValidator = this._tokenValidator) === null || _this$_tokenValidator === void 0 ? void 0 : _this$_tokenValidator.validateToken());
304
+ await this._tokenValidator?.validateToken();
313
305
  // Checking if there is a message left by another app on this domain
314
306
  const message = await this._domainStorage._messagesStorage.get(`domain-message-${DOMAIN_USER_CHANGED_EVENT}`);
315
307
  if (message) {
316
- var _this$user;
317
308
  const {
318
309
  userID,
319
310
  serviceID
320
311
  } = message;
321
- if (serviceID !== this.config.clientId && (!userID || ((_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user.id) !== userID)) {
312
+ if (serviceID !== this.config.clientId && (!userID || this.user?.id !== userID)) {
322
313
  this.forceTokenUpdate();
323
314
  }
324
315
  }
@@ -328,12 +319,11 @@ class Auth {
328
319
  // Check if we have requested to restore state anyway
329
320
  state = await this._checkForStateRestoration();
330
321
  }
331
- (_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);
332
- return (_state = state) === null || _state === void 0 ? void 0 : _state.restoreLocation;
322
+ this._initDeferred?.resolve?.(state && state.restoreLocation);
323
+ return state?.restoreLocation;
333
324
  } catch (error) {
334
325
  if (Auth.storageIsUnavailable) {
335
- var _this$_initDeferred2, _this$_initDeferred2$;
336
- (_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
326
+ this._initDeferred?.resolve?.(); // No way to handle if cookies are disabled
337
327
  await this.requestUser(); // Someone may expect user to be loaded as a part of token validation
338
328
  return null;
339
329
  }
@@ -341,8 +331,7 @@ class Auth {
341
331
  }
342
332
  }
343
333
  async sendRedirect(error) {
344
- var _this$_requestBuilder;
345
- const authRequest = await ((_this$_requestBuilder = this._requestBuilder) === null || _this$_requestBuilder === void 0 ? void 0 : _this$_requestBuilder.prepareAuthRequest());
334
+ const authRequest = await this._requestBuilder?.prepareAuthRequest();
346
335
  if (authRequest != null) {
347
336
  this._redirectCurrentPage(authRequest.url);
348
337
  }
@@ -355,12 +344,10 @@ class Auth {
355
344
  async handleInitError(error) {
356
345
  if ('stateId' in error && error.stateId) {
357
346
  try {
358
- var _this$_storage4;
359
- const state = await ((_this$_storage4 = this._storage) === null || _this$_storage4 === void 0 ? void 0 : _this$_storage4.getState(error.stateId));
347
+ const state = await this._storage?.getState(error.stateId);
360
348
  if (state && state.nonRedirect) {
361
- var _this$_storage5;
362
349
  state.error = error;
363
- (_this$_storage5 = this._storage) === null || _this$_storage5 === void 0 ? void 0 : _this$_storage5.saveState(error.stateId, state);
350
+ this._storage?.saveState(error.stateId, state);
364
351
  // Return endless promise in the background to avoid service start
365
352
  return new Promise(noop);
366
353
  }
@@ -371,8 +358,7 @@ class Auth {
371
358
  throw error;
372
359
  }
373
360
  async handleInitValidationError(error) {
374
- var _error$cause, _this$_initDeferred4, _this$_initDeferred4$;
375
- if ('cause' in error && error.cause instanceof Error && ((_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.message) === 'invalid_client') {
361
+ if ('cause' in error && error.cause instanceof Error && error.cause?.message === 'invalid_client') {
376
362
  // eslint-disable-next-line no-console
377
363
  console.error('RingUI Auth: invalid client detected. Logging out', error);
378
364
  await this.logout();
@@ -385,17 +371,16 @@ class Auth {
385
371
  // Background flow
386
372
  if ('authRedirect' in error && error.authRedirect && !this.config.redirect) {
387
373
  try {
388
- var _this$_backgroundFlow, _this$_tokenValidator2, _this$_initDeferred3, _this$_initDeferred3$;
389
- await ((_this$_backgroundFlow = this._backgroundFlow) === null || _this$_backgroundFlow === void 0 ? void 0 : _this$_backgroundFlow.authorize());
390
- await ((_this$_tokenValidator2 = this._tokenValidator) === null || _this$_tokenValidator2 === void 0 ? void 0 : _this$_tokenValidator2.validateToken());
391
- (_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
+ await this._backgroundFlow?.authorize();
375
+ await this._tokenValidator?.validateToken();
376
+ this._initDeferred?.resolve?.();
392
377
  return undefined;
393
378
  } catch (validationError) {
394
379
  // Fallback to redirect flow
395
380
  return validationError instanceof Error ? this.sendRedirect(validationError) : undefined;
396
381
  }
397
382
  }
398
- (_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);
383
+ this._initDeferred?.reject?.(error);
399
384
  throw error;
400
385
  }
401
386
  /**
@@ -408,13 +393,13 @@ class Auth {
408
393
  throw new Error('You should log in to be able to make requests');
409
394
  }
410
395
  try {
411
- var _this$_initDeferred5, _await$this$_tokenVal, _this$_tokenValidator3;
412
- await ((_this$_initDeferred5 = this._initDeferred) === null || _this$_initDeferred5 === void 0 ? void 0 : _this$_initDeferred5.promise);
396
+ var _await$this$_tokenVal;
397
+ await this._initDeferred?.promise;
413
398
  if (Auth.storageIsUnavailable) {
414
399
  return null; // Forever guest if storage is unavailable
415
400
  }
416
401
 
417
- 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;
402
+ return (_await$this$_tokenVal = await this._tokenValidator?.validateTokenLocally()) !== null && _await$this$_tokenVal !== void 0 ? _await$this$_tokenVal : null;
418
403
  } catch (e) {
419
404
  return this.forceTokenUpdate();
420
405
  }
@@ -435,8 +420,8 @@ class Auth {
435
420
  this._backendCheckPromise = null;
436
421
  }
437
422
  try {
438
- var _await$this$_backgrou, _this$_backgroundFlow2;
439
- 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;
423
+ var _await$this$_backgrou;
424
+ return (_await$this$_backgrou = await this._backgroundFlow?.authorize()) !== null && _await$this$_backgrou !== void 0 ? _await$this$_backgrou : null;
440
425
  } catch (error) {
441
426
  if (!(error instanceof Error)) {
442
427
  return null;
@@ -445,8 +430,7 @@ class Auth {
445
430
  return new Promise(resolve => {
446
431
  const onTryAgain = async () => {
447
432
  try {
448
- var _this$_backgroundFlow3;
449
- const result = await ((_this$_backgroundFlow3 = this._backgroundFlow) === null || _this$_backgroundFlow3 === void 0 ? void 0 : _this$_backgroundFlow3.authorize());
433
+ const result = await this._backgroundFlow?.authorize();
450
434
  resolve(result !== null && result !== void 0 ? result : null);
451
435
  } catch (retryError) {
452
436
  if (retryError instanceof Error) {
@@ -466,8 +450,7 @@ class Auth {
466
450
  });
467
451
  });
468
452
  } else {
469
- var _this$_requestBuilder2;
470
- const authRequest = await ((_this$_requestBuilder2 = this._requestBuilder) === null || _this$_requestBuilder2 === void 0 ? void 0 : _this$_requestBuilder2.prepareAuthRequest());
453
+ const authRequest = await this._requestBuilder?.prepareAuthRequest();
471
454
  if (authRequest != null) {
472
455
  this._redirectCurrentPage(authRequest.url);
473
456
  }
@@ -500,8 +483,7 @@ class Auth {
500
483
  */
501
484
  getUser(accessToken) {
502
485
  if (this.config.cacheCurrentUser) {
503
- var _this$_storage6;
504
- 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));
486
+ return this._storage?.getCachedUser(() => this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams));
505
487
  } else {
506
488
  return this.http.authorizedFetch(Auth.API_PROFILE_PATH, accessToken, this.config.userParams);
507
489
  }
@@ -523,10 +505,9 @@ class Auth {
523
505
  return user;
524
506
  }
525
507
  async updateUser() {
526
- var _this$_storage7;
527
508
  this._setPostponed(false);
528
509
  const accessToken = await this.requestToken();
529
- (_this$_storage7 = this._storage) === null || _this$_storage7 === void 0 ? void 0 : _this$_storage7.wipeCachedCurrentUser();
510
+ this._storage?.wipeCachedCurrentUser();
530
511
  const user = await this.getUser(accessToken);
531
512
  this.user = user;
532
513
  this.listeners.trigger(USER_CHANGED_EVENT, user);
@@ -567,7 +548,6 @@ class Auth {
567
548
  this.logout();
568
549
  }
569
550
  _showAuthDialog() {
570
- var _this$user2, _this$_authDialogServ, _this$_storage9, _this$_storage10;
571
551
  let {
572
552
  nonInteractive,
573
553
  error,
@@ -579,13 +559,13 @@ class Auth {
579
559
  onPostponeLogout,
580
560
  translations
581
561
  } = this.config;
582
- const cancelable = ((_this$user2 = this.user) === null || _this$user2 === void 0 ? void 0 : _this$user2.guest) || canCancel;
562
+ const cancelable = this.user?.guest || canCancel;
583
563
  this._createInitDeferred();
584
564
  const closeDialog = () => {
585
565
  /* eslint-disable @typescript-eslint/no-use-before-define */
586
- stopTokenListening === null || stopTokenListening === void 0 ? void 0 : stopTokenListening();
587
- stopMessageListening === null || stopMessageListening === void 0 ? void 0 : stopMessageListening();
588
- hide === null || hide === void 0 ? void 0 : hide();
566
+ stopTokenListening?.();
567
+ stopMessageListening?.();
568
+ hide?.();
589
569
  /* eslint-enable @typescript-eslint/no-use-before-define */
590
570
  };
591
571
 
@@ -598,29 +578,26 @@ class Auth {
598
578
  this._runEmbeddedLogin();
599
579
  };
600
580
  const onCancel = () => {
601
- var _this$_embeddedFlow, _this$_storage8, _this$user3;
602
- (_this$_embeddedFlow = this._embeddedFlow) === null || _this$_embeddedFlow === void 0 ? void 0 : _this$_embeddedFlow.stop();
603
- (_this$_storage8 = this._storage) === null || _this$_storage8 === void 0 ? void 0 : _this$_storage8.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
581
+ this._embeddedFlow?.stop();
582
+ this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
604
583
  closeDialog();
605
584
  if (!cancelable) {
606
- var _this$_initDeferred6, _this$_initDeferred6$;
607
- (_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);
585
+ this._initDeferred?.resolve?.();
608
586
  this.listeners.trigger(LOGOUT_POSTPONED_EVENT);
609
587
  onPostponeLogout();
610
588
  return;
611
589
  }
612
- if ((_this$user3 = this.user) !== null && _this$user3 !== void 0 && _this$user3.guest && nonInteractive) {
590
+ if (this.user?.guest && nonInteractive) {
613
591
  this.forceTokenUpdate();
614
592
  } else {
615
- var _this$_initDeferred7, _this$_initDeferred7$;
616
- (_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);
593
+ this._initDeferred?.resolve?.();
617
594
  }
618
595
  };
619
596
  const onTryAgainClick = async () => {
620
- await (onTryAgain === null || onTryAgain === void 0 ? void 0 : onTryAgain());
597
+ await onTryAgain?.();
621
598
  closeDialog();
622
599
  };
623
- const hide = (_this$_authDialogServ = this._authDialogService) === null || _this$_authDialogServ === void 0 ? void 0 : _this$_authDialogServ.call(this, {
600
+ const hide = this._authDialogService?.({
624
601
  ...this._service,
625
602
  loginCaption: translations.login,
626
603
  loginToCaption: translations.loginTo,
@@ -632,20 +609,16 @@ class Auth {
632
609
  onCancel,
633
610
  onTryAgain: onTryAgain ? onTryAgainClick : undefined
634
611
  });
635
- const stopTokenListening = (_this$_storage9 = this._storage) === null || _this$_storage9 === void 0 ? void 0 : _this$_storage9.onTokenChange(token => {
612
+ const stopTokenListening = this._storage?.onTokenChange(token => {
636
613
  if (token) {
637
- var _this$_initDeferred8, _this$_initDeferred8$;
638
614
  closeDialog();
639
- (_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);
615
+ this._initDeferred?.resolve?.();
640
616
  }
641
617
  });
642
- const stopMessageListening = (_this$_storage10 = this._storage) === null || _this$_storage10 === void 0 ? void 0 : _this$_storage10.onMessage(Auth.CLOSE_WINDOW_MESSAGE, () => {
643
- var _this$_embeddedFlow2;
644
- return (_this$_embeddedFlow2 = this._embeddedFlow) === null || _this$_embeddedFlow2 === void 0 ? void 0 : _this$_embeddedFlow2.stop();
645
- });
618
+ const stopMessageListening = this._storage?.onMessage(Auth.CLOSE_WINDOW_MESSAGE, () => this._embeddedFlow?.stop());
646
619
  }
647
620
  _showUserChangedDialog(_ref) {
648
- var _this$_authDialogServ2, _newUser$name;
621
+ var _newUser$name;
649
622
  let {
650
623
  newUser,
651
624
  onApply,
@@ -656,12 +629,11 @@ class Auth {
656
629
  } = this.config;
657
630
  this._createInitDeferred();
658
631
  const done = () => {
659
- var _this$_initDeferred9, _this$_initDeferred9$;
660
- (_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);
632
+ this._initDeferred?.resolve?.();
661
633
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
662
- hide === null || hide === void 0 ? void 0 : hide();
634
+ hide?.();
663
635
  };
664
- const hide = (_this$_authDialogServ2 = this._authDialogService) === null || _this$_authDialogServ2 === void 0 ? void 0 : _this$_authDialogServ2.call(this, {
636
+ const hide = this._authDialogService?.({
665
637
  ...this._service,
666
638
  title: translations.youHaveLoggedInAs.replace('%userName%', (_newUser$name = newUser.name) !== null && _newUser$name !== void 0 ? _newUser$name : ''),
667
639
  loginCaption: translations.login,
@@ -708,19 +680,17 @@ class Auth {
708
680
  const REPEAT_TIMEOUT = 5000;
709
681
  let timerId;
710
682
  return new Promise((resolve, reject) => {
711
- var _this$_storage12;
712
683
  const done = () => {
713
- var _this$_storage11;
714
684
  /* eslint-disable @typescript-eslint/no-use-before-define */
715
685
  hide();
716
686
  window.removeEventListener('online', onCheckAgain);
717
- stopListeningCloseMessage === null || stopListeningCloseMessage === void 0 ? void 0 : stopListeningCloseMessage();
687
+ stopListeningCloseMessage?.();
718
688
  /* eslint-enable @typescript-eslint/no-use-before-define */
719
- (_this$_storage11 = this._storage) === null || _this$_storage11 === void 0 ? void 0 : _this$_storage11.sendMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, Date.now());
689
+ this._storage?.sendMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, Date.now());
720
690
  clearTimeout(timerId);
721
691
  };
722
- const stopListeningCloseMessage = (_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.onMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, () => {
723
- stopListeningCloseMessage === null || stopListeningCloseMessage === void 0 ? void 0 : stopListeningCloseMessage();
692
+ const stopListeningCloseMessage = this._storage?.onMessage(Auth.CLOSE_BACKEND_DOWN_MESSAGE, () => {
693
+ stopListeningCloseMessage?.();
724
694
  done();
725
695
  resolve();
726
696
  });
@@ -753,7 +723,6 @@ class Auth {
753
723
  * Wipe accessToken and redirect to auth page with required authorization
754
724
  */
755
725
  async logout(extraParams) {
756
- var _this$_storage13, _this$_requestBuilder3;
757
726
  const requestParams = {
758
727
  // eslint-disable-next-line camelcase
759
728
  request_credentials: 'required',
@@ -762,19 +731,17 @@ class Auth {
762
731
  await this._checkBackendsStatusesIfEnabled();
763
732
  await this.listeners.trigger('logout');
764
733
  this._updateDomainUser(null);
765
- await ((_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.wipeToken());
766
- const authRequest = await ((_this$_requestBuilder3 = this._requestBuilder) === null || _this$_requestBuilder3 === void 0 ? void 0 : _this$_requestBuilder3.prepareAuthRequest(requestParams));
734
+ await this._storage?.wipeToken();
735
+ const authRequest = await this._requestBuilder?.prepareAuthRequest(requestParams);
767
736
  if (authRequest != null) {
768
737
  this._redirectCurrentPage(authRequest.url);
769
738
  }
770
739
  }
771
740
  async _runEmbeddedLogin() {
772
- var _this$_storage14;
773
- (_this$_storage14 = this._storage) === null || _this$_storage14 === void 0 ? void 0 : _this$_storage14.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
741
+ this._storage?.sendMessage(Auth.CLOSE_WINDOW_MESSAGE, Date.now());
774
742
  try {
775
- var _this$_embeddedFlow3;
776
743
  this._isLoginWindowOpen = true;
777
- return await ((_this$_embeddedFlow3 = this._embeddedFlow) === null || _this$_embeddedFlow3 === void 0 ? void 0 : _this$_embeddedFlow3.authorize());
744
+ return await this._embeddedFlow?.authorize();
778
745
  } catch (e) {
779
746
  throw e;
780
747
  } finally {
@@ -792,8 +759,7 @@ class Auth {
792
759
  }
793
760
  await this._checkBackendsStatusesIfEnabled();
794
761
  try {
795
- var _this$_backgroundFlow4;
796
- const accessToken = await ((_this$_backgroundFlow4 = this._backgroundFlow) === null || _this$_backgroundFlow4 === void 0 ? void 0 : _this$_backgroundFlow4.authorize());
762
+ const accessToken = await this._backgroundFlow?.authorize();
797
763
  const user = await this.getUser(accessToken);
798
764
  if (user.guest) {
799
765
  this._beforeLogout();
@@ -820,7 +786,6 @@ class Auth {
820
786
  * @private
821
787
  */
822
788
  async _checkForAuthResponse() {
823
- var _this$_storage15;
824
789
  // getAuthResponseURL may throw an exception
825
790
  const authResponse = this._responseParser.getAuthResponseFromURL();
826
791
  const {
@@ -840,29 +805,27 @@ class Auth {
840
805
  expiresIn,
841
806
  accessToken
842
807
  } = authResponse;
843
- const newState = (await (stateId && ((_this$_storage15 = this._storage) === null || _this$_storage15 === void 0 ? void 0 : _this$_storage15.getState(stateId)))) || {};
808
+ const newState = (await (stateId && this._storage?.getState(stateId))) || {};
844
809
  const scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
845
810
  const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
846
811
  const expires = TokenValidator._epoch() + effectiveExpiresIn;
847
812
  if (accessToken != null) {
848
- var _this$_storage16;
849
- await ((_this$_storage16 = this._storage) === null || _this$_storage16 === void 0 ? void 0 : _this$_storage16.saveToken({
813
+ await this._storage?.saveToken({
850
814
  accessToken,
851
815
  scopes,
852
816
  expires,
853
817
  lifeTime: effectiveExpiresIn
854
- }));
818
+ });
855
819
  }
856
820
  return newState;
857
821
  }
858
822
  async _checkForStateRestoration() {
859
- var _this$_storage17;
860
823
  const authResponse = this._responseParser._authResponse;
861
824
  if (authResponse && this.config.cleanHash) {
862
825
  this.setHash('');
863
826
  }
864
- const stateId = authResponse === null || authResponse === void 0 ? void 0 : authResponse.restoreAuthState;
865
- return (await (stateId && ((_this$_storage17 = this._storage) === null || _this$_storage17 === void 0 ? void 0 : _this$_storage17.getState(stateId)))) || {};
827
+ const stateId = authResponse?.restoreAuthState;
828
+ return (await (stateId && this._storage?.getState(stateId))) || {};
866
829
  }
867
830
  _checkBackendsAreUp() {
868
831
  const abortCtrl = new AbortController();
@@ -112,8 +112,7 @@ class IFrameFlow {
112
112
  }
113
113
  });
114
114
  const cleanUp = () => {
115
- var _this$hideDialog;
116
- (_this$hideDialog = this.hideDialog) === null || _this$hideDialog === void 0 ? void 0 : _this$hideDialog.call(this);
115
+ this.hideDialog?.();
117
116
  removeStateListener();
118
117
  removeTokenListener();
119
118
  };