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