@deephaven/components 0.5.2-beta.0 → 0.6.1-demo.10
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/dist/AutoCompleteInput.js +410 -448
- package/dist/AutoCompleteInput.js.map +1 -1
- package/dist/AutoResizeTextarea.js +17 -46
- package/dist/AutoResizeTextarea.js.map +1 -1
- package/dist/BasicModal.js +18 -19
- package/dist/BasicModal.js.map +1 -1
- package/dist/Button.js +30 -21
- package/dist/Button.js.map +1 -1
- package/dist/ButtonGroup.js +6 -4
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/ButtonOld.js +10 -8
- package/dist/ButtonOld.js.map +1 -1
- package/dist/CardFlip.js +10 -8
- package/dist/CardFlip.js.map +1 -1
- package/dist/Checkbox.js +18 -31
- package/dist/Checkbox.js.map +1 -1
- package/dist/Collapse.js +65 -105
- package/dist/Collapse.js.map +1 -1
- package/dist/ComboBox.js +432 -460
- package/dist/ComboBox.js.map +1 -1
- package/dist/CustomTimeSelect.js +485 -517
- package/dist/CustomTimeSelect.js.map +1 -1
- package/dist/DebouncedSearchInput.js +61 -91
- package/dist/DebouncedSearchInput.js.map +1 -1
- package/dist/DeephavenSpinner.js +6 -6
- package/dist/DeephavenSpinner.js.map +1 -1
- package/dist/DragUtils.js +65 -113
- package/dist/DragUtils.js.map +1 -1
- package/dist/DraggableItemList.d.ts +1 -0
- package/dist/DraggableItemList.d.ts.map +1 -1
- package/dist/DraggableItemList.js +219 -257
- package/dist/DraggableItemList.js.map +1 -1
- package/dist/HierarchicalCheckboxMenu.js +160 -227
- package/dist/HierarchicalCheckboxMenu.js.map +1 -1
- package/dist/ItemList.d.ts +4 -2
- package/dist/ItemList.d.ts.map +1 -1
- package/dist/ItemList.js +595 -598
- package/dist/ItemList.js.map +1 -1
- package/dist/ItemListItem.js +194 -215
- package/dist/ItemListItem.js.map +1 -1
- package/dist/LoadingOverlay.js +9 -10
- package/dist/LoadingOverlay.js.map +1 -1
- package/dist/LoadingSpinner.js +4 -3
- package/dist/LoadingSpinner.js.map +1 -1
- package/dist/MaskedInput.js +59 -70
- package/dist/MaskedInput.js.map +1 -1
- package/dist/Option.js +5 -3
- package/dist/Option.js.map +1 -1
- package/dist/RadioGroup.js +16 -34
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioItem.js +14 -33
- package/dist/RadioItem.js.map +1 -1
- package/dist/SearchInput.js +42 -75
- package/dist/SearchInput.js.map +1 -1
- package/dist/Select.js +10 -8
- package/dist/Select.js.map +1 -1
- package/dist/SelectValueList.js +97 -134
- package/dist/SelectValueList.js.map +1 -1
- package/dist/SocketedButton.js +13 -11
- package/dist/SocketedButton.js.map +1 -1
- package/dist/ThemeExport.js.map +1 -1
- package/dist/TimeInput.js +16 -53
- package/dist/TimeInput.js.map +1 -1
- package/dist/TimeSlider.js +62 -88
- package/dist/TimeSlider.js.map +1 -1
- package/dist/ToastNotification.js +14 -13
- package/dist/ToastNotification.js.map +1 -1
- package/dist/UISwitch.js +9 -8
- package/dist/UISwitch.js.map +1 -1
- package/dist/context-actions/ContextActionUtils.js +173 -231
- package/dist/context-actions/ContextActionUtils.js.map +1 -1
- package/dist/context-actions/ContextActions.js +135 -177
- package/dist/context-actions/ContextActions.js.map +1 -1
- package/dist/context-actions/ContextMenu.js +509 -543
- package/dist/context-actions/ContextMenu.js.map +1 -1
- package/dist/context-actions/ContextMenuItem.js +32 -22
- package/dist/context-actions/ContextMenuItem.js.map +1 -1
- package/dist/context-actions/ContextMenuRoot.js +112 -152
- package/dist/context-actions/ContextMenuRoot.js.map +1 -1
- package/dist/context-actions/GlobalContextAction.js +49 -84
- package/dist/context-actions/GlobalContextAction.js.map +1 -1
- package/dist/context-actions/GlobalContextActions.js +25 -57
- package/dist/context-actions/GlobalContextActions.js.map +1 -1
- package/dist/context-actions/index.js +4 -4
- package/dist/context-actions/index.js.map +1 -1
- package/dist/index.js +39 -39
- package/dist/index.js.map +1 -1
- package/dist/menu-actions/DropdownMenu.js +126 -159
- package/dist/menu-actions/DropdownMenu.js.map +1 -1
- package/dist/menu-actions/Menu.js +215 -245
- package/dist/menu-actions/Menu.js.map +1 -1
- package/dist/menu-actions/index.js +1 -1
- package/dist/menu-actions/index.js.map +1 -1
- package/dist/navigation/Menu.js +14 -18
- package/dist/navigation/Menu.js.map +1 -1
- package/dist/navigation/MenuItem.js +15 -14
- package/dist/navigation/MenuItem.js.map +1 -1
- package/dist/navigation/Page.js +7 -5
- package/dist/navigation/Page.js.map +1 -1
- package/dist/navigation/Stack.js +14 -39
- package/dist/navigation/Stack.js.map +1 -1
- package/dist/navigation/index.js +4 -4
- package/dist/navigation/index.js.map +1 -1
- package/dist/popper/Popper.js +209 -235
- package/dist/popper/Popper.js.map +1 -1
- package/dist/popper/Tooltip.js +227 -257
- package/dist/popper/Tooltip.js.map +1 -1
- package/dist/popper/index.js +2 -2
- package/dist/popper/index.js.map +1 -1
- package/dist/shortcuts/GlobalShortcuts.js +2 -2
- package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
- package/dist/shortcuts/Shortcut.js +263 -291
- package/dist/shortcuts/Shortcut.js.map +1 -1
- package/dist/shortcuts/ShortcutRegistry.js +48 -71
- package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
- package/dist/shortcuts/index.js +4 -4
- package/dist/shortcuts/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -54
package/dist/ItemList.js
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
-
|
|
3
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
2
|
|
|
5
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
-
|
|
7
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
8
|
-
|
|
9
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
10
|
-
|
|
11
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
12
|
-
|
|
13
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
-
|
|
15
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
-
|
|
17
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
18
|
-
|
|
19
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
-
|
|
21
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
|
-
|
|
23
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
|
-
|
|
25
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
4
|
|
|
27
5
|
import React, { PureComponent } from 'react';
|
|
@@ -30,8 +8,8 @@ import { FixedSizeList as List } from 'react-window';
|
|
|
30
8
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
31
9
|
import Log from '@deephaven/log';
|
|
32
10
|
import { RangeUtils } from '@deephaven/utils';
|
|
33
|
-
import ItemListItem from
|
|
34
|
-
import { ContextActionUtils } from
|
|
11
|
+
import ItemListItem from "./ItemListItem.js";
|
|
12
|
+
import { ContextActionUtils } from "./context-actions/index.js";
|
|
35
13
|
import "./ItemList.css";
|
|
36
14
|
var log = Log.module('ItemList');
|
|
37
15
|
|
|
@@ -39,45 +17,45 @@ var log = Log.module('ItemList');
|
|
|
39
17
|
* Show items in a long scrollable list.
|
|
40
18
|
* Can be navigated via keyboard or mouse.
|
|
41
19
|
*/
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
20
|
+
export class ItemList extends PureComponent {
|
|
21
|
+
// By drawing an additional 10 items on each side, tab/keyboard navigation works better (as the next element exists)
|
|
22
|
+
static renderItem(_ref) {
|
|
23
|
+
var {
|
|
24
|
+
item
|
|
25
|
+
} = _ref;
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
className: "item-list-item-content"
|
|
28
|
+
}, item && (item.displayValue || item.value || "".concat(item)));
|
|
29
|
+
}
|
|
51
30
|
|
|
52
|
-
|
|
31
|
+
constructor(_props) {
|
|
32
|
+
super(_props);
|
|
53
33
|
|
|
54
|
-
_defineProperty(
|
|
34
|
+
_defineProperty(this, "list", void 0);
|
|
55
35
|
|
|
56
|
-
_defineProperty(
|
|
36
|
+
_defineProperty(this, "listContainer", void 0);
|
|
57
37
|
|
|
58
|
-
_defineProperty(
|
|
59
|
-
return RangeUtils.isSelected(selectedRanges, index);
|
|
60
|
-
}, {
|
|
38
|
+
_defineProperty(this, "getItemSelected", memoize((index, selectedRanges) => RangeUtils.isSelected(selectedRanges, index), {
|
|
61
39
|
max: ItemList.CACHE_SIZE
|
|
62
40
|
}));
|
|
63
41
|
|
|
64
|
-
_defineProperty(
|
|
42
|
+
_defineProperty(this, "getCachedItem", memoize((itemIndex, key, item, isFocused, isSelected, renderItem, style, disableSelect) => {
|
|
65
43
|
var content = renderItem({
|
|
66
|
-
item
|
|
67
|
-
itemIndex
|
|
68
|
-
isFocused
|
|
69
|
-
isSelected
|
|
70
|
-
style
|
|
44
|
+
item,
|
|
45
|
+
itemIndex,
|
|
46
|
+
isFocused,
|
|
47
|
+
isSelected,
|
|
48
|
+
style
|
|
71
49
|
});
|
|
72
50
|
return /*#__PURE__*/React.createElement(ItemListItem, {
|
|
73
|
-
onContextMenu:
|
|
74
|
-
onDoubleClick:
|
|
75
|
-
onMouseDown:
|
|
76
|
-
onFocus:
|
|
77
|
-
onBlur:
|
|
51
|
+
onContextMenu: this.handleItemContextMenu,
|
|
52
|
+
onDoubleClick: this.handleItemDoubleClick,
|
|
53
|
+
onMouseDown: this.handleItemMouseDown,
|
|
54
|
+
onFocus: this.handleItemFocus,
|
|
55
|
+
onBlur: this.handleItemBlur,
|
|
78
56
|
disableSelect: disableSelect,
|
|
79
|
-
onMouseMove:
|
|
80
|
-
onMouseUp:
|
|
57
|
+
onMouseMove: this.handleItemMouseMove,
|
|
58
|
+
onMouseUp: this.handleItemMouseUp,
|
|
81
59
|
isFocused: isFocused,
|
|
82
60
|
isSelected: isSelected,
|
|
83
61
|
itemIndex: itemIndex,
|
|
@@ -88,63 +66,58 @@ export var ItemList = /*#__PURE__*/function (_PureComponent) {
|
|
|
88
66
|
max: ItemList.CACHE_SIZE
|
|
89
67
|
}));
|
|
90
68
|
|
|
91
|
-
_defineProperty(
|
|
92
|
-
var component = /*#__PURE__*/React.forwardRef(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}, props))
|
|
103
|
-
);
|
|
104
|
-
});
|
|
69
|
+
_defineProperty(this, "getOuterElement", memoize(onKeyDown => {
|
|
70
|
+
var component = /*#__PURE__*/React.forwardRef((props, ref) =>
|
|
71
|
+
/*#__PURE__*/
|
|
72
|
+
// We need to add the tabIndex to make sure it is focusable, otherwise we can't get key events
|
|
73
|
+
React.createElement("div", _extends({
|
|
74
|
+
ref: ref,
|
|
75
|
+
tabIndex: -1,
|
|
76
|
+
onKeyDown: onKeyDown,
|
|
77
|
+
role: "presentation" // eslint-disable-next-line react/jsx-props-no-spreading
|
|
78
|
+
|
|
79
|
+
}, props)));
|
|
105
80
|
component.displayName = 'ItemListOuterElement';
|
|
106
81
|
return component;
|
|
107
82
|
}));
|
|
108
83
|
|
|
109
|
-
_defineProperty(
|
|
110
|
-
var component = /*#__PURE__*/React.forwardRef(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
ref: ref // eslint-disable-next-line react/jsx-props-no-spreading
|
|
84
|
+
_defineProperty(this, "getInnerElement", memoize(() => {
|
|
85
|
+
var component = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("div", _extends({
|
|
86
|
+
className: "item-list-inner-element",
|
|
87
|
+
ref: ref // eslint-disable-next-line react/jsx-props-no-spreading
|
|
114
88
|
|
|
115
|
-
|
|
116
|
-
});
|
|
89
|
+
}, props)));
|
|
117
90
|
component.displayName = 'ItemListInnerElement';
|
|
118
91
|
return component;
|
|
119
92
|
}));
|
|
120
93
|
|
|
121
|
-
_defineProperty(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
94
|
+
_defineProperty(this, "getItemData", memoize((items, selectedRanges, renderItem) => ({
|
|
95
|
+
items,
|
|
96
|
+
selectedRanges,
|
|
97
|
+
renderItem
|
|
98
|
+
})));
|
|
99
|
+
|
|
100
|
+
this.handleItemBlur = this.handleItemBlur.bind(this);
|
|
101
|
+
this.handleItemContextMenu = this.handleItemContextMenu.bind(this);
|
|
102
|
+
this.handleItemFocus = this.handleItemFocus.bind(this);
|
|
103
|
+
this.handleItemDoubleClick = this.handleItemDoubleClick.bind(this);
|
|
104
|
+
this.handleItemMouseDown = this.handleItemMouseDown.bind(this);
|
|
105
|
+
this.handleItemMouseMove = this.handleItemMouseMove.bind(this);
|
|
106
|
+
this.handleItemMouseUp = this.handleItemMouseUp.bind(this);
|
|
107
|
+
this.handleItemsRendered = this.handleItemsRendered.bind(this);
|
|
108
|
+
this.handleWindowMouseUp = this.handleWindowMouseUp.bind(this);
|
|
109
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
110
|
+
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
|
111
|
+
this.handleScroll = this.handleScroll.bind(this);
|
|
112
|
+
this.handleResize = this.handleResize.bind(this);
|
|
113
|
+
this.renderInnerElement = this.renderInnerElement.bind(this);
|
|
114
|
+
this.list = /*#__PURE__*/React.createRef();
|
|
115
|
+
this.listContainer = /*#__PURE__*/React.createRef();
|
|
116
|
+
var {
|
|
117
|
+
isStickyBottom,
|
|
118
|
+
selectedRanges: _selectedRanges
|
|
119
|
+
} = _props;
|
|
120
|
+
this.state = {
|
|
148
121
|
focusIndex: null,
|
|
149
122
|
mouseDownIndex: null,
|
|
150
123
|
selectedRanges: _selectedRanges,
|
|
@@ -154,575 +127,593 @@ export var ItemList = /*#__PURE__*/function (_PureComponent) {
|
|
|
154
127
|
isStuckToBottom: isStickyBottom,
|
|
155
128
|
scrollOffset: null
|
|
156
129
|
};
|
|
157
|
-
return _this;
|
|
158
130
|
}
|
|
159
131
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
132
|
+
componentDidMount() {
|
|
133
|
+
var {
|
|
134
|
+
isStickyBottom
|
|
135
|
+
} = this.props;
|
|
164
136
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
137
|
+
if (isStickyBottom && !this.isListAtBottom()) {
|
|
138
|
+
this.scrollToBottom();
|
|
168
139
|
}
|
|
169
|
-
}
|
|
170
|
-
key: "componentDidUpdate",
|
|
171
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
172
|
-
var propSelectedRanges = this.props.selectedRanges;
|
|
173
|
-
var _this$state = this.state,
|
|
174
|
-
focusIndex = _this$state.focusIndex,
|
|
175
|
-
isStuckToBottom = _this$state.isStuckToBottom,
|
|
176
|
-
scrollOffset = _this$state.scrollOffset,
|
|
177
|
-
height = _this$state.height,
|
|
178
|
-
selectedRanges = _this$state.selectedRanges;
|
|
179
|
-
|
|
180
|
-
if (isStuckToBottom && !this.isListAtBottom()) {
|
|
181
|
-
this.scrollToBottom();
|
|
182
|
-
}
|
|
140
|
+
}
|
|
183
141
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
142
|
+
componentDidUpdate(prevProps, prevState) {
|
|
143
|
+
var {
|
|
144
|
+
selectedRanges: propSelectedRanges
|
|
145
|
+
} = this.props;
|
|
146
|
+
var {
|
|
147
|
+
focusIndex,
|
|
148
|
+
isStuckToBottom,
|
|
149
|
+
scrollOffset,
|
|
150
|
+
height,
|
|
151
|
+
selectedRanges
|
|
152
|
+
} = this.state;
|
|
187
153
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var _onSelectionChange = this.props.onSelectionChange;
|
|
154
|
+
if (isStuckToBottom && !this.isListAtBottom()) {
|
|
155
|
+
this.scrollToBottom();
|
|
156
|
+
}
|
|
192
157
|
|
|
193
|
-
|
|
194
|
-
|
|
158
|
+
if (scrollOffset !== prevState.scrollOffset || height !== prevState.height) {
|
|
159
|
+
this.sendViewportUpdate();
|
|
160
|
+
}
|
|
195
161
|
|
|
196
|
-
|
|
197
|
-
|
|
162
|
+
if (propSelectedRanges !== prevProps.selectedRanges && propSelectedRanges !== selectedRanges) {
|
|
163
|
+
this.setSelectedRanges(propSelectedRanges);
|
|
164
|
+
} else if (selectedRanges !== prevState.selectedRanges) {
|
|
165
|
+
var {
|
|
166
|
+
onSelectionChange: _onSelectionChange
|
|
167
|
+
} = this.props;
|
|
198
168
|
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}, {
|
|
203
|
-
key: "componentWillUnmount",
|
|
204
|
-
value: function componentWillUnmount() {
|
|
205
|
-
window.removeEventListener('mouseup', this.handleWindowMouseUp);
|
|
169
|
+
_onSelectionChange(selectedRanges);
|
|
206
170
|
}
|
|
207
|
-
}, {
|
|
208
|
-
key: "focus",
|
|
209
|
-
value: function focus() {
|
|
210
|
-
var _this$listContainer$c;
|
|
211
171
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
value: function getElement(itemIndex) {
|
|
217
|
-
if (this.listContainer.current == null) {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
172
|
+
if (focusIndex !== prevState.focusIndex) {
|
|
173
|
+
var {
|
|
174
|
+
onFocusChange: _onFocusChange
|
|
175
|
+
} = this.props;
|
|
220
176
|
|
|
221
|
-
|
|
222
|
-
var overscanStartIndex = this.state.overscanStartIndex;
|
|
223
|
-
var elements = this.listContainer.current.querySelectorAll(focusSelector);
|
|
224
|
-
var elementIndex = itemIndex - overscanStartIndex;
|
|
225
|
-
return elements[elementIndex];
|
|
177
|
+
_onFocusChange(focusIndex);
|
|
226
178
|
}
|
|
227
|
-
}
|
|
228
|
-
key: "focusItem",
|
|
229
|
-
value: function focusItem(itemIndex) {
|
|
230
|
-
var disableSelect = this.props.disableSelect;
|
|
231
|
-
if (disableSelect) return;
|
|
232
|
-
this.setState({
|
|
233
|
-
focusIndex: itemIndex
|
|
234
|
-
});
|
|
235
|
-
var element = this.getElement(itemIndex);
|
|
179
|
+
}
|
|
236
180
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
}, {
|
|
242
|
-
key: "scrollToItem",
|
|
243
|
-
value: function scrollToItem(itemIndex) {
|
|
244
|
-
var element = this.getElement(itemIndex);
|
|
245
|
-
|
|
246
|
-
if (element != null) {
|
|
247
|
-
element.scrollIntoView({
|
|
248
|
-
block: 'center'
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}, {
|
|
253
|
-
key: "handleItemContextMenu",
|
|
254
|
-
value: function handleItemContextMenu(itemIndex, e) {
|
|
255
|
-
// Update the selection, but don't consume the mouse event - it will trigger the context menu
|
|
256
|
-
var selectedRanges = this.state.selectedRanges;
|
|
257
|
-
var isSelected = RangeUtils.isSelected(selectedRanges, itemIndex); // When right-clicking, we want to maintain the current selection if the right click happened within the selection even if the modifier key isn't down
|
|
258
|
-
|
|
259
|
-
var isModifierDown = isSelected || ContextActionUtils.isModifierKeyDown(e);
|
|
260
|
-
this.toggleSelect(itemIndex, e.shiftKey, isModifierDown, false);
|
|
261
|
-
}
|
|
262
|
-
}, {
|
|
263
|
-
key: "handleItemDoubleClick",
|
|
264
|
-
value: function handleItemDoubleClick(itemIndex) {
|
|
265
|
-
var _this$props = this.props,
|
|
266
|
-
isDoubleClickSelect = _this$props.isDoubleClickSelect,
|
|
267
|
-
onSelect = _this$props.onSelect;
|
|
268
|
-
|
|
269
|
-
if (isDoubleClickSelect) {
|
|
270
|
-
this.setState(function (_ref) {
|
|
271
|
-
var selectedRanges = _ref.selectedRanges;
|
|
272
|
-
return {
|
|
273
|
-
selectedRanges: RangeUtils.selectRange(selectedRanges, [itemIndex, itemIndex])
|
|
274
|
-
};
|
|
275
|
-
}, function () {
|
|
276
|
-
onSelect(itemIndex);
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}, {
|
|
281
|
-
key: "handleItemMouseDown",
|
|
282
|
-
value: function handleItemMouseDown(index, e) {
|
|
283
|
-
var selectedRanges = this.state.selectedRanges;
|
|
284
|
-
|
|
285
|
-
if (e.target instanceof HTMLElement && ['button', 'select', 'input', 'textarea'].indexOf(e.target.tagName.toLowerCase()) !== -1) {
|
|
286
|
-
// allow these elements to do their own behaviours
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
181
|
+
componentWillUnmount() {
|
|
182
|
+
window.removeEventListener('mouseup', this.handleWindowMouseUp);
|
|
183
|
+
}
|
|
289
184
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
this.focusItem(index);
|
|
293
|
-
this.selectItem(index);
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
185
|
+
focus() {
|
|
186
|
+
var _this$listContainer$c;
|
|
296
187
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
188
|
+
(_this$listContainer$c = this.listContainer.current) === null || _this$listContainer$c === void 0 ? void 0 : _this$listContainer$c.focus();
|
|
189
|
+
}
|
|
300
190
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
window.addEventListener('mouseup', this.handleWindowMouseUp); // Leave selection until mouse up, to allow for dragging behaviour
|
|
191
|
+
getElement(itemIndex) {
|
|
192
|
+
if (this.listContainer.current == null) {
|
|
193
|
+
return null;
|
|
305
194
|
}
|
|
306
|
-
}, {
|
|
307
|
-
key: "handleItemBlur",
|
|
308
|
-
value: function handleItemBlur(itemIndex, e) {
|
|
309
|
-
log.debug2('item blur', itemIndex, e.currentTarget, e.relatedTarget);
|
|
310
195
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
196
|
+
var {
|
|
197
|
+
focusSelector
|
|
198
|
+
} = this.props;
|
|
199
|
+
var {
|
|
200
|
+
overscanStartIndex
|
|
201
|
+
} = this.state;
|
|
202
|
+
var elements = this.listContainer.current.querySelectorAll(focusSelector);
|
|
203
|
+
var elementIndex = itemIndex - overscanStartIndex;
|
|
204
|
+
return elements[elementIndex];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
focusItem(itemIndex) {
|
|
208
|
+
var {
|
|
209
|
+
disableSelect
|
|
210
|
+
} = this.props;
|
|
211
|
+
if (disableSelect) return;
|
|
212
|
+
this.setState({
|
|
213
|
+
focusIndex: itemIndex
|
|
214
|
+
});
|
|
215
|
+
var element = this.getElement(itemIndex);
|
|
216
|
+
|
|
217
|
+
if (element instanceof HTMLElement) {
|
|
218
|
+
element.focus();
|
|
317
219
|
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
this.setState(function (state) {
|
|
323
|
-
var focusIndex = state.focusIndex;
|
|
324
|
-
|
|
325
|
-
if (focusIndex !== itemIndex) {
|
|
326
|
-
return {
|
|
327
|
-
focusIndex: itemIndex
|
|
328
|
-
};
|
|
329
|
-
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
scrollToItem(itemIndex) {
|
|
223
|
+
var element = this.getElement(itemIndex);
|
|
330
224
|
|
|
331
|
-
|
|
225
|
+
if (element != null) {
|
|
226
|
+
element.scrollIntoView({
|
|
227
|
+
block: 'center'
|
|
332
228
|
});
|
|
333
229
|
}
|
|
334
|
-
}
|
|
335
|
-
key: "handleItemMouseMove",
|
|
336
|
-
value: function handleItemMouseMove(itemIndex, e) {
|
|
337
|
-
var _this$props2 = this.props,
|
|
338
|
-
isDragSelect = _this$props2.isDragSelect,
|
|
339
|
-
isMultiSelect = _this$props2.isMultiSelect,
|
|
340
|
-
disableSelect = _this$props2.disableSelect;
|
|
341
|
-
var _this$state2 = this.state,
|
|
342
|
-
mouseDownIndex = _this$state2.mouseDownIndex,
|
|
343
|
-
selectedRanges = _this$state2.selectedRanges;
|
|
344
|
-
if (mouseDownIndex == null || disableSelect) return;
|
|
345
|
-
this.setState({
|
|
346
|
-
isDragging: true
|
|
347
|
-
});
|
|
230
|
+
}
|
|
348
231
|
|
|
349
|
-
|
|
350
|
-
|
|
232
|
+
handleItemContextMenu(itemIndex, e) {
|
|
233
|
+
// Update the selection, but don't consume the mouse event - it will trigger the context menu
|
|
234
|
+
var {
|
|
235
|
+
selectedRanges
|
|
236
|
+
} = this.state;
|
|
237
|
+
var isSelected = RangeUtils.isSelected(selectedRanges, itemIndex); // When right-clicking, we want to maintain the current selection if the right click happened within the selection even if the modifier key isn't down
|
|
351
238
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
this.deselectAll();
|
|
356
|
-
}
|
|
239
|
+
var isModifierDown = isSelected || ContextActionUtils.isModifierKeyDown(e);
|
|
240
|
+
this.toggleSelect(itemIndex, e.shiftKey, isModifierDown, false);
|
|
241
|
+
}
|
|
357
242
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
243
|
+
handleItemDoubleClick(itemIndex, e) {
|
|
244
|
+
var {
|
|
245
|
+
isDoubleClickSelect,
|
|
246
|
+
onSelect
|
|
247
|
+
} = this.props;
|
|
248
|
+
|
|
249
|
+
if (isDoubleClickSelect) {
|
|
250
|
+
this.setState((_ref2) => {
|
|
251
|
+
var {
|
|
252
|
+
selectedRanges
|
|
253
|
+
} = _ref2;
|
|
254
|
+
return {
|
|
255
|
+
selectedRanges: RangeUtils.selectRange(selectedRanges, [itemIndex, itemIndex])
|
|
256
|
+
};
|
|
257
|
+
}, () => {
|
|
258
|
+
onSelect(itemIndex, e);
|
|
259
|
+
});
|
|
363
260
|
}
|
|
364
|
-
}
|
|
365
|
-
key: "handleItemMouseUp",
|
|
366
|
-
value: function handleItemMouseUp(index, e) {
|
|
367
|
-
var _this$props3 = this.props,
|
|
368
|
-
isDoubleClickSelect = _this$props3.isDoubleClickSelect,
|
|
369
|
-
onSelect = _this$props3.onSelect;
|
|
370
|
-
var _this$state3 = this.state,
|
|
371
|
-
mouseDownIndex = _this$state3.mouseDownIndex,
|
|
372
|
-
isDragging = _this$state3.isDragging;
|
|
373
|
-
|
|
374
|
-
if (e.target instanceof HTMLElement && ['button', 'select', 'input', 'textarea'].indexOf(e.target.tagName.toLowerCase()) !== -1) {
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (mouseDownIndex === index && !isDragging) {
|
|
379
|
-
var isShiftDown = e.shiftKey;
|
|
380
|
-
var isModifierDown = ContextActionUtils.isModifierKeyDown(e);
|
|
381
|
-
this.focusItem(index);
|
|
382
|
-
this.toggleSelect(index, isShiftDown, isModifierDown);
|
|
261
|
+
}
|
|
383
262
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
263
|
+
handleItemMouseDown(index, e) {
|
|
264
|
+
var {
|
|
265
|
+
selectedRanges
|
|
266
|
+
} = this.state;
|
|
388
267
|
|
|
389
|
-
|
|
268
|
+
if (e.target instanceof HTMLElement && ['button', 'select', 'input', 'textarea'].indexOf(e.target.tagName.toLowerCase()) !== -1) {
|
|
269
|
+
// allow these elements to do their own behaviours
|
|
270
|
+
return;
|
|
390
271
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
this.
|
|
396
|
-
|
|
397
|
-
});
|
|
272
|
+
|
|
273
|
+
if (e.button === 2 && selectedRanges.length === 0) {
|
|
274
|
+
// allow right click to act as a selection if selection is empty
|
|
275
|
+
this.focusItem(index);
|
|
276
|
+
this.selectItem(index);
|
|
277
|
+
return;
|
|
398
278
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
var height = _ref3.height;
|
|
403
|
-
this.setState({
|
|
404
|
-
height: height
|
|
405
|
-
});
|
|
279
|
+
|
|
280
|
+
if (e.button != null && e.button !== 0) {
|
|
281
|
+
return;
|
|
406
282
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
283
|
+
|
|
284
|
+
this.setState({
|
|
285
|
+
mouseDownIndex: index
|
|
286
|
+
});
|
|
287
|
+
window.addEventListener('mouseup', this.handleWindowMouseUp); // Leave selection until mouse up, to allow for dragging behaviour
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
handleItemBlur(itemIndex, e) {
|
|
291
|
+
log.debug2('item blur', itemIndex, e.currentTarget, e.relatedTarget);
|
|
292
|
+
|
|
293
|
+
if (!e.relatedTarget || this.listContainer.current && e.relatedTarget instanceof HTMLElement && !this.listContainer.current.contains(e.relatedTarget)) {
|
|
294
|
+
// Next focused element is outside of the ItemList
|
|
410
295
|
this.setState({
|
|
411
|
-
|
|
296
|
+
focusIndex: null
|
|
412
297
|
});
|
|
413
298
|
}
|
|
414
|
-
}
|
|
415
|
-
key: "handleWindowMouseUp",
|
|
416
|
-
value: function handleWindowMouseUp() {
|
|
417
|
-
this.resetMouseState();
|
|
418
|
-
window.removeEventListener('mouseup', this.handleWindowMouseUp);
|
|
419
|
-
}
|
|
420
|
-
}, {
|
|
421
|
-
key: "handleKeyDown",
|
|
422
|
-
value: function handleKeyDown(e) {
|
|
423
|
-
var _this$props4 = this.props,
|
|
424
|
-
isMultiSelect = _this$props4.isMultiSelect,
|
|
425
|
-
itemCount = _this$props4.itemCount,
|
|
426
|
-
onSelect = _this$props4.onSelect;
|
|
427
|
-
var oldFocus = this.state.focusIndex;
|
|
428
|
-
var newFocus = oldFocus;
|
|
429
|
-
|
|
430
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
431
|
-
if (!isMultiSelect && newFocus != null) {
|
|
432
|
-
this.setState({
|
|
433
|
-
selectedRanges: [[newFocus, newFocus]]
|
|
434
|
-
}, function () {
|
|
435
|
-
if (newFocus != null) {
|
|
436
|
-
onSelect(newFocus);
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
}
|
|
299
|
+
}
|
|
440
300
|
|
|
441
|
-
|
|
301
|
+
handleItemFocus(itemIndex, e) {
|
|
302
|
+
log.debug2('item focus', itemIndex, e.target);
|
|
303
|
+
this.setState(state => {
|
|
304
|
+
var {
|
|
305
|
+
focusIndex
|
|
306
|
+
} = state;
|
|
307
|
+
|
|
308
|
+
if (focusIndex !== itemIndex) {
|
|
309
|
+
return {
|
|
310
|
+
focusIndex: itemIndex
|
|
311
|
+
};
|
|
442
312
|
}
|
|
443
313
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
314
|
+
return null;
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
handleItemMouseMove(itemIndex, e) {
|
|
319
|
+
var {
|
|
320
|
+
isDragSelect,
|
|
321
|
+
isMultiSelect,
|
|
322
|
+
disableSelect
|
|
323
|
+
} = this.props;
|
|
324
|
+
var {
|
|
325
|
+
mouseDownIndex,
|
|
326
|
+
selectedRanges
|
|
327
|
+
} = this.state;
|
|
328
|
+
if (mouseDownIndex == null || disableSelect) return;
|
|
329
|
+
this.setState({
|
|
330
|
+
isDragging: true
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
if (isDragSelect || mouseDownIndex === itemIndex) {
|
|
334
|
+
this.focusItem(itemIndex);
|
|
335
|
+
|
|
336
|
+
if (isMultiSelect) {
|
|
337
|
+
if (!isDragSelect && !this.getItemSelected(itemIndex, selectedRanges) && !ContextActionUtils.isModifierKeyDown(e)) {
|
|
338
|
+
// If there's already a selection and they select outside of that range while dragging without a modifier key, start a new selection with just the new item
|
|
339
|
+
this.deselectAll();
|
|
455
340
|
}
|
|
341
|
+
|
|
342
|
+
this.selectRange([Math.min(mouseDownIndex, itemIndex), Math.max(mouseDownIndex, itemIndex)]);
|
|
456
343
|
} else {
|
|
457
|
-
|
|
344
|
+
this.toggleSelect(itemIndex, e.shiftKey, ContextActionUtils.isModifierKeyDown(e), false);
|
|
458
345
|
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
459
348
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
349
|
+
handleItemMouseUp(index, e) {
|
|
350
|
+
var {
|
|
351
|
+
isDeselectOnClick,
|
|
352
|
+
isDoubleClickSelect,
|
|
353
|
+
onSelect
|
|
354
|
+
} = this.props;
|
|
355
|
+
var {
|
|
356
|
+
mouseDownIndex,
|
|
357
|
+
isDragging
|
|
358
|
+
} = this.state;
|
|
359
|
+
|
|
360
|
+
if (e.target instanceof HTMLElement && ['button', 'select', 'input', 'textarea'].indexOf(e.target.tagName.toLowerCase()) !== -1) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (mouseDownIndex === index && !isDragging) {
|
|
365
|
+
var isShiftDown = e.shiftKey;
|
|
366
|
+
var isModifierDown = ContextActionUtils.isModifierKeyDown(e);
|
|
367
|
+
this.focusItem(index);
|
|
368
|
+
this.toggleSelect(index, isShiftDown, isModifierDown, isDeselectOnClick);
|
|
369
|
+
|
|
370
|
+
if (!isDoubleClickSelect && !isShiftDown && !isModifierDown) {
|
|
371
|
+
onSelect(index, e);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
465
374
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
this.selectRange([Math.min(newFocus, lastRange[0]), Math.max(newFocus, lastRange[1])]);
|
|
469
|
-
} else {
|
|
470
|
-
this.deselectAll();
|
|
375
|
+
this.resetMouseState();
|
|
376
|
+
}
|
|
471
377
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
378
|
+
handleItemsRendered(_ref3) {
|
|
379
|
+
var {
|
|
380
|
+
overscanStartIndex
|
|
381
|
+
} = _ref3;
|
|
382
|
+
this.setState({
|
|
383
|
+
overscanStartIndex
|
|
384
|
+
});
|
|
385
|
+
}
|
|
476
386
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
387
|
+
handleResize(_ref4) {
|
|
388
|
+
var {
|
|
389
|
+
height
|
|
390
|
+
} = _ref4;
|
|
391
|
+
this.setState({
|
|
392
|
+
height
|
|
393
|
+
});
|
|
394
|
+
}
|
|
480
395
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
value: function handleScroll(_ref4) {
|
|
487
|
-
var _this2 = this;
|
|
488
|
-
|
|
489
|
-
var scrollUpdateWasRequested = _ref4.scrollUpdateWasRequested,
|
|
490
|
-
scrollOffset = _ref4.scrollOffset;
|
|
491
|
-
this.setState(function (state) {
|
|
492
|
-
if (scrollUpdateWasRequested) {
|
|
493
|
-
// The scroll was caused by scrollTo() or scrollToItem()
|
|
494
|
-
// Don't re-calc isStuckToBottom
|
|
495
|
-
return {
|
|
496
|
-
scrollOffset: scrollOffset
|
|
497
|
-
};
|
|
498
|
-
}
|
|
396
|
+
handleMouseLeave() {
|
|
397
|
+
this.setState({
|
|
398
|
+
mouseDownIndex: null
|
|
399
|
+
});
|
|
400
|
+
}
|
|
499
401
|
|
|
500
|
-
|
|
501
|
-
|
|
402
|
+
handleWindowMouseUp() {
|
|
403
|
+
this.resetMouseState();
|
|
404
|
+
window.removeEventListener('mouseup', this.handleWindowMouseUp);
|
|
405
|
+
}
|
|
502
406
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
407
|
+
handleKeyDown(e) {
|
|
408
|
+
var {
|
|
409
|
+
isMultiSelect,
|
|
410
|
+
itemCount,
|
|
411
|
+
onSelect
|
|
412
|
+
} = this.props;
|
|
413
|
+
var {
|
|
414
|
+
focusIndex: oldFocus
|
|
415
|
+
} = this.state;
|
|
416
|
+
var newFocus = oldFocus;
|
|
417
|
+
|
|
418
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
419
|
+
if (!isMultiSelect && newFocus != null) {
|
|
420
|
+
this.setState({
|
|
421
|
+
selectedRanges: [[newFocus, newFocus]]
|
|
422
|
+
}, () => {
|
|
423
|
+
if (newFocus != null) {
|
|
424
|
+
onSelect(newFocus, e);
|
|
425
|
+
}
|
|
506
426
|
});
|
|
427
|
+
}
|
|
507
428
|
|
|
508
|
-
|
|
509
|
-
isStuckToBottom: isStuckToBottom,
|
|
510
|
-
scrollOffset: scrollOffset
|
|
511
|
-
};
|
|
512
|
-
});
|
|
429
|
+
return;
|
|
513
430
|
}
|
|
514
|
-
}, {
|
|
515
|
-
key: "resetMouseState",
|
|
516
|
-
value: function resetMouseState() {
|
|
517
|
-
this.setState({
|
|
518
|
-
mouseDownIndex: null,
|
|
519
|
-
isDragging: false
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
}, {
|
|
523
|
-
key: "scrollToBottom",
|
|
524
|
-
value: function scrollToBottom() {
|
|
525
|
-
var itemCount = this.props.itemCount;
|
|
526
431
|
|
|
527
|
-
|
|
528
|
-
|
|
432
|
+
if (e.key === 'ArrowUp') {
|
|
433
|
+
if (newFocus != null && newFocus >= 0) {
|
|
434
|
+
newFocus = Math.max(0, newFocus - 1);
|
|
435
|
+
} else {
|
|
436
|
+
newFocus = itemCount - 1;
|
|
529
437
|
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
this.list.current.scrollToItem(itemIndex);
|
|
438
|
+
} else if (e.key === 'ArrowDown') {
|
|
439
|
+
if (newFocus != null && newFocus >= 0) {
|
|
440
|
+
newFocus = Math.min(newFocus + 1, itemCount - 1);
|
|
441
|
+
} else {
|
|
442
|
+
newFocus = 0;
|
|
536
443
|
}
|
|
444
|
+
} else {
|
|
445
|
+
return;
|
|
537
446
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
var isDeselectable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
549
|
-
var isMultiSelect = this.props.isMultiSelect;
|
|
550
|
-
var selectedRanges = this.state.selectedRanges;
|
|
551
|
-
|
|
552
|
-
if (isMultiSelect && isShiftDown && selectedRanges.length > 0) {
|
|
447
|
+
|
|
448
|
+
if (oldFocus !== newFocus) {
|
|
449
|
+
e.stopPropagation();
|
|
450
|
+
e.preventDefault();
|
|
451
|
+
this.focusItem(newFocus);
|
|
452
|
+
var {
|
|
453
|
+
selectedRanges
|
|
454
|
+
} = this.state;
|
|
455
|
+
|
|
456
|
+
if (e.shiftKey && selectedRanges.length > 0) {
|
|
553
457
|
var lastRange = selectedRanges[selectedRanges.length - 1];
|
|
554
|
-
this.selectRange([Math.min(lastRange[0]
|
|
555
|
-
} else if (isMultiSelect && selectedRanges.length === 1 && selectedRanges[0][0] === index && selectedRanges[0][1] === index) {
|
|
556
|
-
if (isDeselectable) {
|
|
557
|
-
this.deselectItem(index);
|
|
558
|
-
}
|
|
559
|
-
} else if (isMultiSelect && isModifierDown) {
|
|
560
|
-
if (this.getItemSelected(index, selectedRanges)) {
|
|
561
|
-
if (isDeselectable) {
|
|
562
|
-
this.deselectItem(index);
|
|
563
|
-
}
|
|
564
|
-
} else {
|
|
565
|
-
this.selectItem(index);
|
|
566
|
-
}
|
|
458
|
+
this.selectRange([Math.min(newFocus, lastRange[0]), Math.max(newFocus, lastRange[1])]);
|
|
567
459
|
} else {
|
|
568
460
|
this.deselectAll();
|
|
569
|
-
|
|
461
|
+
|
|
462
|
+
if (newFocus !== null) {
|
|
463
|
+
this.selectItem(newFocus);
|
|
464
|
+
} else {
|
|
465
|
+
var _this$listContainer$c2;
|
|
466
|
+
|
|
467
|
+
(_this$listContainer$c2 = this.listContainer.current) === null || _this$listContainer$c2 === void 0 ? void 0 : _this$listContainer$c2.focus();
|
|
468
|
+
}
|
|
570
469
|
}
|
|
470
|
+
|
|
471
|
+
this.scrollIntoView(newFocus);
|
|
571
472
|
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}, {
|
|
584
|
-
key: "deselectRange",
|
|
585
|
-
value: function deselectRange(range) {
|
|
586
|
-
RangeUtils.validateRange(range);
|
|
587
|
-
this.setState(function (_ref5) {
|
|
588
|
-
var selectedRanges = _ref5.selectedRanges;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
handleScroll(_ref5) {
|
|
476
|
+
var {
|
|
477
|
+
scrollUpdateWasRequested,
|
|
478
|
+
scrollOffset
|
|
479
|
+
} = _ref5;
|
|
480
|
+
this.setState(state => {
|
|
481
|
+
if (scrollUpdateWasRequested) {
|
|
482
|
+
// The scroll was caused by scrollTo() or scrollToItem()
|
|
483
|
+
// Don't re-calc isStuckToBottom
|
|
589
484
|
return {
|
|
590
|
-
|
|
485
|
+
scrollOffset
|
|
591
486
|
};
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
var {
|
|
490
|
+
isStickyBottom
|
|
491
|
+
} = this.props;
|
|
492
|
+
var {
|
|
493
|
+
height
|
|
494
|
+
} = state;
|
|
495
|
+
var isStuckToBottom = isStickyBottom && this.isListAtBottom({
|
|
496
|
+
scrollOffset,
|
|
497
|
+
height
|
|
592
498
|
});
|
|
499
|
+
return {
|
|
500
|
+
isStuckToBottom,
|
|
501
|
+
scrollOffset
|
|
502
|
+
};
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
resetMouseState() {
|
|
507
|
+
this.setState({
|
|
508
|
+
mouseDownIndex: null,
|
|
509
|
+
isDragging: false
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
scrollToBottom() {
|
|
514
|
+
var {
|
|
515
|
+
itemCount
|
|
516
|
+
} = this.props;
|
|
517
|
+
|
|
518
|
+
if (this.list.current) {
|
|
519
|
+
this.list.current.scrollToItem(itemCount);
|
|
593
520
|
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
this.selectRange([index, index]);
|
|
600
|
-
}
|
|
601
|
-
}, {
|
|
602
|
-
key: "selectRange",
|
|
603
|
-
value: function selectRange(range) {
|
|
604
|
-
RangeUtils.validateRange(range);
|
|
605
|
-
this.setState(function (_ref6) {
|
|
606
|
-
var selectedRanges = _ref6.selectedRanges;
|
|
607
|
-
return {
|
|
608
|
-
selectedRanges: RangeUtils.selectRange(selectedRanges, range)
|
|
609
|
-
};
|
|
610
|
-
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
scrollIntoView(itemIndex) {
|
|
524
|
+
if (this.list.current) {
|
|
525
|
+
this.list.current.scrollToItem(itemIndex);
|
|
611
526
|
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* @param index The index to toggle selection for
|
|
530
|
+
* @param isShiftDown True if the shift modifier key is down
|
|
531
|
+
* @param isModifierDown True if the meta modifier key is down
|
|
532
|
+
* @param isDeselectable True if item should be deselected if already selected
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
toggleSelect(index, isShiftDown, isModifierDown) {
|
|
537
|
+
var isDeselectable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
538
|
+
var {
|
|
539
|
+
isMultiSelect
|
|
540
|
+
} = this.props;
|
|
541
|
+
var {
|
|
542
|
+
selectedRanges
|
|
543
|
+
} = this.state;
|
|
544
|
+
|
|
545
|
+
if (isMultiSelect && isShiftDown && selectedRanges.length > 0) {
|
|
546
|
+
var lastRange = selectedRanges[selectedRanges.length - 1];
|
|
547
|
+
this.selectRange([Math.min(lastRange[0], index), Math.max(index, lastRange[1])]);
|
|
548
|
+
} else if (isMultiSelect && selectedRanges.length === 1 && selectedRanges[0][0] === index && selectedRanges[0][1] === index) {
|
|
549
|
+
if (isDeselectable) {
|
|
550
|
+
this.deselectItem(index);
|
|
551
|
+
}
|
|
552
|
+
} else if (isMultiSelect && isModifierDown) {
|
|
553
|
+
if (this.getItemSelected(index, selectedRanges)) {
|
|
554
|
+
if (isDeselectable) {
|
|
555
|
+
this.deselectItem(index);
|
|
556
|
+
}
|
|
557
|
+
} else {
|
|
558
|
+
this.selectItem(index);
|
|
559
|
+
}
|
|
560
|
+
} else {
|
|
561
|
+
this.deselectAll();
|
|
562
|
+
this.selectItem(index);
|
|
618
563
|
}
|
|
619
|
-
}
|
|
620
|
-
key: "sendViewportUpdate",
|
|
621
|
-
value: function sendViewportUpdate() {
|
|
622
|
-
var _this$state4 = this.state,
|
|
623
|
-
scrollOffset = _this$state4.scrollOffset,
|
|
624
|
-
height = _this$state4.height;
|
|
564
|
+
}
|
|
625
565
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
566
|
+
deselectAll() {
|
|
567
|
+
var {
|
|
568
|
+
itemCount
|
|
569
|
+
} = this.props;
|
|
570
|
+
this.deselectRange([0, itemCount]);
|
|
571
|
+
}
|
|
630
572
|
|
|
631
|
-
|
|
573
|
+
deselectItem(index) {
|
|
574
|
+
this.deselectRange([index, index]);
|
|
575
|
+
}
|
|
632
576
|
|
|
633
|
-
|
|
577
|
+
deselectRange(range) {
|
|
578
|
+
RangeUtils.validateRange(range);
|
|
579
|
+
this.setState((_ref6) => {
|
|
580
|
+
var {
|
|
581
|
+
selectedRanges
|
|
582
|
+
} = _ref6;
|
|
583
|
+
return {
|
|
584
|
+
selectedRanges: RangeUtils.deselectRange(selectedRanges, range)
|
|
585
|
+
};
|
|
586
|
+
});
|
|
587
|
+
}
|
|
634
588
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
scrollOffset = _ref7.scrollOffset,
|
|
643
|
-
height = _ref7.height;
|
|
644
|
-
|
|
645
|
-
if (height == null || scrollOffset == null) {
|
|
646
|
-
return false;
|
|
647
|
-
}
|
|
589
|
+
selectItem(index) {
|
|
590
|
+
var {
|
|
591
|
+
disableSelect
|
|
592
|
+
} = this.props;
|
|
593
|
+
if (disableSelect) return;
|
|
594
|
+
this.selectRange([index, index]);
|
|
595
|
+
}
|
|
648
596
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
items = _this$props7.items,
|
|
661
|
-
offset = _this$props7.offset,
|
|
662
|
-
renderItem = _this$props7.renderItem,
|
|
663
|
-
disableSelect = _this$props7.disableSelect;
|
|
664
|
-
var _this$state5 = this.state,
|
|
665
|
-
focusIndex = _this$state5.focusIndex,
|
|
666
|
-
selectedRanges = _this$state5.selectedRanges;
|
|
667
|
-
|
|
668
|
-
if (itemIndex < offset || itemIndex >= offset + items.length) {
|
|
669
|
-
return null;
|
|
670
|
-
}
|
|
597
|
+
selectRange(range) {
|
|
598
|
+
RangeUtils.validateRange(range);
|
|
599
|
+
this.setState((_ref7) => {
|
|
600
|
+
var {
|
|
601
|
+
selectedRanges
|
|
602
|
+
} = _ref7;
|
|
603
|
+
return {
|
|
604
|
+
selectedRanges: RangeUtils.selectRange(selectedRanges, range)
|
|
605
|
+
};
|
|
606
|
+
});
|
|
607
|
+
}
|
|
671
608
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
height: height,
|
|
696
|
-
width: width,
|
|
697
|
-
itemCount: itemCount,
|
|
698
|
-
itemSize: rowHeight // This prop isn't actually used by us, it is passed to the render function by react-window
|
|
699
|
-
// Used here to force a re-render of the List component.
|
|
700
|
-
// Otherwise it doesn't know to call the render again when selection or renderItem changes
|
|
701
|
-
,
|
|
702
|
-
itemData: _this3.getItemData(items, selectedRanges, renderItem),
|
|
703
|
-
onScroll: _this3.handleScroll,
|
|
704
|
-
onItemsRendered: _this3.handleItemsRendered,
|
|
705
|
-
ref: _this3.list,
|
|
706
|
-
outerElementType: _this3.getOuterElement(_this3.handleKeyDown),
|
|
707
|
-
outerRef: _this3.listContainer,
|
|
708
|
-
innerElementType: _this3.getInnerElement(),
|
|
709
|
-
overscanCount: overscanCount
|
|
710
|
-
}, _this3.renderInnerElement);
|
|
711
|
-
});
|
|
609
|
+
setSelectedRanges(selectedRanges) {
|
|
610
|
+
this.setState({
|
|
611
|
+
selectedRanges
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
sendViewportUpdate() {
|
|
616
|
+
var {
|
|
617
|
+
scrollOffset,
|
|
618
|
+
height
|
|
619
|
+
} = this.state;
|
|
620
|
+
|
|
621
|
+
if (scrollOffset != null && height != null) {
|
|
622
|
+
var {
|
|
623
|
+
onViewportChange: _onViewportChange,
|
|
624
|
+
rowHeight
|
|
625
|
+
} = this.props;
|
|
626
|
+
|
|
627
|
+
var _topRow = Math.floor(scrollOffset / rowHeight);
|
|
628
|
+
|
|
629
|
+
var _bottomRow = _topRow + Math.ceil(height / rowHeight);
|
|
630
|
+
|
|
631
|
+
_onViewportChange(_topRow, _bottomRow);
|
|
712
632
|
}
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
isListAtBottom() {
|
|
636
|
+
var {
|
|
637
|
+
scrollOffset,
|
|
638
|
+
height
|
|
639
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state;
|
|
640
|
+
|
|
641
|
+
if (height == null || scrollOffset == null) {
|
|
642
|
+
return false;
|
|
721
643
|
}
|
|
722
|
-
}]);
|
|
723
644
|
|
|
724
|
-
|
|
725
|
-
|
|
645
|
+
var {
|
|
646
|
+
itemCount,
|
|
647
|
+
rowHeight
|
|
648
|
+
} = this.props;
|
|
649
|
+
return scrollOffset + height >= itemCount * rowHeight;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
renderInnerElement(_ref8) {
|
|
653
|
+
var {
|
|
654
|
+
index: itemIndex,
|
|
655
|
+
style
|
|
656
|
+
} = _ref8;
|
|
657
|
+
var {
|
|
658
|
+
items,
|
|
659
|
+
offset,
|
|
660
|
+
renderItem,
|
|
661
|
+
disableSelect
|
|
662
|
+
} = this.props;
|
|
663
|
+
var {
|
|
664
|
+
focusIndex,
|
|
665
|
+
selectedRanges
|
|
666
|
+
} = this.state;
|
|
667
|
+
|
|
668
|
+
if (itemIndex < offset || itemIndex >= offset + items.length) {
|
|
669
|
+
return null;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
var item = items[itemIndex - offset];
|
|
673
|
+
return this.getCachedItem(itemIndex, itemIndex, item, itemIndex === focusIndex && !disableSelect, this.getItemSelected(itemIndex, selectedRanges), renderItem, style, disableSelect);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
render() {
|
|
677
|
+
var {
|
|
678
|
+
items,
|
|
679
|
+
itemCount,
|
|
680
|
+
overscanCount,
|
|
681
|
+
renderItem,
|
|
682
|
+
rowHeight
|
|
683
|
+
} = this.props;
|
|
684
|
+
var {
|
|
685
|
+
selectedRanges
|
|
686
|
+
} = this.state;
|
|
687
|
+
return /*#__PURE__*/React.createElement(AutoSizer, {
|
|
688
|
+
className: "item-list-auto-sizer",
|
|
689
|
+
onResize: this.handleResize
|
|
690
|
+
}, (_ref9) => {
|
|
691
|
+
var {
|
|
692
|
+
width,
|
|
693
|
+
height
|
|
694
|
+
} = _ref9;
|
|
695
|
+
return /*#__PURE__*/React.createElement(List, {
|
|
696
|
+
className: "item-list-scroll-pane",
|
|
697
|
+
height: height,
|
|
698
|
+
width: width,
|
|
699
|
+
itemCount: itemCount,
|
|
700
|
+
itemSize: rowHeight // This prop isn't actually used by us, it is passed to the render function by react-window
|
|
701
|
+
// Used here to force a re-render of the List component.
|
|
702
|
+
// Otherwise it doesn't know to call the render again when selection or renderItem changes
|
|
703
|
+
,
|
|
704
|
+
itemData: this.getItemData(items, selectedRanges, renderItem),
|
|
705
|
+
onScroll: this.handleScroll,
|
|
706
|
+
onItemsRendered: this.handleItemsRendered,
|
|
707
|
+
ref: this.list,
|
|
708
|
+
outerElementType: this.getOuterElement(this.handleKeyDown),
|
|
709
|
+
outerRef: this.listContainer,
|
|
710
|
+
innerElementType: this.getInnerElement(),
|
|
711
|
+
overscanCount: overscanCount
|
|
712
|
+
}, this.renderInnerElement);
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
}
|
|
726
717
|
|
|
727
718
|
_defineProperty(ItemList, "CACHE_SIZE", 1000);
|
|
728
719
|
|
|
@@ -734,19 +725,25 @@ _defineProperty(ItemList, "defaultProps", {
|
|
|
734
725
|
offset: 0,
|
|
735
726
|
items: [],
|
|
736
727
|
rowHeight: ItemList.DEFAULT_ROW_HEIGHT,
|
|
728
|
+
isDeselectOnClick: true,
|
|
737
729
|
isDoubleClickSelect: false,
|
|
738
730
|
isDragSelect: true,
|
|
739
731
|
isMultiSelect: false,
|
|
740
732
|
isStickyBottom: false,
|
|
741
733
|
disableSelect: false,
|
|
742
|
-
|
|
734
|
+
|
|
735
|
+
onFocusChange() {// no-op
|
|
743
736
|
},
|
|
744
|
-
|
|
737
|
+
|
|
738
|
+
onSelect() {// no-op
|
|
745
739
|
},
|
|
746
|
-
|
|
740
|
+
|
|
741
|
+
onSelectionChange() {// no-op
|
|
747
742
|
},
|
|
748
|
-
|
|
743
|
+
|
|
744
|
+
onViewportChange() {// no-op
|
|
749
745
|
},
|
|
746
|
+
|
|
750
747
|
overscanCount: ItemList.DEFAULT_OVERSCAN,
|
|
751
748
|
renderItem: ItemList.renderItem,
|
|
752
749
|
selectedRanges: [],
|