@jetbrains/ring-ui-built 7.0.0-beta.1 → 7.0.0-beta.3

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