@jetbrains/ring-ui-built 6.0.42 → 6.1.1-beta.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.
@@ -208,8 +208,8 @@ function _objectWithoutProperties(e, t) {
208
208
  r,
209
209
  i = _objectWithoutPropertiesLoose(e, t);
210
210
  if (Object.getOwnPropertySymbols) {
211
- var n = Object.getOwnPropertySymbols(e);
212
- for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
211
+ var s = Object.getOwnPropertySymbols(e);
212
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
213
213
  }
214
214
  return i;
215
215
  }
@@ -217,7 +217,7 @@ function _objectWithoutPropertiesLoose(r, e) {
217
217
  if (null == r) return {};
218
218
  var t = {};
219
219
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
220
- if (e.indexOf(n) >= 0) continue;
220
+ if (e.includes(n)) continue;
221
221
  t[n] = r[n];
222
222
  }
223
223
  return t;
@@ -129,7 +129,7 @@ export default class Auth implements HTTPAuth {
129
129
  listeners: Listeners<AuthPayloadMap>;
130
130
  http: HTTP;
131
131
  private _service;
132
- readonly _storage: AuthStorage<number> | null;
132
+ readonly _storage: AuthStorage<number>;
133
133
  private _responseParser;
134
134
  private readonly _requestBuilder;
135
135
  _backgroundFlow: BackgroundFlow | null;
@@ -174,7 +174,7 @@ export default class Auth implements HTTPAuth {
174
174
  /**
175
175
  * @return {Promise.<object>}
176
176
  */
177
- getUser(accessToken?: string | null | undefined): Promise<any> | undefined;
177
+ getUser(accessToken?: string | null | undefined): Promise<any>;
178
178
  /**
179
179
  * @return {Promise.<object>}
180
180
  */
@@ -197,7 +197,7 @@ export default class Auth implements HTTPAuth {
197
197
  */
198
198
  login(): Promise<void>;
199
199
  switchUser(): Promise<void>;
200
- _makeStateFromResponse(authResponse: AuthResponse): AuthState;
200
+ _makeStateFromResponse(authResponse: AuthResponse): AuthState | null;
201
201
  /**
202
202
  * Check if the hash contains an access token.
203
203
  * If it does, extract the state, compare with
@@ -137,7 +137,7 @@ var Auth = /*#__PURE__*/function () {
137
137
  _defineProperty(this, "listeners", new Listeners());
138
138
  _defineProperty(this, "http", void 0);
139
139
  _defineProperty(this, "_service", {});
140
- _defineProperty(this, "_storage", null);
140
+ _defineProperty(this, "_storage", void 0);
141
141
  _defineProperty(this, "_responseParser", new AuthResponseParser());
142
142
  _defineProperty(this, "_requestBuilder", null);
143
143
  _defineProperty(this, "_backgroundFlow", void 0);
@@ -1402,22 +1402,23 @@ var Auth = /*#__PURE__*/function () {
1402
1402
  value: function _makeStateFromResponse(authResponse) {
1403
1403
  var state = authResponse.state;
1404
1404
  if (!state) {
1405
- return {};
1405
+ throw new Error('No state in AuthResponse');
1406
1406
  }
1407
1407
  var defaultScope = this.config.scope;
1408
+ var urlFromState = null;
1408
1409
  try {
1409
- var urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
1410
- if (urlFromState.origin !== window.location.origin) {
1411
- return {};
1412
- }
1413
- return {
1414
- restoreLocation: state,
1415
- created: Date.now(),
1416
- scopes: defaultScope
1417
- };
1418
- } catch (e) {
1419
- return {};
1410
+ urlFromState = new URL(state); // checking if state contains valid URL on same origin, see HUB-11514
1411
+ } catch (_unused2) {
1412
+ return null;
1420
1413
  }
1414
+ if (urlFromState.origin !== window.location.origin) {
1415
+ throw new Error("State contains URL with different origin: \"".concat(state, "\""));
1416
+ }
1417
+ return {
1418
+ restoreLocation: state,
1419
+ created: Date.now(),
1420
+ scopes: defaultScope
1421
+ };
1421
1422
  }
1422
1423
  /**
1423
1424
  * Check if the hash contains an access token.
@@ -1431,8 +1432,7 @@ var Auth = /*#__PURE__*/function () {
1431
1432
  key: "_checkForAuthResponse",
1432
1433
  value: (function () {
1433
1434
  var _checkForAuthResponse2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1434
- var _this$_storage12;
1435
- var authResponse, _this$config4, defaultScope, defaultExpiresIn, cleanHash, stateId, scope, expiresIn, accessToken, newState, scopes, effectiveExpiresIn, expires, _this$_storage13;
1435
+ var authResponse, _this$config4, defaultScope, defaultExpiresIn, cleanHash, stateId, scope, expiresIn, accessToken, newState, scopes, effectiveExpiresIn, expires, _this$_storage12;
1436
1436
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1437
1437
  while (1) switch (_context20.prev = _context20.next) {
1438
1438
  case 0:
@@ -1449,34 +1449,42 @@ var Auth = /*#__PURE__*/function () {
1449
1449
  return _context20.abrupt("return", undefined);
1450
1450
  case 5:
1451
1451
  stateId = authResponse.state, scope = authResponse.scope, expiresIn = authResponse.expiresIn, accessToken = authResponse.accessToken;
1452
- _context20.next = 8;
1453
- return stateId && ((_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.getState(stateId));
1454
- case 8:
1455
- _context20.t0 = _context20.sent;
1456
- if (_context20.t0) {
1457
- _context20.next = 11;
1452
+ newState = null;
1453
+ if (!stateId) {
1454
+ _context20.next = 12;
1458
1455
  break;
1459
1456
  }
1460
- _context20.t0 = this._makeStateFromResponse(authResponse);
1461
- case 11:
1462
- newState = _context20.t0;
1457
+ _context20.next = 10;
1458
+ return this._storage.getState(stateId);
1459
+ case 10:
1460
+ newState = _context20.sent;
1461
+ if (!newState) {
1462
+ newState = this._makeStateFromResponse(authResponse);
1463
+ }
1464
+ case 12:
1465
+ if (newState) {
1466
+ _context20.next = 14;
1467
+ break;
1468
+ }
1469
+ throw new Error("Could not create state where stateId=\"".concat(stateId, "\""));
1470
+ case 14:
1463
1471
  scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
1464
1472
  effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
1465
1473
  expires = TokenValidator._epoch() + effectiveExpiresIn;
1466
1474
  if (!(accessToken != null)) {
1467
- _context20.next = 18;
1475
+ _context20.next = 20;
1468
1476
  break;
1469
1477
  }
1470
- _context20.next = 18;
1471
- return (_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.saveToken({
1478
+ _context20.next = 20;
1479
+ return (_this$_storage12 = this._storage) === null || _this$_storage12 === void 0 ? void 0 : _this$_storage12.saveToken({
1472
1480
  accessToken,
1473
1481
  scopes,
1474
1482
  expires,
1475
1483
  lifeTime: effectiveExpiresIn
1476
1484
  });
1477
- case 18:
1485
+ case 20:
1478
1486
  return _context20.abrupt("return", newState);
1479
- case 19:
1487
+ case 21:
1480
1488
  case "end":
1481
1489
  return _context20.stop();
1482
1490
  }
@@ -1491,7 +1499,7 @@ var Auth = /*#__PURE__*/function () {
1491
1499
  key: "_checkForStateRestoration",
1492
1500
  value: function () {
1493
1501
  var _checkForStateRestoration2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1494
- var _this$_storage14;
1502
+ var _this$_storage13;
1495
1503
  var authResponse, stateId;
1496
1504
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1497
1505
  while (1) switch (_context21.prev = _context21.next) {
@@ -1502,7 +1510,7 @@ var Auth = /*#__PURE__*/function () {
1502
1510
  }
1503
1511
  stateId = authResponse === null || authResponse === void 0 ? void 0 : authResponse.restoreAuthState;
1504
1512
  _context21.next = 5;
1505
- return stateId && ((_this$_storage14 = this._storage) === null || _this$_storage14 === void 0 ? void 0 : _this$_storage14.getState(stateId));
1513
+ return stateId && ((_this$_storage13 = this._storage) === null || _this$_storage13 === void 0 ? void 0 : _this$_storage13.getState(stateId));
1506
1514
  case 5:
1507
1515
  _context21.t0 = _context21.sent;
1508
1516
  if (_context21.t0) {
@@ -53,7 +53,9 @@ var ContentLayout = /*#__PURE__*/function (_Component) {
53
53
  var contentChildren = childrenArray.filter(function (child) {
54
54
  return child !== sidebarChild;
55
55
  });
56
- return /*#__PURE__*/jsxs("div", _objectSpread2(_objectSpread2({}, restProps), {}, {
56
+ return /*#__PURE__*/jsxs("div", _objectSpread2(_objectSpread2({
57
+ "data-test": "content-layout"
58
+ }, restProps), {}, {
57
59
  className: classes,
58
60
  children: [sidebar, /*#__PURE__*/jsx("main", {
59
61
  className: contentClasses,
@@ -654,7 +654,7 @@ var QueryAssist = /*#__PURE__*/function (_Component) {
654
654
  key: "_pushHistory",
655
655
  value: function _pushHistory(state) {
656
656
  var _this$historyStack$;
657
- var queryIsSet = ('query' in state);
657
+ var queryIsSet = 'query' in state;
658
658
  var queryIsSame = ((_this$historyStack$ = this.historyStack[0]) === null || _this$historyStack$ === void 0 ? void 0 : _this$historyStack$.query) === state.query;
659
659
  if (queryIsSet && !queryIsSame) {
660
660
  var _this$caret$getPositi, _this$caret9;
@@ -982,12 +982,16 @@ var Select = /*#__PURE__*/function (_Component) {
982
982
  [modules_9d0de074["size".concat(this.props.size)]]: this.props.type !== Type.INLINE,
983
983
  [modules_9d0de074.disabled]: this.props.disabled
984
984
  });
985
- var icons = this._getIcons();
986
- var style = getStyle(icons.length);
987
- var iconsNode = /*#__PURE__*/jsx("div", {
988
- className: modules_9d0de074.icons,
989
- children: icons
990
- });
985
+ var style;
986
+ var iconsNode;
987
+ if (this.props.type === Type.INPUT || this.props.type === Type.BUTTON) {
988
+ var icons = this._getIcons();
989
+ style = getStyle(icons.length);
990
+ iconsNode = /*#__PURE__*/jsx("div", {
991
+ className: modules_9d0de074.icons,
992
+ children: icons
993
+ });
994
+ }
991
995
  var ariaProps = this.state.showPopup ? {
992
996
  'aria-owns': this.listId,
993
997
  'aria-activedescendant': activeItemId,
@@ -1029,7 +1033,7 @@ var Select = /*#__PURE__*/function (_Component) {
1029
1033
  "data-test": "ring-select__focus",
1030
1034
  enableShortcuts: shortcutsEnabled ? Object.keys(_objectSpread2(_objectSpread2({}, this.getShortcutsMap()), (_this$_popup5 = this._popup) === null || _this$_popup5 === void 0 || (_this$_popup5 = _this$_popup5.list) === null || _this$_popup5 === void 0 ? void 0 : _this$_popup5.shortcutsMap)) : undefined,
1031
1035
  icon: this.props.filterIcon,
1032
- afterInput: this.props.type === Type.INPUT && iconsNode
1036
+ afterInput: iconsNode
1033
1037
  })), this._renderPopup()]
1034
1038
  }), this.props.error && /*#__PURE__*/jsx("div", {
1035
1039
  className: classNames(modules_88cfaf40.errorText, modules_88cfaf40["size".concat(this.props.size)]),
@@ -51,8 +51,10 @@ var Shortcuts = /*#__PURE__*/function () {
51
51
  if (element === document || !(element instanceof HTMLElement) || key == null || element.matches(_this.ALLOW_SHORTCUTS_SELECTOR) || (element.dataset.enabledShortcuts != null ? element.dataset.enabledShortcuts.split(',').includes(key) : element.closest(_this.ALLOW_SHORTCUTS_SELECTOR) != null)) {
52
52
  return false;
53
53
  }
54
- // stop for input, select, and textarea
55
- return element.matches('input:not([type=checkbox]),select,textarea') || element.contentEditable === 'true';
54
+ var elementContentEditableAttribute = element.contentEditable;
55
+ var isElementContentEditable = elementContentEditableAttribute === 'true' || elementContentEditableAttribute === 'plaintext-only';
56
+ // stop for input, select, textarea and content-editable elements
57
+ return element.matches('input:not([type=checkbox]),select,textarea') || isElementContentEditable;
56
58
  });
57
59
  this.setFilter();
58
60
  this.setScope();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui-built",
3
- "version": "6.0.42",
3
+ "version": "6.1.1-beta.0",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",