@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.
- package/components/_helpers/_rollupPluginBabelHelpers.js +1 -504
- package/components/_helpers/anchor.js +7 -10
- package/components/_helpers/button__classes.js +23 -20
- package/components/_helpers/caption.js +11 -21
- package/components/_helpers/card.js +91 -123
- package/components/_helpers/dialog__body-scroll-preventer.js +10 -17
- package/components/_helpers/header.js +1 -1
- package/components/_helpers/icon__svg.js +27 -29
- package/components/_helpers/input.js +151 -193
- package/components/_helpers/query-assist__suggestions.js +79 -94
- package/components/_helpers/select__filter.js +56 -75
- package/components/_helpers/services-link.js +23 -39
- package/components/_helpers/sidebar.js +91 -102
- package/components/_helpers/tab-link.js +8 -12
- package/components/_helpers/theme.js +61 -51
- package/components/_helpers/title.js +59 -84
- package/components/alert/alert.d.ts +7 -24
- package/components/alert/alert.js +111 -179
- package/components/alert/container.d.ts +0 -5
- package/components/alert/container.js +32 -44
- package/components/alert-service/alert-service.js +104 -162
- package/components/analytics/analytics.js +12 -20
- package/components/analytics/analytics__custom-plugin.js +52 -68
- package/components/auth/auth.js +2 -31
- package/components/auth/auth__core.d.ts +4 -4
- package/components/auth/auth__core.js +755 -1433
- package/components/auth/background-flow.js +84 -121
- package/components/auth/down-notification.js +32 -79
- package/components/auth/iframe-flow.js +71 -125
- package/components/auth/request-builder.js +46 -77
- package/components/auth/response-parser.js +84 -112
- package/components/auth/storage.js +162 -324
- package/components/auth/token-validator.js +132 -227
- package/components/auth/window-flow.js +84 -121
- package/components/auth-dialog/auth-dialog.d.ts +0 -18
- package/components/auth-dialog/auth-dialog.js +107 -176
- package/components/auth-dialog-service/auth-dialog-service.js +12 -33
- package/components/avatar/avatar-example-datauri.js +1 -1
- package/components/avatar/avatar.d.ts +0 -13
- package/components/avatar/avatar.js +94 -136
- package/components/avatar/fallback-avatar.d.ts +1 -10
- package/components/avatar/fallback-avatar.js +20 -40
- package/components/badge/badge.d.ts +0 -10
- package/components/badge/badge.js +32 -48
- package/components/breadcrumbs/breadcrumbs.js +13 -17
- package/components/button/button.d.ts +0 -21
- package/components/button/button.js +68 -104
- package/components/button/button__classes.d.ts +1 -1
- package/components/button-group/button-group.d.ts +0 -5
- package/components/button-group/button-group.js +27 -41
- package/components/button-group/caption.d.ts +0 -4
- package/components/button-group/caption.js +0 -1
- package/components/button-set/button-set.d.ts +0 -6
- package/components/button-set/button-set.js +19 -33
- package/components/button-toolbar/button-toolbar.d.ts +0 -6
- package/components/button-toolbar/button-toolbar.js +17 -31
- package/components/caret/caret.js +184 -211
- package/components/checkbox/checkbox.d.ts +0 -19
- package/components/checkbox/checkbox.js +69 -104
- package/components/clipboard/clipboard-fallback.js +7 -7
- package/components/clipboard/clipboard.js +36 -129
- package/components/code/code.d.ts +0 -12
- package/components/code/code.js +83 -163
- package/components/collapse/collapse-content.js +42 -60
- package/components/collapse/collapse-context.js +2 -2
- package/components/collapse/collapse-control.js +12 -12
- package/components/collapse/collapse.js +12 -17
- package/components/collapse/consts.js +4 -4
- package/components/collapse/utils.js +1 -3
- package/components/confirm/confirm.d.ts +0 -14
- package/components/confirm/confirm.js +68 -112
- package/components/confirm-service/confirm-service.js +25 -47
- package/components/content-layout/content-layout.d.ts +0 -7
- package/components/content-layout/content-layout.js +41 -63
- package/components/content-layout/sidebar.d.ts +0 -9
- package/components/content-layout/sidebar.js +1 -2
- package/components/contenteditable/contenteditable.d.ts +1 -22
- package/components/contenteditable/contenteditable.js +37 -60
- package/components/control-help/control-help.js +5 -3
- package/components/control-label/control-label.js +9 -14
- package/components/data-list/data-list.d.ts +0 -2
- package/components/data-list/data-list.js +115 -179
- package/components/data-list/data-list.mock.js +3 -6
- package/components/data-list/item.js +119 -165
- package/components/data-list/selection.js +77 -135
- package/components/data-list/title.d.ts +2 -2
- package/components/data-list/title.js +2 -12
- package/components/date-picker/consts.d.ts +0 -2
- package/components/date-picker/consts.js +16 -24
- package/components/date-picker/date-input.d.ts +0 -20
- package/components/date-picker/date-input.js +100 -148
- package/components/date-picker/date-picker.d.ts +0 -29
- package/components/date-picker/date-picker.js +143 -224
- package/components/date-picker/date-popup.d.ts +0 -22
- package/components/date-picker/date-popup.js +282 -352
- package/components/date-picker/day.d.ts +0 -14
- package/components/date-picker/day.js +72 -109
- package/components/date-picker/month-names.d.ts +1 -11
- package/components/date-picker/month-names.js +42 -72
- package/components/date-picker/month-slider.d.ts +0 -9
- package/components/date-picker/month-slider.js +43 -71
- package/components/date-picker/month.d.ts +1 -9
- package/components/date-picker/month.js +18 -30
- package/components/date-picker/months.d.ts +1 -9
- package/components/date-picker/months.js +45 -55
- package/components/date-picker/weekdays.d.ts +2 -8
- package/components/date-picker/weekdays.js +12 -25
- package/components/date-picker/years.d.ts +0 -6
- package/components/date-picker/years.js +77 -104
- package/components/dialog/dialog.d.ts +0 -20
- package/components/dialog/dialog.js +153 -211
- package/components/dialog/dialog__body-scroll-preventer.js +0 -3
- package/components/dropdown/anchor.d.ts +1 -8
- package/components/dropdown/anchor.js +0 -7
- package/components/dropdown/dropdown.d.ts +4 -22
- package/components/dropdown/dropdown.js +134 -176
- package/components/dropdown-menu/dropdown-menu.js +51 -103
- package/components/editable-heading/editable-heading.js +69 -118
- package/components/error-bubble/error-bubble.d.ts +0 -6
- package/components/error-bubble/error-bubble.js +30 -60
- package/components/error-message/error-message.d.ts +0 -10
- package/components/error-message/error-message.js +34 -59
- package/components/footer/footer.js +28 -44
- package/components/form/form.js +1 -1
- package/components/global/compose.js +1 -8
- package/components/global/composeRefs.d.ts +0 -3
- package/components/global/composeRefs.js +8 -15
- package/components/global/controls-height.js +2 -2
- package/components/global/create-stateful-context.d.ts +0 -4
- package/components/global/create-stateful-context.js +14 -17
- package/components/global/data-tests.js +7 -12
- package/components/global/dom.js +49 -82
- package/components/global/focus-sensor-hoc.js +95 -122
- package/components/global/fuzzy-highlight.js +23 -34
- package/components/global/get-event-key.js +8 -8
- package/components/global/get-uid.js +3 -7
- package/components/global/inject-styles.js +7 -14
- package/components/global/listeners.js +28 -47
- package/components/global/memoize.js +6 -10
- package/components/global/normalize-indent.js +19 -46
- package/components/global/promise-with-timeout.js +6 -8
- package/components/global/react-dom-renderer.d.ts +0 -5
- package/components/global/react-dom-renderer.js +29 -45
- package/components/global/rerender-hoc.d.ts +2 -2
- package/components/global/rerender-hoc.js +16 -32
- package/components/global/schedule-raf.js +4 -4
- package/components/global/sniffer.js +1 -1
- package/components/global/theme.d.ts +8 -2
- package/components/global/theme.js +2 -20
- package/components/global/trivial-template-tag.js +4 -9
- package/components/global/typescript-utils.js +2 -6
- package/components/global/url.js +20 -23
- package/components/global/use-event-callback.js +7 -4
- package/components/grid/col.d.ts +0 -14
- package/components/grid/col.js +27 -53
- package/components/grid/grid.d.ts +0 -5
- package/components/grid/grid.js +20 -32
- package/components/grid/row.d.ts +0 -18
- package/components/grid/row.js +23 -47
- package/components/group/group.d.ts +0 -5
- package/components/group/group.js +18 -27
- package/components/header/header-icon.d.ts +0 -22
- package/components/header/header-icon.js +20 -37
- package/components/header/header.d.ts +0 -7
- package/components/header/header.js +30 -74
- package/components/header/links.d.ts +2 -0
- package/components/header/links.js +20 -0
- package/components/header/logo.d.ts +0 -4
- package/components/header/logo.js +15 -30
- package/components/header/profile.d.ts +1 -39
- package/components/header/profile.js +126 -191
- package/components/header/services-link.d.ts +0 -10
- package/components/header/services-link.js +1 -4
- package/components/header/services.d.ts +0 -14
- package/components/header/services.js +65 -110
- package/components/header/smart-profile.d.ts +0 -9
- package/components/header/smart-profile.js +116 -205
- package/components/header/smart-services.d.ts +0 -4
- package/components/header/smart-services.js +72 -141
- package/components/header/tray.d.ts +0 -5
- package/components/header/tray.js +21 -35
- package/components/heading/heading.js +21 -26
- package/components/http/http.js +162 -319
- package/components/http/http.mock.js +50 -98
- package/components/hub-source/hub-source.js +77 -182
- package/components/hub-source/hub-source__user.js +9 -37
- package/components/hub-source/hub-source__users-groups.js +34 -60
- package/components/i18n/i18n-context.js +7 -8
- package/components/i18n/i18n.js +3 -6
- package/components/icon/icon.d.ts +0 -11
- package/components/icon/icon.js +60 -85
- package/components/icon/icon__svg.d.ts +0 -8
- package/components/icon/icon__svg.js +0 -6
- package/components/icon/index.js +0 -6
- package/components/input/input-legacy.js +1 -1
- package/components/input/input.js +2 -14
- package/components/input-size/input-size.js +1 -1
- package/components/island/adaptive-island-hoc.d.ts +0 -1
- package/components/island/adaptive-island-hoc.js +30 -39
- package/components/island/content.d.ts +0 -10
- package/components/island/content.js +99 -119
- package/components/island/header.js +55 -73
- package/components/island/island.d.ts +0 -9
- package/components/island/island.js +25 -41
- package/components/island-legacy/content-legacy.d.ts +0 -5
- package/components/island-legacy/content-legacy.js +16 -27
- package/components/island-legacy/header-legacy.d.ts +0 -5
- package/components/island-legacy/header-legacy.js +19 -30
- package/components/island-legacy/island-legacy.d.ts +0 -5
- package/components/island-legacy/island-legacy.js +16 -27
- package/components/link/clickableLink.d.ts +0 -9
- package/components/link/clickableLink.js +33 -51
- package/components/link/link.d.ts +0 -25
- package/components/link/link.js +47 -68
- package/components/list/consts.js +2 -2
- package/components/list/list.d.ts +0 -32
- package/components/list/list.js +399 -516
- package/components/list/list__custom.js +51 -78
- package/components/list/list__hint.d.ts +0 -4
- package/components/list/list__hint.js +8 -21
- package/components/list/list__item.js +147 -211
- package/components/list/list__link.js +39 -59
- package/components/list/list__separator.js +15 -30
- package/components/list/list__title.js +25 -41
- package/components/list/list__users-groups-source.js +55 -123
- package/components/loader/loader.d.ts +0 -10
- package/components/loader/loader.js +38 -70
- package/components/loader/loader__core.js +123 -184
- package/components/loader-inline/loader-inline.d.ts +0 -6
- package/components/loader-inline/loader-inline.js +24 -38
- package/components/loader-screen/loader-screen.d.ts +0 -6
- package/components/loader-screen/loader-screen.js +24 -46
- package/components/login-dialog/login-dialog.d.ts +0 -11
- package/components/login-dialog/login-dialog.js +94 -145
- package/components/login-dialog/service.js +11 -33
- package/components/markdown/markdown.js +16 -29
- package/components/message/message.js +171 -218
- package/components/old-browsers-message/old-browsers-message.js +11 -14
- package/components/old-browsers-message/old-browsers-message__stop.js +1 -4
- package/components/old-browsers-message/white-list.js +8 -13
- package/components/pager/pager.js +211 -275
- package/components/panel/panel.d.ts +0 -5
- package/components/panel/panel.js +16 -27
- package/components/permissions/permissions.js +118 -161
- package/components/permissions/permissions__cache.js +191 -218
- package/components/popup/popup.consts.js +1 -1
- package/components/popup/popup.js +237 -329
- package/components/popup/popup.target.js +9 -12
- package/components/popup/position.js +94 -101
- package/components/popup-menu/popup-menu.js +31 -76
- package/components/progress-bar/progress-bar.d.ts +19 -33
- package/components/progress-bar/progress-bar.js +55 -99
- package/components/query-assist/query-assist.d.ts +63 -93
- package/components/query-assist/query-assist.js +585 -748
- package/components/query-assist/query-assist__suggestions.js +2 -28
- package/components/radio/radio.d.ts +0 -8
- package/components/radio/radio.js +15 -35
- package/components/radio/radio__item.d.ts +0 -9
- package/components/radio/radio__item.js +52 -72
- package/components/scrollable-section/scrollable-section.js +53 -0
- package/components/select/select.d.ts +3 -0
- package/components/select/select.js +714 -863
- package/components/select/select__filter.js +2 -29
- package/components/select/select__popup.js +317 -465
- package/components/shortcuts/core.js +147 -195
- package/components/shortcuts/shortcut-title.js +6 -10
- package/components/shortcuts/shortcuts-hoc.d.ts +0 -5
- package/components/shortcuts/shortcuts-hoc.js +23 -46
- package/components/shortcuts/shortcuts.d.ts +0 -8
- package/components/shortcuts/shortcuts.js +41 -72
- package/components/slider/slider.js +93 -113
- package/components/slider/slider.utils.js +16 -23
- package/components/storage/storage.d.ts +2 -3
- package/components/storage/storage.js +2 -46
- package/components/storage/storage__local.js +89 -148
- package/components/style.css +1 -1
- package/components/tab-trap/tab-trap.js +35 -61
- package/components/table/cell.d.ts +0 -6
- package/components/table/cell.js +11 -27
- package/components/table/disable-hover-hoc.d.ts +0 -1
- package/components/table/disable-hover-hoc.js +27 -42
- package/components/table/header-cell.d.ts +0 -10
- package/components/table/header-cell.js +59 -85
- package/components/table/header.d.ts +1 -23
- package/components/table/header.js +89 -126
- package/components/table/multitable.d.ts +0 -4
- package/components/table/multitable.js +83 -93
- package/components/table/row-with-focus-sensor.d.ts +2 -2
- package/components/table/row-with-focus-sensor.js +26 -60
- package/components/table/row.js +170 -235
- package/components/table/selection-adapter.js +2 -2
- package/components/table/selection-shortcuts-hoc.js +102 -126
- package/components/table/selection.js +150 -217
- package/components/table/simple-table.d.ts +0 -44
- package/components/table/simple-table.js +18 -59
- package/components/table/smart-table.d.ts +0 -48
- package/components/table/smart-table.js +41 -83
- package/components/table/table.d.ts +0 -2
- package/components/table/table.js +269 -377
- package/components/tabs/collapsible-more.d.ts +1 -9
- package/components/tabs/collapsible-more.js +47 -97
- package/components/tabs/collapsible-tab.js +32 -44
- package/components/tabs/collapsible-tabs.d.ts +2 -29
- package/components/tabs/collapsible-tabs.js +89 -161
- package/components/tabs/custom-item.d.ts +1 -7
- package/components/tabs/custom-item.js +4 -7
- package/components/tabs/dumb-tabs.d.ts +0 -11
- package/components/tabs/dumb-tabs.js +60 -104
- package/components/tabs/smart-tabs.d.ts +0 -6
- package/components/tabs/smart-tabs.js +29 -68
- package/components/tabs/tab-link.d.ts +0 -8
- package/components/tabs/tab-link.js +1 -4
- package/components/tabs/tab.d.ts +0 -8
- package/components/tabs/tab.js +14 -32
- package/components/tabs/tabs.js +1 -28
- package/components/tag/tag.d.ts +0 -19
- package/components/tag/tag.js +120 -179
- package/components/tags-input/tags-input.d.ts +7 -33
- package/components/tags-input/tags-input.js +224 -339
- package/components/tags-list/tags-list.d.ts +0 -13
- package/components/tags-list/tags-list.js +45 -74
- package/components/text/text.d.ts +0 -7
- package/components/text/text.js +27 -43
- package/components/toggle/toggle.d.ts +0 -15
- package/components/toggle/toggle.js +52 -77
- package/components/tooltip/tooltip.d.ts +4 -10
- package/components/tooltip/tooltip.js +105 -137
- package/components/user-agreement/service.d.ts +2 -1
- package/components/user-agreement/service.js +260 -405
- package/components/user-agreement/user-agreement.d.ts +0 -18
- package/components/user-agreement/user-agreement.js +92 -138
- package/components/user-card/card.d.ts +0 -35
- package/components/user-card/card.js +2 -27
- package/components/user-card/smart-user-card-tooltip.d.ts +0 -5
- package/components/user-card/smart-user-card-tooltip.js +52 -108
- package/components/user-card/tooltip.d.ts +0 -9
- package/components/user-card/tooltip.js +35 -74
- package/components/user-card/user-card.js +1 -26
- package/package.json +4 -6
- package/components/global/prop-types.d.ts +0 -4
- package/components/global/prop-types.js +0 -9
- package/components/global/react-render-adapter.d.ts +0 -1
- package/components/global/react-render-adapter.js +0 -6
- package/components/header/scrollable-section.js +0 -47
- package/components/header/tray-icon.d.ts +0 -1
- package/components/header/tray-icon.js +0 -26
- package/components/storage/storage__fallback.d.ts +0 -79
- package/components/storage/storage__fallback.js +0 -253
- /package/components/{header → scrollable-section}/scrollable-section.d.ts +0 -0
package/components/list/list.js
CHANGED
@@ -1,16 +1,7 @@
|
|
1
|
-
import { _ as _defineProperty,
|
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/
|
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
|
-
|
51
|
+
const _excluded = ["selectedLabel", "originalModel"];
|
78
52
|
function noop() {}
|
79
|
-
|
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
|
-
|
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
|
-
|
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(
|
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
|
-
|
101
|
-
|
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
|
-
|
113
|
-
|
82
|
+
class List extends Component {
|
83
|
+
constructor() {
|
114
84
|
var _this;
|
115
|
-
|
116
|
-
|
117
|
-
|
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(
|
132
|
-
_defineProperty(
|
133
|
-
_defineProperty(
|
134
|
-
_defineProperty(
|
135
|
-
_defineProperty(
|
136
|
-
_defineProperty(
|
137
|
-
|
138
|
-
return
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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(
|
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(
|
157
|
-
if (index === 0 || index ===
|
119
|
+
_defineProperty(this, "sizeCacheKey", index => {
|
120
|
+
if (index === 0 || index === this.props.data.length + 1) {
|
158
121
|
return Type.MARGIN;
|
159
122
|
}
|
160
|
-
|
161
|
-
|
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(
|
180
|
-
defaultHeight:
|
142
|
+
_defineProperty(this, "_cache", new CellMeasurerCache({
|
143
|
+
defaultHeight: this.defaultItemHeight(),
|
181
144
|
fixedWidth: true,
|
182
|
-
keyMapper:
|
183
|
-
}));
|
184
|
-
_defineProperty(_this, "_hasActivatableItems", memoizeOne(function (items) {
|
185
|
-
return items.some(isActivatable);
|
145
|
+
keyMapper: this.sizeCacheKey
|
186
146
|
}));
|
187
|
-
_defineProperty(
|
188
|
-
|
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
|
-
|
151
|
+
this.setState({
|
191
152
|
activeIndex: firstActivatableIndex,
|
192
|
-
activeItem:
|
153
|
+
activeItem: this.props.data[firstActivatableIndex],
|
193
154
|
needScrollToActive: true
|
194
155
|
});
|
195
156
|
}
|
196
157
|
});
|
197
|
-
_defineProperty(
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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(
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
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
|
-
|
189
|
+
this.moveHandler(newIndex, this.upHandler, e);
|
234
190
|
});
|
235
|
-
_defineProperty(
|
236
|
-
|
237
|
-
data
|
238
|
-
disableMoveOverflow
|
239
|
-
disableMoveDownOverflow
|
240
|
-
|
241
|
-
|
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
|
-
|
210
|
+
this.moveHandler(newIndex, this.downHandler, e);
|
254
211
|
});
|
255
|
-
_defineProperty(
|
256
|
-
|
212
|
+
_defineProperty(this, "homeHandler", e => {
|
213
|
+
this.moveHandler(0, this.downHandler, e);
|
257
214
|
});
|
258
|
-
_defineProperty(
|
259
|
-
|
215
|
+
_defineProperty(this, "endHandler", e => {
|
216
|
+
this.moveHandler(this.props.data.length - 1, this.upHandler, e);
|
260
217
|
});
|
261
|
-
_defineProperty(
|
262
|
-
if (
|
263
|
-
|
218
|
+
_defineProperty(this, "onDocumentMouseMove", () => {
|
219
|
+
if (this.state.disabledHover) {
|
220
|
+
this.setState({
|
264
221
|
disabledHover: false
|
265
222
|
});
|
266
223
|
}
|
267
224
|
});
|
268
|
-
_defineProperty(
|
269
|
-
|
270
|
-
if (!
|
271
|
-
|
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(
|
277
|
-
|
233
|
+
_defineProperty(this, "mouseHandler", () => {
|
234
|
+
this.setState({
|
278
235
|
scrolling: false
|
279
236
|
});
|
280
237
|
});
|
281
|
-
_defineProperty(
|
282
|
-
|
238
|
+
_defineProperty(this, "scrollHandler", () => {
|
239
|
+
this.setState({
|
283
240
|
scrolling: true
|
284
|
-
},
|
241
|
+
}, this.scrollEndHandler);
|
285
242
|
});
|
286
|
-
_defineProperty(
|
287
|
-
if (
|
288
|
-
|
289
|
-
|
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(
|
305
|
-
|
261
|
+
_defineProperty(this, "clearSelected", () => {
|
262
|
+
this.setState({
|
306
263
|
activeIndex: null,
|
307
264
|
needScrollToActive: false
|
308
265
|
});
|
309
266
|
});
|
310
|
-
_defineProperty(
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
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
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
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(
|
337
|
-
|
338
|
-
index =
|
339
|
-
style
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
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 ===
|
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
|
360
|
-
|
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
|
-
|
322
|
+
const itemProps = Object.assign({
|
370
323
|
rgItemType: DEFAULT_ITEM_TYPE
|
371
324
|
}, restProps);
|
372
325
|
itemKey = key || itemId;
|
373
|
-
itemProps.hover = realIndex ===
|
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 =
|
330
|
+
itemProps.onMouseOver = this.hoverHandler(realIndex);
|
378
331
|
itemProps.tabIndex = -1;
|
379
332
|
itemProps.scrolling = isScrolling;
|
380
|
-
|
381
|
-
if (
|
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 =
|
339
|
+
itemProps.onCheckboxChange = this.checkboxHandler(realIndex);
|
387
340
|
if (itemProps.compact == null) {
|
388
|
-
itemProps.compact =
|
341
|
+
itemProps.compact = this.props.compact;
|
389
342
|
}
|
390
|
-
|
391
|
-
|
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
|
-
|
352
|
+
this.addItemDataTestToProp(itemProps);
|
400
353
|
break;
|
401
354
|
case Type.ITEM:
|
402
355
|
ItemComponent = ListItem;
|
403
|
-
|
356
|
+
this.addItemDataTestToProp(itemProps);
|
404
357
|
break;
|
405
358
|
case Type.CUSTOM:
|
406
359
|
ItemComponent = ListCustom;
|
407
|
-
|
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:
|
374
|
+
cache: this._cache,
|
422
375
|
parent: parent,
|
423
376
|
rowIndex: index,
|
424
377
|
columnIndex: 0,
|
425
|
-
children:
|
426
|
-
|
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(
|
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(
|
452
|
-
|
406
|
+
_defineProperty(this, "virtualizedListRef", el => {
|
407
|
+
this.virtualizedList = el;
|
453
408
|
});
|
454
|
-
_defineProperty(
|
455
|
-
|
409
|
+
_defineProperty(this, "containerRef", el => {
|
410
|
+
this.container = el;
|
456
411
|
});
|
457
|
-
_defineProperty(
|
458
|
-
_defineProperty(
|
459
|
-
_defineProperty(
|
460
|
-
_defineProperty(
|
461
|
-
up:
|
462
|
-
down:
|
463
|
-
home:
|
464
|
-
end:
|
465
|
-
enter:
|
466
|
-
'meta+enter':
|
467
|
-
'ctrl+enter':
|
468
|
-
'command+enter':
|
469
|
-
'shift+enter':
|
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
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
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
|
-
|
493
|
-
|
494
|
-
|
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
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
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
|
-
|
549
|
-
|
550
|
-
|
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
|
-
|
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
|
-
|
559
|
-
|
560
|
-
|
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
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
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
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
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
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
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
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
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
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
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
|
-
|
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,
|