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

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 (349) hide show
  1. package/components/_helpers/_rollupPluginBabelHelpers.js +1 -504
  2. package/components/_helpers/anchor.js +7 -10
  3. package/components/_helpers/button__classes.js +23 -20
  4. package/components/_helpers/caption.js +11 -21
  5. package/components/_helpers/card.js +91 -123
  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 -29
  9. package/components/_helpers/input.js +151 -193
  10. package/components/_helpers/query-assist__suggestions.js +79 -94
  11. package/components/_helpers/select__filter.js +56 -75
  12. package/components/_helpers/services-link.js +23 -39
  13. package/components/_helpers/sidebar.js +91 -102
  14. package/components/_helpers/tab-link.js +8 -12
  15. package/components/_helpers/theme.js +61 -51
  16. package/components/_helpers/title.js +59 -84
  17. package/components/alert/alert.d.ts +7 -24
  18. package/components/alert/alert.js +111 -179
  19. package/components/alert/container.d.ts +0 -5
  20. package/components/alert/container.js +32 -44
  21. package/components/alert-service/alert-service.js +104 -162
  22. package/components/analytics/analytics.js +12 -20
  23. package/components/analytics/analytics__custom-plugin.js +52 -68
  24. package/components/auth/auth.js +2 -31
  25. package/components/auth/auth__core.d.ts +4 -4
  26. package/components/auth/auth__core.js +755 -1433
  27. package/components/auth/background-flow.js +84 -121
  28. package/components/auth/down-notification.js +32 -79
  29. package/components/auth/iframe-flow.js +71 -125
  30. package/components/auth/request-builder.js +46 -77
  31. package/components/auth/response-parser.js +84 -112
  32. package/components/auth/storage.js +162 -324
  33. package/components/auth/token-validator.js +132 -227
  34. package/components/auth/window-flow.js +84 -121
  35. package/components/auth-dialog/auth-dialog.d.ts +0 -18
  36. package/components/auth-dialog/auth-dialog.js +107 -176
  37. package/components/auth-dialog-service/auth-dialog-service.js +12 -33
  38. package/components/avatar/avatar-example-datauri.js +1 -1
  39. package/components/avatar/avatar.d.ts +0 -13
  40. package/components/avatar/avatar.js +94 -136
  41. package/components/avatar/fallback-avatar.d.ts +1 -10
  42. package/components/avatar/fallback-avatar.js +20 -40
  43. package/components/badge/badge.d.ts +0 -10
  44. package/components/badge/badge.js +32 -48
  45. package/components/breadcrumbs/breadcrumbs.js +13 -17
  46. package/components/button/button.d.ts +0 -21
  47. package/components/button/button.js +68 -104
  48. package/components/button/button__classes.d.ts +1 -1
  49. package/components/button-group/button-group.d.ts +0 -5
  50. package/components/button-group/button-group.js +27 -41
  51. package/components/button-group/caption.d.ts +0 -4
  52. package/components/button-group/caption.js +0 -1
  53. package/components/button-set/button-set.d.ts +0 -6
  54. package/components/button-set/button-set.js +19 -33
  55. package/components/button-toolbar/button-toolbar.d.ts +0 -6
  56. package/components/button-toolbar/button-toolbar.js +17 -31
  57. package/components/caret/caret.js +184 -211
  58. package/components/checkbox/checkbox.d.ts +0 -19
  59. package/components/checkbox/checkbox.js +69 -104
  60. package/components/clipboard/clipboard-fallback.js +7 -7
  61. package/components/clipboard/clipboard.js +36 -129
  62. package/components/code/code.d.ts +0 -12
  63. package/components/code/code.js +83 -163
  64. package/components/collapse/collapse-content.js +42 -60
  65. package/components/collapse/collapse-context.js +2 -2
  66. package/components/collapse/collapse-control.js +12 -12
  67. package/components/collapse/collapse.js +12 -17
  68. package/components/collapse/consts.js +4 -4
  69. package/components/collapse/utils.js +1 -3
  70. package/components/confirm/confirm.d.ts +0 -14
  71. package/components/confirm/confirm.js +68 -112
  72. package/components/confirm-service/confirm-service.js +25 -47
  73. package/components/content-layout/content-layout.d.ts +0 -7
  74. package/components/content-layout/content-layout.js +41 -63
  75. package/components/content-layout/sidebar.d.ts +0 -9
  76. package/components/content-layout/sidebar.js +1 -2
  77. package/components/contenteditable/contenteditable.d.ts +1 -22
  78. package/components/contenteditable/contenteditable.js +37 -60
  79. package/components/control-help/control-help.js +5 -3
  80. package/components/control-label/control-label.js +9 -14
  81. package/components/data-list/data-list.d.ts +0 -2
  82. package/components/data-list/data-list.js +115 -179
  83. package/components/data-list/data-list.mock.js +3 -6
  84. package/components/data-list/item.js +119 -165
  85. package/components/data-list/selection.js +77 -135
  86. package/components/data-list/title.d.ts +2 -2
  87. package/components/data-list/title.js +2 -12
  88. package/components/date-picker/consts.d.ts +0 -2
  89. package/components/date-picker/consts.js +16 -24
  90. package/components/date-picker/date-input.d.ts +0 -20
  91. package/components/date-picker/date-input.js +100 -148
  92. package/components/date-picker/date-picker.d.ts +0 -29
  93. package/components/date-picker/date-picker.js +143 -224
  94. package/components/date-picker/date-popup.d.ts +0 -22
  95. package/components/date-picker/date-popup.js +282 -352
  96. package/components/date-picker/day.d.ts +0 -14
  97. package/components/date-picker/day.js +72 -109
  98. package/components/date-picker/month-names.d.ts +1 -11
  99. package/components/date-picker/month-names.js +42 -72
  100. package/components/date-picker/month-slider.d.ts +0 -9
  101. package/components/date-picker/month-slider.js +43 -71
  102. package/components/date-picker/month.d.ts +1 -9
  103. package/components/date-picker/month.js +18 -30
  104. package/components/date-picker/months.d.ts +1 -9
  105. package/components/date-picker/months.js +45 -55
  106. package/components/date-picker/weekdays.d.ts +2 -8
  107. package/components/date-picker/weekdays.js +12 -25
  108. package/components/date-picker/years.d.ts +0 -6
  109. package/components/date-picker/years.js +77 -104
  110. package/components/dialog/dialog.d.ts +0 -20
  111. package/components/dialog/dialog.js +153 -211
  112. package/components/dialog/dialog__body-scroll-preventer.js +0 -3
  113. package/components/dropdown/anchor.d.ts +1 -8
  114. package/components/dropdown/anchor.js +0 -7
  115. package/components/dropdown/dropdown.d.ts +4 -22
  116. package/components/dropdown/dropdown.js +134 -176
  117. package/components/dropdown-menu/dropdown-menu.js +51 -103
  118. package/components/editable-heading/editable-heading.js +69 -118
  119. package/components/error-bubble/error-bubble.d.ts +0 -6
  120. package/components/error-bubble/error-bubble.js +30 -60
  121. package/components/error-message/error-message.d.ts +0 -10
  122. package/components/error-message/error-message.js +34 -59
  123. package/components/footer/footer.js +28 -44
  124. package/components/form/form.js +1 -1
  125. package/components/global/compose.js +1 -8
  126. package/components/global/composeRefs.d.ts +0 -3
  127. package/components/global/composeRefs.js +8 -15
  128. package/components/global/controls-height.js +2 -2
  129. package/components/global/create-stateful-context.d.ts +0 -4
  130. package/components/global/create-stateful-context.js +14 -17
  131. package/components/global/data-tests.js +7 -12
  132. package/components/global/dom.js +49 -82
  133. package/components/global/focus-sensor-hoc.js +95 -122
  134. package/components/global/fuzzy-highlight.js +23 -34
  135. package/components/global/get-event-key.js +8 -8
  136. package/components/global/get-uid.js +3 -7
  137. package/components/global/inject-styles.js +7 -14
  138. package/components/global/listeners.js +28 -47
  139. package/components/global/memoize.js +6 -10
  140. package/components/global/normalize-indent.js +19 -46
  141. package/components/global/promise-with-timeout.js +6 -8
  142. package/components/global/react-dom-renderer.d.ts +0 -5
  143. package/components/global/react-dom-renderer.js +29 -45
  144. package/components/global/rerender-hoc.d.ts +2 -2
  145. package/components/global/rerender-hoc.js +16 -32
  146. package/components/global/schedule-raf.js +4 -4
  147. package/components/global/sniffer.js +1 -1
  148. package/components/global/theme.d.ts +8 -2
  149. package/components/global/theme.js +2 -20
  150. package/components/global/trivial-template-tag.js +4 -9
  151. package/components/global/typescript-utils.js +2 -6
  152. package/components/global/url.js +20 -23
  153. package/components/global/use-event-callback.js +7 -4
  154. package/components/grid/col.d.ts +0 -14
  155. package/components/grid/col.js +27 -53
  156. package/components/grid/grid.d.ts +0 -5
  157. package/components/grid/grid.js +20 -32
  158. package/components/grid/row.d.ts +0 -18
  159. package/components/grid/row.js +23 -47
  160. package/components/group/group.d.ts +0 -5
  161. package/components/group/group.js +18 -27
  162. package/components/header/header-icon.d.ts +0 -22
  163. package/components/header/header-icon.js +20 -37
  164. package/components/header/header.d.ts +0 -7
  165. package/components/header/header.js +30 -74
  166. package/components/header/links.d.ts +2 -0
  167. package/components/header/links.js +20 -0
  168. package/components/header/logo.d.ts +0 -4
  169. package/components/header/logo.js +15 -30
  170. package/components/header/profile.d.ts +1 -39
  171. package/components/header/profile.js +126 -191
  172. package/components/header/services-link.d.ts +0 -10
  173. package/components/header/services-link.js +1 -4
  174. package/components/header/services.d.ts +0 -14
  175. package/components/header/services.js +65 -110
  176. package/components/header/smart-profile.d.ts +0 -9
  177. package/components/header/smart-profile.js +116 -205
  178. package/components/header/smart-services.d.ts +0 -4
  179. package/components/header/smart-services.js +72 -141
  180. package/components/header/tray.d.ts +0 -5
  181. package/components/header/tray.js +21 -35
  182. package/components/heading/heading.js +21 -26
  183. package/components/http/http.js +162 -319
  184. package/components/http/http.mock.js +50 -98
  185. package/components/hub-source/hub-source.js +77 -182
  186. package/components/hub-source/hub-source__user.js +9 -37
  187. package/components/hub-source/hub-source__users-groups.js +34 -60
  188. package/components/i18n/i18n-context.js +7 -8
  189. package/components/i18n/i18n.js +3 -6
  190. package/components/icon/icon.d.ts +0 -11
  191. package/components/icon/icon.js +60 -85
  192. package/components/icon/icon__svg.d.ts +0 -8
  193. package/components/icon/icon__svg.js +0 -6
  194. package/components/icon/index.js +0 -6
  195. package/components/input/input-legacy.js +1 -1
  196. package/components/input/input.js +2 -14
  197. package/components/input-size/input-size.js +1 -1
  198. package/components/island/adaptive-island-hoc.d.ts +0 -1
  199. package/components/island/adaptive-island-hoc.js +30 -39
  200. package/components/island/content.d.ts +0 -10
  201. package/components/island/content.js +99 -119
  202. package/components/island/header.js +55 -73
  203. package/components/island/island.d.ts +0 -9
  204. package/components/island/island.js +25 -41
  205. package/components/island-legacy/content-legacy.d.ts +0 -5
  206. package/components/island-legacy/content-legacy.js +16 -27
  207. package/components/island-legacy/header-legacy.d.ts +0 -5
  208. package/components/island-legacy/header-legacy.js +19 -30
  209. package/components/island-legacy/island-legacy.d.ts +0 -5
  210. package/components/island-legacy/island-legacy.js +16 -27
  211. package/components/link/clickableLink.d.ts +0 -9
  212. package/components/link/clickableLink.js +33 -51
  213. package/components/link/link.d.ts +0 -25
  214. package/components/link/link.js +47 -68
  215. package/components/list/consts.js +2 -2
  216. package/components/list/list.d.ts +0 -32
  217. package/components/list/list.js +399 -516
  218. package/components/list/list__custom.js +51 -78
  219. package/components/list/list__hint.d.ts +0 -4
  220. package/components/list/list__hint.js +8 -21
  221. package/components/list/list__item.js +147 -211
  222. package/components/list/list__link.js +39 -59
  223. package/components/list/list__separator.js +15 -30
  224. package/components/list/list__title.js +25 -41
  225. package/components/list/list__users-groups-source.js +55 -123
  226. package/components/loader/loader.d.ts +0 -10
  227. package/components/loader/loader.js +38 -70
  228. package/components/loader/loader__core.js +123 -184
  229. package/components/loader-inline/loader-inline.d.ts +0 -6
  230. package/components/loader-inline/loader-inline.js +24 -38
  231. package/components/loader-screen/loader-screen.d.ts +0 -6
  232. package/components/loader-screen/loader-screen.js +24 -46
  233. package/components/login-dialog/login-dialog.d.ts +0 -11
  234. package/components/login-dialog/login-dialog.js +94 -145
  235. package/components/login-dialog/service.js +11 -33
  236. package/components/markdown/markdown.js +16 -29
  237. package/components/message/message.js +171 -218
  238. package/components/old-browsers-message/old-browsers-message.js +11 -14
  239. package/components/old-browsers-message/old-browsers-message__stop.js +1 -4
  240. package/components/old-browsers-message/white-list.js +8 -13
  241. package/components/pager/pager.js +211 -275
  242. package/components/panel/panel.d.ts +0 -5
  243. package/components/panel/panel.js +16 -27
  244. package/components/permissions/permissions.js +118 -161
  245. package/components/permissions/permissions__cache.js +191 -218
  246. package/components/popup/popup.consts.js +1 -1
  247. package/components/popup/popup.js +237 -329
  248. package/components/popup/popup.target.js +9 -12
  249. package/components/popup/position.js +94 -101
  250. package/components/popup-menu/popup-menu.js +31 -76
  251. package/components/progress-bar/progress-bar.d.ts +19 -33
  252. package/components/progress-bar/progress-bar.js +55 -99
  253. package/components/query-assist/query-assist.d.ts +63 -93
  254. package/components/query-assist/query-assist.js +585 -748
  255. package/components/query-assist/query-assist__suggestions.js +2 -28
  256. package/components/radio/radio.d.ts +0 -8
  257. package/components/radio/radio.js +15 -35
  258. package/components/radio/radio__item.d.ts +0 -9
  259. package/components/radio/radio__item.js +52 -72
  260. package/components/scrollable-section/scrollable-section.js +53 -0
  261. package/components/select/select.d.ts +3 -0
  262. package/components/select/select.js +714 -863
  263. package/components/select/select__filter.js +2 -29
  264. package/components/select/select__popup.js +317 -465
  265. package/components/shortcuts/core.js +147 -195
  266. package/components/shortcuts/shortcut-title.js +6 -10
  267. package/components/shortcuts/shortcuts-hoc.d.ts +0 -5
  268. package/components/shortcuts/shortcuts-hoc.js +23 -46
  269. package/components/shortcuts/shortcuts.d.ts +0 -8
  270. package/components/shortcuts/shortcuts.js +41 -72
  271. package/components/slider/slider.js +93 -113
  272. package/components/slider/slider.utils.js +16 -23
  273. package/components/storage/storage.d.ts +2 -3
  274. package/components/storage/storage.js +2 -46
  275. package/components/storage/storage__local.js +89 -148
  276. package/components/style.css +1 -1
  277. package/components/tab-trap/tab-trap.js +35 -61
  278. package/components/table/cell.d.ts +0 -6
  279. package/components/table/cell.js +11 -27
  280. package/components/table/disable-hover-hoc.d.ts +0 -1
  281. package/components/table/disable-hover-hoc.js +27 -42
  282. package/components/table/header-cell.d.ts +0 -10
  283. package/components/table/header-cell.js +59 -85
  284. package/components/table/header.d.ts +1 -23
  285. package/components/table/header.js +89 -126
  286. package/components/table/multitable.d.ts +0 -4
  287. package/components/table/multitable.js +83 -93
  288. package/components/table/row-with-focus-sensor.d.ts +2 -2
  289. package/components/table/row-with-focus-sensor.js +26 -60
  290. package/components/table/row.js +170 -235
  291. package/components/table/selection-adapter.js +2 -2
  292. package/components/table/selection-shortcuts-hoc.js +102 -126
  293. package/components/table/selection.js +150 -217
  294. package/components/table/simple-table.d.ts +0 -44
  295. package/components/table/simple-table.js +18 -59
  296. package/components/table/smart-table.d.ts +0 -48
  297. package/components/table/smart-table.js +41 -83
  298. package/components/table/table.d.ts +0 -2
  299. package/components/table/table.js +269 -377
  300. package/components/tabs/collapsible-more.d.ts +1 -9
  301. package/components/tabs/collapsible-more.js +47 -97
  302. package/components/tabs/collapsible-tab.js +32 -44
  303. package/components/tabs/collapsible-tabs.d.ts +2 -29
  304. package/components/tabs/collapsible-tabs.js +89 -161
  305. package/components/tabs/custom-item.d.ts +1 -7
  306. package/components/tabs/custom-item.js +4 -7
  307. package/components/tabs/dumb-tabs.d.ts +0 -11
  308. package/components/tabs/dumb-tabs.js +60 -104
  309. package/components/tabs/smart-tabs.d.ts +0 -6
  310. package/components/tabs/smart-tabs.js +29 -68
  311. package/components/tabs/tab-link.d.ts +0 -8
  312. package/components/tabs/tab-link.js +1 -4
  313. package/components/tabs/tab.d.ts +0 -8
  314. package/components/tabs/tab.js +14 -32
  315. package/components/tabs/tabs.js +1 -28
  316. package/components/tag/tag.d.ts +0 -19
  317. package/components/tag/tag.js +120 -179
  318. package/components/tags-input/tags-input.d.ts +7 -33
  319. package/components/tags-input/tags-input.js +224 -339
  320. package/components/tags-list/tags-list.d.ts +0 -13
  321. package/components/tags-list/tags-list.js +45 -74
  322. package/components/text/text.d.ts +0 -7
  323. package/components/text/text.js +27 -43
  324. package/components/toggle/toggle.d.ts +0 -15
  325. package/components/toggle/toggle.js +52 -77
  326. package/components/tooltip/tooltip.d.ts +4 -10
  327. package/components/tooltip/tooltip.js +105 -137
  328. package/components/user-agreement/service.d.ts +2 -1
  329. package/components/user-agreement/service.js +260 -405
  330. package/components/user-agreement/user-agreement.d.ts +0 -18
  331. package/components/user-agreement/user-agreement.js +92 -138
  332. package/components/user-card/card.d.ts +0 -35
  333. package/components/user-card/card.js +2 -27
  334. package/components/user-card/smart-user-card-tooltip.d.ts +0 -5
  335. package/components/user-card/smart-user-card-tooltip.js +52 -108
  336. package/components/user-card/tooltip.d.ts +0 -9
  337. package/components/user-card/tooltip.js +35 -74
  338. package/components/user-card/user-card.js +1 -26
  339. package/package.json +4 -6
  340. package/components/global/prop-types.d.ts +0 -4
  341. package/components/global/prop-types.js +0 -9
  342. package/components/global/react-render-adapter.d.ts +0 -1
  343. package/components/global/react-render-adapter.js +0 -6
  344. package/components/header/scrollable-section.js +0 -47
  345. package/components/header/tray-icon.d.ts +0 -1
  346. package/components/header/tray-icon.js +0 -26
  347. package/components/storage/storage__fallback.d.ts +0 -79
  348. package/components/storage/storage__fallback.js +0 -253
  349. /package/components/{header → scrollable-section}/scrollable-section.d.ts +0 -0
