@jetbrains/ring-ui-built 6.0.32 → 6.0.33

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 (224) hide show
  1. package/components/_helpers/_rollupPluginBabelHelpers.js +567 -1
  2. package/components/_helpers/anchor.js +6 -7
  3. package/components/_helpers/button__classes.js +14 -16
  4. package/components/_helpers/caption.js +20 -14
  5. package/components/_helpers/card.js +105 -95
  6. package/components/_helpers/dialog__body-scroll-preventer.js +19 -11
  7. package/components/_helpers/icon__svg.js +25 -22
  8. package/components/_helpers/input.js +177 -146
  9. package/components/_helpers/query-assist__suggestions.js +90 -74
  10. package/components/_helpers/select__filter.js +69 -48
  11. package/components/_helpers/services-link.js +37 -29
  12. package/components/_helpers/sidebar.js +107 -99
  13. package/components/_helpers/tab-link.js +7 -7
  14. package/components/_helpers/theme.js +40 -31
  15. package/components/_helpers/title.js +72 -57
  16. package/components/alert/alert.js +202 -150
  17. package/components/alert/container.js +41 -32
  18. package/components/alert-service/alert-service.js +170 -105
  19. package/components/analytics/analytics.js +22 -12
  20. package/components/analytics/analytics__custom-plugin.js +75 -54
  21. package/components/auth/auth.js +36 -4
  22. package/components/auth/auth__core.js +1471 -746
  23. package/components/auth/background-flow.js +127 -87
  24. package/components/auth/down-notification.js +73 -30
  25. package/components/auth/iframe-flow.js +133 -75
  26. package/components/auth/request-builder.js +82 -46
  27. package/components/auth/response-parser.js +116 -86
  28. package/components/auth/storage.js +334 -171
  29. package/components/auth/token-validator.js +242 -137
  30. package/components/auth/window-flow.js +134 -92
  31. package/components/auth-dialog/auth-dialog.js +172 -114
  32. package/components/auth-dialog-service/auth-dialog-service.js +31 -8
  33. package/components/avatar/avatar-example-datauri.js +1 -23
  34. package/components/avatar/avatar.js +152 -119
  35. package/components/avatar/fallback-avatar.js +38 -22
  36. package/components/badge/badge.js +45 -35
  37. package/components/button/button.js +107 -86
  38. package/components/button-group/button-group.js +33 -19
  39. package/components/button-set/button-set.js +32 -20
  40. package/components/button-toolbar/button-toolbar.js +31 -19
  41. package/components/caret/caret.js +220 -186
  42. package/components/checkbox/checkbox.js +101 -76
  43. package/components/clipboard/clipboard-fallback.js +10 -10
  44. package/components/clipboard/clipboard.js +132 -35
  45. package/components/code/code.js +166 -92
  46. package/components/collapse/collapse-content.js +64 -42
  47. package/components/collapse/collapse-context.js +2 -2
  48. package/components/collapse/collapse-control.js +14 -12
  49. package/components/collapse/collapse.js +17 -11
  50. package/components/collapse/consts.js +4 -4
  51. package/components/collapse/utils.js +3 -1
  52. package/components/confirm/confirm.js +104 -66
  53. package/components/confirm-service/confirm-service.js +59 -37
  54. package/components/content-layout/content-layout.js +64 -43
  55. package/components/content-layout/sidebar.js +1 -0
  56. package/components/contenteditable/contenteditable.js +59 -50
  57. package/components/control-label/control-label.js +9 -9
  58. package/components/data-list/data-list.js +182 -129
  59. package/components/data-list/data-list.mock.js +6 -2
  60. package/components/data-list/item.js +170 -143
  61. package/components/data-list/selection.js +136 -76
  62. package/components/data-list/title.js +12 -1
  63. package/components/date-picker/consts.js +26 -19
  64. package/components/date-picker/date-input.js +144 -113
  65. package/components/date-picker/date-picker.js +282 -227
  66. package/components/date-picker/date-popup.js +395 -350
  67. package/components/date-picker/day.js +116 -87
  68. package/components/date-picker/month-names.js +66 -43
  69. package/components/date-picker/month-slider.js +76 -51
  70. package/components/date-picker/month.js +25 -16
  71. package/components/date-picker/months.js +50 -43
  72. package/components/date-picker/weekdays.js +22 -12
  73. package/components/date-picker/years.js +110 -83
  74. package/components/dialog/dialog.js +190 -142
  75. package/components/dialog/dialog__body-scroll-preventer.js +4 -0
  76. package/components/dropdown/anchor.js +9 -0
  77. package/components/dropdown/dropdown.js +213 -182
  78. package/components/dropdown-menu/dropdown-menu.js +97 -71
  79. package/components/editable-heading/editable-heading.js +127 -75
  80. package/components/error-bubble/error-bubble.js +60 -31
  81. package/components/error-message/error-message.js +59 -39
  82. package/components/footer/footer.js +30 -27
  83. package/components/global/compose.js +10 -1
  84. package/components/global/composeRefs.js +12 -7
  85. package/components/global/controls-height.js +2 -2
  86. package/components/global/create-stateful-context.js +15 -15
  87. package/components/global/data-tests.js +14 -6
  88. package/components/global/dom.js +86 -47
  89. package/components/global/focus-sensor-hoc.js +132 -122
  90. package/components/global/fuzzy-highlight.js +36 -22
  91. package/components/global/get-event-key.js +8 -8
  92. package/components/global/get-uid.js +8 -4
  93. package/components/global/inject-styles.js +15 -10
  94. package/components/global/listeners.js +51 -27
  95. package/components/global/memoize.js +12 -6
  96. package/components/global/normalize-indent.js +50 -19
  97. package/components/global/promise-with-timeout.js +8 -6
  98. package/components/global/prop-types.js +5 -3
  99. package/components/global/react-dom-renderer.js +44 -28
  100. package/components/global/react-render-adapter.js +1 -1
  101. package/components/global/rerender-hoc.js +30 -12
  102. package/components/global/schedule-raf.js +6 -5
  103. package/components/global/sniffer.js +1 -1
  104. package/components/global/theme.js +22 -0
  105. package/components/global/trivial-template-tag.js +10 -3
  106. package/components/global/typescript-utils.js +6 -2
  107. package/components/global/url.js +26 -20
  108. package/components/global/use-event-callback.js +4 -6
  109. package/components/grid/col.js +52 -35
  110. package/components/grid/grid.js +31 -17
  111. package/components/grid/row.js +47 -35
  112. package/components/group/group.js +25 -17
  113. package/components/header/header.js +78 -33
  114. package/components/header/logo.js +36 -20
  115. package/components/header/profile.js +199 -166
  116. package/components/header/services-link.js +4 -0
  117. package/components/header/services.js +116 -73
  118. package/components/header/smart-profile.js +203 -111
  119. package/components/header/smart-services.js +113 -62
  120. package/components/header/tray-icon.js +37 -21
  121. package/components/header/tray.js +32 -21
  122. package/components/heading/heading.js +25 -24
  123. package/components/http/http.js +353 -203
  124. package/components/http/http.mock.js +101 -49
  125. package/components/hub-source/hub-source.js +190 -83
  126. package/components/hub-source/hub-source__user.js +44 -11
  127. package/components/hub-source/hub-source__users-groups.js +65 -37
  128. package/components/i18n/i18n-context.js +10 -7
  129. package/components/i18n/i18n.js +10 -7
  130. package/components/icon/icon.js +93 -76
  131. package/components/icon/icon__svg.js +8 -0
  132. package/components/icon/index.js +8 -0
  133. package/components/input/input.js +13 -0
  134. package/components/island/adaptive-island-hoc.js +43 -30
  135. package/components/island/content.js +132 -115
  136. package/components/island/header.js +70 -57
  137. package/components/island/island.js +40 -28
  138. package/components/island-legacy/content-legacy.js +25 -17
  139. package/components/island-legacy/header-legacy.js +27 -19
  140. package/components/island-legacy/island-legacy.js +25 -17
  141. package/components/link/clickableLink.js +59 -44
  142. package/components/link/link.js +68 -57
  143. package/components/list/consts.js +2 -2
  144. package/components/list/list.js +698 -611
  145. package/components/list/list__custom.js +62 -44
  146. package/components/list/list__hint.js +19 -10
  147. package/components/list/list__item.js +174 -133
  148. package/components/list/list__link.js +50 -37
  149. package/components/list/list__separator.js +24 -14
  150. package/components/list/list__title.js +32 -22
  151. package/components/list/list__users-groups-source.js +126 -54
  152. package/components/loader/loader.js +74 -43
  153. package/components/loader/loader__core.js +263 -198
  154. package/components/loader-inline/loader-inline.js +35 -23
  155. package/components/loader-screen/loader-screen.js +46 -25
  156. package/components/login-dialog/login-dialog.js +158 -111
  157. package/components/login-dialog/service.js +34 -8
  158. package/components/markdown/markdown.js +23 -15
  159. package/components/message/message.js +203 -161
  160. package/components/old-browsers-message/old-browsers-message.js +18 -11
  161. package/components/old-browsers-message/old-browsers-message__stop.js +7 -0
  162. package/components/old-browsers-message/white-list.js +16 -8
  163. package/components/pager/pager.js +271 -212
  164. package/components/panel/panel.js +25 -17
  165. package/components/permissions/permissions.js +172 -127
  166. package/components/permissions/permissions__cache.js +224 -194
  167. package/components/popup/popup.consts.js +1 -1
  168. package/components/popup/popup.js +343 -284
  169. package/components/popup/popup.target.js +8 -9
  170. package/components/popup/position.js +106 -96
  171. package/components/popup-menu/popup-menu.js +81 -44
  172. package/components/progress-bar/progress-bar.js +104 -87
  173. package/components/query-assist/query-assist.js +916 -838
  174. package/components/query-assist/query-assist__suggestions.js +30 -1
  175. package/components/radio/radio.js +34 -19
  176. package/components/radio/radio__item.js +69 -52
  177. package/components/select/select.js +957 -852
  178. package/components/select/select__filter.js +30 -0
  179. package/components/select/select__popup.js +487 -373
  180. package/components/shortcuts/core.js +217 -166
  181. package/components/shortcuts/shortcut-title.js +11 -6
  182. package/components/shortcuts/shortcuts-hoc.js +45 -19
  183. package/components/shortcuts/shortcuts.js +75 -50
  184. package/components/slider/slider.js +122 -99
  185. package/components/slider/slider.utils.js +24 -14
  186. package/components/storage/storage.js +33 -4
  187. package/components/storage/storage__fallback.js +224 -149
  188. package/components/storage/storage__local.js +153 -90
  189. package/components/tab-trap/tab-trap.js +153 -122
  190. package/components/table/cell.js +26 -14
  191. package/components/table/disable-hover-hoc.js +51 -33
  192. package/components/table/header-cell.js +89 -64
  193. package/components/table/header.js +132 -104
  194. package/components/table/multitable.js +125 -107
  195. package/components/table/row-with-focus-sensor.js +69 -25
  196. package/components/table/row.js +216 -175
  197. package/components/table/selection-adapter.js +3 -1
  198. package/components/table/selection-shortcuts-hoc.js +181 -180
  199. package/components/table/selection.js +226 -156
  200. package/components/table/smart-table.js +88 -50
  201. package/components/table/table.js +358 -289
  202. package/components/tabs/collapsible-more.js +79 -46
  203. package/components/tabs/collapsible-tab.js +38 -31
  204. package/components/tabs/collapsible-tabs.js +153 -88
  205. package/components/tabs/custom-item.js +2 -4
  206. package/components/tabs/dumb-tabs.js +117 -74
  207. package/components/tabs/smart-tabs.js +69 -29
  208. package/components/tabs/tab-link.js +5 -1
  209. package/components/tabs/tab.js +31 -19
  210. package/components/tabs/tabs.js +31 -0
  211. package/components/tag/tag.js +173 -133
  212. package/components/tags-input/tags-input.js +427 -329
  213. package/components/tags-list/tags-list.js +78 -57
  214. package/components/text/text.js +39 -28
  215. package/components/toggle/toggle.js +70 -56
  216. package/components/tooltip/tooltip.js +190 -146
  217. package/components/user-agreement/service.js +371 -228
  218. package/components/user-agreement/toolbox.eula.js +1 -160
  219. package/components/user-agreement/user-agreement.js +120 -85
  220. package/components/user-card/card.js +29 -0
  221. package/components/user-card/smart-user-card-tooltip.js +111 -51
  222. package/components/user-card/tooltip.js +84 -47
  223. package/components/user-card/user-card.js +29 -0
  224. package/package.json +1 -1
