@jetbrains/ring-ui-built 7.0.65 → 7.0.70
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/anchor.js +12 -17
- package/components/_helpers/avatar-info.js +4 -5
- package/components/_helpers/button.classes.js +20 -21
- package/components/_helpers/caption.js +3 -3
- package/components/_helpers/card.js +26 -32
- package/components/_helpers/dialog-body-scroll-preventer.js +1 -2
- package/components/_helpers/icon-svg.js +9 -12
- package/components/_helpers/input.js +78 -86
- package/components/_helpers/loader-core.js +260 -0
- package/components/_helpers/query-assist-suggestions.js +0 -1
- package/components/_helpers/select-filter.js +19 -26
- package/components/_helpers/services-link.js +9 -12
- package/components/_helpers/sidebar.js +36 -44
- package/components/_helpers/tab-link.js +9 -11
- package/components/_helpers/theme.js +20 -24
- package/components/_helpers/title.js +12 -17
- package/components/alert/alert.js +41 -49
- package/components/alert/container.js +9 -12
- package/components/alert-service/alert-service.js +23 -32
- package/components/analytics/analytics-custom-plugin.js +12 -17
- package/components/analytics/analytics.js +1 -3
- package/components/auth/auth-core.js +128 -170
- package/components/auth/auth.js +3 -10
- package/components/auth/background-flow.js +5 -8
- package/components/auth/down-notification.js +9 -17
- package/components/auth/iframe-flow.js +13 -19
- package/components/auth/request-builder.js +4 -9
- package/components/auth/response-parser.js +9 -12
- package/components/auth/storage.js +12 -18
- package/components/auth/token-validator.js +19 -30
- package/components/auth/window-flow.js +22 -27
- package/components/auth-dialog/auth-dialog.js +40 -48
- package/components/auth-dialog-service/auth-dialog-service.js +10 -13
- package/components/avatar/avatar.figma.js +6 -6
- package/components/avatar/avatar.js +58 -59
- package/components/avatar/fallback-avatar.js +8 -11
- package/components/avatar-stack/avatar-stack.figma.js +10 -11
- package/components/avatar-stack/avatar-stack.js +25 -31
- package/components/banner/banner.js +0 -6
- package/components/breadcrumbs/breadcrumbs.figma.js +8 -6
- package/components/breadcrumbs/breadcrumbs.js +4 -5
- package/components/button/button.figma.js +15 -10
- package/components/button/button.js +59 -64
- package/components/button-group/button-group.js +11 -15
- package/components/button-group/caption.js +0 -1
- package/components/button-set/button-set.js +9 -12
- package/components/button-toolbar/button-toolbar.js +8 -11
- package/components/caret/caret.js +20 -28
- package/components/checkbox/checkbox-group.figma.js +8 -10
- package/components/checkbox/checkbox.figma.js +5 -5
- package/components/checkbox/checkbox.js +27 -35
- package/components/clipboard/clipboard-fallback.js +3 -3
- package/components/clipboard/clipboard.js +3 -16
- package/components/code/code.js +8 -14
- package/components/collapse/collapse-content.js +10 -15
- package/components/collapse/collapse-control.js +5 -7
- package/components/collapse/collapse.js +9 -11
- package/components/collapse/utils.js +1 -1
- package/components/confirm/confirm.js +17 -26
- package/components/confirm-service/confirm-service.js +30 -31
- package/components/content-layout/content-layout.js +21 -28
- package/components/content-layout/sidebar.js +0 -2
- package/components/contenteditable/contenteditable.js +23 -28
- package/components/control-help/control-help.js +8 -10
- package/components/control-label/control-label.js +12 -17
- package/components/data-list/data-list.js +57 -65
- package/components/data-list/data-list.mock.js +0 -4
- package/components/data-list/item.js +65 -72
- package/components/data-list/selection.js +11 -19
- package/components/data-list/title.js +0 -4
- package/components/date-picker/consts.js +3 -4
- package/components/date-picker/date-input.js +25 -33
- package/components/date-picker/date-picker.js +179 -193
- package/components/date-picker/date-popup.js +135 -127
- package/components/date-picker/day.d.ts +1 -1
- package/components/date-picker/day.js +24 -30
- package/components/date-picker/month-names.js +7 -12
- package/components/date-picker/month-slider.js +16 -22
- package/components/date-picker/month.js +3 -5
- package/components/date-picker/months.js +6 -6
- package/components/date-picker/weekdays.js +0 -1
- package/components/date-picker/years.js +20 -26
- package/components/dialog/dialog-body-scroll-preventer.js +0 -1
- package/components/dialog/dialog.js +73 -83
- package/components/dropdown/anchor.js +0 -4
- package/components/dropdown/dropdown.js +98 -114
- package/components/dropdown-menu/dropdown-menu.js +80 -79
- package/components/editable-heading/editable-heading.js +48 -54
- package/components/error-bubble/error-bubble.figma.js +4 -4
- package/components/error-bubble/error-bubble.js +9 -13
- package/components/error-message/error-message.js +1 -6
- package/components/footer/footer.js +11 -15
- package/components/global/compose-refs.js +1 -4
- package/components/global/compose.js +1 -4
- package/components/global/configuration.js +3 -3
- package/components/global/controls-height.js +0 -1
- package/components/global/create-stateful-context.js +10 -14
- package/components/global/data-tests.js +2 -10
- package/components/global/dom.js +6 -19
- package/components/global/focus-sensor-hoc.js +74 -87
- package/components/global/fuzzy-highlight.js +3 -8
- package/components/global/get-uid.js +1 -1
- package/components/global/inject-styles.js +5 -6
- package/components/global/listeners.js +2 -11
- package/components/global/memoize.js +0 -2
- package/components/global/normalize-indent.js +2 -6
- package/components/global/promise-with-timeout.js +4 -5
- package/components/global/react-dom-renderer.js +4 -9
- package/components/global/rerender-hoc.js +8 -11
- package/components/global/schedule-raf.js +1 -2
- package/components/global/theme.js +0 -5
- package/components/global/trivial-template-tag.js +1 -6
- package/components/global/url.js +2 -6
- package/components/global/use-event-callback.js +2 -3
- package/components/grid/col.js +7 -18
- package/components/grid/grid.js +9 -14
- package/components/grid/row.js +7 -11
- package/components/group/group.js +9 -12
- package/components/header/header-icon.js +8 -13
- package/components/header/header.js +16 -27
- package/components/header/links.js +7 -10
- package/components/header/logo.js +12 -16
- package/components/header/profile.js +73 -83
- package/components/header/services-link.js +0 -2
- package/components/header/services.js +32 -43
- package/components/header/smart-profile.js +44 -59
- package/components/header/smart-services.js +33 -45
- package/components/header/tray.js +8 -10
- package/components/heading/heading.js +27 -27
- package/components/http/http.js +120 -125
- package/components/http/http.mock.js +6 -10
- package/components/hub-source/hub-source-user.js +6 -13
- package/components/hub-source/hub-source-users-groups.js +8 -12
- package/components/hub-source/hub-source.js +8 -10
- package/components/i18n/i18n-context.js +4 -7
- package/components/i18n/i18n.js +5 -5
- package/components/icon/icon-svg.js +0 -4
- package/components/icon/icon.js +28 -32
- package/components/icon/index.js +0 -4
- package/components/input/input.figma.js +8 -8
- package/components/input/input.js +0 -4
- package/components/island/adaptive-island-hoc.js +19 -23
- package/components/island/content.js +70 -75
- package/components/island/header.js +21 -21
- package/components/island/island.js +11 -14
- package/components/link/clickable-link.js +30 -37
- package/components/link/link.js +27 -29
- package/components/list/list-custom.js +6 -11
- package/components/list/list-item.js +49 -56
- package/components/list/list-separator.js +0 -1
- package/components/list/list-title.js +0 -1
- package/components/list/list-users-groups-source.js +14 -22
- package/components/list/list.classes.js +8 -9
- package/components/list/list.js +387 -404
- package/components/loader/loader-core.js +2 -265
- package/components/loader/loader.d.ts +8 -0
- package/components/loader/loader.js +43 -29
- package/components/loader-inline/loader-inline.js +9 -12
- package/components/loader-screen/loader-screen.js +10 -14
- package/components/login-dialog/login-dialog.js +46 -54
- package/components/login-dialog/service.js +13 -15
- package/components/message/message.js +65 -79
- package/components/old-browsers-message/old-browsers-message-stop.js +0 -3
- package/components/old-browsers-message/old-browsers-message.js +1 -4
- package/components/old-browsers-message/white-list.js +5 -7
- package/components/pager/pager.js +73 -88
- package/components/panel/panel.js +9 -12
- package/components/permissions/permissions-cache.js +6 -8
- package/components/permissions/permissions.js +19 -21
- package/components/popup/popup.js +136 -145
- package/components/popup/popup.target.js +8 -10
- package/components/popup/position-css.js +19 -27
- package/components/popup/position.js +22 -28
- package/components/popup-menu/popup-menu.js +27 -37
- package/components/progress-bar/progress-bar.js +26 -32
- package/components/query-assist/query-assist-suggestions.js +0 -6
- package/components/query-assist/query-assist.js +432 -468
- package/components/radio/radio-item.js +30 -40
- package/components/radio/radio.js +6 -10
- package/components/scrollable-section/scrollable-section.js +7 -10
- package/components/select/select-filter.js +0 -6
- package/components/select/select-popup.js +155 -174
- package/components/select/select.js +464 -479
- package/components/shortcuts/core.js +40 -45
- package/components/shortcuts/shortcut-title.js +0 -1
- package/components/shortcuts/shortcuts-hoc.js +9 -15
- package/components/shortcuts/shortcuts.js +3 -5
- package/components/slider/slider.js +53 -66
- package/components/slider/slider.utils.js +1 -4
- package/components/storage/storage-local.js +2 -8
- package/components/storage/storage.js +0 -5
- package/components/style.css +1 -1
- package/components/tab-trap/tab-trap.js +21 -30
- package/components/table/cell.js +3 -4
- package/components/table/disable-hover-hoc.js +24 -28
- package/components/table/header-cell.js +30 -38
- package/components/table/header.js +20 -28
- package/components/table/multitable.js +81 -101
- package/components/table/row-with-focus-sensor.js +17 -28
- package/components/table/row.js +89 -99
- package/components/table/selection-adapter.js +0 -2
- package/components/table/selection-shortcuts-hoc.js +159 -161
- package/components/table/selection.js +23 -31
- package/components/table/simple-table.js +16 -22
- package/components/table/smart-table.js +19 -26
- package/components/table/table.js +137 -146
- package/components/tabs/collapsible-more.js +34 -47
- package/components/tabs/collapsible-tab.js +28 -33
- package/components/tabs/collapsible-tabs.js +18 -26
- package/components/tabs/custom-item.js +3 -6
- package/components/tabs/dumb-tabs.js +48 -64
- package/components/tabs/smart-tabs.js +14 -23
- package/components/tabs/tab-link.js +0 -2
- package/components/tabs/tab.js +0 -1
- package/components/tabs/tabs.js +0 -7
- package/components/tag/tag.js +30 -35
- package/components/tags-input/tags-input.js +192 -218
- package/components/tags-list/tags-list.js +26 -31
- package/components/text/text.js +16 -19
- package/components/toggle/toggle.js +19 -23
- package/components/tooltip/tooltip.js +110 -121
- package/components/upload/upload.js +19 -28
- package/components/user-agreement/service.js +247 -252
- package/components/user-agreement/toolbox.eula.js +160 -1
- package/components/user-agreement/user-agreement.js +23 -32
- package/components/user-card/card.js +0 -5
- package/components/user-card/smart-user-card-tooltip.js +41 -50
- package/components/user-card/tooltip.js +32 -38
- package/components/user-card/user-card.js +0 -5
- package/package.json +9 -3
- package/components/_helpers/_rollupPluginBabelHelpers.js +0 -72
package/components/list/list.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { _ as _defineProperty, a as _objectWithoutProperties, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import 'core-js/modules/es.symbol.description.js';
|
|
3
|
-
import 'core-js/modules/es.string.trim.js';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
1
|
import { Component, createElement } from 'react';
|
|
6
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
3
|
import classNames from 'classnames';
|
|
@@ -25,14 +21,12 @@ import ListSeparator from './list-separator.js';
|
|
|
25
21
|
import ListHint from './list-hint.js';
|
|
26
22
|
import { Type, Dimension, DEFAULT_ITEM_TYPE } from './consts.js';
|
|
27
23
|
import { s as styles } from '../_helpers/list.js';
|
|
28
|
-
import 'core-js/modules/es.regexp.exec.js';
|
|
29
24
|
import '../shortcuts/core.js';
|
|
30
25
|
import 'combokeys';
|
|
31
26
|
import '../global/sniffer.js';
|
|
32
27
|
import 'sniffr';
|
|
33
28
|
import '../avatar/avatar.js';
|
|
34
29
|
import '../global/url.js';
|
|
35
|
-
import 'core-js/modules/es.string.replace.js';
|
|
36
30
|
import '../_helpers/avatar-info.js';
|
|
37
31
|
import '../avatar/avatar-size.js';
|
|
38
32
|
import '../avatar/fallback-avatar.js';
|
|
@@ -50,7 +44,6 @@ import '../_helpers/link.js';
|
|
|
50
44
|
import './list.classes.js';
|
|
51
45
|
import '../global/get-event-key.js';
|
|
52
46
|
|
|
53
|
-
const _excluded = ["selectedLabel", "originalModel"];
|
|
54
47
|
function noop() {}
|
|
55
48
|
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.');
|
|
56
49
|
/**
|
|
@@ -69,7 +62,7 @@ function isActivatable(item) {
|
|
|
69
62
|
return item !== null && item !== undefined && !nonActivatableTypes.includes(item.rgItemType) && !item.disabled;
|
|
70
63
|
}
|
|
71
64
|
function getDataHash(data) {
|
|
72
|
-
return data.map(it =>
|
|
65
|
+
return data.map(it => `${it.key}-${it.disabled}`).join('-');
|
|
73
66
|
}
|
|
74
67
|
const shouldActivateFirstItem = props => props.activateFirstItem || props.activateSingleItem && props.data.length === 1;
|
|
75
68
|
const ActiveItemContext = createStatefulContext(undefined, 'ActiveItem');
|
|
@@ -82,319 +75,33 @@ const ActiveItemContext = createStatefulContext(undefined, 'ActiveItem');
|
|
|
82
75
|
* Displays a list of items.
|
|
83
76
|
*/
|
|
84
77
|
class List extends Component {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const isFirst = index === 1;
|
|
113
|
-
switch (item.rgItemType) {
|
|
114
|
-
case Type.SEPARATOR:
|
|
115
|
-
case Type.TITLE:
|
|
116
|
-
return "".concat(item.rgItemType).concat(isFirst ? '_first' : '').concat(item.description ? '_desc' : '');
|
|
117
|
-
case Type.MARGIN:
|
|
118
|
-
return Type.MARGIN;
|
|
119
|
-
case Type.CUSTOM:
|
|
120
|
-
return "".concat(Type.CUSTOM, "_").concat(item.key);
|
|
121
|
-
case Type.ITEM:
|
|
122
|
-
case Type.LINK:
|
|
123
|
-
default:
|
|
124
|
-
if (item.details) {
|
|
125
|
-
return "".concat(Type.ITEM, "_").concat(item.details);
|
|
126
|
-
}
|
|
127
|
-
return Type.ITEM;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
_defineProperty(this, "_cache", new CellMeasurerCache({
|
|
131
|
-
defaultHeight: this.defaultItemHeight(),
|
|
132
|
-
fixedWidth: true,
|
|
133
|
-
keyMapper: this.sizeCacheKey
|
|
134
|
-
}));
|
|
135
|
-
_defineProperty(this, "_hasActivatableItems", memoizeOne(items => items.some(isActivatable)));
|
|
136
|
-
_defineProperty(this, "activateFirst", () => {
|
|
137
|
-
const firstActivatableIndex = this.props.data.findIndex(isActivatable);
|
|
138
|
-
if (firstActivatableIndex >= 0) {
|
|
139
|
-
this.setState({
|
|
140
|
-
activeIndex: firstActivatableIndex,
|
|
141
|
-
activeItem: this.props.data[firstActivatableIndex],
|
|
142
|
-
needScrollToActive: true
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
_defineProperty(this, "selectHandler", memoize(index => function (event) {
|
|
147
|
-
let tryKeepOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
148
|
-
const item = _this.props.data[index];
|
|
149
|
-
if (!_this.props.useMouseUp && item.onClick) {
|
|
150
|
-
item.onClick(item, event);
|
|
151
|
-
} else if (_this.props.useMouseUp && item.onMouseUp) {
|
|
152
|
-
item.onMouseUp(item, event);
|
|
153
|
-
}
|
|
154
|
-
if (_this.props.onSelect) {
|
|
155
|
-
_this.props.onSelect(item, event, {
|
|
156
|
-
tryKeepOpen
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}));
|
|
160
|
-
_defineProperty(this, "checkboxHandler", memoize(index => event => this.selectHandler(index)(event, true)));
|
|
161
|
-
_defineProperty(this, "upHandler", e => {
|
|
162
|
-
const {
|
|
163
|
-
data,
|
|
164
|
-
disableMoveOverflow
|
|
165
|
-
} = this.props;
|
|
166
|
-
const index = this.state.activeIndex;
|
|
167
|
-
let newIndex;
|
|
168
|
-
if (index === null || index === 0) {
|
|
169
|
-
if (!disableMoveOverflow) {
|
|
170
|
-
newIndex = data.length - 1;
|
|
171
|
-
} else {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
newIndex = index - 1;
|
|
176
|
-
}
|
|
177
|
-
this.moveHandler(newIndex, this.upHandler, e);
|
|
178
|
-
});
|
|
179
|
-
_defineProperty(this, "downHandler", e => {
|
|
180
|
-
const {
|
|
181
|
-
data,
|
|
182
|
-
disableMoveOverflow,
|
|
183
|
-
disableMoveDownOverflow
|
|
184
|
-
} = this.props;
|
|
185
|
-
const index = this.state.activeIndex;
|
|
186
|
-
let newIndex;
|
|
187
|
-
if (index === null) {
|
|
188
|
-
newIndex = 0;
|
|
189
|
-
} else if (index + 1 === data.length) {
|
|
190
|
-
if (!disableMoveOverflow && !disableMoveDownOverflow) {
|
|
191
|
-
newIndex = 0;
|
|
192
|
-
} else {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
} else {
|
|
196
|
-
newIndex = index + 1;
|
|
197
|
-
}
|
|
198
|
-
this.moveHandler(newIndex, this.downHandler, e);
|
|
199
|
-
});
|
|
200
|
-
_defineProperty(this, "homeHandler", e => {
|
|
201
|
-
this.moveHandler(0, this.downHandler, e);
|
|
202
|
-
});
|
|
203
|
-
_defineProperty(this, "endHandler", e => {
|
|
204
|
-
this.moveHandler(this.props.data.length - 1, this.upHandler, e);
|
|
205
|
-
});
|
|
206
|
-
_defineProperty(this, "mouseHandler", () => {
|
|
207
|
-
this.setState({
|
|
208
|
-
scrolling: false
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
_defineProperty(this, "scrollHandler", () => {
|
|
212
|
-
this.setState({
|
|
213
|
-
scrolling: true
|
|
214
|
-
}, this.scrollEndHandler);
|
|
215
|
-
});
|
|
216
|
-
_defineProperty(this, "enterHandler", (event, shortcut) => {
|
|
217
|
-
if (this.state.activeIndex !== null) {
|
|
218
|
-
const item = this.props.data[this.state.activeIndex];
|
|
219
|
-
this.selectHandler(this.state.activeIndex)(event);
|
|
220
|
-
if (item.href && !event.defaultPrevented) {
|
|
221
|
-
if (shortcut !== null && shortcut !== undefined && ['command+enter', 'ctrl+enter'].includes(shortcut)) {
|
|
222
|
-
window.open(item.href, '_blank');
|
|
223
|
-
} else if (shortcut === 'shift+enter') {
|
|
224
|
-
window.open(item.href);
|
|
225
|
-
} else {
|
|
226
|
-
window.location.href = item.href;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return false; // do not propagate event
|
|
230
|
-
}
|
|
231
|
-
return true; // propagate event to the parent component (e.g., QueryAssist)
|
|
232
|
-
});
|
|
233
|
-
_defineProperty(this, "scrollEndHandler", () => this.scheduleScrollListener(() => {
|
|
234
|
-
const innerContainer = this.inner;
|
|
235
|
-
if (innerContainer) {
|
|
236
|
-
const maxScrollingPosition = innerContainer.scrollHeight;
|
|
237
|
-
const sensitivity = this.defaultItemHeight() / 2;
|
|
238
|
-
const currentScrollingPosition = innerContainer.scrollTop + innerContainer.clientHeight + sensitivity;
|
|
239
|
-
const scrolledToBottom = maxScrollingPosition > 0 && currentScrollingPosition >= maxScrollingPosition;
|
|
240
|
-
if (!this.unmounted) {
|
|
241
|
-
this.setState({
|
|
242
|
-
scrolledToBottom
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
if (scrolledToBottom) {
|
|
246
|
-
this.props.onScrollToBottom();
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}));
|
|
250
|
-
_defineProperty(this, "checkOverflow", () => {
|
|
251
|
-
if (this.inner) {
|
|
252
|
-
this.setState({
|
|
253
|
-
hasOverflow: this.inner.scrollHeight - this.inner.clientHeight > 1
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
// eslint-disable-next-line complexity
|
|
258
|
-
_defineProperty(this, "renderItem", _ref => {
|
|
259
|
-
let {
|
|
260
|
-
index = 1,
|
|
261
|
-
style,
|
|
262
|
-
isScrolling = false,
|
|
263
|
-
parent,
|
|
264
|
-
key
|
|
265
|
-
} = _ref;
|
|
266
|
-
let itemKey;
|
|
267
|
-
let el;
|
|
268
|
-
const realIndex = index - 1;
|
|
269
|
-
const item = this.props.data[realIndex];
|
|
270
|
-
const itemId = this.getId(item);
|
|
271
|
-
const isActive = realIndex === this.state.activeIndex;
|
|
272
|
-
// top and bottom margins
|
|
273
|
-
if (index === 0 || index === this.props.data.length + 1 || item.rgItemType === Type.MARGIN) {
|
|
274
|
-
itemKey = key || "".concat(Type.MARGIN, "_").concat(index);
|
|
275
|
-
el = jsx("div", {
|
|
276
|
-
style: {
|
|
277
|
-
height: Dimension.MARGIN
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
} else {
|
|
281
|
-
// Hack around SelectNG implementation
|
|
282
|
-
const {
|
|
283
|
-
selectedLabel,
|
|
284
|
-
originalModel
|
|
285
|
-
} = item,
|
|
286
|
-
restProps = _objectWithoutProperties(item, _excluded);
|
|
287
|
-
const cleanedProps = restProps;
|
|
288
|
-
if (cleanedProps.url) {
|
|
289
|
-
cleanedProps.href = cleanedProps.url;
|
|
290
|
-
}
|
|
291
|
-
if (cleanedProps.href) {
|
|
292
|
-
cleanedProps.rgItemType = Type.LINK;
|
|
293
|
-
}
|
|
294
|
-
cleanedProps.description = typeof cleanedProps.description === 'string' ? cleanedProps.description.trim() : cleanedProps.description;
|
|
295
|
-
const itemProps = Object.assign({
|
|
296
|
-
rgItemType: DEFAULT_ITEM_TYPE
|
|
297
|
-
}, restProps);
|
|
298
|
-
itemKey = key || itemId;
|
|
299
|
-
itemProps.hover = isActive;
|
|
300
|
-
if (itemProps.hoverClassName !== null && itemProps.hoverClassName !== undefined && itemProps.hover) {
|
|
301
|
-
itemProps.className = classNames(itemProps.className, itemProps.hoverClassName);
|
|
302
|
-
}
|
|
303
|
-
itemProps.tabIndex = -1;
|
|
304
|
-
itemProps.scrolling = isScrolling;
|
|
305
|
-
const selectHandler = this.selectHandler(realIndex);
|
|
306
|
-
if (this.props.useMouseUp) {
|
|
307
|
-
itemProps.onMouseUp = selectHandler;
|
|
308
|
-
} else {
|
|
309
|
-
itemProps.onClick = selectHandler;
|
|
310
|
-
}
|
|
311
|
-
itemProps.onCheckboxChange = this.checkboxHandler(realIndex);
|
|
312
|
-
if (itemProps.compact === null || itemProps.compact === undefined) {
|
|
313
|
-
itemProps.compact = this.props.compact;
|
|
314
|
-
}
|
|
315
|
-
let ItemComponent;
|
|
316
|
-
const isFirst = index === 1;
|
|
317
|
-
switch (itemProps.rgItemType) {
|
|
318
|
-
case Type.SEPARATOR:
|
|
319
|
-
ItemComponent = ListSeparator;
|
|
320
|
-
itemProps.isFirst = isFirst;
|
|
321
|
-
break;
|
|
322
|
-
case Type.LINK:
|
|
323
|
-
case Type.ITEM:
|
|
324
|
-
ItemComponent = ListItem;
|
|
325
|
-
this.addItemDataTestToProp(itemProps);
|
|
326
|
-
break;
|
|
327
|
-
case Type.CUSTOM:
|
|
328
|
-
ItemComponent = ListCustom;
|
|
329
|
-
this.addItemDataTestToProp(itemProps);
|
|
330
|
-
break;
|
|
331
|
-
case Type.TITLE:
|
|
332
|
-
itemProps.isFirst = isFirst;
|
|
333
|
-
ItemComponent = ListTitle;
|
|
334
|
-
break;
|
|
335
|
-
default:
|
|
336
|
-
throw new Error("Unknown menu element type: ".concat(itemProps.rgItemType));
|
|
337
|
-
}
|
|
338
|
-
el = /*#__PURE__*/createElement(ItemComponent, _objectSpread2(_objectSpread2({}, itemProps), {}, {
|
|
339
|
-
key: itemProps.key
|
|
340
|
-
}));
|
|
341
|
-
}
|
|
342
|
-
return parent ? jsx(CellMeasurer, {
|
|
343
|
-
cache: this._cache,
|
|
344
|
-
parent: parent,
|
|
345
|
-
rowIndex: index,
|
|
346
|
-
columnIndex: 0,
|
|
347
|
-
children: _ref2 => {
|
|
348
|
-
let {
|
|
349
|
-
registerChild
|
|
350
|
-
} = _ref2;
|
|
351
|
-
return jsx("div", {
|
|
352
|
-
ref: registerChild,
|
|
353
|
-
style: style,
|
|
354
|
-
role: 'row',
|
|
355
|
-
"aria-selected": isActive,
|
|
356
|
-
id: itemId,
|
|
357
|
-
children: jsx("div", {
|
|
358
|
-
role: 'cell',
|
|
359
|
-
children: el
|
|
360
|
-
})
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
}, itemKey) : jsx("div", {
|
|
364
|
-
role: 'row',
|
|
365
|
-
"aria-selected": isActive,
|
|
366
|
-
id: itemId,
|
|
367
|
-
children: jsx("div", {
|
|
368
|
-
role: 'cell',
|
|
369
|
-
children: el
|
|
370
|
-
})
|
|
371
|
-
}, itemKey);
|
|
372
|
-
});
|
|
373
|
-
_defineProperty(this, "addItemDataTestToProp", props => {
|
|
374
|
-
props['data-test'] = joinDataTestAttributes('ring-list-item', props['data-test']);
|
|
375
|
-
return props;
|
|
376
|
-
});
|
|
377
|
-
_defineProperty(this, "virtualizedListRef", el => {
|
|
378
|
-
this.virtualizedList = el;
|
|
379
|
-
});
|
|
380
|
-
_defineProperty(this, "containerRef", el => {
|
|
381
|
-
this.container = el;
|
|
382
|
-
});
|
|
383
|
-
_defineProperty(this, "_inner", void 0);
|
|
384
|
-
_defineProperty(this, "id", getUID('list-'));
|
|
385
|
-
_defineProperty(this, "shortcutsScope", this.id);
|
|
386
|
-
_defineProperty(this, "shortcutsMap", {
|
|
387
|
-
up: this.upHandler,
|
|
388
|
-
down: this.downHandler,
|
|
389
|
-
home: this.homeHandler,
|
|
390
|
-
end: this.endHandler,
|
|
391
|
-
enter: this.enterHandler,
|
|
392
|
-
'meta+enter': this.enterHandler,
|
|
393
|
-
'ctrl+enter': this.enterHandler,
|
|
394
|
-
'command+enter': this.enterHandler,
|
|
395
|
-
'shift+enter': this.enterHandler
|
|
396
|
-
});
|
|
397
|
-
}
|
|
78
|
+
static defaultProps = {
|
|
79
|
+
data: [],
|
|
80
|
+
restoreActiveIndex: false,
|
|
81
|
+
// restore active item using its "key" property
|
|
82
|
+
activateSingleItem: false,
|
|
83
|
+
// if there is only one item, activate it
|
|
84
|
+
activateFirstItem: false,
|
|
85
|
+
// if there no active items, activate the first one
|
|
86
|
+
onMouseOut: noop,
|
|
87
|
+
onSelect: noop,
|
|
88
|
+
onScrollToBottom: noop,
|
|
89
|
+
onResize: noop,
|
|
90
|
+
shortcuts: false,
|
|
91
|
+
renderOptimization: true,
|
|
92
|
+
disableMoveDownOverflow: false,
|
|
93
|
+
ariaLabel: 'List'
|
|
94
|
+
};
|
|
95
|
+
state = {
|
|
96
|
+
activeIndex: null,
|
|
97
|
+
prevActiveIndex: null,
|
|
98
|
+
prevData: [],
|
|
99
|
+
activeItem: null,
|
|
100
|
+
needScrollToActive: false,
|
|
101
|
+
scrolling: false,
|
|
102
|
+
hasOverflow: false,
|
|
103
|
+
scrolledToBottom: false
|
|
104
|
+
};
|
|
398
105
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
399
106
|
const {
|
|
400
107
|
prevActiveIndex,
|
|
@@ -443,14 +150,13 @@ class List extends Component {
|
|
|
443
150
|
return Object.keys(nextProps).some(key => !Object.is(nextProps[key], this.props[key])) || Object.keys(nextState).some(key => nextState[key] !== this.state[key]);
|
|
444
151
|
}
|
|
445
152
|
componentDidUpdate(prevProps) {
|
|
446
|
-
var _prevProps$data$activ, _this$props$data$acti;
|
|
447
153
|
if (this.virtualizedList && prevProps.data !== this.props.data) {
|
|
448
154
|
this.virtualizedList.recomputeRowHeights();
|
|
449
155
|
}
|
|
450
156
|
const {
|
|
451
157
|
activeIndex
|
|
452
158
|
} = this.state;
|
|
453
|
-
const isActiveItemRetainedPosition = activeIndex ?
|
|
159
|
+
const isActiveItemRetainedPosition = activeIndex ? prevProps.data[activeIndex]?.key === this.props.data[activeIndex]?.key : false;
|
|
454
160
|
if ((this.props.activeIndex === null || this.props.activeIndex === undefined) && getDataHash(this.props.data) !== getDataHash(prevProps.data) && shouldActivateFirstItem(this.props) && !isActiveItemRetainedPosition) {
|
|
455
161
|
this.activateFirst();
|
|
456
162
|
}
|
|
@@ -459,9 +165,120 @@ class List extends Component {
|
|
|
459
165
|
componentWillUnmount() {
|
|
460
166
|
this.unmounted = true;
|
|
461
167
|
}
|
|
168
|
+
scheduleScrollListener = scheduleRAF();
|
|
169
|
+
static isItemType = isItemType;
|
|
170
|
+
static ListHint = ListHint;
|
|
171
|
+
static ListProps = {
|
|
172
|
+
Type,
|
|
173
|
+
Dimension
|
|
174
|
+
};
|
|
175
|
+
virtualizedList;
|
|
176
|
+
unmounted;
|
|
177
|
+
container;
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
179
|
+
_bufferSize = 10; // keep X items above and below of the visible area
|
|
180
|
+
// reuse size cache for similar items
|
|
181
|
+
sizeCacheKey = index => {
|
|
182
|
+
if (index === 0 || index === this.props.data.length + 1) {
|
|
183
|
+
return Type.MARGIN;
|
|
184
|
+
}
|
|
185
|
+
const item = this.props.data[index - 1];
|
|
186
|
+
const isFirst = index === 1;
|
|
187
|
+
switch (item.rgItemType) {
|
|
188
|
+
case Type.SEPARATOR:
|
|
189
|
+
case Type.TITLE:
|
|
190
|
+
return `${item.rgItemType}${isFirst ? '_first' : ''}${item.description ? '_desc' : ''}`;
|
|
191
|
+
case Type.MARGIN:
|
|
192
|
+
return Type.MARGIN;
|
|
193
|
+
case Type.CUSTOM:
|
|
194
|
+
return `${Type.CUSTOM}_${item.key}`;
|
|
195
|
+
case Type.ITEM:
|
|
196
|
+
case Type.LINK:
|
|
197
|
+
default:
|
|
198
|
+
if (item.details) {
|
|
199
|
+
return `${Type.ITEM}_${item.details}`;
|
|
200
|
+
}
|
|
201
|
+
return Type.ITEM;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
_cache = new CellMeasurerCache({
|
|
205
|
+
defaultHeight: this.defaultItemHeight(),
|
|
206
|
+
fixedWidth: true,
|
|
207
|
+
keyMapper: this.sizeCacheKey
|
|
208
|
+
});
|
|
209
|
+
_hasActivatableItems = memoizeOne(items => items.some(isActivatable));
|
|
462
210
|
hasActivatableItems() {
|
|
463
211
|
return this._hasActivatableItems(this.props.data);
|
|
464
212
|
}
|
|
213
|
+
activateFirst = () => {
|
|
214
|
+
const firstActivatableIndex = this.props.data.findIndex(isActivatable);
|
|
215
|
+
if (firstActivatableIndex >= 0) {
|
|
216
|
+
this.setState({
|
|
217
|
+
activeIndex: firstActivatableIndex,
|
|
218
|
+
activeItem: this.props.data[firstActivatableIndex],
|
|
219
|
+
needScrollToActive: true
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
selectHandler = memoize(index => (event, tryKeepOpen = false) => {
|
|
224
|
+
const item = this.props.data[index];
|
|
225
|
+
if (!this.props.useMouseUp && item.onClick) {
|
|
226
|
+
item.onClick(item, event);
|
|
227
|
+
} else if (this.props.useMouseUp && item.onMouseUp) {
|
|
228
|
+
item.onMouseUp(item, event);
|
|
229
|
+
}
|
|
230
|
+
if (this.props.onSelect) {
|
|
231
|
+
this.props.onSelect(item, event, {
|
|
232
|
+
tryKeepOpen
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
checkboxHandler = memoize(index => event => this.selectHandler(index)(event, true));
|
|
237
|
+
upHandler = e => {
|
|
238
|
+
const {
|
|
239
|
+
data,
|
|
240
|
+
disableMoveOverflow
|
|
241
|
+
} = this.props;
|
|
242
|
+
const index = this.state.activeIndex;
|
|
243
|
+
let newIndex;
|
|
244
|
+
if (index === null || index === 0) {
|
|
245
|
+
if (!disableMoveOverflow) {
|
|
246
|
+
newIndex = data.length - 1;
|
|
247
|
+
} else {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
newIndex = index - 1;
|
|
252
|
+
}
|
|
253
|
+
this.moveHandler(newIndex, this.upHandler, e);
|
|
254
|
+
};
|
|
255
|
+
downHandler = e => {
|
|
256
|
+
const {
|
|
257
|
+
data,
|
|
258
|
+
disableMoveOverflow,
|
|
259
|
+
disableMoveDownOverflow
|
|
260
|
+
} = this.props;
|
|
261
|
+
const index = this.state.activeIndex;
|
|
262
|
+
let newIndex;
|
|
263
|
+
if (index === null) {
|
|
264
|
+
newIndex = 0;
|
|
265
|
+
} else if (index + 1 === data.length) {
|
|
266
|
+
if (!disableMoveOverflow && !disableMoveDownOverflow) {
|
|
267
|
+
newIndex = 0;
|
|
268
|
+
} else {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
newIndex = index + 1;
|
|
273
|
+
}
|
|
274
|
+
this.moveHandler(newIndex, this.downHandler, e);
|
|
275
|
+
};
|
|
276
|
+
homeHandler = e => {
|
|
277
|
+
this.moveHandler(0, this.downHandler, e);
|
|
278
|
+
};
|
|
279
|
+
endHandler = e => {
|
|
280
|
+
this.moveHandler(this.props.data.length - 1, this.upHandler, e);
|
|
281
|
+
};
|
|
465
282
|
moveHandler(index, retryCallback, e) {
|
|
466
283
|
let correctedIndex;
|
|
467
284
|
if (this.props.data.length === 0 || !this.hasActivatableItems()) {
|
|
@@ -487,6 +304,33 @@ class List extends Component {
|
|
|
487
304
|
}
|
|
488
305
|
});
|
|
489
306
|
}
|
|
307
|
+
mouseHandler = () => {
|
|
308
|
+
this.setState({
|
|
309
|
+
scrolling: false
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
scrollHandler = () => {
|
|
313
|
+
this.setState({
|
|
314
|
+
scrolling: true
|
|
315
|
+
}, this.scrollEndHandler);
|
|
316
|
+
};
|
|
317
|
+
enterHandler = (event, shortcut) => {
|
|
318
|
+
if (this.state.activeIndex !== null) {
|
|
319
|
+
const item = this.props.data[this.state.activeIndex];
|
|
320
|
+
this.selectHandler(this.state.activeIndex)(event);
|
|
321
|
+
if (item.href && !event.defaultPrevented) {
|
|
322
|
+
if (shortcut !== null && shortcut !== undefined && ['command+enter', 'ctrl+enter'].includes(shortcut)) {
|
|
323
|
+
window.open(item.href, '_blank');
|
|
324
|
+
} else if (shortcut === 'shift+enter') {
|
|
325
|
+
window.open(item.href);
|
|
326
|
+
} else {
|
|
327
|
+
window.location.href = item.href;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return false; // do not propagate event
|
|
331
|
+
}
|
|
332
|
+
return true; // propagate event to the parent component (e.g., QueryAssist)
|
|
333
|
+
};
|
|
490
334
|
getFirst() {
|
|
491
335
|
return this.props.data.find(item => item.rgItemType === Type.ITEM || item.rgItemType === Type.CUSTOM);
|
|
492
336
|
}
|
|
@@ -496,6 +340,30 @@ class List extends Component {
|
|
|
496
340
|
defaultItemHeight() {
|
|
497
341
|
return this.props.compact ? Dimension.COMPACT_ITEM_HEIGHT : Dimension.ITEM_HEIGHT;
|
|
498
342
|
}
|
|
343
|
+
scrollEndHandler = () => this.scheduleScrollListener(() => {
|
|
344
|
+
const innerContainer = this.inner;
|
|
345
|
+
if (innerContainer) {
|
|
346
|
+
const maxScrollingPosition = innerContainer.scrollHeight;
|
|
347
|
+
const sensitivity = this.defaultItemHeight() / 2;
|
|
348
|
+
const currentScrollingPosition = innerContainer.scrollTop + innerContainer.clientHeight + sensitivity;
|
|
349
|
+
const scrolledToBottom = maxScrollingPosition > 0 && currentScrollingPosition >= maxScrollingPosition;
|
|
350
|
+
if (!this.unmounted) {
|
|
351
|
+
this.setState({
|
|
352
|
+
scrolledToBottom
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
if (scrolledToBottom) {
|
|
356
|
+
this.props.onScrollToBottom();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
checkOverflow = () => {
|
|
361
|
+
if (this.inner) {
|
|
362
|
+
this.setState({
|
|
363
|
+
hasOverflow: this.inner.scrollHeight - this.inner.clientHeight > 1
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
};
|
|
499
367
|
getVisibleListHeight(maxHeight) {
|
|
500
368
|
return maxHeight - this.defaultItemHeight() - Dimension.INNER_PADDING;
|
|
501
369
|
}
|
|
@@ -504,77 +372,198 @@ class List extends Component {
|
|
|
504
372
|
const isString = typeof identificator === 'string' || identificator instanceof String;
|
|
505
373
|
if (identificator && !isString) {
|
|
506
374
|
warnEmptyKey();
|
|
507
|
-
return
|
|
375
|
+
return `${itemProps.rgItemType}_${JSON.stringify(identificator)}`;
|
|
508
376
|
}
|
|
509
|
-
return
|
|
377
|
+
return `${itemProps.rgItemType}_${identificator}`;
|
|
510
378
|
}
|
|
511
379
|
getId(item) {
|
|
512
|
-
return item !== null && item !== undefined ?
|
|
380
|
+
return item !== null && item !== undefined ? `${this.id}:${item.key || this._deprecatedGenerateKeyFromContent(item)}` : undefined;
|
|
513
381
|
}
|
|
382
|
+
// eslint-disable-next-line complexity
|
|
383
|
+
renderItem = ({
|
|
384
|
+
index = 1,
|
|
385
|
+
style,
|
|
386
|
+
isScrolling = false,
|
|
387
|
+
parent,
|
|
388
|
+
key
|
|
389
|
+
}) => {
|
|
390
|
+
let itemKey;
|
|
391
|
+
let el;
|
|
392
|
+
const realIndex = index - 1;
|
|
393
|
+
const item = this.props.data[realIndex];
|
|
394
|
+
const itemId = this.getId(item);
|
|
395
|
+
const isActive = realIndex === this.state.activeIndex;
|
|
396
|
+
// top and bottom margins
|
|
397
|
+
if (index === 0 || index === this.props.data.length + 1 || item.rgItemType === Type.MARGIN) {
|
|
398
|
+
itemKey = key || `${Type.MARGIN}_${index}`;
|
|
399
|
+
el = jsx("div", {
|
|
400
|
+
style: {
|
|
401
|
+
height: Dimension.MARGIN
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
} else {
|
|
405
|
+
// Hack around SelectNG implementation
|
|
406
|
+
const {
|
|
407
|
+
selectedLabel,
|
|
408
|
+
originalModel,
|
|
409
|
+
...restProps
|
|
410
|
+
} = item;
|
|
411
|
+
const cleanedProps = restProps;
|
|
412
|
+
if (cleanedProps.url) {
|
|
413
|
+
cleanedProps.href = cleanedProps.url;
|
|
414
|
+
}
|
|
415
|
+
if (cleanedProps.href) {
|
|
416
|
+
cleanedProps.rgItemType = Type.LINK;
|
|
417
|
+
}
|
|
418
|
+
cleanedProps.description = typeof cleanedProps.description === 'string' ? cleanedProps.description.trim() : cleanedProps.description;
|
|
419
|
+
const itemProps = Object.assign({
|
|
420
|
+
rgItemType: DEFAULT_ITEM_TYPE
|
|
421
|
+
}, restProps);
|
|
422
|
+
itemKey = key || itemId;
|
|
423
|
+
itemProps.hover = isActive;
|
|
424
|
+
if (itemProps.hoverClassName !== null && itemProps.hoverClassName !== undefined && itemProps.hover) {
|
|
425
|
+
itemProps.className = classNames(itemProps.className, itemProps.hoverClassName);
|
|
426
|
+
}
|
|
427
|
+
itemProps.tabIndex = -1;
|
|
428
|
+
itemProps.scrolling = isScrolling;
|
|
429
|
+
const selectHandler = this.selectHandler(realIndex);
|
|
430
|
+
if (this.props.useMouseUp) {
|
|
431
|
+
itemProps.onMouseUp = selectHandler;
|
|
432
|
+
} else {
|
|
433
|
+
itemProps.onClick = selectHandler;
|
|
434
|
+
}
|
|
435
|
+
itemProps.onCheckboxChange = this.checkboxHandler(realIndex);
|
|
436
|
+
if (itemProps.compact === null || itemProps.compact === undefined) {
|
|
437
|
+
itemProps.compact = this.props.compact;
|
|
438
|
+
}
|
|
439
|
+
let ItemComponent;
|
|
440
|
+
const isFirst = index === 1;
|
|
441
|
+
switch (itemProps.rgItemType) {
|
|
442
|
+
case Type.SEPARATOR:
|
|
443
|
+
ItemComponent = ListSeparator;
|
|
444
|
+
itemProps.isFirst = isFirst;
|
|
445
|
+
break;
|
|
446
|
+
case Type.LINK:
|
|
447
|
+
case Type.ITEM:
|
|
448
|
+
ItemComponent = ListItem;
|
|
449
|
+
this.addItemDataTestToProp(itemProps);
|
|
450
|
+
break;
|
|
451
|
+
case Type.CUSTOM:
|
|
452
|
+
ItemComponent = ListCustom;
|
|
453
|
+
this.addItemDataTestToProp(itemProps);
|
|
454
|
+
break;
|
|
455
|
+
case Type.TITLE:
|
|
456
|
+
itemProps.isFirst = isFirst;
|
|
457
|
+
ItemComponent = ListTitle;
|
|
458
|
+
break;
|
|
459
|
+
default:
|
|
460
|
+
throw new Error(`Unknown menu element type: ${itemProps.rgItemType}`);
|
|
461
|
+
}
|
|
462
|
+
el = /*#__PURE__*/createElement(ItemComponent, {
|
|
463
|
+
...itemProps,
|
|
464
|
+
key: itemProps.key
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
return parent ? jsx(CellMeasurer, {
|
|
468
|
+
cache: this._cache,
|
|
469
|
+
parent: parent,
|
|
470
|
+
rowIndex: index,
|
|
471
|
+
columnIndex: 0,
|
|
472
|
+
children: ({
|
|
473
|
+
registerChild
|
|
474
|
+
}) => jsx("div", {
|
|
475
|
+
ref: registerChild,
|
|
476
|
+
style: style,
|
|
477
|
+
role: 'row',
|
|
478
|
+
"aria-selected": isActive,
|
|
479
|
+
id: itemId,
|
|
480
|
+
children: jsx("div", {
|
|
481
|
+
role: 'cell',
|
|
482
|
+
children: el
|
|
483
|
+
})
|
|
484
|
+
})
|
|
485
|
+
}, itemKey) : jsx("div", {
|
|
486
|
+
role: 'row',
|
|
487
|
+
"aria-selected": isActive,
|
|
488
|
+
id: itemId,
|
|
489
|
+
children: jsx("div", {
|
|
490
|
+
role: 'cell',
|
|
491
|
+
children: el
|
|
492
|
+
})
|
|
493
|
+
}, itemKey);
|
|
494
|
+
};
|
|
495
|
+
addItemDataTestToProp = props => {
|
|
496
|
+
props['data-test'] = joinDataTestAttributes('ring-list-item', props['data-test']);
|
|
497
|
+
return props;
|
|
498
|
+
};
|
|
499
|
+
virtualizedListRef = el => {
|
|
500
|
+
this.virtualizedList = el;
|
|
501
|
+
};
|
|
502
|
+
containerRef = el => {
|
|
503
|
+
this.container = el;
|
|
504
|
+
};
|
|
505
|
+
_inner;
|
|
514
506
|
get inner() {
|
|
515
507
|
if (!this._inner) {
|
|
516
508
|
this._inner = this.container && this.container.querySelector('.ring-list__i');
|
|
517
509
|
}
|
|
518
510
|
return this._inner;
|
|
519
511
|
}
|
|
520
|
-
renderVirtualizedInner(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
} = _ref3;
|
|
512
|
+
renderVirtualizedInner({
|
|
513
|
+
height,
|
|
514
|
+
maxHeight,
|
|
515
|
+
autoHeight = false,
|
|
516
|
+
rowCount,
|
|
517
|
+
isScrolling,
|
|
518
|
+
onChildScroll = noop,
|
|
519
|
+
scrollTop,
|
|
520
|
+
registerChild
|
|
521
|
+
}) {
|
|
531
522
|
const dirOverride = {
|
|
532
523
|
direction: 'inherit'
|
|
533
524
|
}; // Virtualized sets "direction: ltr" by default https://github.com/bvaughn/react-virtualized/issues/457
|
|
534
525
|
return jsx(AutoSizer, {
|
|
535
526
|
disableHeight: true,
|
|
536
527
|
onResize: this.props.onResize,
|
|
537
|
-
children:
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
});
|
|
577
|
-
}
|
|
528
|
+
children: ({
|
|
529
|
+
width
|
|
530
|
+
}) => jsx("div", {
|
|
531
|
+
ref: registerChild,
|
|
532
|
+
children: jsx(VirtualizedList, {
|
|
533
|
+
"aria-label": this.props.ariaLabel,
|
|
534
|
+
ref: this.virtualizedListRef,
|
|
535
|
+
className: classNames('ring-list__i', {
|
|
536
|
+
[styles.overscrollNone]: this.props.preventListOverscroll
|
|
537
|
+
}),
|
|
538
|
+
autoHeight: autoHeight,
|
|
539
|
+
style: maxHeight ? {
|
|
540
|
+
maxHeight,
|
|
541
|
+
height: 'auto',
|
|
542
|
+
...dirOverride
|
|
543
|
+
} : dirOverride,
|
|
544
|
+
autoContainerWidth: true,
|
|
545
|
+
height: height,
|
|
546
|
+
width: width,
|
|
547
|
+
isScrolling: isScrolling,
|
|
548
|
+
onScroll: e => {
|
|
549
|
+
onChildScroll(e);
|
|
550
|
+
this.scrollEndHandler();
|
|
551
|
+
},
|
|
552
|
+
scrollTop: scrollTop,
|
|
553
|
+
rowCount: rowCount,
|
|
554
|
+
estimatedRowSize: this.defaultItemHeight(),
|
|
555
|
+
rowHeight: this._cache.rowHeight,
|
|
556
|
+
rowRenderer: this.renderItem,
|
|
557
|
+
overscanRowCount: this._bufferSize,
|
|
558
|
+
// ensure rerendering
|
|
559
|
+
noop: () => {},
|
|
560
|
+
scrollToIndex: !this.props.disableScrollToActive && this.state.needScrollToActive && this.state.activeIndex !== null && this.state.activeIndex !== undefined ? this.state.activeIndex + 1 : undefined,
|
|
561
|
+
scrollToAlignment: 'center',
|
|
562
|
+
deferredMeasurementCache: this._cache,
|
|
563
|
+
onRowsRendered: this.checkOverflow,
|
|
564
|
+
containerRole: 'none' // row role is set by rowRenderer
|
|
565
|
+
})
|
|
566
|
+
})
|
|
578
567
|
});
|
|
579
568
|
}
|
|
580
569
|
renderVirtualized(maxHeight, rowCount) {
|
|
@@ -586,10 +575,11 @@ class List extends Component {
|
|
|
586
575
|
});
|
|
587
576
|
}
|
|
588
577
|
return jsx(WindowScrollerComponent, {
|
|
589
|
-
children: props => this.renderVirtualizedInner(
|
|
578
|
+
children: props => this.renderVirtualizedInner({
|
|
579
|
+
...props,
|
|
590
580
|
rowCount,
|
|
591
581
|
autoHeight: true
|
|
592
|
-
})
|
|
582
|
+
})
|
|
593
583
|
});
|
|
594
584
|
}
|
|
595
585
|
renderSimple(maxHeight, rowCount) {
|
|
@@ -614,6 +604,19 @@ class List extends Component {
|
|
|
614
604
|
})
|
|
615
605
|
});
|
|
616
606
|
}
|
|
607
|
+
id = getUID('list-');
|
|
608
|
+
shortcutsScope = this.id;
|
|
609
|
+
shortcutsMap = {
|
|
610
|
+
up: this.upHandler,
|
|
611
|
+
down: this.downHandler,
|
|
612
|
+
home: this.homeHandler,
|
|
613
|
+
end: this.endHandler,
|
|
614
|
+
enter: this.enterHandler,
|
|
615
|
+
'meta+enter': this.enterHandler,
|
|
616
|
+
'ctrl+enter': this.enterHandler,
|
|
617
|
+
'command+enter': this.enterHandler,
|
|
618
|
+
'shift+enter': this.enterHandler
|
|
619
|
+
};
|
|
617
620
|
/** @override */
|
|
618
621
|
render() {
|
|
619
622
|
const hint = this.getSelected() && this.props.hintOnSelection || this.props.hint;
|
|
@@ -635,7 +638,10 @@ class List extends Component {
|
|
|
635
638
|
onBlur: this.props.onMouseOut,
|
|
636
639
|
"data-test": 'ring-list',
|
|
637
640
|
children: [this.props.shortcuts && jsx(Shortcuts, {
|
|
638
|
-
map: this.props.shortcutsMap ?
|
|
641
|
+
map: this.props.shortcutsMap ? {
|
|
642
|
+
...this.shortcutsMap,
|
|
643
|
+
...this.props.shortcutsMap
|
|
644
|
+
} : this.shortcutsMap,
|
|
639
645
|
scope: this.shortcutsScope
|
|
640
646
|
}), this.props.renderOptimization ? this.renderVirtualized(maxHeight, rowCount) : this.renderSimple(maxHeight, rowCount), this.state.hasOverflow && !this.state.scrolledToBottom && jsx("div", {
|
|
641
647
|
className: styles.fade,
|
|
@@ -647,28 +653,5 @@ class List extends Component {
|
|
|
647
653
|
});
|
|
648
654
|
}
|
|
649
655
|
}
|
|
650
|
-
_defineProperty(List, "defaultProps", {
|
|
651
|
-
data: [],
|
|
652
|
-
restoreActiveIndex: false,
|
|
653
|
-
// restore active item using its "key" property
|
|
654
|
-
activateSingleItem: false,
|
|
655
|
-
// if there is only one item, activate it
|
|
656
|
-
activateFirstItem: false,
|
|
657
|
-
// if there no active items, activate the first one
|
|
658
|
-
onMouseOut: noop,
|
|
659
|
-
onSelect: noop,
|
|
660
|
-
onScrollToBottom: noop,
|
|
661
|
-
onResize: noop,
|
|
662
|
-
shortcuts: false,
|
|
663
|
-
renderOptimization: true,
|
|
664
|
-
disableMoveDownOverflow: false,
|
|
665
|
-
ariaLabel: 'List'
|
|
666
|
-
});
|
|
667
|
-
_defineProperty(List, "isItemType", isItemType);
|
|
668
|
-
_defineProperty(List, "ListHint", ListHint);
|
|
669
|
-
_defineProperty(List, "ListProps", {
|
|
670
|
-
Type,
|
|
671
|
-
Dimension
|
|
672
|
-
});
|
|
673
656
|
|
|
674
657
|
export { ActiveItemContext, List as default };
|