@@ -1,16 +1,7 @@
1
- import { _ as _defineProperty, a as _inherits, b as _createClass, d as _objectSpread2, e as _classCallCheck, f as _callSuper, c as _objectWithoutProperties } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import 'core-js/modules/es.symbol.js';
1
+ import { _ as _defineProperty, b as _objectSpread2, a as _objectWithoutProperties } from '../_helpers/_rollupPluginBabelHelpers.js';
3
2
  import 'core-js/modules/es.symbol.description.js';
4
- import 'core-js/modules/es.array.concat.js';
5
- import 'core-js/modules/es.array.find.js';
6
- import 'core-js/modules/es.array.find-index.js';
7
- import 'core-js/modules/es.array.includes.js';
8
- import 'core-js/modules/es.array.map.js';
9
- import 'core-js/modules/es.object.assign.js';
10
- import 'core-js/modules/es.object.to-string.js';
11
- import 'core-js/modules/es.string.includes.js';
3
+ import 'core-js/modules/web.dom-collections.iterator.js';
12
4
  import { Component, createElement } from 'react';
13
- import PropTypes from 'prop-types';
14
5
  import classNames from 'classnames';
15
6
  import VirtualizedList from 'react-virtualized/dist/es/List';
16
7
  import AutoSizer from 'react-virtualized/dist/es/AutoSizer';