@@ -1,3 +1,8 @@
1
+ import { b as _createClass, f as _classCallCheck, _ as _defineProperty, h as _asyncToGenerator, d as _objectSpread2, i as _regeneratorRuntime, j as _slicedToArray } from '../_helpers/_rollupPluginBabelHelpers.js';
2
+ import 'core-js/modules/es.array.iterator.js';
3
+ import 'core-js/modules/es.object.to-string.js';
4
+ import 'core-js/modules/es.promise.js';
5
+ import 'core-js/modules/web.dom-collections.iterator.js';
1
6
  import React from 'react';
2
7
  import { createRoot } from 'react-dom/client';
3
8
  import ActualStorage from '../storage/storage.js';
@@ -9,16 +14,24 @@ import { ControlsHeightContext, getGlobalControlsHeight } from '../global/contro
9
14
  import UserAgreement from './user-agreement.js';
10
15
  import '../storage/storage__local.js';
11
16
  import '../storage/storage__fallback.js';
17
+ import 'core-js/modules/es.array.concat.js';
18
+ import 'core-js/modules/es.array.index-of.js';
19
+ import 'core-js/modules/es.reflect.delete-property.js';
12
20
  import 'deep-equal';
13
- import '../_helpers/_rollupPluginBabelHelpers.js';
21
+ import 'core-js/modules/es.array.filter.js';
22
+ import 'core-js/modules/es.array.map.js';
14
23
  import '../global/get-uid.js';
