@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
|
@@ -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
|
/**
|
|
@@ -49,7 +27,7 @@ import PropTypes from 'prop-types';
|
|
|
49
27
|
import memoize from 'memoizee';
|
|
50
28
|
import classNames from 'classnames';
|
|
51
29
|
import debounce from 'lodash.debounce';
|
|
52
|
-
import { Popper } from
|
|
30
|
+
import { Popper } from "./popper/index.js";
|
|
53
31
|
import "./AutoCompleteInput.css";
|
|
54
32
|
var DEBOUNCE_DELAY = 100;
|
|
55
33
|
var MENU_NAVIGATION_DIRECTION;
|
|
@@ -59,34 +37,24 @@ var MENU_NAVIGATION_DIRECTION;
|
|
|
59
37
|
MENU_NAVIGATION_DIRECTION["DOWN"] = "DOWN";
|
|
60
38
|
})(MENU_NAVIGATION_DIRECTION || (MENU_NAVIGATION_DIRECTION = {}));
|
|
61
39
|
|
|
62
|
-
|
|
63
|
-
|
|
40
|
+
class AutoCompleteInput extends Component {
|
|
41
|
+
constructor(props) {
|
|
42
|
+
super(props);
|
|
64
43
|
|
|
65
|
-
|
|
44
|
+
_defineProperty(this, "popper", void 0);
|
|
66
45
|
|
|
67
|
-
|
|
68
|
-
var _this;
|
|
46
|
+
_defineProperty(this, "cbContainer", void 0);
|
|
69
47
|
|
|
70
|
-
|
|
48
|
+
_defineProperty(this, "menuContainer", void 0);
|
|
71
49
|
|
|
72
|
-
|
|
50
|
+
_defineProperty(this, "input", void 0);
|
|
73
51
|
|
|
74
|
-
_defineProperty(
|
|
52
|
+
_defineProperty(this, "getCachedFilteredOptions", memoize((options, input) => options.filter( // supports partial match
|
|
53
|
+
option => option.title.toLowerCase().indexOf(input.toLowerCase()) >= 0)));
|
|
75
54
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_defineProperty(_assertThisInitialized(_this), "input", void 0);
|
|
81
|
-
|
|
82
|
-
_defineProperty(_assertThisInitialized(_this), "getCachedFilteredOptions", memoize(function (options, input) {
|
|
83
|
-
return options.filter( // supports partial match
|
|
84
|
-
function (option) {
|
|
85
|
-
return option.title.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
86
|
-
});
|
|
87
|
-
}));
|
|
88
|
-
|
|
89
|
-
var popperOptions = _this.props.popperOptions;
|
|
55
|
+
var {
|
|
56
|
+
popperOptions
|
|
57
|
+
} = this.props;
|
|
90
58
|
popperOptions = _objectSpread({
|
|
91
59
|
placement: 'bottom-end',
|
|
92
60
|
modifiers: {
|
|
@@ -95,479 +63,470 @@ var AutoCompleteInput = /*#__PURE__*/function (_Component) {
|
|
|
95
63
|
}
|
|
96
64
|
}
|
|
97
65
|
}, popperOptions);
|
|
98
|
-
|
|
66
|
+
this.state = {
|
|
99
67
|
title: '',
|
|
100
68
|
filteredOptions: [],
|
|
101
69
|
keyboardOptionIndex: 0,
|
|
102
70
|
menuIsOpen: false,
|
|
103
71
|
inputWidth: 100,
|
|
104
72
|
invalid: false,
|
|
105
|
-
popperOptions
|
|
73
|
+
popperOptions
|
|
106
74
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return _this;
|
|
75
|
+
this.handleMenuKeyDown = this.handleMenuKeyDown.bind(this);
|
|
76
|
+
this.handleMenuBlur = this.handleMenuBlur.bind(this);
|
|
77
|
+
this.handleInputChange = this.handleInputChange.bind(this);
|
|
78
|
+
this.handleInputKeyDown = this.handleInputKeyDown.bind(this);
|
|
79
|
+
this.handleInputBlur = this.handleInputBlur.bind(this);
|
|
80
|
+
this.handelInputFocus = this.handelInputFocus.bind(this);
|
|
81
|
+
this.handleInputClick = this.handleInputClick.bind(this);
|
|
82
|
+
this.updateInputValue = debounce(this.updateInputValue, DEBOUNCE_DELAY);
|
|
83
|
+
this.handleOptionClick = this.handleOptionClick.bind(this);
|
|
84
|
+
this.handleMenuOpened = this.handleMenuOpened.bind(this);
|
|
85
|
+
this.handleMenuExited = this.handleMenuExited.bind(this);
|
|
86
|
+
this.popper = /*#__PURE__*/React.createRef();
|
|
87
|
+
this.cbContainer = /*#__PURE__*/React.createRef();
|
|
88
|
+
this.menuContainer = /*#__PURE__*/React.createRef();
|
|
89
|
+
this.input = /*#__PURE__*/React.createRef();
|
|
123
90
|
}
|
|
124
91
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.setState({
|
|
130
|
-
inputWidth: this.cbContainer.current.getBoundingClientRect().width
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}, {
|
|
135
|
-
key: "getValueAndValidate",
|
|
136
|
-
value: // validation needs to be an exact case-sensitve match on value
|
|
137
|
-
function getValueAndValidate(title) {
|
|
138
|
-
if (!title) {
|
|
139
|
-
this.setState({
|
|
140
|
-
invalid: false
|
|
141
|
-
});
|
|
142
|
-
return {
|
|
143
|
-
value: title,
|
|
144
|
-
isValid: false
|
|
145
|
-
};
|
|
146
|
-
} // validate
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var options = this.props.options;
|
|
150
|
-
var result = options.filter(function (option) {
|
|
151
|
-
return option.title.toLowerCase() === title.toLowerCase();
|
|
92
|
+
setInputWidth() {
|
|
93
|
+
if (this.cbContainer.current) {
|
|
94
|
+
this.setState({
|
|
95
|
+
inputWidth: this.cbContainer.current.getBoundingClientRect().width
|
|
152
96
|
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
153
99
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
return {
|
|
159
|
-
value: title,
|
|
160
|
-
isValid: false
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
100
|
+
// validation needs to be an exact case-sensitve match on value
|
|
101
|
+
getValueAndValidate(title) {
|
|
102
|
+
if (!title) {
|
|
164
103
|
this.setState({
|
|
165
104
|
invalid: false
|
|
166
105
|
});
|
|
167
106
|
return {
|
|
168
|
-
value:
|
|
169
|
-
isValid:
|
|
107
|
+
value: title,
|
|
108
|
+
isValid: false
|
|
170
109
|
};
|
|
171
|
-
} // validate
|
|
110
|
+
} // validate
|
|
172
111
|
|
|
173
|
-
}, {
|
|
174
|
-
key: "updateInputValue",
|
|
175
|
-
value: function updateInputValue(title) {
|
|
176
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
177
112
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
113
|
+
var {
|
|
114
|
+
options
|
|
115
|
+
} = this.props;
|
|
116
|
+
var result = options.filter(option => option.title.toLowerCase() === title.toLowerCase());
|
|
181
117
|
|
|
182
|
-
|
|
183
|
-
this.fireOnChange(value, isValid);
|
|
184
|
-
}
|
|
185
|
-
}, {
|
|
186
|
-
key: "fireOnChange",
|
|
187
|
-
value: function fireOnChange(value) {
|
|
188
|
-
var isValid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
189
|
-
var onChange = this.props.onChange;
|
|
190
|
-
onChange(value, isValid);
|
|
191
|
-
}
|
|
192
|
-
}, {
|
|
193
|
-
key: "processFilterChange",
|
|
194
|
-
value: function processFilterChange(filter) {
|
|
195
|
-
var _this$popper$current;
|
|
196
|
-
|
|
197
|
-
var options = this.props.options;
|
|
198
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
199
|
-
var filteredOptions = filter ? this.getCachedFilteredOptions(options, filter) : options;
|
|
200
|
-
var perfectMatch = filteredOptions.length === 1 && filteredOptions[0].title === filter;
|
|
118
|
+
if (result.length < 1) {
|
|
201
119
|
this.setState({
|
|
202
|
-
|
|
203
|
-
keyboardOptionIndex: 0
|
|
120
|
+
invalid: true
|
|
204
121
|
});
|
|
122
|
+
return {
|
|
123
|
+
value: title,
|
|
124
|
+
isValid: false
|
|
125
|
+
};
|
|
126
|
+
}
|
|
205
127
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
128
|
+
this.setState({
|
|
129
|
+
invalid: false
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
value: result[0].value,
|
|
133
|
+
isValid: true
|
|
134
|
+
};
|
|
135
|
+
} // validate typed entries emit change event using value
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
updateInputValue(title) {
|
|
139
|
+
var {
|
|
140
|
+
menuIsOpen
|
|
141
|
+
} = this.state;
|
|
142
|
+
var {
|
|
143
|
+
value,
|
|
144
|
+
isValid
|
|
145
|
+
} = this.getValueAndValidate(title);
|
|
146
|
+
if (menuIsOpen) this.processFilterChange(title);
|
|
147
|
+
this.fireOnChange(value, isValid);
|
|
148
|
+
}
|
|
210
149
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
150
|
+
fireOnChange(value) {
|
|
151
|
+
var isValid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
152
|
+
var {
|
|
153
|
+
onChange
|
|
154
|
+
} = this.props;
|
|
155
|
+
onChange(value, isValid);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
processFilterChange(filter) {
|
|
159
|
+
var _this$popper$current;
|
|
160
|
+
|
|
161
|
+
var {
|
|
162
|
+
options
|
|
163
|
+
} = this.props;
|
|
164
|
+
var {
|
|
165
|
+
menuIsOpen
|
|
166
|
+
} = this.state;
|
|
167
|
+
var filteredOptions = filter ? this.getCachedFilteredOptions(options, filter) : options;
|
|
168
|
+
var perfectMatch = filteredOptions.length === 1 && filteredOptions[0].title === filter;
|
|
169
|
+
this.setState({
|
|
170
|
+
filteredOptions,
|
|
171
|
+
keyboardOptionIndex: 0
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
if (perfectMatch && menuIsOpen) {
|
|
175
|
+
this.closeMenu();
|
|
176
|
+
return;
|
|
225
177
|
}
|
|
226
|
-
}, {
|
|
227
|
-
key: "handleMenuKeyDown",
|
|
228
|
-
value: function handleMenuKeyDown(event) {
|
|
229
|
-
var _this$input$current;
|
|
230
|
-
|
|
231
|
-
var _this$state = this.state,
|
|
232
|
-
filteredOptions = _this$state.filteredOptions,
|
|
233
|
-
keyboardOptionIndex = _this$state.keyboardOptionIndex;
|
|
234
|
-
var option = filteredOptions[keyboardOptionIndex];
|
|
235
|
-
|
|
236
|
-
switch (event.key) {
|
|
237
|
-
case 'Enter':
|
|
238
|
-
case 'ArrowRight':
|
|
239
|
-
event.stopPropagation();
|
|
240
|
-
event.preventDefault();
|
|
241
|
-
|
|
242
|
-
if (option) {
|
|
243
|
-
this.setState({
|
|
244
|
-
title: option.title,
|
|
245
|
-
invalid: false
|
|
246
|
-
});
|
|
247
|
-
this.fireOnChange(option.value);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
this.closeMenu();
|
|
251
|
-
(_this$input$current = this.input.current) === null || _this$input$current === void 0 ? void 0 : _this$input$current.focus();
|
|
252
|
-
break;
|
|
253
178
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
event.preventDefault();
|
|
257
|
-
this.navigateMenu(AutoCompleteInput.MENU_NAVIGATION_DIRECTION.UP);
|
|
258
|
-
break;
|
|
179
|
+
(_this$popper$current = this.popper.current) === null || _this$popper$current === void 0 ? void 0 : _this$popper$current.scheduleUpdate(); // filtered options list can change size, may need to be repositioned
|
|
180
|
+
}
|
|
259
181
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
182
|
+
resetValue() {
|
|
183
|
+
this.setState({
|
|
184
|
+
title: ''
|
|
185
|
+
});
|
|
186
|
+
this.fireOnChange('');
|
|
187
|
+
}
|
|
265
188
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
189
|
+
handleResize() {
|
|
190
|
+
this.setInputWidth();
|
|
191
|
+
}
|
|
269
192
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
193
|
+
handleMenuKeyDown(event) {
|
|
194
|
+
var _this$input$current;
|
|
274
195
|
|
|
275
|
-
|
|
276
|
-
|
|
196
|
+
var {
|
|
197
|
+
filteredOptions,
|
|
198
|
+
keyboardOptionIndex
|
|
199
|
+
} = this.state;
|
|
200
|
+
var option = filteredOptions[keyboardOptionIndex];
|
|
277
201
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
202
|
+
switch (event.key) {
|
|
203
|
+
case 'Enter':
|
|
204
|
+
case 'ArrowRight':
|
|
205
|
+
event.stopPropagation();
|
|
206
|
+
event.preventDefault();
|
|
283
207
|
|
|
284
|
-
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}, {
|
|
289
|
-
key: "navigateMenu",
|
|
290
|
-
value: function navigateMenu(direction) {
|
|
291
|
-
var _this$state2 = this.state,
|
|
292
|
-
filteredOptions = _this$state2.filteredOptions,
|
|
293
|
-
keyboardOptionIndex = _this$state2.keyboardOptionIndex;
|
|
294
|
-
var newKeyboardOptionIndex = keyboardOptionIndex;
|
|
295
|
-
|
|
296
|
-
if (direction === AutoCompleteInput.MENU_NAVIGATION_DIRECTION.UP) {
|
|
297
|
-
if (keyboardOptionIndex > 0) {
|
|
298
|
-
newKeyboardOptionIndex = (newKeyboardOptionIndex - 1) % filteredOptions.length;
|
|
208
|
+
if (option) {
|
|
299
209
|
this.setState({
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
} else if (keyboardOptionIndex === 0) {
|
|
303
|
-
newKeyboardOptionIndex = filteredOptions.length - 1;
|
|
304
|
-
this.setState({
|
|
305
|
-
keyboardOptionIndex: newKeyboardOptionIndex
|
|
210
|
+
title: option.title,
|
|
211
|
+
invalid: false
|
|
306
212
|
});
|
|
213
|
+
this.fireOnChange(option.value);
|
|
307
214
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
215
|
+
|
|
216
|
+
this.closeMenu();
|
|
217
|
+
(_this$input$current = this.input.current) === null || _this$input$current === void 0 ? void 0 : _this$input$current.focus();
|
|
218
|
+
break;
|
|
219
|
+
|
|
220
|
+
case 'ArrowUp':
|
|
221
|
+
event.stopPropagation();
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
this.navigateMenu(AutoCompleteInput.MENU_NAVIGATION_DIRECTION.UP);
|
|
224
|
+
break;
|
|
225
|
+
|
|
226
|
+
case 'ArrowDown':
|
|
227
|
+
event.stopPropagation();
|
|
228
|
+
event.preventDefault();
|
|
229
|
+
this.navigateMenu(AutoCompleteInput.MENU_NAVIGATION_DIRECTION.DOWN);
|
|
230
|
+
break;
|
|
231
|
+
|
|
232
|
+
case 'Tab':
|
|
233
|
+
event.stopPropagation();
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
|
|
236
|
+
if (event.shiftKey) {
|
|
237
|
+
this.navigateMenu(AutoCompleteInput.MENU_NAVIGATION_DIRECTION.UP);
|
|
238
|
+
break;
|
|
314
239
|
}
|
|
315
|
-
}
|
|
316
240
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
value: function handleInputKeyDown(event) {
|
|
322
|
-
var onEnter = this.props.onEnter;
|
|
323
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
324
|
-
|
|
325
|
-
if (menuIsOpen) {
|
|
326
|
-
this.handleMenuKeyDown(event);
|
|
327
|
-
} else if (event.key === 'Enter') {
|
|
328
|
-
onEnter();
|
|
329
|
-
} else if (event.key === 'Escape') {
|
|
330
|
-
this.resetValue();
|
|
241
|
+
this.navigateMenu(AutoCompleteInput.MENU_NAVIGATION_DIRECTION.DOWN);
|
|
242
|
+
break;
|
|
243
|
+
|
|
244
|
+
case 'Escape':
|
|
331
245
|
event.preventDefault();
|
|
332
246
|
event.stopPropagation();
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}, {
|
|
338
|
-
key: "handleInputChange",
|
|
339
|
-
value: function handleInputChange(event) {
|
|
340
|
-
this.setState({
|
|
341
|
-
title: event.target.value
|
|
342
|
-
});
|
|
343
|
-
this.updateInputValue(event.target.value);
|
|
344
|
-
}
|
|
345
|
-
}, {
|
|
346
|
-
key: "handleOptionClick",
|
|
347
|
-
value: function handleOptionClick(option) {
|
|
348
|
-
var _this$input$current2;
|
|
247
|
+
this.closeMenu();
|
|
248
|
+
break;
|
|
349
249
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
invalid: false
|
|
353
|
-
});
|
|
354
|
-
this.fireOnChange(option.value);
|
|
355
|
-
this.closeMenu();
|
|
356
|
-
(_this$input$current2 = this.input.current) === null || _this$input$current2 === void 0 ? void 0 : _this$input$current2.focus();
|
|
250
|
+
default:
|
|
251
|
+
break;
|
|
357
252
|
}
|
|
358
|
-
}
|
|
359
|
-
key: "handelInputFocus",
|
|
360
|
-
value: function handelInputFocus() {
|
|
361
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
253
|
+
}
|
|
362
254
|
|
|
363
|
-
|
|
364
|
-
|
|
255
|
+
navigateMenu(direction) {
|
|
256
|
+
var {
|
|
257
|
+
filteredOptions,
|
|
258
|
+
keyboardOptionIndex
|
|
259
|
+
} = this.state;
|
|
260
|
+
var newKeyboardOptionIndex = keyboardOptionIndex;
|
|
261
|
+
|
|
262
|
+
if (direction === AutoCompleteInput.MENU_NAVIGATION_DIRECTION.UP) {
|
|
263
|
+
if (keyboardOptionIndex > 0) {
|
|
264
|
+
newKeyboardOptionIndex = (newKeyboardOptionIndex - 1) % filteredOptions.length;
|
|
265
|
+
this.setState({
|
|
266
|
+
keyboardOptionIndex: newKeyboardOptionIndex
|
|
267
|
+
});
|
|
268
|
+
} else if (keyboardOptionIndex === 0) {
|
|
269
|
+
newKeyboardOptionIndex = filteredOptions.length - 1;
|
|
270
|
+
this.setState({
|
|
271
|
+
keyboardOptionIndex: newKeyboardOptionIndex
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
} else if (direction === AutoCompleteInput.MENU_NAVIGATION_DIRECTION.DOWN) {
|
|
275
|
+
if (keyboardOptionIndex < filteredOptions.length) {
|
|
276
|
+
newKeyboardOptionIndex = (newKeyboardOptionIndex + 1) % filteredOptions.length;
|
|
277
|
+
this.setState({
|
|
278
|
+
keyboardOptionIndex: newKeyboardOptionIndex
|
|
279
|
+
});
|
|
365
280
|
}
|
|
366
281
|
}
|
|
367
|
-
}, {
|
|
368
|
-
key: "handleInputClick",
|
|
369
|
-
value: function handleInputClick() {
|
|
370
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
371
282
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
283
|
+
this.scrollOptionIntoView(newKeyboardOptionIndex);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
handleInputKeyDown(event) {
|
|
287
|
+
var {
|
|
288
|
+
onEnter
|
|
289
|
+
} = this.props;
|
|
290
|
+
var {
|
|
291
|
+
menuIsOpen
|
|
292
|
+
} = this.state;
|
|
293
|
+
|
|
294
|
+
if (menuIsOpen) {
|
|
295
|
+
this.handleMenuKeyDown(event);
|
|
296
|
+
} else if (event.key === 'Enter') {
|
|
297
|
+
onEnter();
|
|
298
|
+
} else if (event.key === 'Escape') {
|
|
299
|
+
this.resetValue();
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
event.stopPropagation();
|
|
302
|
+
} else if (!(event.key === 'ArrowRight' || event.key === 'ArrowLeft' || event.key === 'Tab' || event.key === 'Shift')) {
|
|
303
|
+
this.openMenu();
|
|
375
304
|
}
|
|
376
|
-
}
|
|
377
|
-
key: "handleInputBlur",
|
|
378
|
-
value: function handleInputBlur(event) {
|
|
379
|
-
var _this$popper$current2;
|
|
305
|
+
}
|
|
380
306
|
|
|
381
|
-
|
|
307
|
+
handleInputChange(event) {
|
|
308
|
+
this.setState({
|
|
309
|
+
title: event.target.value
|
|
310
|
+
});
|
|
311
|
+
this.updateInputValue(event.target.value);
|
|
312
|
+
}
|
|
382
313
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
314
|
+
handleOptionClick(option) {
|
|
315
|
+
var _this$input$current2;
|
|
386
316
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
value
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
317
|
+
this.setState({
|
|
318
|
+
title: option.title,
|
|
319
|
+
invalid: false
|
|
320
|
+
});
|
|
321
|
+
this.fireOnChange(option.value);
|
|
322
|
+
this.closeMenu();
|
|
323
|
+
(_this$input$current2 = this.input.current) === null || _this$input$current2 === void 0 ? void 0 : _this$input$current2.focus();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
handelInputFocus() {
|
|
327
|
+
var {
|
|
328
|
+
menuIsOpen
|
|
329
|
+
} = this.state;
|
|
398
330
|
|
|
399
|
-
|
|
331
|
+
if (!menuIsOpen) {
|
|
332
|
+
this.openMenu();
|
|
400
333
|
}
|
|
401
|
-
}
|
|
402
|
-
key: "handleMenuOpened",
|
|
403
|
-
value: function handleMenuOpened() {
|
|
404
|
-
var _this$input$current3;
|
|
334
|
+
}
|
|
405
335
|
|
|
406
|
-
|
|
336
|
+
handleInputClick() {
|
|
337
|
+
var {
|
|
338
|
+
menuIsOpen
|
|
339
|
+
} = this.state;
|
|
340
|
+
|
|
341
|
+
if (!menuIsOpen) {
|
|
342
|
+
this.openMenu();
|
|
407
343
|
}
|
|
408
|
-
}
|
|
409
|
-
key: "handleMenuExited",
|
|
410
|
-
value: function handleMenuExited() {
|
|
411
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
344
|
+
}
|
|
412
345
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
346
|
+
handleInputBlur(event) {
|
|
347
|
+
var _this$popper$current2;
|
|
348
|
+
|
|
349
|
+
var {
|
|
350
|
+
menuIsOpen
|
|
351
|
+
} = this.state;
|
|
352
|
+
|
|
353
|
+
if (menuIsOpen && event.relatedTarget instanceof Element && (_this$popper$current2 = this.popper.current) !== null && _this$popper$current2 !== void 0 && _this$popper$current2.element.contains(event.relatedTarget)) {
|
|
354
|
+
return;
|
|
419
355
|
}
|
|
420
|
-
}, {
|
|
421
|
-
key: "openMenu",
|
|
422
|
-
value: function openMenu() {
|
|
423
|
-
var _this2 = this;
|
|
424
|
-
|
|
425
|
-
var title = this.state.title;
|
|
426
|
-
this.processFilterChange(title);
|
|
427
|
-
this.setInputWidth();
|
|
428
|
-
this.setState({
|
|
429
|
-
menuIsOpen: true
|
|
430
|
-
}); // https://github.com/reactjs/react-transition-group/issues/382
|
|
431
356
|
|
|
432
|
-
|
|
433
|
-
|
|
357
|
+
this.closeMenu(false);
|
|
358
|
+
}
|
|
434
359
|
|
|
435
|
-
|
|
436
|
-
|
|
360
|
+
handleMenuBlur(event) {
|
|
361
|
+
var _this$popper$current3;
|
|
362
|
+
|
|
363
|
+
// if blur event is caused by focusing on the input or focus on options don't close menu
|
|
364
|
+
if (event.relatedTarget === this.input.current || event.relatedTarget instanceof Element && (_this$popper$current3 = this.popper.current) !== null && _this$popper$current3 !== void 0 && _this$popper$current3.element.contains(event.relatedTarget)) {
|
|
365
|
+
return;
|
|
437
366
|
}
|
|
438
|
-
}, {
|
|
439
|
-
key: "closeMenu",
|
|
440
|
-
value: function closeMenu() {
|
|
441
|
-
var _this$popper$current4;
|
|
442
367
|
|
|
443
|
-
|
|
368
|
+
this.closeMenu(false);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
handleMenuOpened() {
|
|
372
|
+
var _this$input$current3;
|
|
373
|
+
|
|
374
|
+
(_this$input$current3 = this.input.current) === null || _this$input$current3 === void 0 ? void 0 : _this$input$current3.focus();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
handleMenuExited() {
|
|
378
|
+
var {
|
|
379
|
+
menuIsOpen
|
|
380
|
+
} = this.state;
|
|
381
|
+
|
|
382
|
+
if (menuIsOpen) {
|
|
444
383
|
this.setState({
|
|
445
384
|
menuIsOpen: false,
|
|
446
385
|
keyboardOptionIndex: 0
|
|
447
386
|
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
448
389
|
|
|
449
|
-
|
|
450
|
-
|
|
390
|
+
openMenu() {
|
|
391
|
+
var {
|
|
392
|
+
title
|
|
393
|
+
} = this.state;
|
|
394
|
+
this.processFilterChange(title);
|
|
395
|
+
this.setInputWidth();
|
|
396
|
+
this.setState({
|
|
397
|
+
menuIsOpen: true
|
|
398
|
+
}); // https://github.com/reactjs/react-transition-group/issues/382
|
|
399
|
+
|
|
400
|
+
window.requestAnimationFrame(() => {
|
|
401
|
+
var _this$popper$current4;
|
|
451
402
|
|
|
452
|
-
|
|
453
|
-
|
|
403
|
+
(_this$popper$current4 = this.popper.current) === null || _this$popper$current4 === void 0 ? void 0 : _this$popper$current4.show();
|
|
404
|
+
});
|
|
405
|
+
}
|
|
454
406
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
}, {
|
|
470
|
-
key: "renderMenuElement",
|
|
471
|
-
value: function renderMenuElement() {
|
|
472
|
-
var inputWidth = this.state.inputWidth;
|
|
473
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
474
|
-
className: classNames('aci-options'),
|
|
475
|
-
ref: this.menuContainer,
|
|
476
|
-
role: "presentation",
|
|
477
|
-
onKeyDown: this.handleMenuKeyDown,
|
|
478
|
-
style: {
|
|
479
|
-
width: inputWidth
|
|
480
|
-
},
|
|
481
|
-
onBlur: this.handleMenuBlur
|
|
482
|
-
}, this.renderOptions());
|
|
407
|
+
closeMenu() {
|
|
408
|
+
var _this$popper$current5;
|
|
409
|
+
|
|
410
|
+
var focusInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
411
|
+
this.setState({
|
|
412
|
+
menuIsOpen: false,
|
|
413
|
+
keyboardOptionIndex: 0
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
if (focusInput) {
|
|
417
|
+
var _this$input$current4;
|
|
418
|
+
|
|
419
|
+
(_this$input$current4 = this.input.current) === null || _this$input$current4 === void 0 ? void 0 : _this$input$current4.focus();
|
|
483
420
|
}
|
|
484
|
-
}, {
|
|
485
|
-
key: "renderOptions",
|
|
486
|
-
value: function renderOptions() {
|
|
487
|
-
var _this3 = this;
|
|
488
|
-
|
|
489
|
-
var noMatchText = this.props.noMatchText;
|
|
490
|
-
var _this$state3 = this.state,
|
|
491
|
-
title = _this$state3.title,
|
|
492
|
-
filteredOptions = _this$state3.filteredOptions;
|
|
493
|
-
|
|
494
|
-
if (title && filteredOptions.length === 0) {
|
|
495
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
496
|
-
className: "no-match"
|
|
497
|
-
}, noMatchText);
|
|
498
|
-
}
|
|
499
421
|
|
|
500
|
-
|
|
501
|
-
|
|
422
|
+
(_this$popper$current5 = this.popper.current) === null || _this$popper$current5 === void 0 ? void 0 : _this$popper$current5.hide();
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
scrollOptionIntoView(index) {
|
|
426
|
+
if (this.menuContainer.current) {
|
|
427
|
+
var _this$menuContainer$c;
|
|
428
|
+
|
|
429
|
+
(_this$menuContainer$c = this.menuContainer.current.children.item(index)) === null || _this$menuContainer$c === void 0 ? void 0 : _this$menuContainer$c.scrollIntoView({
|
|
430
|
+
behavior: 'smooth',
|
|
431
|
+
block: 'nearest'
|
|
502
432
|
});
|
|
503
433
|
}
|
|
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
|
-
|
|
532
|
-
inputPlaceholder = _this$props.inputPlaceholder,
|
|
533
|
-
disabled = _this$props.disabled,
|
|
534
|
-
className = _this$props.className,
|
|
535
|
-
defaultTitle = _this$props.defaultTitle,
|
|
536
|
-
spellCheck = _this$props.spellCheck;
|
|
537
|
-
var _this$state4 = this.state,
|
|
538
|
-
title = _this$state4.title,
|
|
539
|
-
menuIsOpen = _this$state4.menuIsOpen,
|
|
540
|
-
popperOptions = _this$state4.popperOptions,
|
|
541
|
-
invalid = _this$state4.invalid;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
renderMenuElement() {
|
|
437
|
+
var {
|
|
438
|
+
inputWidth
|
|
439
|
+
} = this.state;
|
|
440
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
441
|
+
className: classNames('aci-options'),
|
|
442
|
+
ref: this.menuContainer,
|
|
443
|
+
role: "presentation",
|
|
444
|
+
onKeyDown: this.handleMenuKeyDown,
|
|
445
|
+
style: {
|
|
446
|
+
width: inputWidth
|
|
447
|
+
},
|
|
448
|
+
onBlur: this.handleMenuBlur
|
|
449
|
+
}, this.renderOptions());
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
renderOptions() {
|
|
453
|
+
var {
|
|
454
|
+
noMatchText
|
|
455
|
+
} = this.props;
|
|
456
|
+
var {
|
|
457
|
+
title,
|
|
458
|
+
filteredOptions
|
|
459
|
+
} = this.state;
|
|
460
|
+
|
|
461
|
+
if (title && filteredOptions.length === 0) {
|
|
542
462
|
return /*#__PURE__*/React.createElement("div", {
|
|
543
|
-
className: "
|
|
544
|
-
|
|
545
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
546
|
-
value: title || defaultTitle,
|
|
547
|
-
className: classNames('form-control', className, 'aci-input', {
|
|
548
|
-
'is-invalid': invalid && !menuIsOpen
|
|
549
|
-
}),
|
|
550
|
-
ref: this.input,
|
|
551
|
-
onChange: this.handleInputChange,
|
|
552
|
-
placeholder: inputPlaceholder || options[0].title,
|
|
553
|
-
disabled: disabled,
|
|
554
|
-
onFocus: this.handelInputFocus,
|
|
555
|
-
onClick: this.handleInputClick,
|
|
556
|
-
onBlur: this.handleInputBlur,
|
|
557
|
-
onKeyDown: this.handleInputKeyDown,
|
|
558
|
-
spellCheck: spellCheck
|
|
559
|
-
}), /*#__PURE__*/React.createElement(Popper, {
|
|
560
|
-
ref: this.popper,
|
|
561
|
-
options: popperOptions,
|
|
562
|
-
className: classNames('aci-options-popper interactive'),
|
|
563
|
-
onEntered: this.handleMenuOpened,
|
|
564
|
-
onExited: this.handleMenuExited
|
|
565
|
-
}, this.renderMenuElement()));
|
|
463
|
+
className: "no-match"
|
|
464
|
+
}, noMatchText);
|
|
566
465
|
}
|
|
567
|
-
}]);
|
|
568
466
|
|
|
569
|
-
|
|
570
|
-
}
|
|
467
|
+
return filteredOptions.map((option, index) => this.renderOption(option, index));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
renderOption(option, index) {
|
|
471
|
+
var {
|
|
472
|
+
keyboardOptionIndex
|
|
473
|
+
} = this.state;
|
|
474
|
+
var key = "option-".concat(index, "-").concat(option.value);
|
|
475
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
476
|
+
key: key,
|
|
477
|
+
type: "button",
|
|
478
|
+
className: classNames('aci-option-btn', {
|
|
479
|
+
'keyboard-active': keyboardOptionIndex === index
|
|
480
|
+
}),
|
|
481
|
+
onClick: () => this.handleOptionClick(option),
|
|
482
|
+
onFocus: () => this.setState({
|
|
483
|
+
keyboardOptionIndex: index
|
|
484
|
+
})
|
|
485
|
+
}, option.title);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
render() {
|
|
489
|
+
var {
|
|
490
|
+
options,
|
|
491
|
+
inputPlaceholder,
|
|
492
|
+
disabled,
|
|
493
|
+
className,
|
|
494
|
+
defaultTitle,
|
|
495
|
+
spellCheck
|
|
496
|
+
} = this.props;
|
|
497
|
+
var {
|
|
498
|
+
title,
|
|
499
|
+
menuIsOpen,
|
|
500
|
+
popperOptions,
|
|
501
|
+
invalid
|
|
502
|
+
} = this.state;
|
|
503
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
504
|
+
className: "aci-container",
|
|
505
|
+
ref: this.cbContainer
|
|
506
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
507
|
+
value: title || defaultTitle,
|
|
508
|
+
className: classNames('form-control', className, 'aci-input', {
|
|
509
|
+
'is-invalid': invalid && !menuIsOpen
|
|
510
|
+
}),
|
|
511
|
+
ref: this.input,
|
|
512
|
+
onChange: this.handleInputChange,
|
|
513
|
+
placeholder: inputPlaceholder || options[0].title,
|
|
514
|
+
disabled: disabled,
|
|
515
|
+
onFocus: this.handelInputFocus,
|
|
516
|
+
onClick: this.handleInputClick,
|
|
517
|
+
onBlur: this.handleInputBlur,
|
|
518
|
+
onKeyDown: this.handleInputKeyDown,
|
|
519
|
+
spellCheck: spellCheck
|
|
520
|
+
}), /*#__PURE__*/React.createElement(Popper, {
|
|
521
|
+
ref: this.popper,
|
|
522
|
+
options: popperOptions,
|
|
523
|
+
className: classNames('aci-options-popper interactive'),
|
|
524
|
+
onEntered: this.handleMenuOpened,
|
|
525
|
+
onExited: this.handleMenuExited
|
|
526
|
+
}, this.renderMenuElement()));
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
}
|
|
571
530
|
|
|
572
531
|
_defineProperty(AutoCompleteInput, "propTypes", {
|
|
573
532
|
options: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -586,16 +545,19 @@ _defineProperty(AutoCompleteInput, "propTypes", {
|
|
|
586
545
|
});
|
|
587
546
|
|
|
588
547
|
_defineProperty(AutoCompleteInput, "defaultProps", {
|
|
589
|
-
onChange
|
|
548
|
+
onChange() {// no-op
|
|
590
549
|
},
|
|
550
|
+
|
|
591
551
|
inputPlaceholder: '',
|
|
592
552
|
disabled: false,
|
|
593
553
|
className: '',
|
|
594
554
|
defaultTitle: '',
|
|
595
555
|
popperOptions: null,
|
|
596
556
|
spellCheck: true,
|
|
597
|
-
|
|
557
|
+
|
|
558
|
+
onEnter() {// no-op
|
|
598
559
|
},
|
|
560
|
+
|
|
599
561
|
noMatchText: 'No matching items found'
|
|
600
562
|
});
|
|
601
563
|
|