@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/ComboBox.js
CHANGED
|
@@ -1,29 +1,7 @@
|
|
|
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
2
|
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
4
|
|
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
|
|
9
|
-
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); } }
|
|
10
|
-
|
|
11
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
12
|
-
|
|
13
|
-
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); }
|
|
14
|
-
|
|
15
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
-
|
|
17
|
-
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); }; }
|
|
18
|
-
|
|
19
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
20
|
-
|
|
21
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
22
|
-
|
|
23
|
-
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; } }
|
|
24
|
-
|
|
25
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
26
|
-
|
|
27
5
|
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; }
|
|
28
6
|
|
|
29
7
|
/**
|
|
@@ -46,8 +24,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
46
24
|
import { vsTriangleDown } from '@deephaven/icons';
|
|
47
25
|
import memoize from 'memoizee';
|
|
48
26
|
import classNames from 'classnames';
|
|
49
|
-
import SearchInput from
|
|
50
|
-
import { Popper } from
|
|
27
|
+
import SearchInput from "./SearchInput.js";
|
|
28
|
+
import { Popper } from "./popper/index.js";
|
|
51
29
|
import "./ComboBox.css";
|
|
52
30
|
var MENU_NAVIGATION_DIRECTION;
|
|
53
31
|
|
|
@@ -56,37 +34,25 @@ var MENU_NAVIGATION_DIRECTION;
|
|
|
56
34
|
MENU_NAVIGATION_DIRECTION["DOWN"] = "DOWN";
|
|
57
35
|
})(MENU_NAVIGATION_DIRECTION || (MENU_NAVIGATION_DIRECTION = {}));
|
|
58
36
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var _super = _createSuper(ComboBox);
|
|
63
|
-
|
|
64
|
-
function ComboBox(props) {
|
|
65
|
-
var _this;
|
|
37
|
+
class ComboBox extends Component {
|
|
38
|
+
constructor(props) {
|
|
39
|
+
super(props);
|
|
66
40
|
|
|
67
|
-
|
|
41
|
+
_defineProperty(this, "popper", void 0);
|
|
68
42
|
|
|
69
|
-
|
|
43
|
+
_defineProperty(this, "cbContainer", void 0);
|
|
70
44
|
|
|
71
|
-
_defineProperty(
|
|
45
|
+
_defineProperty(this, "toggleButton", void 0);
|
|
72
46
|
|
|
73
|
-
_defineProperty(
|
|
47
|
+
_defineProperty(this, "menuContainer", void 0);
|
|
74
48
|
|
|
75
|
-
_defineProperty(
|
|
49
|
+
_defineProperty(this, "input", void 0);
|
|
76
50
|
|
|
77
|
-
_defineProperty(
|
|
51
|
+
_defineProperty(this, "searchInput", void 0);
|
|
78
52
|
|
|
79
|
-
_defineProperty(
|
|
53
|
+
_defineProperty(this, "getCachedFilteredOptions", memoize((options, input) => options.filter(option => option.title.toLowerCase().indexOf(input.toLowerCase()) >= 0 || option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0)));
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
_defineProperty(_assertThisInitialized(_this), "getCachedFilteredOptions", memoize(function (options, input) {
|
|
84
|
-
return options.filter(function (option) {
|
|
85
|
-
return option.title.toLowerCase().indexOf(input.toLowerCase()) >= 0 || option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
86
|
-
});
|
|
87
|
-
}));
|
|
88
|
-
|
|
89
|
-
_this.state = {
|
|
55
|
+
this.state = {
|
|
90
56
|
value: '',
|
|
91
57
|
filter: '',
|
|
92
58
|
filteredOptions: props.options,
|
|
@@ -94,461 +60,464 @@ var ComboBox = /*#__PURE__*/function (_Component) {
|
|
|
94
60
|
menuIsOpen: false,
|
|
95
61
|
inputWidth: 100
|
|
96
62
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return _this;
|
|
63
|
+
this.toggleMenu = this.toggleMenu.bind(this);
|
|
64
|
+
this.handleMenuKeyDown = this.handleMenuKeyDown.bind(this);
|
|
65
|
+
this.handleMenuBlur = this.handleMenuBlur.bind(this);
|
|
66
|
+
this.closeMenu = this.closeMenu.bind(this);
|
|
67
|
+
this.handleInputChange = this.handleInputChange.bind(this);
|
|
68
|
+
this.handleInputKeyDown = this.handleInputKeyDown.bind(this);
|
|
69
|
+
this.handleInputBlur = this.handleInputBlur.bind(this);
|
|
70
|
+
this.handleFilterChange = this.handleFilterChange.bind(this);
|
|
71
|
+
this.handleOptionClick = this.handleOptionClick.bind(this);
|
|
72
|
+
this.handleOptionFocus = this.handleOptionFocus.bind(this);
|
|
73
|
+
this.handleMenuOpened = this.handleMenuOpened.bind(this);
|
|
74
|
+
this.handleMenuExited = this.handleMenuExited.bind(this);
|
|
75
|
+
this.popper = /*#__PURE__*/React.createRef();
|
|
76
|
+
this.cbContainer = /*#__PURE__*/React.createRef();
|
|
77
|
+
this.toggleButton = /*#__PURE__*/React.createRef();
|
|
78
|
+
this.menuContainer = /*#__PURE__*/React.createRef();
|
|
79
|
+
this.input = /*#__PURE__*/React.createRef();
|
|
80
|
+
this.searchInput = /*#__PURE__*/React.createRef();
|
|
116
81
|
}
|
|
117
82
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
keyboardOptionIndex = _this$state.keyboardOptionIndex;
|
|
83
|
+
componentDidUpdate() {
|
|
84
|
+
var {
|
|
85
|
+
menuIsOpen,
|
|
86
|
+
keyboardOptionIndex
|
|
87
|
+
} = this.state;
|
|
124
88
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "setInputWidth",
|
|
131
|
-
value: function setInputWidth() {
|
|
132
|
-
if (this.cbContainer.current) {
|
|
133
|
-
this.setState({
|
|
134
|
-
inputWidth: this.cbContainer.current.getBoundingClientRect().width
|
|
135
|
-
});
|
|
136
|
-
}
|
|
89
|
+
if (menuIsOpen && keyboardOptionIndex >= 0) {
|
|
90
|
+
this.scrollOptionIntoView();
|
|
137
91
|
}
|
|
138
|
-
}
|
|
139
|
-
key: "focus",
|
|
140
|
-
value: function focus() {
|
|
141
|
-
var _this$input$current;
|
|
92
|
+
}
|
|
142
93
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}, {
|
|
146
|
-
key: "resetValue",
|
|
147
|
-
value: function resetValue() {
|
|
148
|
-
this.setState({
|
|
149
|
-
value: ''
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}, {
|
|
153
|
-
key: "updateInputValue",
|
|
154
|
-
value: function updateInputValue(value) {
|
|
155
|
-
var onChange = this.props.onChange;
|
|
94
|
+
setInputWidth() {
|
|
95
|
+
if (this.cbContainer.current) {
|
|
156
96
|
this.setState({
|
|
157
|
-
|
|
97
|
+
inputWidth: this.cbContainer.current.getBoundingClientRect().width
|
|
158
98
|
});
|
|
159
|
-
onChange(value);
|
|
160
99
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
focus() {
|
|
103
|
+
var _this$input$current;
|
|
104
|
+
|
|
105
|
+
(_this$input$current = this.input.current) === null || _this$input$current === void 0 ? void 0 : _this$input$current.focus();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
resetValue() {
|
|
109
|
+
this.setState({
|
|
110
|
+
value: ''
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
updateInputValue(value) {
|
|
115
|
+
var {
|
|
116
|
+
onChange
|
|
117
|
+
} = this.props;
|
|
118
|
+
this.setState({
|
|
119
|
+
value
|
|
120
|
+
});
|
|
121
|
+
onChange(value);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
handleResize() {
|
|
125
|
+
this.setInputWidth();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
handleMenuKeyDown(event) {
|
|
129
|
+
var _menuOptions$keyboard, _this$input$current2;
|
|
130
|
+
|
|
131
|
+
var {
|
|
132
|
+
filter,
|
|
133
|
+
filteredOptions,
|
|
134
|
+
keyboardOptionIndex
|
|
135
|
+
} = this.state;
|
|
136
|
+
var {
|
|
137
|
+
options
|
|
138
|
+
} = this.props;
|
|
139
|
+
var menuOptions = filter ? filteredOptions : options;
|
|
140
|
+
|
|
141
|
+
switch (event.key) {
|
|
142
|
+
case 'Enter':
|
|
143
|
+
if (((_menuOptions$keyboard = menuOptions[keyboardOptionIndex]) === null || _menuOptions$keyboard === void 0 ? void 0 : _menuOptions$keyboard.value) != null) {
|
|
144
|
+
this.updateInputValue(menuOptions[keyboardOptionIndex].value);
|
|
145
|
+
}
|
|
183
146
|
|
|
147
|
+
this.closeMenu();
|
|
148
|
+
(_this$input$current2 = this.input.current) === null || _this$input$current2 === void 0 ? void 0 : _this$input$current2.focus();
|
|
149
|
+
event.stopPropagation();
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case 'ArrowUp':
|
|
154
|
+
this.handleMenuNavigation(ComboBox.MENU_NAVIGATION_DIRECTION.UP);
|
|
155
|
+
event.stopPropagation();
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
break;
|
|
158
|
+
|
|
159
|
+
case 'ArrowDown':
|
|
160
|
+
this.handleMenuNavigation(ComboBox.MENU_NAVIGATION_DIRECTION.DOWN);
|
|
161
|
+
event.stopPropagation();
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
break;
|
|
164
|
+
|
|
165
|
+
case 'Escape':
|
|
166
|
+
if (filter !== '') {
|
|
167
|
+
this.setState({
|
|
168
|
+
filter: ''
|
|
169
|
+
});
|
|
170
|
+
event.stopPropagation(); // Don't trigger blur on input element
|
|
171
|
+
} else {
|
|
184
172
|
this.closeMenu();
|
|
185
|
-
|
|
186
|
-
event.stopPropagation();
|
|
187
|
-
event.preventDefault();
|
|
188
|
-
break;
|
|
189
|
-
|
|
190
|
-
case 'ArrowUp':
|
|
191
|
-
this.handleMenuNavigation(ComboBox.MENU_NAVIGATION_DIRECTION.UP);
|
|
192
|
-
event.stopPropagation();
|
|
193
|
-
event.preventDefault();
|
|
194
|
-
break;
|
|
195
|
-
|
|
196
|
-
case 'ArrowDown':
|
|
197
|
-
this.handleMenuNavigation(ComboBox.MENU_NAVIGATION_DIRECTION.DOWN);
|
|
198
|
-
event.stopPropagation();
|
|
199
|
-
event.preventDefault();
|
|
200
|
-
break;
|
|
201
|
-
|
|
202
|
-
case 'Escape':
|
|
203
|
-
if (filter !== '') {
|
|
204
|
-
this.setState({
|
|
205
|
-
filter: ''
|
|
206
|
-
});
|
|
207
|
-
event.stopPropagation(); // Don't trigger blur on input element
|
|
208
|
-
} else {
|
|
209
|
-
this.closeMenu();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
break;
|
|
213
|
-
|
|
214
|
-
case 'Tab':
|
|
215
|
-
if (!event.shiftKey && keyboardOptionIndex === menuOptions.length - 1) {
|
|
216
|
-
this.closeMenu();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
break;
|
|
220
|
-
|
|
221
|
-
default:
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}, {
|
|
226
|
-
key: "handleMenuNavigation",
|
|
227
|
-
value: function handleMenuNavigation(direction) {
|
|
228
|
-
var _this$state3 = this.state,
|
|
229
|
-
filter = _this$state3.filter,
|
|
230
|
-
filteredOptions = _this$state3.filteredOptions,
|
|
231
|
-
keyboardOptionIndex = _this$state3.keyboardOptionIndex;
|
|
232
|
-
var options = this.props.options;
|
|
233
|
-
var menuOptions = filter ? filteredOptions : options;
|
|
234
|
-
var menuOptionsLength = menuOptions.length;
|
|
235
|
-
var delta = 0;
|
|
236
|
-
|
|
237
|
-
switch (direction) {
|
|
238
|
-
case ComboBox.MENU_NAVIGATION_DIRECTION.UP:
|
|
239
|
-
delta = -1;
|
|
240
|
-
break;
|
|
241
|
-
|
|
242
|
-
case ComboBox.MENU_NAVIGATION_DIRECTION.DOWN:
|
|
243
|
-
delta = 1;
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
173
|
+
}
|
|
246
174
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
}, {
|
|
254
|
-
key: "handleInputKeyDown",
|
|
255
|
-
value: function handleInputKeyDown(event) {
|
|
256
|
-
var onEnter = this.props.onEnter;
|
|
257
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
258
|
-
|
|
259
|
-
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
260
|
-
if (!menuIsOpen) {
|
|
261
|
-
this.openMenu();
|
|
175
|
+
break;
|
|
176
|
+
|
|
177
|
+
case 'Tab':
|
|
178
|
+
if (!event.shiftKey && keyboardOptionIndex === menuOptions.length - 1) {
|
|
179
|
+
this.closeMenu();
|
|
262
180
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
key: "handleInputChange",
|
|
269
|
-
value: function handleInputChange(event) {
|
|
270
|
-
this.updateInputValue(event.target.value);
|
|
271
|
-
}
|
|
272
|
-
}, {
|
|
273
|
-
key: "handleOptionClick",
|
|
274
|
-
value: function handleOptionClick(event) {
|
|
275
|
-
var _this$input$current3;
|
|
276
|
-
|
|
277
|
-
var optionIndex = Number(event.currentTarget.value);
|
|
278
|
-
var _this$state4 = this.state,
|
|
279
|
-
filter = _this$state4.filter,
|
|
280
|
-
filteredOptions = _this$state4.filteredOptions;
|
|
281
|
-
var options = this.props.options;
|
|
282
|
-
var menuOptions = filter ? filteredOptions : options;
|
|
283
|
-
this.updateInputValue(menuOptions[optionIndex].value);
|
|
284
|
-
this.closeMenu();
|
|
285
|
-
(_this$input$current3 = this.input.current) === null || _this$input$current3 === void 0 ? void 0 : _this$input$current3.focus();
|
|
181
|
+
|
|
182
|
+
break;
|
|
183
|
+
|
|
184
|
+
default:
|
|
185
|
+
break;
|
|
286
186
|
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
handleMenuNavigation(direction) {
|
|
190
|
+
var {
|
|
191
|
+
filter,
|
|
192
|
+
filteredOptions,
|
|
193
|
+
keyboardOptionIndex
|
|
194
|
+
} = this.state;
|
|
195
|
+
var {
|
|
196
|
+
options
|
|
197
|
+
} = this.props;
|
|
198
|
+
var menuOptions = filter ? filteredOptions : options;
|
|
199
|
+
var menuOptionsLength = menuOptions.length;
|
|
200
|
+
var delta = 0;
|
|
201
|
+
|
|
202
|
+
switch (direction) {
|
|
203
|
+
case ComboBox.MENU_NAVIGATION_DIRECTION.UP:
|
|
204
|
+
delta = -1;
|
|
205
|
+
break;
|
|
206
|
+
|
|
207
|
+
case ComboBox.MENU_NAVIGATION_DIRECTION.DOWN:
|
|
208
|
+
delta = 1;
|
|
209
|
+
break;
|
|
293
210
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
value: function handleFilterChange(event) {
|
|
297
|
-
var _this$popper$current;
|
|
298
|
-
|
|
299
|
-
var options = this.props.options;
|
|
300
|
-
var filter = event.target.value;
|
|
301
|
-
var filteredOptions = this.getCachedFilteredOptions(options, filter);
|
|
211
|
+
|
|
212
|
+
if (delta !== 0) {
|
|
302
213
|
this.setState({
|
|
303
|
-
|
|
304
|
-
filteredOptions: filteredOptions,
|
|
305
|
-
keyboardOptionIndex: 0
|
|
214
|
+
keyboardOptionIndex: (keyboardOptionIndex + delta + menuOptionsLength) % menuOptionsLength
|
|
306
215
|
});
|
|
307
|
-
(_this$popper$current = this.popper.current) === null || _this$popper$current === void 0 ? void 0 : _this$popper$current.scheduleUpdate();
|
|
308
216
|
}
|
|
309
|
-
}
|
|
310
|
-
key: "handleMenuBlur",
|
|
311
|
-
value: function handleMenuBlur(event) {
|
|
312
|
-
var _this$popper$current2;
|
|
313
|
-
|
|
314
|
-
// close if menu blurs, unless its an internal option or the toggleButton which triggers close via click
|
|
315
|
-
if (event.relatedTarget instanceof Element && (_this$popper$current2 = this.popper.current) !== null && _this$popper$current2 !== void 0 && _this$popper$current2.element.contains(event.relatedTarget) || event.relatedTarget === this.toggleButton.current) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
217
|
+
}
|
|
318
218
|
|
|
319
|
-
|
|
219
|
+
handleInputKeyDown(event) {
|
|
220
|
+
var {
|
|
221
|
+
onEnter
|
|
222
|
+
} = this.props;
|
|
223
|
+
var {
|
|
224
|
+
menuIsOpen
|
|
225
|
+
} = this.state;
|
|
226
|
+
|
|
227
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
228
|
+
if (!menuIsOpen) {
|
|
229
|
+
this.openMenu();
|
|
230
|
+
}
|
|
231
|
+
} else if (event.key === 'Enter') {
|
|
232
|
+
onEnter();
|
|
320
233
|
}
|
|
321
|
-
}
|
|
322
|
-
key: "handleInputBlur",
|
|
323
|
-
value: function handleInputBlur(event) {
|
|
324
|
-
var _this$popper$current3;
|
|
234
|
+
}
|
|
325
235
|
|
|
326
|
-
|
|
327
|
-
|
|
236
|
+
handleInputChange(event) {
|
|
237
|
+
this.updateInputValue(event.target.value);
|
|
238
|
+
}
|
|
328
239
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
240
|
+
handleOptionClick(event) {
|
|
241
|
+
var _this$input$current3;
|
|
242
|
+
|
|
243
|
+
var optionIndex = Number(event.currentTarget.value);
|
|
244
|
+
var {
|
|
245
|
+
filter,
|
|
246
|
+
filteredOptions
|
|
247
|
+
} = this.state;
|
|
248
|
+
var {
|
|
249
|
+
options
|
|
250
|
+
} = this.props;
|
|
251
|
+
var menuOptions = filter ? filteredOptions : options;
|
|
252
|
+
this.updateInputValue(menuOptions[optionIndex].value);
|
|
253
|
+
this.closeMenu();
|
|
254
|
+
(_this$input$current3 = this.input.current) === null || _this$input$current3 === void 0 ? void 0 : _this$input$current3.focus();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
handleOptionFocus(event) {
|
|
258
|
+
this.setState({
|
|
259
|
+
keyboardOptionIndex: Number(event.target.value)
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
handleFilterChange(event) {
|
|
264
|
+
var _this$popper$current;
|
|
265
|
+
|
|
266
|
+
var {
|
|
267
|
+
options
|
|
268
|
+
} = this.props;
|
|
269
|
+
var filter = event.target.value;
|
|
270
|
+
var filteredOptions = this.getCachedFilteredOptions(options, filter);
|
|
271
|
+
this.setState({
|
|
272
|
+
filter,
|
|
273
|
+
filteredOptions,
|
|
274
|
+
keyboardOptionIndex: 0
|
|
275
|
+
});
|
|
276
|
+
(_this$popper$current = this.popper.current) === null || _this$popper$current === void 0 ? void 0 : _this$popper$current.scheduleUpdate();
|
|
277
|
+
}
|
|
332
278
|
|
|
333
|
-
|
|
279
|
+
handleMenuBlur(event) {
|
|
280
|
+
var _this$popper$current2;
|
|
281
|
+
|
|
282
|
+
// close if menu blurs, unless its an internal option or the toggleButton which triggers close via click
|
|
283
|
+
if (event.relatedTarget instanceof Element && (_this$popper$current2 = this.popper.current) !== null && _this$popper$current2 !== void 0 && _this$popper$current2.element.contains(event.relatedTarget) || event.relatedTarget === this.toggleButton.current) {
|
|
284
|
+
return;
|
|
334
285
|
}
|
|
335
|
-
}, {
|
|
336
|
-
key: "handleMenuOpened",
|
|
337
|
-
value: function handleMenuOpened() {
|
|
338
|
-
var _this$searchInput$cur;
|
|
339
286
|
|
|
340
|
-
|
|
341
|
-
|
|
287
|
+
this.closeMenu(false);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
handleInputBlur(event) {
|
|
291
|
+
var _this$popper$current3;
|
|
292
|
+
|
|
293
|
+
// if blur event is caused by focusing on search input or open menu by keyboard, don't close the menu
|
|
294
|
+
var {
|
|
295
|
+
menuIsOpen
|
|
296
|
+
} = this.state;
|
|
297
|
+
|
|
298
|
+
if (menuIsOpen && event.relatedTarget instanceof Element && (_this$popper$current3 = this.popper.current) !== null && _this$popper$current3 !== void 0 && _this$popper$current3.element.contains(event.relatedTarget)) {
|
|
299
|
+
return;
|
|
342
300
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
301
|
+
|
|
302
|
+
this.closeMenu(false);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
handleMenuOpened() {
|
|
306
|
+
var _this$searchInput$cur;
|
|
307
|
+
|
|
308
|
+
this.scrollOptionIntoView();
|
|
309
|
+
(_this$searchInput$cur = this.searchInput.current) === null || _this$searchInput$cur === void 0 ? void 0 : _this$searchInput$cur.focus();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
handleMenuExited() {
|
|
313
|
+
var {
|
|
314
|
+
menuIsOpen
|
|
315
|
+
} = this.state;
|
|
316
|
+
|
|
317
|
+
if (menuIsOpen) {
|
|
318
|
+
var _this$popper$current4;
|
|
356
319
|
|
|
357
320
|
this.setState({
|
|
358
|
-
|
|
321
|
+
menuIsOpen: false
|
|
359
322
|
});
|
|
323
|
+
(_this$popper$current4 = this.popper.current) === null || _this$popper$current4 === void 0 ? void 0 : _this$popper$current4.hide();
|
|
360
324
|
}
|
|
361
|
-
}, {
|
|
362
|
-
key: "toggleMenu",
|
|
363
|
-
value: function toggleMenu(event) {
|
|
364
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
365
325
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
326
|
+
this.setState({
|
|
327
|
+
filter: ''
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
toggleMenu(event) {
|
|
332
|
+
var {
|
|
333
|
+
menuIsOpen
|
|
334
|
+
} = this.state;
|
|
371
335
|
|
|
372
|
-
|
|
336
|
+
if (menuIsOpen) {
|
|
337
|
+
this.closeMenu();
|
|
338
|
+
} else {
|
|
339
|
+
this.openMenu();
|
|
373
340
|
}
|
|
374
|
-
}, {
|
|
375
|
-
key: "openMenu",
|
|
376
|
-
value: function openMenu() {
|
|
377
|
-
var _this2 = this;
|
|
378
341
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
this.setState({
|
|
382
|
-
menuIsOpen: true
|
|
383
|
-
});
|
|
384
|
-
window.requestAnimationFrame(function () {
|
|
385
|
-
var _this2$popper$current;
|
|
342
|
+
event.stopPropagation();
|
|
343
|
+
}
|
|
386
344
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
345
|
+
openMenu() {
|
|
346
|
+
this.updateKeyboardIndex();
|
|
347
|
+
this.setInputWidth();
|
|
348
|
+
this.setState({
|
|
349
|
+
menuIsOpen: true
|
|
350
|
+
});
|
|
351
|
+
window.requestAnimationFrame(() => {
|
|
393
352
|
var _this$popper$current5;
|
|
394
353
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
});
|
|
354
|
+
(_this$popper$current5 = this.popper.current) === null || _this$popper$current5 === void 0 ? void 0 : _this$popper$current5.show();
|
|
355
|
+
});
|
|
356
|
+
}
|
|
399
357
|
|
|
400
|
-
|
|
401
|
-
|
|
358
|
+
closeMenu() {
|
|
359
|
+
var _this$popper$current6;
|
|
402
360
|
|
|
403
|
-
|
|
404
|
-
|
|
361
|
+
var focusInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
362
|
+
this.setState({
|
|
363
|
+
menuIsOpen: false
|
|
364
|
+
});
|
|
405
365
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
value: function updateKeyboardIndex() {
|
|
411
|
-
var _this$state5 = this.state,
|
|
412
|
-
value = _this$state5.value,
|
|
413
|
-
filter = _this$state5.filter,
|
|
414
|
-
filteredOptions = _this$state5.filteredOptions;
|
|
415
|
-
var options = this.props.options;
|
|
416
|
-
var menuOptions = filter ? filteredOptions : options;
|
|
417
|
-
var valueIndex = menuOptions.findIndex(function (option) {
|
|
418
|
-
return option.value === value;
|
|
419
|
-
});
|
|
420
|
-
this.setState({
|
|
421
|
-
keyboardOptionIndex: valueIndex
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
}, {
|
|
425
|
-
key: "scrollOptionIntoView",
|
|
426
|
-
value: function scrollOptionIntoView() {
|
|
427
|
-
var _this$menuContainer$c;
|
|
428
|
-
|
|
429
|
-
var activeOption = (_this$menuContainer$c = this.menuContainer.current) === null || _this$menuContainer$c === void 0 ? void 0 : _this$menuContainer$c.querySelector('.cb-option-btn.keyboard-active');
|
|
430
|
-
|
|
431
|
-
if (activeOption instanceof HTMLElement) {
|
|
432
|
-
activeOption.scrollIntoView({
|
|
433
|
-
block: 'nearest',
|
|
434
|
-
inline: 'nearest'
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}, {
|
|
439
|
-
key: "renderMenuElement",
|
|
440
|
-
value: function renderMenuElement() {
|
|
441
|
-
var searchPlaceholder = this.props.searchPlaceholder;
|
|
442
|
-
var _this$state6 = this.state,
|
|
443
|
-
filter = _this$state6.filter,
|
|
444
|
-
inputWidth = _this$state6.inputWidth;
|
|
445
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
446
|
-
className: "cb-menu-container",
|
|
447
|
-
ref: this.menuContainer,
|
|
448
|
-
role: "presentation",
|
|
449
|
-
onKeyDown: this.handleMenuKeyDown,
|
|
450
|
-
onClick: function onClick(event) {
|
|
451
|
-
event.stopPropagation();
|
|
452
|
-
},
|
|
453
|
-
style: {
|
|
454
|
-
width: inputWidth
|
|
455
|
-
},
|
|
456
|
-
onBlur: this.handleMenuBlur
|
|
457
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
458
|
-
className: "cb-search-input-container"
|
|
459
|
-
}, /*#__PURE__*/React.createElement(SearchInput, {
|
|
460
|
-
value: filter,
|
|
461
|
-
ref: this.searchInput,
|
|
462
|
-
onChange: this.handleFilterChange,
|
|
463
|
-
className: "cb-search-input",
|
|
464
|
-
placeholder: searchPlaceholder
|
|
465
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
466
|
-
className: "cb-options-container"
|
|
467
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
468
|
-
className: "cb-options"
|
|
469
|
-
}, this.renderOptions())));
|
|
366
|
+
if (focusInput) {
|
|
367
|
+
var _this$input$current4;
|
|
368
|
+
|
|
369
|
+
(_this$input$current4 = this.input.current) === null || _this$input$current4 === void 0 ? void 0 : _this$input$current4.focus();
|
|
470
370
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
371
|
+
|
|
372
|
+
(_this$popper$current6 = this.popper.current) === null || _this$popper$current6 === void 0 ? void 0 : _this$popper$current6.hide();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
updateKeyboardIndex() {
|
|
376
|
+
var {
|
|
377
|
+
value,
|
|
378
|
+
filter,
|
|
379
|
+
filteredOptions
|
|
380
|
+
} = this.state;
|
|
381
|
+
var {
|
|
382
|
+
options
|
|
383
|
+
} = this.props;
|
|
384
|
+
var menuOptions = filter ? filteredOptions : options;
|
|
385
|
+
var valueIndex = menuOptions.findIndex(option => option.value === value);
|
|
386
|
+
this.setState({
|
|
387
|
+
keyboardOptionIndex: valueIndex
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
scrollOptionIntoView() {
|
|
392
|
+
var _this$menuContainer$c;
|
|
393
|
+
|
|
394
|
+
var activeOption = (_this$menuContainer$c = this.menuContainer.current) === null || _this$menuContainer$c === void 0 ? void 0 : _this$menuContainer$c.querySelector('.cb-option-btn.keyboard-active');
|
|
395
|
+
|
|
396
|
+
if (activeOption instanceof HTMLElement) {
|
|
397
|
+
activeOption.scrollIntoView({
|
|
398
|
+
block: 'nearest',
|
|
399
|
+
inline: 'nearest'
|
|
494
400
|
});
|
|
495
401
|
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
renderMenuElement() {
|
|
405
|
+
var {
|
|
406
|
+
searchPlaceholder
|
|
407
|
+
} = this.props;
|
|
408
|
+
var {
|
|
409
|
+
filter,
|
|
410
|
+
inputWidth
|
|
411
|
+
} = this.state;
|
|
412
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
413
|
+
className: "cb-menu-container",
|
|
414
|
+
ref: this.menuContainer,
|
|
415
|
+
role: "presentation",
|
|
416
|
+
onKeyDown: this.handleMenuKeyDown,
|
|
417
|
+
onClick: event => {
|
|
418
|
+
event.stopPropagation();
|
|
419
|
+
},
|
|
420
|
+
style: {
|
|
421
|
+
width: inputWidth
|
|
422
|
+
},
|
|
423
|
+
onBlur: this.handleMenuBlur
|
|
424
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
425
|
+
className: "cb-search-input-container"
|
|
426
|
+
}, /*#__PURE__*/React.createElement(SearchInput, {
|
|
427
|
+
value: filter,
|
|
428
|
+
ref: this.searchInput,
|
|
429
|
+
onChange: this.handleFilterChange,
|
|
430
|
+
className: "cb-search-input",
|
|
431
|
+
placeholder: searchPlaceholder
|
|
432
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
433
|
+
className: "cb-options-container"
|
|
434
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
435
|
+
className: "cb-options"
|
|
436
|
+
}, this.renderOptions())));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
renderOptions() {
|
|
440
|
+
var {
|
|
441
|
+
options
|
|
442
|
+
} = this.props;
|
|
443
|
+
var {
|
|
444
|
+
keyboardOptionIndex,
|
|
445
|
+
filter,
|
|
446
|
+
filteredOptions
|
|
447
|
+
} = this.state;
|
|
448
|
+
var menuOptions = filter ? filteredOptions : options;
|
|
449
|
+
return menuOptions.map((option, index) => {
|
|
450
|
+
var key = "option-".concat(index, "-").concat(option.value);
|
|
451
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
452
|
+
key: key,
|
|
532
453
|
type: "button",
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
454
|
+
value: index,
|
|
455
|
+
className: classNames('cb-option-btn', {
|
|
456
|
+
'keyboard-active': keyboardOptionIndex === index
|
|
457
|
+
}),
|
|
458
|
+
onClick: this.handleOptionClick,
|
|
459
|
+
onFocus: this.handleOptionFocus
|
|
460
|
+
}, option.title);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
render() {
|
|
465
|
+
var {
|
|
466
|
+
options,
|
|
467
|
+
inputPlaceholder,
|
|
468
|
+
disabled,
|
|
469
|
+
className,
|
|
470
|
+
defaultValue,
|
|
471
|
+
spellCheck
|
|
472
|
+
} = this.props;
|
|
473
|
+
var {
|
|
474
|
+
value
|
|
475
|
+
} = this.state;
|
|
476
|
+
var {
|
|
477
|
+
popperOptions
|
|
478
|
+
} = this.props;
|
|
479
|
+
popperOptions = _objectSpread({
|
|
480
|
+
placement: 'bottom-end',
|
|
481
|
+
modifiers: {
|
|
482
|
+
preventOverflow: {
|
|
483
|
+
enabled: false
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}, popperOptions);
|
|
487
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
488
|
+
className: "input-group cb-container",
|
|
489
|
+
ref: this.cbContainer
|
|
490
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
491
|
+
value: value || defaultValue,
|
|
492
|
+
className: classNames('form-control', className, 'cb-input'),
|
|
493
|
+
ref: this.input,
|
|
494
|
+
onChange: this.handleInputChange,
|
|
495
|
+
placeholder: inputPlaceholder || options[0] && options[0].title,
|
|
496
|
+
disabled: disabled,
|
|
497
|
+
onBlur: this.handleInputBlur,
|
|
498
|
+
onKeyDown: this.handleInputKeyDown,
|
|
499
|
+
spellCheck: spellCheck
|
|
500
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
501
|
+
className: "input-group-append cb-dropdown"
|
|
502
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
503
|
+
type: "button",
|
|
504
|
+
className: "btn cb-btn form-control",
|
|
505
|
+
ref: this.toggleButton,
|
|
506
|
+
onClick: this.toggleMenu,
|
|
507
|
+
onKeyDown: this.handleInputKeyDown,
|
|
508
|
+
disabled: disabled
|
|
509
|
+
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
510
|
+
icon: vsTriangleDown
|
|
511
|
+
}), /*#__PURE__*/React.createElement(Popper, {
|
|
512
|
+
ref: this.popper,
|
|
513
|
+
options: popperOptions,
|
|
514
|
+
className: classNames('combobox interactive'),
|
|
515
|
+
onEntered: this.handleMenuOpened,
|
|
516
|
+
onExited: this.handleMenuExited
|
|
517
|
+
}, this.renderMenuElement()))));
|
|
518
|
+
}
|
|
549
519
|
|
|
550
|
-
|
|
551
|
-
}(Component);
|
|
520
|
+
}
|
|
552
521
|
|
|
553
522
|
_defineProperty(ComboBox, "MENU_NAVIGATION_DIRECTION", MENU_NAVIGATION_DIRECTION);
|
|
554
523
|
|
|
@@ -574,8 +543,9 @@ _defineProperty(ComboBox, "propTypes", {
|
|
|
574
543
|
});
|
|
575
544
|
|
|
576
545
|
_defineProperty(ComboBox, "defaultProps", {
|
|
577
|
-
onChange
|
|
546
|
+
onChange() {// no-op
|
|
578
547
|
},
|
|
548
|
+
|
|
579
549
|
inputPlaceholder: '',
|
|
580
550
|
searchPlaceholder: 'Search',
|
|
581
551
|
disabled: false,
|
|
@@ -583,8 +553,10 @@ _defineProperty(ComboBox, "defaultProps", {
|
|
|
583
553
|
defaultValue: '',
|
|
584
554
|
popperOptions: null,
|
|
585
555
|
spellCheck: true,
|
|
586
|
-
|
|
556
|
+
|
|
557
|
+
onEnter() {// no-op
|
|
587
558
|
}
|
|
559
|
+
|
|
588
560
|
});
|
|
589
561
|
|
|
590
562
|
export default ComboBox;
|