24
+ import 'core-js/modules/es.regexp.to-string.js';
15
25
  import '../alert/container.js';
16
26
  import 'react-dom';
17
27
  import 'classnames';
18
28
  import 'prop-types';
19
29
  import '../global/data-tests.js';
30
+ import 'core-js/modules/es.array.reduce.js';
31
+ import 'core-js/modules/es.object.entries.js';
20
32
  import '../link/clickableLink.js';
21
33
  import '../_helpers/link.js';
34
+ import 'core-js/modules/es.object.values.js';
22
35
  import '@jetbrains/icons/exception';
23
36
  import '@jetbrains/icons/checkmark';
24
37
  import '@jetbrains/icons/warning';
@@ -27,9 +40,18 @@ import '../icon/icon.js';
27
40
  import 'util-deprecate';
28
41
  import '../icon/icon__constants.js';
29
42
  import '../_helpers/icon__svg.js';
43
+ import 'core-js/modules/es.regexp.exec.js';
44
+ import 'core-js/modules/es.string.replace.js';
45
+ import 'core-js/modules/es.string.starts-with.js';
30
46
  import '../global/memoize.js';
47
+ import 'core-js/modules/es.map.js';
48
+ import 'core-js/modules/es.weak-map.js';
31
49
  import '../loader-inline/loader-inline.js';