@@ -35,72 +26,51 @@ import { Type, Dimension, DEFAULT_ITEM_TYPE } from './consts.js';
35
26
  import { m as modules_3b67a421 } from '../_helpers/list.js';
36
27
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
37
28
  import 'core-js/modules/es.array.reduce.js';
38
- import 'core-js/modules/es.object.entries.js';
39
- import 'core-js/modules/es.regexp.to-string.js';
40
- import 'core-js/modules/es.array.iterator.js';
41
- import 'core-js/modules/es.map.js';
42
- import 'core-js/modules/es.weak-map.js';
43
- import 'core-js/modules/web.dom-collections.iterator.js';
44
- import 'core-js/modules/es.array.filter.js';
45
29
  import 'core-js/modules/es.regexp.exec.js';
46
- import 'core-js/modules/es.set.js';
47
- import 'core-js/modules/es.string.split.js';
48
- import 'core-js/modules/web.dom-collections.for-each.js';
49
30
  import '../shortcuts/core.js';
50
- import 'core-js/modules/es.array.slice.js';
51
- import 'core-js/modules/es.array.splice.js';
52
- import 'core-js/modules/es.string.match.js';
53
31
  import 'combokeys';
54
32
  import '../global/sniffer.js';
55
33
  import 'sniffr';
56
34
  import '../link/link.js';
57
35
  import '../link/clickableLink.js';
58
36
  import '../_helpers/link.js';
59
- import 'core-js/modules/es.array.index-of.js';
60
37
  import '../avatar/avatar.js';
61
38
  import '../global/url.js';
62
39
  import 'core-js/modules/es.string.replace.js';
63
40
  import '../avatar/fallback-avatar.js';
64
- import 'core-js/modules/es.array.from.js';
65
41
  import '../checkbox/checkbox.js';
66
42
  import '@jetbrains/icons/checkmark-12px';
67
43
  import '@jetbrains/icons/remove-12px';
68
44
  import '../icon/icon.js';
69
45
  import '../icon/icon__constants.js';
70
46
  import '../_helpers/icon__svg.js';
71
- import 'core-js/modules/es.string.starts-with.js';
72
- import '../global/prop-types.js';
73
47
  import '../global/composeRefs.js';
74
48
  import '../control-help/control-help.js';
75
49
  import '../global/get-event-key.js';
76
50
 
77
- var _excluded = ["selectedLabel", "originalModel"];
51
+ const _excluded = ["selectedLabel", "originalModel"];
78
52
  function noop() {}
79
- var warnEmptyKey = deprecate(function () {}, 'No key passed for list item with non-string label. It is considered as a bad practice and has been deprecated, please provide a key.');
53
+ const warnEmptyKey = deprecate(() => {}, 'No key passed for list item with non-string label. It is considered as a bad practice and has been deprecated, please provide a key.');
80
54
  /**
81
55
  * @param {Type} listItemType
82
56
  * @param {Object} item list item
83
57
  */
84
58
  function isItemType(listItemType, item) {
85
- var type = item.rgItemType;
59
+ let type = item.rgItemType;
86
60
  if (type == null) {
87
61
  type = DEFAULT_ITEM_TYPE;
88
62
  }
89
63
  return type === listItemType;
90
64
  }
91
- var nonActivatableTypes = [Type.SEPARATOR, Type.TITLE, Type.MARGIN];
65
+ const nonActivatableTypes = [Type.SEPARATOR, Type.TITLE, Type.MARGIN];
92
66
  function isActivatable(item) {
93
67
  return item != null && !nonActivatableTypes.includes(item.rgItemType) && !item.disabled;
94
68
  }
95
69
  function getDataHash(data) {
96
- return data.map(function (it) {
97
- return "".concat(it.key, "-").concat(it.disabled);
98
- }).join('-');
70
+ return data.map(it => "".concat(it.key, "-").concat(it.disabled)).join('-');
99
71
  }
100
- var shouldActivateFirstItem = function shouldActivateFirstItem(props) {
101
- return props.activateFirstItem || props.activateSingleItem && props.data.length === 1;
102
- };
103
- var ActiveItemContext = createStatefulContext(undefined, 'ActiveItem');
72
+ const shouldActivateFirstItem = props => props.activateFirstItem || props.activateSingleItem && props.data.length === 1;
73
+ const ActiveItemContext = createStatefulContext(undefined, 'ActiveItem');
104
74
  /**
105
75
  * @name List
106
76
  * @constructor
@@ -109,15 +79,12 @@ var ActiveItemContext = createStatefulContext(undefined, 'ActiveItem');
109
79
  /**
110
80
  * Displays a list of items.
111
81
  */