32
50
  import '../global/dom.js';
51
+ import 'core-js/modules/es.object.assign.js';
52
+ import 'core-js/modules/es.set.js';
53
+ import 'core-js/modules/es.string.split.js';
54
+ import 'core-js/modules/web.dom-collections.for-each.js';
33
55
  import '../button/button.js';
34
56
  import '@jetbrains/icons/chevron-10px';
35
57
  import '../_helpers/button__classes.js';
@@ -39,11 +61,18 @@ import '../popup/popup.js';
39
61
  import '../global/schedule-raf.js';
40
62
  import '../shortcuts/shortcuts.js';
41
63
  import '../shortcuts/core.js';
64
+ import 'core-js/modules/es.array.find-index.js';
65
+ import 'core-js/modules/es.array.includes.js';
66
+ import 'core-js/modules/es.array.slice.js';
67
+ import 'core-js/modules/es.array.splice.js';
68
+ import 'core-js/modules/es.string.includes.js';
69
+ import 'core-js/modules/es.string.match.js';
42
70
  import 'combokeys';
43
71
  import '../global/sniffer.js';
44
72
  import 'sniffr';
45
73
  import '../tab-trap/tab-trap.js';
46
74
  import '../popup/position.js';
75
+ import 'core-js/modules/es.array.sort.js';
47
76
  import '../popup/popup.consts.js';
48
77
  import '../dialog/dialog.js';
49
78
  import '../island/island.js';
@@ -59,286 +88,400 @@ import '../panel/panel.js';
59
88
  import '../i18n/i18n-context.js';
60
89
  import '../i18n/i18n.js';
61
90
 
62
- const GUEST_SESSION_KEY = 'end-user-agreement-consent';
63
- const ONE_HOUR = 60 * 60 * 1000; // eslint-disable-line @typescript-eslint/no-magic-numbers
64
- const storageKey = 'userAgreementKey';
65
- const showMessage = 'userAgreementShow';
66
- const hideMessage = 'userAgreementHide';
67
- const DEFAULT_CONSENT = {
91
+ var GUEST_SESSION_KEY = 'end-user-agreement-consent';
92
+ var ONE_HOUR = 60 * 60 * 1000; // eslint-disable-line @typescript-eslint/no-magic-numbers
93
+ var storageKey = 'userAgreementKey';
94
+ var showMessage = 'userAgreementShow';
95
+ var hideMessage = 'userAgreementHide';
96
+ var DEFAULT_CONSENT = {
68
97
  accepted: false,
69
98
  majorVersion: 0,
70
99
  minorVersion: 0
71
100
  };
72
- const DEFAULT_AGREEMENT = {
101
+ var DEFAULT_AGREEMENT = {
73
102
  enabled: false,
74
103
  majorVersion: 0,
75
104
  minorVersion: 0,
76
105
  requiredForREST: false,
77
106
  content: ''
78
107
  };
79
- class UserAgreementService {
80
- config;
81
- constructor(config) {
82
- if (!config) {
83
- throw new Error('Please pass a config to UserAgreementService');
84
- }
85
- if (!config.getUserAgreement) {
86
- throw new Error('Please pass a "getUserAgreement" option to UserAgreementService');
87
- }
88
- if (!config.getUserConsent) {
89
- throw new Error('Please pass a "getUserConsent" option to UserAgreementService');
90
- }
91
- if (!config.setUserConsent) {
92
- throw new Error('Please pass a "setUserConsent" option to UserAgreementService');
93
- }
94
- this.config = config;
95
- this.interval = config.interval || this.interval;
96
- }
97
- _dialogPromise = null;
98
- _alertPromise = null;
99
- tabId = Math.random();
100
- interval = ONE_HOUR;
101
- container = document.createElement('div');
102
- reactRoot = createRoot(this.container);
103
- storage = new ActualStorage();
104
- checkingPromise = null;
105
- guest = false;
106
- userAgreement = DEFAULT_AGREEMENT;
107
- userConsent = DEFAULT_CONSENT;
108
- intervalId;
109
- startChecking = () => {
110
- this.intervalId = window.setInterval(this.checkConsentAndShowDialog, this.interval);
111
- window.addEventListener('storage', this.onStorageEvent);
112
- this.checkConsentAndShowDialog();
113
- };
114
- stopChecking = () => {
115
- clearInterval(this.intervalId);
116
- window.removeEventListener('storage', this.onStorageEvent);
117
- this.hideDialog();
118
- };
119
- onStorageEvent = event => {
108
+ var UserAgreementService = /*#__PURE__*/_createClass(function UserAgreementService(config) {
109
+ var _this = this;
110
+ _classCallCheck(this, UserAgreementService);
111
+ _defineProperty(this, "config", void 0);
112
+ _defineProperty(this, "_dialogPromise", null);
113
+ _defineProperty(this, "_alertPromise", null);
114
+ _defineProperty(this, "tabId", Math.random());
115
+ _defineProperty(this, "interval", ONE_HOUR);
116
+ _defineProperty(this, "container", document.createElement('div'));
117
+ _defineProperty(this, "reactRoot", createRoot(this.container));
118
+ _defineProperty(this, "storage", new ActualStorage());
119
+ _defineProperty(this, "checkingPromise", null);
120
+ _defineProperty(this, "guest", false);
121
+ _defineProperty(this, "userAgreement", DEFAULT_AGREEMENT);
122
+ _defineProperty(this, "userConsent", DEFAULT_CONSENT);
123
+ _defineProperty(this, "intervalId", void 0);
124
+ _defineProperty(this, "startChecking", function () {
125
+ _this.intervalId = window.setInterval(_this.checkConsentAndShowDialog, _this.interval);
126
+ window.addEventListener('storage', _this.onStorageEvent);
127
+ _this.checkConsentAndShowDialog();
128
+ });
129
+ _defineProperty(this, "stopChecking", function () {
130
+ clearInterval(_this.intervalId);
131
+ window.removeEventListener('storage', _this.onStorageEvent);
132
+ _this.hideDialog();
133
+ });
134
+ _defineProperty(this, "onStorageEvent", function (event) {
120
135
  if (event.key === storageKey && event.newValue != null) {
121
- const {
122
- tabId,
123
- command
124
- } = JSON.parse(event.newValue);
125
- if (tabId !== this.tabId) {
136
+ var _JSON$parse = JSON.parse(event.newValue),
137
+ tabId = _JSON$parse.tabId,
138
+ command = _JSON$parse.command;
139
+ if (tabId !== _this.tabId) {
126
140
  if (command === showMessage) {
127
- this.checkConsentAndShowDialog(true);
141
+ _this.checkConsentAndShowDialog(true);
128
142
  } else if (command === hideMessage) {
129
- this.hideDialogAndAlert(true);
143
+ _this.hideDialogAndAlert(true);
130
144
  }
131
145
  }
132
146
  }
133
- };
134
- _notifyAboutShowing = () => {
147
+ });
148
+ _defineProperty(this, "_notifyAboutShowing", function () {
135
149
  localStorage.setItem(storageKey, JSON.stringify({
136
150
  command: showMessage,
137
- tabId: this.tabId
151
+ tabId: _this.tabId
138
152
  }));
139
- };
140
- _notifyAboutHiding = () => {
153
+ });
154
+ _defineProperty(this, "_notifyAboutHiding", function () {
141
155
  localStorage.setItem(storageKey, JSON.stringify({
142
156
  command: hideMessage,
143
- tabId: this.tabId
157
+ tabId: _this.tabId
144
158
  }));
145
- };
146
- getUserAgreement = async () => {
147
- this.userAgreement = (await this.config.getUserAgreement()) || DEFAULT_AGREEMENT;
148
- return this.userAgreement;
149
- };
150
- getUserConsent = async () => {
151
- const {
152
- guest,
153
- endUserAgreementConsent
154
- } = await this.config.getUserConsent();
155
- this.guest = guest;
156
- if (guest) {
157
- this.userConsent = (await this.storage.get(GUEST_SESSION_KEY)) || this.userConsent;
158
- } else {
159
- this.userConsent = endUserAgreementConsent || this.userConsent;
160
- }
161
- return this.userConsent;
162
- };
163
- checkConsentAndShowDialog = async withoutNotifications => {
164
- if (await this.checkConsent()) {
165
- return this.hideDialogAndAlert(withoutNotifications);
166
- } else {
167
- return this.showDialogOrAlert(withoutNotifications);
168
- }
169
- };
170
- checkConsent = async () => {
171
- if (!this.checkingPromise) {
172
- this.checkingPromise = Promise.all([this.getUserAgreement(), this.getUserConsent()]);
173
- }
174
- const [userAgreement, userConsent] = await this.checkingPromise;
175
- this.checkingPromise = null;
176
- const {
177
- enabled,
178
- majorVersion: actualVersion
179
- } = userAgreement;
180
- const {
181
- accepted,
182
- majorVersion: acceptedVersion
183
- } = userConsent;
184
- return !enabled || accepted && actualVersion === acceptedVersion;
185
- };
186
- alertKey;
187
- showAlert = withoutNotifications => {
188
- if (this._alertPromise) {
189
- return this._alertPromise;
159
+ });
160
+ _defineProperty(this, "getUserAgreement", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
161
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
162
+ while (1) switch (_context.prev = _context.next) {
163
+ case 0:
164
+ _context.next = 2;
165
+ return _this.config.getUserAgreement();
166
+ case 2:
167
+ _context.t0 = _context.sent;
168
+ if (_context.t0) {
169
+ _context.next = 5;
170
+ break;
171
+ }
172
+ _context.t0 = DEFAULT_AGREEMENT;
173
+ case 5:
174
+ _this.userAgreement = _context.t0;
175
+ return _context.abrupt("return", _this.userAgreement);
176
+ case 7:
177
+ case "end":
178
+ return _context.stop();
179
+ }
180
+ }, _callee);
181
+ })));
182
+ _defineProperty(this, "getUserConsent", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
183
+ var _yield$_this$config$g, guest, endUserAgreementConsent;
184
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
185
+ while (1) switch (_context2.prev = _context2.next) {
186
+ case 0:
187
+ _context2.next = 2;
188
+ return _this.config.getUserConsent();
189
+ case 2:
190
+ _yield$_this$config$g = _context2.sent;
191
+ guest = _yield$_this$config$g.guest;
192
+ endUserAgreementConsent = _yield$_this$config$g.endUserAgreementConsent;
193
+ _this.guest = guest;
194
+ if (!guest) {
195
+ _context2.next = 15;
196
+ break;
197
+ }
198
+ _context2.next = 9;
199
+ return _this.storage.get(GUEST_SESSION_KEY);
200
+ case 9:
201
+ _context2.t0 = _context2.sent;
202
+ if (_context2.t0) {
203
+ _context2.next = 12;
204
+ break;
205
+ }
206
+ _context2.t0 = _this.userConsent;
207
+ case 12:
208
+ _this.userConsent = _context2.t0;
209
+ _context2.next = 16;
210
+ break;
211
+ case 15:
212
+ _this.userConsent = endUserAgreementConsent || _this.userConsent;
213
+ case 16:
214
+ return _context2.abrupt("return", _this.userConsent);
215
+ case 17:
216
+ case "end":
217
+ return _context2.stop();
218
+ }
219
+ }, _callee2);
220
+ })));
221
+ _defineProperty(this, "checkConsentAndShowDialog", /*#__PURE__*/function () {
222
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(withoutNotifications) {
223
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
224
+ while (1) switch (_context3.prev = _context3.next) {
225
+ case 0:
226
+ _context3.next = 2;
227
+ return _this.checkConsent();
228
+ case 2:
229
+ if (!_context3.sent) {
230
+ _context3.next = 6;
231
+ break;
232
+ }
233
+ return _context3.abrupt("return", _this.hideDialogAndAlert(withoutNotifications));
234
+ case 6:
235
+ return _context3.abrupt("return", _this.showDialogOrAlert(withoutNotifications));
236
+ case 7:
237
+ case "end":
238
+ return _context3.stop();
239
+ }
240
+ }, _callee3);
241
+ }));
242
+ return function (_x) {
243
+ return _ref3.apply(this, arguments);
244
+ };
245
+ }());
246
+ _defineProperty(this, "checkConsent", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
247
+ var _yield$_this$checking, _yield$_this$checking2, userAgreement, userConsent, enabled, actualVersion, accepted, acceptedVersion;
248
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
249
+ while (1) switch (_context4.prev = _context4.next) {
250
+ case 0:
251
+ if (!_this.checkingPromise) {
252
+ _this.checkingPromise = Promise.all([_this.getUserAgreement(), _this.getUserConsent()]);
253
+ }
254
+ _context4.next = 3;
255
+ return _this.checkingPromise;
256
+ case 3:
257
+ _yield$_this$checking = _context4.sent;
258
+ _yield$_this$checking2 = _slicedToArray(_yield$_this$checking, 2);
259
+ userAgreement = _yield$_this$checking2[0];
260
+ userConsent = _yield$_this$checking2[1];
261
+ _this.checkingPromise = null;
262
+ enabled = userAgreement.enabled, actualVersion = userAgreement.majorVersion;
263
+ accepted = userConsent.accepted, acceptedVersion = userConsent.majorVersion;
264
+ return _context4.abrupt("return", !enabled || accepted && actualVersion === acceptedVersion);
265
+ case 11:
266
+ case "end":
267
+ return _context4.stop();
268
+ }
269
+ }, _callee4);
270
+ })));
271
+ _defineProperty(this, "alertKey", void 0);
272
+ _defineProperty(this, "showAlert", function (withoutNotifications) {
273
+ if (_this._alertPromise) {
274
+ return _this._alertPromise;
190
275
  }
191
- this._alertPromise = new Promise((resolve, reject) => {
192
- const {
193
- userAgreement,
194
- reviewNow,
195
- remindLater
196
- } = this.config.translations || {};
197
- const onRemind = () => {
198
- this.hideDialogAndAlert(withoutNotifications);
276
+ _this._alertPromise = new Promise(function (resolve, reject) {
277
+ var _ref5 = _this.config.translations || {},
278
+ userAgreement = _ref5.userAgreement,
279
+ reviewNow = _ref5.reviewNow,
280
+ remindLater = _ref5.remindLater;
281
+ var onRemind = function onRemind() {
282
+ _this.hideDialogAndAlert(withoutNotifications);
199
283
  reject('Postponed');
200
284
  };
201
- const onReview = async () => {
202
- await this.showDialog(true, false, {
203
- onRemindLater: onRemind
204
- });
205
- this.hideAlert(withoutNotifications);
206
- resolve();
207
- };
208
- const message = /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement("span", null, userAgreement || 'User Agreement'), /*#__PURE__*/React.createElement(Link, {
285
+ var onReview = /*#__PURE__*/function () {
286
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
287
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
288
+ while (1) switch (_context5.prev = _context5.next) {
289
+ case 0:
290
+ _context5.next = 2;
291
+ return _this.showDialog(true, false, {
292
+ onRemindLater: onRemind
293
+ });
294
+ case 2:
295
+ _this.hideAlert(withoutNotifications);
296
+ resolve();
297
+ case 4:
298
+ case "end":
299
+ return _context5.stop();
300
+ }
301
+ }, _callee5);
302
+ }));
303
+ return function onReview() {
304
+ return _ref6.apply(this, arguments);
305
+ };
306
+ }();
307
+ var message = /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement("span", null, userAgreement || 'User Agreement'), /*#__PURE__*/React.createElement(Link, {
209
308
  onClick: onReview,
210
309
  "data-test": "review"
211
310
  }, reviewNow || 'Review now'), /*#__PURE__*/React.createElement(Link, {
212
311
  onClick: onRemind,
213
312
  "data-test": "later"
214
313
  }, remindLater || 'Remind me later'));
215
- this.alertKey = alertService.addAlert(message, Alert.Type.WARNING, 0, {
314
+ _this.alertKey = alertService.addAlert(message, Alert.Type.WARNING, 0, {
216
315
  closeable: false
217
316
  });
218
317
  });
219
318
  if (!withoutNotifications) {
220
- this._notifyAboutShowing();
319
+ _this._notifyAboutShowing();
221
320
  }
222
- return this._alertPromise;
223
- };
224
- hideAlert = withoutNotifications => {
225
- const {
226
- onRemindLater
227
- } = this.config;
228
- alertService.remove(this.alertKey);
229
- this.alertKey = null;
230
- this._alertPromise = null;
321
+ return _this._alertPromise;
322
+ });
323
+ _defineProperty(this, "hideAlert", function (withoutNotifications) {
324
+ var onRemindLater = _this.config.onRemindLater;
325
+ alertService.remove(_this.alertKey);
326
+ _this.alertKey = null;
327
+ _this._alertPromise = null;
231
328
  if (onRemindLater) {
232
329
  onRemindLater();
233
330
  }
234
331
  if (!withoutNotifications) {
235
- this._notifyAboutHiding();
332
+ _this._notifyAboutHiding();
236
333
  }
237
- };
238
- showDialog = (() => {
239
- var _this = this;
240
- return function (withoutNotifications) {
241
- let preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
242
- let restOptions = arguments.length > 2 ? arguments[2] : undefined;
243
- const {
244
- translations,
245
- onDialogShow
246
- } = _this.config;
247
- const {
248
- content
249
- } = _this.userAgreement;
250
- const show = true;
251
- if (!_this._dialogPromise) {
252
- _this._dialogPromise = new Promise((resolve, reject) => {
253
- const onAccept = async () => {
254
- await _this.onAccept();
255
- resolve();
256
- };
257
- const onDecline = async () => {
258
- await _this.onDecline();
259
- reject();
334
+ });
335
+ _defineProperty(this, "showDialog", function (withoutNotifications) {
336
+ var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
337
+ var restOptions = arguments.length > 2 ? arguments[2] : undefined;
338
+ var _this$config = _this.config,
339
+ translations = _this$config.translations,
340
+ onDialogShow = _this$config.onDialogShow;
341
+ var content = _this.userAgreement.content;
342
+ var show = true;
343
+ if (!_this._dialogPromise) {
344
+ _this._dialogPromise = new Promise(function (resolve, reject) {
345
+ var onAccept = /*#__PURE__*/function () {
346
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
347
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
348
+ while (1) switch (_context6.prev = _context6.next) {
349
+ case 0:
350
+ _context6.next = 2;
351
+ return _this.onAccept();
352
+ case 2:
353
+ resolve();
354
+ case 3:
355
+ case "end":
356
+ return _context6.stop();
357
+ }
358
+ }, _callee6);
359
+ }));
360
+ return function onAccept() {
361
+ return _ref7.apply(this, arguments);
260
362
  };
261
- const onClose = _this.hideDialogAndAlert;
262
- const props = {
263
- children: content,
264
- show,
265
- onAccept,
266
- onDecline,
267
- onClose,
268
- translations,
269
- preview,
270
- ...restOptions
363
+ }();
364
+ var onDecline = /*#__PURE__*/function () {
365
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
366
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
367
+ while (1) switch (_context7.prev = _context7.next) {
368
+ case 0:
369
+ _context7.next = 2;
370
+ return _this.onDecline();
371
+ case 2:
372
+ reject();
373
+ case 3:
374
+ case "end":
375
+ return _context7.stop();
376
+ }
377
+ }, _callee7);
378
+ }));
379
+ return function onDecline() {
380
+ return _ref8.apply(this, arguments);
271
381
  };
272
- _this.reactRoot.render( /*#__PURE__*/React.createElement(ControlsHeightContext.Provider, {
273
- value: getGlobalControlsHeight()
274
- }, /*#__PURE__*/React.createElement(UserAgreement, props)));
275
- if (onDialogShow) {
276
- onDialogShow();
277
- }
278
- });
279
- if (!withoutNotifications) {
280
- _this._notifyAboutShowing();
382
+ }();
383
+ var onClose = _this.hideDialogAndAlert;
384
+ var props = _objectSpread2({
385
+ children: content,
386
+ show,
387
+ onAccept,
388
+ onDecline,
389
+ onClose,
390
+ translations,
391
+ preview
392
+ }, restOptions);
393
+ _this.reactRoot.render( /*#__PURE__*/React.createElement(ControlsHeightContext.Provider, {
394
+ value: getGlobalControlsHeight()
395
+ }, /*#__PURE__*/React.createElement(UserAgreement, props)));
396
+ if (onDialogShow) {
397
+ onDialogShow();
281
398
  }
399
+ });
400
+ if (!withoutNotifications) {
401
+ _this._notifyAboutShowing();
282
402
  }