112
- var List = /*#__PURE__*/function (_Component) {
113
- function List() {
82
+ class List extends Component {
83
+ constructor() {
114
84
  var _this;
115
- _classCallCheck(this, List);
116
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
117
- args[_key] = arguments[_key];
118
- }
119
- _this = _callSuper(this, List, [].concat(args));
120
- _defineProperty(_this, "state", {
85
+ super(...arguments);
86
+ _this = this;
87
+ _defineProperty(this, "state", {
121
88
  activeIndex: null,
122
89
  prevActiveIndex: null,
123
90
  prevData: [],
@@ -128,37 +95,33 @@ var List = /*#__PURE__*/function (_Component) {
128
95
  disabledHover: false,
129
96
  scrolledToBottom: false
130
97
  });
131
- _defineProperty(_this, "scheduleScrollListener", scheduleRAF());
132
- _defineProperty(_this, "scheduleHoverListener", scheduleRAF());
133
- _defineProperty(_this, "virtualizedList", void 0);
134
- _defineProperty(_this, "unmounted", void 0);
135
- _defineProperty(_this, "container", void 0);
136
- _defineProperty(_this, "hoverHandler", memoize(function (index) {
137
- return function () {
138
- return _this.scheduleHoverListener(function () {
139
- if (_this.state.disabledHover) {
140
- return;
141
- }
142
- if (_this.container) {
143
- _this.setState({
144
- activeIndex: index,
145
- activeItem: _this.props.data[index],
146
- needScrollToActive: false
147
- });
148
- }
98
+ _defineProperty(this, "scheduleScrollListener", scheduleRAF());
99
+ _defineProperty(this, "scheduleHoverListener", scheduleRAF());
100
+ _defineProperty(this, "virtualizedList", void 0);
101
+ _defineProperty(this, "unmounted", void 0);
102
+ _defineProperty(this, "container", void 0);
103
+ _defineProperty(this, "hoverHandler", memoize(index => () => this.scheduleHoverListener(() => {
104
+ if (this.state.disabledHover) {
105
+ return;
106
+ }
107
+ if (this.container) {
108
+ this.setState({
109
+ activeIndex: index,
110
+ activeItem: this.props.data[index],
111
+ needScrollToActive: false
149
112
  });
150
- };
151
- }));
113
+ }
114
+ })));
152
115
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
153
- _defineProperty(_this, "_bufferSize", 10);
116
+ _defineProperty(this, "_bufferSize", 10);
154
117
  // keep X items above and below of the visible area
155
118
  // reuse size cache for similar items
156
- _defineProperty(_this, "sizeCacheKey", function (index) {
157
- if (index === 0 || index === _this.props.data.length + 1) {
119
+ _defineProperty(this, "sizeCacheKey", index => {
120
+ if (index === 0 || index === this.props.data.length + 1) {
158
121
  return Type.MARGIN;
159
122
  }
160
- var item = _this.props.data[index - 1];
161
- var isFirst = index === 1;
123
+ const item = this.props.data[index - 1];
124
+ const isFirst = index === 1;
162
125
  switch (item.rgItemType) {
163
126
  case Type.SEPARATOR:
164
127
  case Type.TITLE:
@@ -176,51 +139,44 @@ var List = /*#__PURE__*/function (_Component) {
176
139
  return Type.ITEM;
177
140
  }
178
141
  });
179
- _defineProperty(_this, "_cache", new CellMeasurerCache({
180
- defaultHeight: _this.defaultItemHeight(),
142
+ _defineProperty(this, "_cache", new CellMeasurerCache({
143
+ defaultHeight: this.defaultItemHeight(),
181
144
  fixedWidth: true,
182
- keyMapper: _this.sizeCacheKey
183
- }));
184
- _defineProperty(_this, "_hasActivatableItems", memoizeOne(function (items) {
185
- return items.some(isActivatable);
145
+ keyMapper: this.sizeCacheKey
186
146
  }));
187
- _defineProperty(_this, "activateFirst", function () {
188
- var firstActivatableIndex = _this.props.data.findIndex(isActivatable);
147
+ _defineProperty(this, "_hasActivatableItems", memoizeOne(items => items.some(isActivatable)));
148
+ _defineProperty(this, "activateFirst", () => {
149
+ const firstActivatableIndex = this.props.data.findIndex(isActivatable);
189
150
  if (firstActivatableIndex >= 0) {
190
- _this.setState({
151
+ this.setState({
191
152
  activeIndex: firstActivatableIndex,
192
- activeItem: _this.props.data[firstActivatableIndex],
153
+ activeItem: this.props.data[firstActivatableIndex],
193
154
  needScrollToActive: true
194
155
  });
195
156
  }
196
157
  });
197
- _defineProperty(_this, "selectHandler", memoize(function (index) {
198
- return function (event) {
199
- var tryKeepOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
200
- var item = _this.props.data[index];
201
- if (!_this.props.useMouseUp && item.onClick) {
202
- item.onClick(item, event);
203
- } else if (_this.props.useMouseUp && item.onMouseUp) {
204
- item.onMouseUp(item, event);
205
- }
206
- if (_this.props.onSelect) {
207
- _this.props.onSelect(item, event, {
208
- tryKeepOpen
209
- });
210
- }
211
- };
212
- }));
213
- _defineProperty(_this, "checkboxHandler", memoize(function (index) {
214
- return function (event) {
215
- return _this.selectHandler(index)(event, true);
216
- };
158
+ _defineProperty(this, "selectHandler", memoize(index => function (event) {
159
+ let tryKeepOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
160
+ const item = _this.props.data[index];
161
+ if (!_this.props.useMouseUp && item.onClick) {
162
+ item.onClick(item, event);
163
+ } else if (_this.props.useMouseUp && item.onMouseUp) {
164
+ item.onMouseUp(item, event);
165
+ }
166
+ if (_this.props.onSelect) {
167
+ _this.props.onSelect(item, event, {
168
+ tryKeepOpen
169
+ });
170
+ }
217
171
  }));
218
- _defineProperty(_this, "upHandler", function (e) {
219
- var _this$props = _this.props,
220
- data = _this$props.data,
221
- disableMoveOverflow = _this$props.disableMoveOverflow;
222
- var index = _this.state.activeIndex;
223
- var newIndex;
172
+ _defineProperty(this, "checkboxHandler", memoize(index => event => this.selectHandler(index)(event, true)));
173
+ _defineProperty(this, "upHandler", e => {
174
+ const {
175
+ data,
176
+ disableMoveOverflow
177
+ } = this.props;
178
+ const index = this.state.activeIndex;
179
+ let newIndex;
224
180
  if (index === null || index === 0) {
225
181
  if (!disableMoveOverflow) {
226
182
  newIndex = data.length - 1;
@@ -230,15 +186,16 @@ var List = /*#__PURE__*/function (_Component) {
230
186
  } else {
231
187
  newIndex = index - 1;
232
188
  }
233
- _this.moveHandler(newIndex, _this.upHandler, e);
189
+ this.moveHandler(newIndex, this.upHandler, e);
234
190
  });
235
- _defineProperty(_this, "downHandler", function (e) {
236
- var _this$props2 = _this.props,
237
- data = _this$props2.data,
238
- disableMoveOverflow = _this$props2.disableMoveOverflow,
239
- disableMoveDownOverflow = _this$props2.disableMoveDownOverflow;
240
- var index = _this.state.activeIndex;
241
- var newIndex;
191
+ _defineProperty(this, "downHandler", e => {
192
+ const {
193
+ data,
194
+ disableMoveOverflow,
195
+ disableMoveDownOverflow
196
+ } = this.props;
197
+ const index = this.state.activeIndex;
198
+ let newIndex;
242
199
  if (index === null) {
243
200
  newIndex = 0;
244
201
  } else if (index + 1 === data.length) {
@@ -250,43 +207,43 @@ var List = /*#__PURE__*/function (_Component) {
250
207
  } else {
251
208
  newIndex = index + 1;
252
209
  }
253
- _this.moveHandler(newIndex, _this.downHandler, e);
210
+ this.moveHandler(newIndex, this.downHandler, e);
254
211
  });
255
- _defineProperty(_this, "homeHandler", function (e) {
256
- _this.moveHandler(0, _this.downHandler, e);
212
+ _defineProperty(this, "homeHandler", e => {
213
+ this.moveHandler(0, this.downHandler, e);
257
214
  });
258
- _defineProperty(_this, "endHandler", function (e) {
259
- _this.moveHandler(_this.props.data.length - 1, _this.upHandler, e);
215
+ _defineProperty(this, "endHandler", e => {
216
+ this.moveHandler(this.props.data.length - 1, this.upHandler, e);
260
217
  });
261
- _defineProperty(_this, "onDocumentMouseMove", function () {
262
- if (_this.state.disabledHover) {
263
- _this.setState({
218
+ _defineProperty(this, "onDocumentMouseMove", () => {
219
+ if (this.state.disabledHover) {
220
+ this.setState({
264
221
  disabledHover: false
265
222
  });
266
223
  }
267
224
  });
268
- _defineProperty(_this, "onDocumentKeyDown", function (e) {
269
- var metaKeys = [16, 17, 18, 19, 20, 91]; // eslint-disable-line @typescript-eslint/no-magic-numbers
270
- if (!_this.state.disabledHover && !metaKeys.includes(e.keyCode)) {
271
- _this.setState({
225
+ _defineProperty(this, "onDocumentKeyDown", e => {
226
+ const metaKeys = [16, 17, 18, 19, 20, 91]; // eslint-disable-line @typescript-eslint/no-magic-numbers
227
+ if (!this.state.disabledHover && !metaKeys.includes(e.keyCode)) {
228
+ this.setState({
272
229
  disabledHover: true
273
230
  });
274
231
  }
275
232
  });
276
- _defineProperty(_this, "mouseHandler", function () {
277
- _this.setState({
233
+ _defineProperty(this, "mouseHandler", () => {
234
+ this.setState({
278
235
  scrolling: false
279
236
  });
280
237
  });
281
- _defineProperty(_this, "scrollHandler", function () {
282
- _this.setState({
238
+ _defineProperty(this, "scrollHandler", () => {
239
+ this.setState({
283
240
  scrolling: true
284
- }, _this.scrollEndHandler);
241
+ }, this.scrollEndHandler);
285
242
  });
286
- _defineProperty(_this, "enterHandler", function (event, shortcut) {
287
- if (_this.state.activeIndex !== null) {
288
- var item = _this.props.data[_this.state.activeIndex];
289
- _this.selectHandler(_this.state.activeIndex)(event);
243
+ _defineProperty(this, "enterHandler", (event, shortcut) => {
244
+ if (this.state.activeIndex !== null) {
245
+ const item = this.props.data[this.state.activeIndex];
246
+ this.selectHandler(this.state.activeIndex)(event);
290
247
  if (item.href && !event.defaultPrevented) {
291
248
  if (shortcut != null && ['command+enter', 'ctrl+enter'].includes(shortcut)) {
292
249
  window.open(item.href, '_blank');
@@ -301,53 +258,51 @@ var List = /*#__PURE__*/function (_Component) {
301
258
  return true; // propagate event to the parent component (e.g., QueryAssist)
302
259
  }
303
260
  });
304
- _defineProperty(_this, "clearSelected", function () {
305
- _this.setState({
261
+ _defineProperty(this, "clearSelected", () => {
262
+ this.setState({
306
263
  activeIndex: null,
307
264
  needScrollToActive: false
308
265
  });
309
266
  });
310
- _defineProperty(_this, "scrollEndHandler", function () {
311
- return _this.scheduleScrollListener(function () {
312
- var innerContainer = _this.inner;
313
- if (innerContainer) {
314
- var maxScrollingPosition = innerContainer.scrollHeight;
315
- var sensitivity = _this.defaultItemHeight() / 2;
316
- var currentScrollingPosition = innerContainer.scrollTop + innerContainer.clientHeight + sensitivity;
317
- var scrolledToBottom = maxScrollingPosition > 0 && currentScrollingPosition >= maxScrollingPosition;
318
- if (!_this.unmounted) {
319
- _this.setState({
320
- scrolledToBottom
321
- });
322
- }
323
- if (scrolledToBottom) {
324
- _this.props.onScrollToBottom();
325
- }
267
+ _defineProperty(this, "scrollEndHandler", () => this.scheduleScrollListener(() => {
268
+ const innerContainer = this.inner;
269
+ if (innerContainer) {
270
+ const maxScrollingPosition = innerContainer.scrollHeight;
271
+ const sensitivity = this.defaultItemHeight() / 2;
272
+ const currentScrollingPosition = innerContainer.scrollTop + innerContainer.clientHeight + sensitivity;
273
+ const scrolledToBottom = maxScrollingPosition > 0 && currentScrollingPosition >= maxScrollingPosition;
274
+ if (!this.unmounted) {
275
+ this.setState({
276
+ scrolledToBottom
277
+ });
326
278
  }
327
- });
328
- });
329
- _defineProperty(_this, "checkOverflow", function () {
330
- if (_this.inner) {
331
- _this.setState({
332
- hasOverflow: _this.inner.scrollHeight - _this.inner.clientHeight > 1
279
+ if (scrolledToBottom) {
280
+ this.props.onScrollToBottom();
281
+ }
282
+ }
283
+ }));
284
+ _defineProperty(this, "checkOverflow", () => {
285
+ if (this.inner) {
286
+ this.setState({
287
+ hasOverflow: this.inner.scrollHeight - this.inner.clientHeight > 1
333
288
  });
334
289
  }
335
290
  });
336
- _defineProperty(_this, "renderItem", function (_ref) {
337
- var _ref$index = _ref.index,
338
- index = _ref$index === void 0 ? 1 : _ref$index,
339
- style = _ref.style,
340
- _ref$isScrolling = _ref.isScrolling,
341
- isScrolling = _ref$isScrolling === void 0 ? false : _ref$isScrolling,
342
- parent = _ref.parent,
343
- key = _ref.key;
344
- var itemKey;
345
- var el;
346
- var realIndex = index - 1;
347
- var item = _this.props.data[realIndex];
348
- var itemId = _this.getId(item);
291
+ _defineProperty(this, "renderItem", _ref => {
292
+ let {
293
+ index = 1,
294
+ style,
295
+ isScrolling = false,
296
+ parent,
297
+ key
298
+ } = _ref;
299
+ let itemKey;
300
+ let el;
301
+ const realIndex = index - 1;
302
+ const item = this.props.data[realIndex];
303
+ const itemId = this.getId(item);
349
304
  // top and bottom margins
350
- if (index === 0 || index === _this.props.data.length + 1 || item.rgItemType === Type.MARGIN) {
305
+ if (index === 0 || index === this.props.data.length + 1 || item.rgItemType === Type.MARGIN) {
351
306
  itemKey = key || "".concat(Type.MARGIN, "_").concat(index);
352
307
  el = /*#__PURE__*/jsx("div", {
353
308
  style: {
@@ -356,39 +311,37 @@ var List = /*#__PURE__*/function (_Component) {
356
311
  });
357
312
  } else {
358
313
  // Hack around SelectNG implementation
359
- item.selectedLabel;
360
- item.originalModel;
361
- var restProps = _objectWithoutProperties(item, _excluded);
362
- var cleanedProps = restProps;
314
+ const restProps = _objectWithoutProperties(item, _excluded);
315
+ const cleanedProps = restProps;
363
316
  if (cleanedProps.url) {
364
317
  cleanedProps.href = cleanedProps.url;
365
318
  }
366
319
  if (cleanedProps.href) {
367
320
  cleanedProps.rgItemType = Type.LINK;
368
321
  }
369
- var itemProps = Object.assign({
322
+ const itemProps = Object.assign({
370
323
  rgItemType: DEFAULT_ITEM_TYPE
371
324
  }, restProps);
372
325
  itemKey = key || itemId;
373
- itemProps.hover = realIndex === _this.state.activeIndex;
326
+ itemProps.hover = realIndex === this.state.activeIndex;
374
327
  if (itemProps.hoverClassName != null && itemProps.hover) {
375
328
  itemProps.className = classNames(itemProps.className, itemProps.hoverClassName);
376
329
  }
377
- itemProps.onMouseOver = _this.hoverHandler(realIndex);
330
+ itemProps.onMouseOver = this.hoverHandler(realIndex);
378
331
  itemProps.tabIndex = -1;
379
332
  itemProps.scrolling = isScrolling;
380
- var selectHandler = _this.selectHandler(realIndex);
381
- if (_this.props.useMouseUp) {
333
+ const selectHandler = this.selectHandler(realIndex);
334
+ if (this.props.useMouseUp) {
382
335
  itemProps.onMouseUp = selectHandler;
383
336
  } else {
384
337
  itemProps.onClick = selectHandler;
385
338
  }
386
- itemProps.onCheckboxChange = _this.checkboxHandler(realIndex);
339
+ itemProps.onCheckboxChange = this.checkboxHandler(realIndex);
387
340
  if (itemProps.compact == null) {
388
- itemProps.compact = _this.props.compact;
341
+ itemProps.compact = this.props.compact;
389
342
  }
390
- var ItemComponent;
391
- var isFirst = index === 1;
343
+ let ItemComponent;
344
+ const isFirst = index === 1;
392
345
  switch (itemProps.rgItemType) {
393
346
  case Type.SEPARATOR:
394
347
  ItemComponent = ListSeparator;
@@ -396,15 +349,15 @@ var List = /*#__PURE__*/function (_Component) {
396
349
  break;
397
350
  case Type.LINK:
398
351
  ItemComponent = ListLink;
399
- _this.addItemDataTestToProp(itemProps);
352
+ this.addItemDataTestToProp(itemProps);
400
353
  break;
401
354
  case Type.ITEM:
402
355
  ItemComponent = ListItem;
403
- _this.addItemDataTestToProp(itemProps);
356
+ this.addItemDataTestToProp(itemProps);
404
357
  break;
405
358
  case Type.CUSTOM:
406
359
  ItemComponent = ListCustom;
407
- _this.addItemDataTestToProp(itemProps);
360
+ this.addItemDataTestToProp(itemProps);
408
361
  break;
409
362
  case Type.TITLE:
410
363
  itemProps.isFirst = isFirst;
@@ -418,12 +371,14 @@ var List = /*#__PURE__*/function (_Component) {
418
371
  }));
419
372
  }
420
373
  return parent ? /*#__PURE__*/jsx(CellMeasurer, {
421
- cache: _this._cache,
374
+ cache: this._cache,
422
375
  parent: parent,
423
376
  rowIndex: index,
424
377
  columnIndex: 0,
425
- children: function children(_ref2) {
426
- var registerChild = _ref2.registerChild;
378
+ children: _ref2 => {
379
+ let {
380
+ registerChild
381
+ } = _ref2;
427
382
  return /*#__PURE__*/jsx("div", {
428
383
  ref: registerChild,
429
384
  style: style,
@@ -444,354 +399,282 @@ var List = /*#__PURE__*/function (_Component) {
444
399
  })
445
400
  }, itemKey);
446
401
  });
447
- _defineProperty(_this, "addItemDataTestToProp", function (props) {
402
+ _defineProperty(this, "addItemDataTestToProp", props => {
448
403
  props['data-test'] = joinDataTestAttributes('ring-list-item', props['data-test']);
449
404
  return props;
450
405
  });
451
- _defineProperty(_this, "virtualizedListRef", function (el) {
452
- _this.virtualizedList = el;
406
+ _defineProperty(this, "virtualizedListRef", el => {
407
+ this.virtualizedList = el;
453
408
  });
454
- _defineProperty(_this, "containerRef", function (el) {
455
- _this.container = el;
409
+ _defineProperty(this, "containerRef", el => {
410
+ this.container = el;
456
411
  });
457
- _defineProperty(_this, "_inner", void 0);
458
- _defineProperty(_this, "id", getUID('list-'));
459
- _defineProperty(_this, "shortcutsScope", _this.id);
460
- _defineProperty(_this, "shortcutsMap", {
461
- up: _this.upHandler,
462
- down: _this.downHandler,
463
- home: _this.homeHandler,
464
- end: _this.endHandler,
465
- enter: _this.enterHandler,
466
- 'meta+enter': _this.enterHandler,
467
- 'ctrl+enter': _this.enterHandler,
468
- 'command+enter': _this.enterHandler,
469
- 'shift+enter': _this.enterHandler
412
+ _defineProperty(this, "_inner", void 0);
413
+ _defineProperty(this, "id", getUID('list-'));
414
+ _defineProperty(this, "shortcutsScope", this.id);
415
+ _defineProperty(this, "shortcutsMap", {
416
+ up: this.upHandler,
417
+ down: this.downHandler,
418
+ home: this.homeHandler,
419
+ end: this.endHandler,
420
+ enter: this.enterHandler,
421
+ 'meta+enter': this.enterHandler,
422
+ 'ctrl+enter': this.enterHandler,
423
+ 'command+enter': this.enterHandler,
424
+ 'shift+enter': this.enterHandler
470
425
  });
471
- return _this;
472
426
  }
473
- _inherits(List, _Component);
474
- return _createClass(List, [{
475
- key: "componentDidMount",
476
- value: function componentDidMount() {
477
- document.addEventListener('mousemove', this.onDocumentMouseMove);
478
- document.addEventListener('keydown', this.onDocumentKeyDown, true);
479
- if (this.props.activeIndex == null && shouldActivateFirstItem(this.props)) {
480
- this.activateFirst();
481
- }
482
- }
483
- }, {
484
- key: "shouldComponentUpdate",
485
- value: function shouldComponentUpdate(nextProps, nextState) {
486
- var _this2 = this;
487
- return nextProps !== this.props || Object.keys(nextState).some(function (key) {
488
- return nextState[key] !== _this2.state[key];
427
+ static getDerivedStateFromProps(nextProps, prevState) {
428
+ const {
429
+ prevActiveIndex,
430
+ prevData,
431
+ activeItem
432
+ } = prevState;
433
+ const {
434
+ data,
435
+ activeIndex,
436
+ restoreActiveIndex
437
+ } = nextProps;
438
+ const nextState = {
439
+ prevActiveIndex: activeIndex,
440
+ prevData: data
441
+ };
442
+ if (data !== prevData) {
443
+ Object.assign(nextState, {
444
+ activeIndex: null,
445
+ activeItem: null
489
446
  });
490
447
  }
491
- }, {
492
- key: "componentDidUpdate",
493
- value: function componentDidUpdate(prevProps) {
494
- if (this.virtualizedList && prevProps.data !== this.props.data) {
495
- this.virtualizedList.recomputeRowHeights();
496
- }
497
- if (this.props.activeIndex == null && getDataHash(this.props.data) !== getDataHash(prevProps.data) && shouldActivateFirstItem(this.props)) {
498
- this.activateFirst();
499
- }
500
- this.checkOverflow();
501
- }
502
- }, {
503
- key: "componentWillUnmount",
504
- value: function componentWillUnmount() {
505
- this.unmounted = true;
506
- document.removeEventListener('mousemove', this.onDocumentMouseMove);
507
- document.removeEventListener('keydown', this.onDocumentKeyDown, true);
508
- }
509
- }, {
510
- key: "hasActivatableItems",
511
- value: function hasActivatableItems() {
512
- return this._hasActivatableItems(this.props.data);
513
- }
514
- }, {
515
- key: "moveHandler",
516
- value: function moveHandler(index, retryCallback, e) {
517
- var correctedIndex;
518
- if (this.props.data.length === 0 || !this.hasActivatableItems()) {
519
- return;
520
- } else if (this.props.data.length < index) {
521
- correctedIndex = 0;
522
- } else {
523
- correctedIndex = index;
524
- }
525
- var item = this.props.data[correctedIndex];
526
- this.setState({
527
- activeIndex: correctedIndex,
528
- activeItem: item,
448
+ if (activeIndex != null && activeIndex !== prevActiveIndex && data[activeIndex] != null) {
449
+ Object.assign(nextState, {
450
+ activeIndex,
451
+ activeItem: data[activeIndex],
529
452
  needScrollToActive: true
530
- }, function onSet() {
531
- if (!isActivatable(item)) {
532
- retryCallback(e);
533
- return;
534
- }
535
- if (e.key !== 'Home' && e.key !== 'End') {
536
- preventDefault(e);
537
- }
538
453
  });
454
+ } else if (data !== prevData && restoreActiveIndex && activeItem != null && activeItem.key != null) {
455
+ // Restore active index if there is an item with the same "key" property
456
+ const index = data.findIndex(item => item.key === activeItem.key);
457
+ if (index >= 0) {
458
+ Object.assign(nextState, {
459
+ activeIndex: index,
460
+ activeItem: data[index]
461
+ });
462
+ }
539
463
  }
540
- }, {
541
- key: "getFirst",
542
- value: function getFirst() {
543
- return this.props.data.find(function (item) {
544
- return item.rgItemType === Type.ITEM || item.rgItemType === Type.CUSTOM;
545
- });
464
+ return nextState;
465
+ }
466
+ componentDidMount() {
467
+ document.addEventListener('mousemove', this.onDocumentMouseMove);
468
+ document.addEventListener('keydown', this.onDocumentKeyDown, true);
469
+ if (this.props.activeIndex == null && shouldActivateFirstItem(this.props)) {
470
+ this.activateFirst();
546
471
  }
547
- }, {
548
- key: "getSelected",
549
- value: function getSelected() {
550
- return this.state.activeIndex != null ? this.props.data[this.state.activeIndex] : null;
472
+ }
473
+ shouldComponentUpdate(nextProps, nextState) {
474
+ return nextProps !== this.props || Object.keys(nextState).some(key => nextState[key] !== this.state[key]);
475
+ }
476
+ componentDidUpdate(prevProps) {
477
+ if (this.virtualizedList && prevProps.data !== this.props.data) {
478
+ this.virtualizedList.recomputeRowHeights();
551
479
  }
552
- }, {
553
- key: "defaultItemHeight",
554
- value: function defaultItemHeight() {
555
- return this.props.compact ? Dimension.COMPACT_ITEM_HEIGHT : Dimension.ITEM_HEIGHT;
480
+ if (this.props.activeIndex == null && getDataHash(this.props.data) !== getDataHash(prevProps.data) && shouldActivateFirstItem(this.props)) {
481
+ this.activateFirst();
556
482
  }
557
- }, {
558
- key: "getVisibleListHeight",
559
- value: function getVisibleListHeight(maxHeight) {
560
- return maxHeight - this.defaultItemHeight() - Dimension.INNER_PADDING;
483
+ this.checkOverflow();
484
+ }
485
+ componentWillUnmount() {
486
+ this.unmounted = true;
487
+ document.removeEventListener('mousemove', this.onDocumentMouseMove);
488
+ document.removeEventListener('keydown', this.onDocumentKeyDown, true);
489
+ }
490
+ hasActivatableItems() {
491
+ return this._hasActivatableItems(this.props.data);
492
+ }
493
+ moveHandler(index, retryCallback, e) {
494
+ let correctedIndex;
495
+ if (this.props.data.length === 0 || !this.hasActivatableItems()) {
496
+ return;
497
+ } else if (this.props.data.length < index) {
498
+ correctedIndex = 0;
499
+ } else {
500
+ correctedIndex = index;
561
501
  }
562
- }, {
563
- key: "_deprecatedGenerateKeyFromContent",
564
- value: function _deprecatedGenerateKeyFromContent(itemProps) {
565
- var identificator = itemProps.label || itemProps.description;
566
- var isString = typeof identificator === 'string' || identificator instanceof String;
567
- if (identificator && !isString) {
568
- warnEmptyKey();
569
- "".concat(itemProps.rgItemType, "_").concat(JSON.stringify(identificator));
502
+ const item = this.props.data[correctedIndex];
503
+ this.setState({
504
+ activeIndex: correctedIndex,
505
+ activeItem: item,
506
+ needScrollToActive: true
507
+ }, function onSet() {
508
+ if (!isActivatable(item)) {
509
+ retryCallback(e);
510
+ return;
570
511
  }
571
- return "".concat(itemProps.rgItemType, "_").concat(identificator);
572
- }
573
- }, {
574
- key: "getId",
575
- value: function getId(item) {
576
- return item != null ? "".concat(this.id, ":").concat(item.key || this._deprecatedGenerateKeyFromContent(item)) : undefined;
577
- }
578
- }, {
579
- key: "inner",
580
- get: function get() {
581
- if (!this._inner) {
582
- this._inner = this.container && this.container.querySelector('.ring-list__i');
512
+ if (e.key !== 'Home' && e.key !== 'End') {
513
+ preventDefault(e);
583
514
  }
584
- return this._inner;
515
+ });
516
+ }
517
+ getFirst() {
518
+ return this.props.data.find(item => item.rgItemType === Type.ITEM || item.rgItemType === Type.CUSTOM);
519
+ }
520
+ getSelected() {
521
+ return this.state.activeIndex != null ? this.props.data[this.state.activeIndex] : null;
522
+ }
523
+ defaultItemHeight() {
524
+ return this.props.compact ? Dimension.COMPACT_ITEM_HEIGHT : Dimension.ITEM_HEIGHT;
525
+ }
526
+ getVisibleListHeight(maxHeight) {
527
+ return maxHeight - this.defaultItemHeight() - Dimension.INNER_PADDING;
528
+ }
529
+ _deprecatedGenerateKeyFromContent(itemProps) {
530
+ const identificator = itemProps.label || itemProps.description;
531
+ const isString = typeof identificator === 'string' || identificator instanceof String;
532
+ if (identificator && !isString) {
533
+ warnEmptyKey();
534
+ return "".concat(itemProps.rgItemType, "_").concat(JSON.stringify(identificator));
585
535
  }
586
- }, {
587
- key: "renderVirtualizedInner",
588
- value: function renderVirtualizedInner(_ref3) {
589
- var _this3 = this;
590
- var height = _ref3.height,
591
- maxHeight = _ref3.maxHeight,
592
- _ref3$autoHeight = _ref3.autoHeight,
593
- autoHeight = _ref3$autoHeight === void 0 ? false : _ref3$autoHeight,
594
- rowCount = _ref3.rowCount,
595
- isScrolling = _ref3.isScrolling,
596
- _ref3$onChildScroll = _ref3.onChildScroll,
597
- onChildScroll = _ref3$onChildScroll === void 0 ? noop : _ref3$onChildScroll,
598
- scrollTop = _ref3.scrollTop,
599
- registerChild = _ref3.registerChild;
600
- var dirOverride = {
601
- direction: 'inherit'
602
- }; // Virtualized sets "direction: ltr" by default https://github.com/bvaughn/react-virtualized/issues/457
603
- return /*#__PURE__*/jsx(AutoSizer, {
604
- disableHeight: true,
605
- onResize: this.props.onResize,
606
- children: function children(_ref4) {
607
- var width = _ref4.width;
608
- return /*#__PURE__*/jsx("div", {
609
- ref: registerChild,
610
- children: /*#__PURE__*/jsx(VirtualizedList, {
611
- "aria-label": _this3.props.ariaLabel,
612
- ref: _this3.virtualizedListRef,
613
- className: classNames('ring-list__i', {
614
- [modules_3b67a421.overscrollNone]: _this3.props.preventListOverscroll
615
- }),
616
- autoHeight: autoHeight,
617
- style: maxHeight ? _objectSpread2({
618
- maxHeight,
619
- height: 'auto'
620
- }, dirOverride) : dirOverride,
621
- autoContainerWidth: true,
622
- height: height,
623
- width: width,
624
- isScrolling: isScrolling,
625
- onScroll: function onScroll(e) {
626
- onChildScroll(e);
627
- _this3.scrollEndHandler();
628
- },
629
- scrollTop: scrollTop,
630
- rowCount: rowCount,
631
- estimatedRowSize: _this3.defaultItemHeight(),
632
- rowHeight: _this3._cache.rowHeight,
633
- rowRenderer: _this3.renderItem,
634
- overscanRowCount: _this3._bufferSize
635
- // ensure rerendering
636
- ,
637
- noop: function noop() {},
638
- scrollToIndex: !_this3.props.disableScrollToActive && _this3.state.needScrollToActive && _this3.state.activeIndex != null ? _this3.state.activeIndex + 1 : undefined,
639
- scrollToAlignment: "center",
640
- deferredMeasurementCache: _this3._cache,
641
- onRowsRendered: _this3.checkOverflow
642
- })
643
- });
644
- }
645
- });
536
+ return "".concat(itemProps.rgItemType, "_").concat(identificator);
537
+ }
538
+ getId(item) {
539
+ return item != null ? "".concat(this.id, ":").concat(item.key || this._deprecatedGenerateKeyFromContent(item)) : undefined;
540
+ }
541
+ get inner() {
542
+ if (!this._inner) {
543
+ this._inner = this.container && this.container.querySelector('.ring-list__i');
646
544
  }
647
- }, {
648
- key: "renderVirtualized",
649
- value: function renderVirtualized(maxHeight, rowCount) {
650
- var _this4 = this;
651
- if (maxHeight) {
652
- return this.renderVirtualizedInner({
653
- height: maxHeight,
654
- maxHeight,
655
- rowCount
545
+ return this._inner;
546
+ }
547
+ renderVirtualizedInner(_ref3) {
548
+ let {
549
+ height,
550
+ maxHeight,
551
+ autoHeight = false,
552
+ rowCount,
553
+ isScrolling,
554
+ onChildScroll = noop,
555
+ scrollTop,
556
+ registerChild
557
+ } = _ref3;
558
+ const dirOverride = {
559
+ direction: 'inherit'
560
+ }; // Virtualized sets "direction: ltr" by default https://github.com/bvaughn/react-virtualized/issues/457
561
+ return /*#__PURE__*/jsx(AutoSizer, {
562
+ disableHeight: true,
563
+ onResize: this.props.onResize,
564
+ children: _ref4 => {
565
+ let {
566
+ width
567
+ } = _ref4;
568
+ return /*#__PURE__*/jsx("div", {
569
+ ref: registerChild,
570
+ children: /*#__PURE__*/jsx(VirtualizedList, {
571
+ "aria-label": this.props.ariaLabel,
572
+ ref: this.virtualizedListRef,
573
+ className: classNames('ring-list__i', {
574
+ [modules_3b67a421.overscrollNone]: this.props.preventListOverscroll
575
+ }),
576
+ autoHeight: autoHeight,
577
+ style: maxHeight ? _objectSpread2({
578
+ maxHeight,
579
+ height: 'auto'
580
+ }, dirOverride) : dirOverride,
581
+ autoContainerWidth: true,
582
+ height: height,
583
+ width: width,
584
+ isScrolling: isScrolling,
585
+ onScroll: e => {
586
+ onChildScroll(e);
587
+ this.scrollEndHandler();
588
+ },
589
+ scrollTop: scrollTop,
590
+ rowCount: rowCount,
591
+ estimatedRowSize: this.defaultItemHeight(),
592
+ rowHeight: this._cache.rowHeight,
593
+ rowRenderer: this.renderItem,
594
+ overscanRowCount: this._bufferSize
595
+ // ensure rerendering
596
+ ,
597
+ noop: () => {},
598
+ scrollToIndex: !this.props.disableScrollToActive && this.state.needScrollToActive && this.state.activeIndex != null ? this.state.activeIndex + 1 : undefined,
599
+ scrollToAlignment: "center",
600
+ deferredMeasurementCache: this._cache,
601
+ onRowsRendered: this.checkOverflow
602
+ })
656
603
  });
657
604
  }
658
- return /*#__PURE__*/jsx(WindowScroller, {
659
- children: function children(props) {
660
- return _this4.renderVirtualizedInner(_objectSpread2(_objectSpread2({}, props), {}, {
661
- rowCount,
662
- autoHeight: true
663
- }));
664
- }
605
+ });
606
+ }
607
+ renderVirtualized(maxHeight, rowCount) {
608
+ if (maxHeight) {
609
+ return this.renderVirtualizedInner({
610
+ height: maxHeight,
611
+ maxHeight,
612
+ rowCount
665
613
  });
666
614
  }
667
- }, {
668
- key: "renderSimple",
669
- value: function renderSimple(maxHeight, rowCount) {
670
- var items = [];
671
- for (var index = 0; index < rowCount; index++) {
672
- items.push(this.renderItem({
673
- index,
674
- isScrolling: this.state.scrolling
675
- }));
676
- }
677
- return /*#__PURE__*/jsx("div", {
678
- className: classNames('ring-list__i', modules_3b67a421.simpleInner),
679
- onScroll: this.scrollHandler,
680
- onMouseMove: this.mouseHandler,
681
- children: /*#__PURE__*/jsx("div", {
682
- "aria-label": this.props.ariaLabel,
683
- role: "grid",
684
- style: maxHeight ? {
685
- maxHeight: this.getVisibleListHeight(maxHeight)
686
- } : undefined,
687
- children: items
688
- })
689
- });
615
+ return /*#__PURE__*/jsx(WindowScroller, {
616
+ children: props => this.renderVirtualizedInner(_objectSpread2(_objectSpread2({}, props), {}, {
617
+ rowCount,
618
+ autoHeight: true
619
+ }))
620
+ });
621
+ }
622
+ renderSimple(maxHeight, rowCount) {
623
+ const items = [];
624
+ for (let index = 0; index < rowCount; index++) {
625
+ items.push(this.renderItem({
626
+ index,
627
+ isScrolling: this.state.scrolling
628
+ }));
690
629
  }
691
- }, {
692
- key: "render",
693
- value: /** @override */
694
- function render() {
695
- var hint = this.getSelected() && this.props.hintOnSelection || this.props.hint;
696
- var fadeStyles = hint ? {
697
- bottom: Dimension.ITEM_HEIGHT
698
- } : undefined;
699
- var rowCount = this.props.data.length + 2;
700
- var maxHeight = this.props.maxHeight && this.getVisibleListHeight(this.props.maxHeight);
701
- var classes = classNames(modules_3b67a421.list, this.props.className);
702
- return /*#__PURE__*/jsxs(Fragment, {
703
- children: [/*#__PURE__*/jsx(ActiveItemContext.Updater, {
704
- value: this.getId(this.state.activeItem),
705
- skipUpdate: this.props.hidden || !isActivatable(this.state.activeItem)
706
- }), /*#__PURE__*/jsxs("div", {
707
- id: this.props.id,
708
- ref: this.containerRef,
709
- className: classes,
710
- onMouseOut: this.props.onMouseOut,
711
- onBlur: this.props.onMouseOut,
712
- onMouseLeave: this.clearSelected,
713
- "data-test": "ring-list",
714
- children: [this.props.shortcuts && /*#__PURE__*/jsx(Shortcuts, {
715
- map: this.props.shortcutsMap ? _objectSpread2(_objectSpread2({}, this.shortcutsMap), this.props.shortcutsMap) : this.shortcutsMap,
716
- scope: this.shortcutsScope
717
- }), this.props.renderOptimization ? this.renderVirtualized(maxHeight, rowCount) : this.renderSimple(maxHeight, rowCount), this.state.hasOverflow && !this.state.scrolledToBottom && /*#__PURE__*/jsx("div", {
718
- className: modules_3b67a421.fade,
719
- style: fadeStyles
720
- }), hint && /*#__PURE__*/jsx(ListHint, {
721
- label: hint
722
- })]
630
+ return /*#__PURE__*/jsx("div", {
631
+ className: classNames('ring-list__i', modules_3b67a421.simpleInner),
632
+ onScroll: this.scrollHandler,
633
+ onMouseMove: this.mouseHandler,
634
+ children: /*#__PURE__*/jsx("div", {
635
+ "aria-label": this.props.ariaLabel,
636
+ role: "grid",
637
+ style: maxHeight ? {
638
+ maxHeight: this.getVisibleListHeight(maxHeight)
639
+ } : undefined,
640
+ children: items
641
+ })
642
+ });
643
+ }
644
+ /** @override */
645
+ render() {
646
+ const hint = this.getSelected() && this.props.hintOnSelection || this.props.hint;
647
+ const fadeStyles = hint ? {
648
+ bottom: Dimension.ITEM_HEIGHT
649
+ } : undefined;
650
+ const rowCount = this.props.data.length + 2;
651
+ const maxHeight = this.props.maxHeight && this.getVisibleListHeight(this.props.maxHeight);
652
+ const classes = classNames(modules_3b67a421.list, this.props.className);
653
+ return /*#__PURE__*/jsxs(Fragment, {
654
+ children: [/*#__PURE__*/jsx(ActiveItemContext.Updater, {
655
+ value: this.getId(this.state.activeItem),
656
+ skipUpdate: this.props.hidden || !isActivatable(this.state.activeItem)
657
+ }), /*#__PURE__*/jsxs("div", {
658
+ id: this.props.id,
659
+ ref: this.containerRef,
660
+ className: classes,
661
+ onMouseOut: this.props.onMouseOut,
662
+ onBlur: this.props.onMouseOut,
663
+ onMouseLeave: this.clearSelected,
664
+ "data-test": "ring-list",
665
+ children: [this.props.shortcuts && /*#__PURE__*/jsx(Shortcuts, {
666
+ map: this.props.shortcutsMap ? _objectSpread2(_objectSpread2({}, this.shortcutsMap), this.props.shortcutsMap) : this.shortcutsMap,
667
+ scope: this.shortcutsScope
668
+ }), this.props.renderOptimization ? this.renderVirtualized(maxHeight, rowCount) : this.renderSimple(maxHeight, rowCount), this.state.hasOverflow && !this.state.scrolledToBottom && /*#__PURE__*/jsx("div", {
669
+ className: modules_3b67a421.fade,
670
+ style: fadeStyles
671
+ }), hint && /*#__PURE__*/jsx(ListHint, {
672
+ label: hint
723
673
  })]
724
- });
725
- }
726
- }], [{
727
- key: "getDerivedStateFromProps",
728
- value: function getDerivedStateFromProps(nextProps, prevState) {
729
- var prevActiveIndex = prevState.prevActiveIndex,
730
- prevData = prevState.prevData,
731
- activeItem = prevState.activeItem;
732
- var data = nextProps.data,
733
- activeIndex = nextProps.activeIndex,
734
- restoreActiveIndex = nextProps.restoreActiveIndex;
735
- var nextState = {
736
- prevActiveIndex: activeIndex,
737
- prevData: data
738
- };
739
- if (data !== prevData) {
740
- Object.assign(nextState, {
741
- activeIndex: null,
742
- activeItem: null
743
- });
744
- }
745
- if (activeIndex != null && activeIndex !== prevActiveIndex && data[activeIndex] != null) {
746
- Object.assign(nextState, {
747
- activeIndex,
748
- activeItem: data[activeIndex],
749
- needScrollToActive: true
750
- });
751
- } else if (data !== prevData && restoreActiveIndex && activeItem != null && activeItem.key != null) {
752
- // Restore active index if there is an item with the same "key" property
753
- var index = data.findIndex(function (item) {
754
- return item.key === activeItem.key;
755
- });
756
- if (index >= 0) {
757
- Object.assign(nextState, {
758
- activeIndex: index,
759
- activeItem: data[index]
760
- });
761
- }
762
- }
763
- return nextState;
764
- }
765
- }]);
766
- }(Component);
767
- _defineProperty(List, "propTypes", {
768
- id: PropTypes.string,
769
- className: PropTypes.string,
770
- hint: PropTypes.node,
771
- hintOnSelection: PropTypes.string,
772
- data: PropTypes.array,
773
- maxHeight: PropTypes.number,
774
- activeIndex: PropTypes.number,
775
- restoreActiveIndex: PropTypes.bool,
776
- activateSingleItem: PropTypes.bool,
777
- activateFirstItem: PropTypes.bool,
778
- shortcuts: PropTypes.bool,
779
- shortcutsMap: PropTypes.object,
780
- onMouseOut: PropTypes.func,
781
- onSelect: PropTypes.func,
782
- onScrollToBottom: PropTypes.func,
783
- onResize: PropTypes.func,
784
- useMouseUp: PropTypes.bool,
785
- visible: PropTypes.bool,
786
- renderOptimization: PropTypes.bool,
787
- disableMoveOverflow: PropTypes.bool,
788
- disableMoveDownOverflow: PropTypes.bool,
789
- compact: PropTypes.bool,
790
- disableScrollToActive: PropTypes.bool,
791
- hidden: PropTypes.bool,
792
- ariaLabel: PropTypes.string,
793
- preventListOverscroll: PropTypes.bool
794
- });
674
+ })]
675
+ });
676
+ }
677
+ }
795
678
  _defineProperty(List, "defaultProps", {
796
679
  data: [],
797
680
  restoreActiveIndex: false,