283
- return _this._dialogPromise;
284
- };
285
- })();
286
- hideDialog = withoutNotifications => {
287
- const {
288
- onDialogHide
289
- } = this.config;
290
- this.reactRoot.render(null);
403
+ }
404
+ return _this._dialogPromise;
405
+ });
406
+ _defineProperty(this, "hideDialog", function (withoutNotifications) {
407
+ var onDialogHide = _this.config.onDialogHide;
408
+ _this.reactRoot.render(null);
291
409
  if (onDialogHide) {
292
410
  onDialogHide();
293
- this._dialogPromise = null;
411
+ _this._dialogPromise = null;
294
412
  if (!withoutNotifications) {
295
- this._notifyAboutHiding();
413
+ _this._notifyAboutHiding();
296
414
  }
297
415
  }
298
- };
299
- showDialogOrAlert = (withoutNotifications, preview, restOptions) => {
300
- if (this.guest && !this.userAgreement.requiredForREST) {
301
- return this.showAlert(withoutNotifications);
302
- }
303
- return this.showDialog(withoutNotifications, preview, restOptions);
304
- };
305
- hideDialogAndAlert = withoutNotifications => {
306
- this.hideAlert(withoutNotifications);
307
- this.hideDialog(withoutNotifications);
308
- };
309
- onAccept = async () => {
310
- const {
311
- setUserConsent,
312
- onAccept
313
- } = this.config;
314
- if (this.guest) {
315
- const {
316
- majorVersion,
317
- minorVersion
318
- } = this.userAgreement;
319
- this.userConsent = {
320
- majorVersion,
321
- minorVersion,
322
- accepted: true
323
- };
324
- await this.storage.set(GUEST_SESSION_KEY, this.userConsent);
325
- } else {
326
- this.userConsent = await setUserConsent();
327
- }
328
- this.hideDialog();
329
- if (onAccept) {
330
- onAccept();
416
+ });
417
+ _defineProperty(this, "showDialogOrAlert", function (withoutNotifications, preview, restOptions) {
418
+ if (_this.guest && !_this.userAgreement.requiredForREST) {
419
+ return _this.showAlert(withoutNotifications);
331
420
  }
332
- };
333
- onDecline = () => {
334
- const {
335
- onDecline
336
- } = this.config;
337
- this.hideDialog();
421
+ return _this.showDialog(withoutNotifications, preview, restOptions);
422
+ });
423
+ _defineProperty(this, "hideDialogAndAlert", function (withoutNotifications) {
424
+ _this.hideAlert(withoutNotifications);
425
+ _this.hideDialog(withoutNotifications);
426
+ });
427
+ _defineProperty(this, "onAccept", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
428
+ var _this$config2, setUserConsent, onAccept, _this$userAgreement, majorVersion, minorVersion;
429
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
430
+ while (1) switch (_context8.prev = _context8.next) {
431
+ case 0:
432
+ _this$config2 = _this.config, setUserConsent = _this$config2.setUserConsent, onAccept = _this$config2.onAccept;
433
+ if (!_this.guest) {
434
+ _context8.next = 8;
435
+ break;
436
+ }
437
+ _this$userAgreement = _this.userAgreement, majorVersion = _this$userAgreement.majorVersion, minorVersion = _this$userAgreement.minorVersion;
438
+ _this.userConsent = {
439
+ majorVersion,
440
+ minorVersion,
441
+ accepted: true
442
+ };
443
+ _context8.next = 6;
444
+ return _this.storage.set(GUEST_SESSION_KEY, _this.userConsent);
445
+ case 6:
446
+ _context8.next = 11;
447
+ break;
448
+ case 8:
449
+ _context8.next = 10;
450
+ return setUserConsent();
451
+ case 10:
452
+ _this.userConsent = _context8.sent;
453
+ case 11:
454
+ _this.hideDialog();
455
+ if (onAccept) {
456
+ onAccept();
457
+ }
458
+ case 13:
459
+ case "end":
460
+ return _context8.stop();
461
+ }
462
+ }, _callee8);
463
+ })));
464
+ _defineProperty(this, "onDecline", function () {
465
+ var onDecline = _this.config.onDecline;
466
+ _this.hideDialog();
338
467
  if (onDecline) {
339
468
  onDecline();
340
469
  }
341
- };
342
- }
470
+ });
471
+ if (!config) {
472
+ throw new Error('Please pass a config to UserAgreementService');
473
+ }
474
+ if (!config.getUserAgreement) {
475
+ throw new Error('Please pass a "getUserAgreement" option to UserAgreementService');
476
+ }
477
+ if (!config.getUserConsent) {
478
+ throw new Error('Please pass a "getUserConsent" option to UserAgreementService');
479
+ }
480
+ if (!config.setUserConsent) {
481
+ throw new Error('Please pass a "setUserConsent" option to UserAgreementService');
482
+ }
483
+ this.config = config;
484
+ this.interval = config.interval || this.interval;
485
+ });
343
486
 
344
487
  export { UserAgreementService as default, hideMessage, showMessage };