@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/CustomTimeSelect.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
|
import React, { Component } from 'react';
|
|
@@ -31,8 +9,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
31
9
|
import { vsCheck, dhSort } from '@deephaven/icons';
|
|
32
10
|
import { TimeUtils } from '@deephaven/utils';
|
|
33
11
|
import classNames from 'classnames';
|
|
34
|
-
import TimeInput from
|
|
35
|
-
import DropdownMenu from
|
|
12
|
+
import TimeInput from "./TimeInput.js";
|
|
13
|
+
import DropdownMenu from "./menu-actions/DropdownMenu.js";
|
|
36
14
|
import "./CustomTimeSelect.css";
|
|
37
15
|
import "./context-actions/ContextActions.css";
|
|
38
16
|
var CUSTOM_OPTION = -1;
|
|
@@ -43,584 +21,574 @@ var MENU_NAVIGATION_DIRECTION;
|
|
|
43
21
|
MENU_NAVIGATION_DIRECTION["DOWN"] = "DOWN";
|
|
44
22
|
})(MENU_NAVIGATION_DIRECTION || (MENU_NAVIGATION_DIRECTION = {}));
|
|
45
23
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_this.handleCustomInput = _this.handleCustomInput.bind(_assertThisInitialized(_this));
|
|
76
|
-
_this.csContainer = /*#__PURE__*/React.createRef();
|
|
77
|
-
_this.menuContainer = /*#__PURE__*/React.createRef();
|
|
78
|
-
_this.button = /*#__PURE__*/React.createRef();
|
|
79
|
-
_this.input = /*#__PURE__*/React.createRef();
|
|
80
|
-
_this.state = {
|
|
24
|
+
class CustomTimeSelect extends Component {
|
|
25
|
+
constructor(props) {
|
|
26
|
+
super(props);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "csContainer", void 0);
|
|
29
|
+
|
|
30
|
+
_defineProperty(this, "menuContainer", void 0);
|
|
31
|
+
|
|
32
|
+
_defineProperty(this, "button", void 0);
|
|
33
|
+
|
|
34
|
+
_defineProperty(this, "input", void 0);
|
|
35
|
+
|
|
36
|
+
var {
|
|
37
|
+
value,
|
|
38
|
+
valueToTime
|
|
39
|
+
} = props;
|
|
40
|
+
this.toggleMenu = this.toggleMenu.bind(this);
|
|
41
|
+
this.handleMenuKeyDown = this.handleMenuKeyDown.bind(this);
|
|
42
|
+
this.closeMenu = this.closeMenu.bind(this);
|
|
43
|
+
this.handleOptionClick = this.handleOptionClick.bind(this);
|
|
44
|
+
this.handleOptionFocus = this.handleOptionFocus.bind(this);
|
|
45
|
+
this.handleMenuOpened = this.handleMenuOpened.bind(this);
|
|
46
|
+
this.handleMenuExited = this.handleMenuExited.bind(this);
|
|
47
|
+
this.handleCustomInput = this.handleCustomInput.bind(this);
|
|
48
|
+
this.csContainer = /*#__PURE__*/React.createRef();
|
|
49
|
+
this.menuContainer = /*#__PURE__*/React.createRef();
|
|
50
|
+
this.button = /*#__PURE__*/React.createRef();
|
|
51
|
+
this.input = /*#__PURE__*/React.createRef();
|
|
52
|
+
this.state = {
|
|
81
53
|
keyboardOptionIndex: 0,
|
|
82
54
|
menuIsOpen: false,
|
|
83
55
|
inputWidth: 100,
|
|
84
56
|
customTime: valueToTime(value),
|
|
85
57
|
inputFocused: false
|
|
86
58
|
};
|
|
87
|
-
return _this;
|
|
88
59
|
}
|
|
89
60
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
for (var i = 0; i < options.length; i += 1) {
|
|
104
|
-
var option = options[i];
|
|
61
|
+
getSelectedText() {
|
|
62
|
+
var {
|
|
63
|
+
options,
|
|
64
|
+
value,
|
|
65
|
+
placeholder
|
|
66
|
+
} = this.props;
|
|
67
|
+
var {
|
|
68
|
+
customTime
|
|
69
|
+
} = this.state;
|
|
70
|
+
|
|
71
|
+
if (value === null) {
|
|
72
|
+
return placeholder;
|
|
73
|
+
}
|
|
105
74
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
}
|
|
75
|
+
for (var i = 0; i < options.length; i += 1) {
|
|
76
|
+
var option = options[i];
|
|
110
77
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}, {
|
|
114
|
-
key: "setInputWidth",
|
|
115
|
-
value: function setInputWidth() {
|
|
116
|
-
if (this.csContainer.current) {
|
|
117
|
-
this.setState({
|
|
118
|
-
inputWidth: this.csContainer.current.getBoundingClientRect().width
|
|
119
|
-
});
|
|
78
|
+
if (option.value === value) {
|
|
79
|
+
return option.title;
|
|
120
80
|
}
|
|
121
81
|
}
|
|
122
|
-
}, {
|
|
123
|
-
key: "focus",
|
|
124
|
-
value: function focus() {
|
|
125
|
-
var _this$button$current;
|
|
126
82
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}, {
|
|
136
|
-
key: "handleResize",
|
|
137
|
-
value: function handleResize() {
|
|
138
|
-
this.setInputWidth();
|
|
83
|
+
return TimeUtils.formatTime(customTime);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
setInputWidth() {
|
|
87
|
+
if (this.csContainer.current) {
|
|
88
|
+
this.setState({
|
|
89
|
+
inputWidth: this.csContainer.current.getBoundingClientRect().width
|
|
90
|
+
});
|
|
139
91
|
}
|
|
140
|
-
}
|
|
141
|
-
key: "handleMenuKeyDown",
|
|
142
|
-
value: function handleMenuKeyDown(event) {
|
|
143
|
-
var _this$button$current2;
|
|
144
|
-
|
|
145
|
-
var _this$state = this.state,
|
|
146
|
-
keyboardOptionIndex = _this$state.keyboardOptionIndex,
|
|
147
|
-
inputFocused = _this$state.inputFocused;
|
|
148
|
-
var options = this.props.options;
|
|
149
|
-
|
|
150
|
-
switch (event.key) {
|
|
151
|
-
case 'Enter':
|
|
152
|
-
case ' ':
|
|
153
|
-
// Space Bar
|
|
154
|
-
if (inputFocused) {
|
|
155
|
-
this.updateFromCustom();
|
|
156
|
-
} else {
|
|
157
|
-
this.updateInputValue(options[keyboardOptionIndex].value);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
this.closeMenu();
|
|
161
|
-
(_this$button$current2 = this.button.current) === null || _this$button$current2 === void 0 ? void 0 : _this$button$current2.focus();
|
|
162
|
-
event.stopPropagation();
|
|
163
|
-
event.preventDefault();
|
|
164
|
-
break;
|
|
92
|
+
}
|
|
165
93
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this.handleMenuNavigation(CustomTimeSelect.MENU_NAVIGATION_DIRECTION.UP);
|
|
169
|
-
} else {
|
|
170
|
-
this.handleMenuNavigation(CustomTimeSelect.MENU_NAVIGATION_DIRECTION.DOWN);
|
|
171
|
-
}
|
|
94
|
+
focus() {
|
|
95
|
+
var _this$button$current;
|
|
172
96
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
break;
|
|
97
|
+
(_this$button$current = this.button.current) === null || _this$button$current === void 0 ? void 0 : _this$button$current.focus();
|
|
98
|
+
}
|
|
176
99
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
100
|
+
updateInputValue(value) {
|
|
101
|
+
var {
|
|
102
|
+
onChange
|
|
103
|
+
} = this.props;
|
|
104
|
+
onChange(value);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
handleResize() {
|
|
108
|
+
this.setInputWidth();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
handleMenuKeyDown(event) {
|
|
112
|
+
var _this$button$current2;
|
|
113
|
+
|
|
114
|
+
var {
|
|
115
|
+
keyboardOptionIndex,
|
|
116
|
+
inputFocused
|
|
117
|
+
} = this.state;
|
|
118
|
+
var {
|
|
119
|
+
options
|
|
120
|
+
} = this.props;
|
|
121
|
+
|
|
122
|
+
switch (event.key) {
|
|
123
|
+
case 'Enter':
|
|
124
|
+
case ' ':
|
|
125
|
+
// Space Bar
|
|
126
|
+
if (inputFocused) {
|
|
127
|
+
this.updateFromCustom();
|
|
128
|
+
} else {
|
|
129
|
+
this.updateInputValue(options[keyboardOptionIndex].value);
|
|
130
|
+
}
|
|
182
131
|
|
|
183
|
-
|
|
132
|
+
this.closeMenu();
|
|
133
|
+
(_this$button$current2 = this.button.current) === null || _this$button$current2 === void 0 ? void 0 : _this$button$current2.focus();
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
break;
|
|
137
|
+
|
|
138
|
+
case 'Tab':
|
|
139
|
+
if (event.shiftKey) {
|
|
140
|
+
this.handleMenuNavigation(CustomTimeSelect.MENU_NAVIGATION_DIRECTION.UP);
|
|
141
|
+
} else {
|
|
184
142
|
this.handleMenuNavigation(CustomTimeSelect.MENU_NAVIGATION_DIRECTION.DOWN);
|
|
185
|
-
|
|
186
|
-
event.preventDefault();
|
|
187
|
-
break;
|
|
143
|
+
}
|
|
188
144
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
145
|
+
event.stopPropagation();
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
break;
|
|
192
148
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
149
|
+
case 'ArrowUp':
|
|
150
|
+
this.handleMenuNavigation(CustomTimeSelect.MENU_NAVIGATION_DIRECTION.UP);
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
break;
|
|
154
|
+
|
|
155
|
+
case 'ArrowDown':
|
|
156
|
+
this.handleMenuNavigation(CustomTimeSelect.MENU_NAVIGATION_DIRECTION.DOWN);
|
|
157
|
+
event.stopPropagation();
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
break;
|
|
160
|
+
|
|
161
|
+
case 'Escape':
|
|
162
|
+
this.closeMenu();
|
|
163
|
+
break;
|
|
164
|
+
|
|
165
|
+
default:
|
|
166
|
+
break;
|
|
196
167
|
}
|
|
197
|
-
}
|
|
198
|
-
key: "handleMenuNavigation",
|
|
199
|
-
value: function handleMenuNavigation(direction) {
|
|
200
|
-
var _this$state2 = this.state,
|
|
201
|
-
keyboardOptionIndex = _this$state2.keyboardOptionIndex,
|
|
202
|
-
inputFocused = _this$state2.inputFocused;
|
|
203
|
-
var options = this.props.options;
|
|
204
|
-
var menuOptionsLength = options.length;
|
|
205
|
-
var newKeyboardOptionIndex = keyboardOptionIndex;
|
|
206
|
-
|
|
207
|
-
switch (direction) {
|
|
208
|
-
case CustomTimeSelect.MENU_NAVIGATION_DIRECTION.UP:
|
|
209
|
-
if (!inputFocused && keyboardOptionIndex === 0) {
|
|
210
|
-
this.focusInput();
|
|
211
|
-
break;
|
|
212
|
-
} else if (inputFocused) {
|
|
213
|
-
this.focusOption(keyboardOptionIndex);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (keyboardOptionIndex > 0 && !inputFocused) {
|
|
217
|
-
newKeyboardOptionIndex = (newKeyboardOptionIndex - 1) % menuOptionsLength;
|
|
218
|
-
this.setState({
|
|
219
|
-
keyboardOptionIndex: newKeyboardOptionIndex
|
|
220
|
-
});
|
|
221
|
-
} else if (keyboardOptionIndex === 0) {
|
|
222
|
-
newKeyboardOptionIndex = menuOptionsLength - 1;
|
|
223
|
-
this.setState({
|
|
224
|
-
keyboardOptionIndex: newKeyboardOptionIndex
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
this.scrollOptionIntoView(newKeyboardOptionIndex);
|
|
229
|
-
break;
|
|
168
|
+
}
|
|
230
169
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
this.scrollOptionIntoView(newKeyboardOptionIndex);
|
|
170
|
+
handleMenuNavigation(direction) {
|
|
171
|
+
var {
|
|
172
|
+
keyboardOptionIndex,
|
|
173
|
+
inputFocused
|
|
174
|
+
} = this.state;
|
|
175
|
+
var {
|
|
176
|
+
options
|
|
177
|
+
} = this.props;
|
|
178
|
+
var menuOptionsLength = options.length;
|
|
179
|
+
var newKeyboardOptionIndex = keyboardOptionIndex;
|
|
180
|
+
|
|
181
|
+
switch (direction) {
|
|
182
|
+
case CustomTimeSelect.MENU_NAVIGATION_DIRECTION.UP:
|
|
183
|
+
if (!inputFocused && keyboardOptionIndex === 0) {
|
|
184
|
+
this.focusInput();
|
|
247
185
|
break;
|
|
186
|
+
} else if (inputFocused) {
|
|
187
|
+
this.focusOption(keyboardOptionIndex);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (keyboardOptionIndex > 0 && !inputFocused) {
|
|
191
|
+
newKeyboardOptionIndex = (newKeyboardOptionIndex - 1) % menuOptionsLength;
|
|
192
|
+
this.setState({
|
|
193
|
+
keyboardOptionIndex: newKeyboardOptionIndex
|
|
194
|
+
});
|
|
195
|
+
} else if (keyboardOptionIndex === 0) {
|
|
196
|
+
newKeyboardOptionIndex = menuOptionsLength - 1;
|
|
197
|
+
this.setState({
|
|
198
|
+
keyboardOptionIndex: newKeyboardOptionIndex
|
|
199
|
+
});
|
|
200
|
+
}
|
|
248
201
|
|
|
249
|
-
|
|
202
|
+
this.scrollOptionIntoView(newKeyboardOptionIndex);
|
|
203
|
+
break;
|
|
204
|
+
|
|
205
|
+
case CustomTimeSelect.MENU_NAVIGATION_DIRECTION.DOWN:
|
|
206
|
+
if (!inputFocused && keyboardOptionIndex === menuOptionsLength - 1) {
|
|
207
|
+
this.focusInput();
|
|
250
208
|
break;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
key: "handleOptionClick",
|
|
255
|
-
value: function handleOptionClick(event) {
|
|
256
|
-
var optionIndex = Number(event.currentTarget.value);
|
|
257
|
-
var _this$props2 = this.props,
|
|
258
|
-
options = _this$props2.options,
|
|
259
|
-
timeToValue = _this$props2.timeToValue;
|
|
260
|
-
var customTime = this.state.customTime;
|
|
261
|
-
|
|
262
|
-
if (optionIndex === CUSTOM_OPTION) {
|
|
263
|
-
var update = timeToValue(customTime);
|
|
264
|
-
this.updateAndClose(update);
|
|
265
|
-
} else {
|
|
266
|
-
this.updateAndClose(options[optionIndex].value);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}, {
|
|
270
|
-
key: "updateAndClose",
|
|
271
|
-
value: function updateAndClose(update) {
|
|
272
|
-
var _this$button$current3;
|
|
209
|
+
} else if (inputFocused) {
|
|
210
|
+
this.focusOption(keyboardOptionIndex);
|
|
211
|
+
}
|
|
273
212
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
213
|
+
if (keyboardOptionIndex < menuOptionsLength && !(inputFocused && keyboardOptionIndex === 0)) {
|
|
214
|
+
newKeyboardOptionIndex = (newKeyboardOptionIndex + 1) % menuOptionsLength;
|
|
215
|
+
this.setState({
|
|
216
|
+
keyboardOptionIndex: newKeyboardOptionIndex
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.scrollOptionIntoView(newKeyboardOptionIndex);
|
|
221
|
+
break;
|
|
222
|
+
|
|
223
|
+
default:
|
|
224
|
+
break;
|
|
277
225
|
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
handleOptionClick(event) {
|
|
229
|
+
var optionIndex = Number(event.currentTarget.value);
|
|
230
|
+
var {
|
|
231
|
+
options,
|
|
232
|
+
timeToValue
|
|
233
|
+
} = this.props;
|
|
234
|
+
var {
|
|
235
|
+
customTime
|
|
236
|
+
} = this.state;
|
|
237
|
+
|
|
238
|
+
if (optionIndex === CUSTOM_OPTION) {
|
|
239
|
+
var update = timeToValue(customTime);
|
|
240
|
+
this.updateAndClose(update);
|
|
241
|
+
} else {
|
|
242
|
+
this.updateAndClose(options[optionIndex].value);
|
|
284
243
|
}
|
|
285
|
-
}
|
|
286
|
-
key: "handleMenuOpened",
|
|
287
|
-
value: function handleMenuOpened() {
|
|
288
|
-
var _this$menuContainer$c;
|
|
289
|
-
|
|
290
|
-
var _this$props3 = this.props,
|
|
291
|
-
options = _this$props3.options,
|
|
292
|
-
value = _this$props3.value;
|
|
293
|
-
var keyboardOptionIndex = this.state.keyboardOptionIndex;
|
|
294
|
-
this.scrollOptionIntoView(keyboardOptionIndex);
|
|
295
|
-
var activeOption = (_this$menuContainer$c = this.menuContainer.current) === null || _this$menuContainer$c === void 0 ? void 0 : _this$menuContainer$c.querySelector('.cs-option-btn.keyboard-active');
|
|
296
|
-
|
|
297
|
-
if (activeOption instanceof HTMLElement) {
|
|
298
|
-
activeOption.focus();
|
|
299
|
-
}
|
|
244
|
+
}
|
|
300
245
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
246
|
+
updateAndClose(update) {
|
|
247
|
+
var _this$button$current3;
|
|
304
248
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
249
|
+
this.updateInputValue(update);
|
|
250
|
+
this.closeMenu();
|
|
251
|
+
(_this$button$current3 = this.button.current) === null || _this$button$current3 === void 0 ? void 0 : _this$button$current3.focus();
|
|
252
|
+
}
|
|
308
253
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}, {
|
|
315
|
-
key: "focusInput",
|
|
316
|
-
value: function focusInput() {
|
|
317
|
-
var _this$input$current;
|
|
254
|
+
handleOptionFocus(event) {
|
|
255
|
+
this.setState({
|
|
256
|
+
keyboardOptionIndex: Number(event.target.value)
|
|
257
|
+
});
|
|
258
|
+
}
|
|
318
259
|
|
|
319
|
-
|
|
260
|
+
handleMenuOpened() {
|
|
261
|
+
var _this$menuContainer$c;
|
|
262
|
+
|
|
263
|
+
var {
|
|
264
|
+
options,
|
|
265
|
+
value
|
|
266
|
+
} = this.props;
|
|
267
|
+
var {
|
|
268
|
+
keyboardOptionIndex
|
|
269
|
+
} = this.state;
|
|
270
|
+
this.scrollOptionIntoView(keyboardOptionIndex);
|
|
271
|
+
var activeOption = (_this$menuContainer$c = this.menuContainer.current) === null || _this$menuContainer$c === void 0 ? void 0 : _this$menuContainer$c.querySelector('.cs-option-btn.keyboard-active');
|
|
272
|
+
|
|
273
|
+
if (activeOption instanceof HTMLElement) {
|
|
274
|
+
activeOption.focus();
|
|
320
275
|
}
|
|
321
|
-
}, {
|
|
322
|
-
key: "focusOption",
|
|
323
|
-
value: function focusOption(index) {
|
|
324
|
-
var _this$menuContainer$c2;
|
|
325
276
|
|
|
326
|
-
|
|
277
|
+
if (value === null) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
327
280
|
|
|
328
|
-
|
|
329
|
-
var option = options.children.item(index);
|
|
281
|
+
var valueIndex = options.map(option => option.value).indexOf(value);
|
|
330
282
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
283
|
+
if (valueIndex < 0) {
|
|
284
|
+
// The custom option should be selected
|
|
285
|
+
this.focusInput();
|
|
335
286
|
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
focusInput() {
|
|
290
|
+
var _this$input$current;
|
|
291
|
+
|
|
292
|
+
(_this$input$current = this.input.current) === null || _this$input$current === void 0 ? void 0 : _this$input$current.focus();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
focusOption(index) {
|
|
296
|
+
var _this$menuContainer$c2;
|
|
297
|
+
|
|
298
|
+
var options = (_this$menuContainer$c2 = this.menuContainer.current) === null || _this$menuContainer$c2 === void 0 ? void 0 : _this$menuContainer$c2.querySelector('.cs-options');
|
|
299
|
+
|
|
300
|
+
if (options && options.children) {
|
|
301
|
+
var option = options.children.item(index);
|
|
302
|
+
|
|
303
|
+
if (option instanceof HTMLElement) {
|
|
304
|
+
option.focus();
|
|
346
305
|
}
|
|
347
306
|
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
handleMenuExited() {
|
|
310
|
+
var {
|
|
311
|
+
menuIsOpen
|
|
312
|
+
} = this.state;
|
|
313
|
+
|
|
314
|
+
if (menuIsOpen) {
|
|
354
315
|
this.setState({
|
|
355
|
-
|
|
316
|
+
menuIsOpen: false,
|
|
317
|
+
keyboardOptionIndex: 0
|
|
356
318
|
});
|
|
357
319
|
}
|
|
358
|
-
}
|
|
359
|
-
key: "updateFromCustom",
|
|
360
|
-
value: function updateFromCustom() {
|
|
361
|
-
var timeToValue = this.props.timeToValue;
|
|
362
|
-
var customTime = this.state.customTime;
|
|
363
|
-
var update = timeToValue(customTime);
|
|
364
|
-
this.updateInputValue(update);
|
|
365
|
-
}
|
|
366
|
-
}, {
|
|
367
|
-
key: "toggleMenu",
|
|
368
|
-
value: function toggleMenu(event) {
|
|
369
|
-
var menuIsOpen = this.state.menuIsOpen;
|
|
320
|
+
}
|
|
370
321
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
322
|
+
handleCustomInput(value) {
|
|
323
|
+
var {
|
|
324
|
+
timeToValue
|
|
325
|
+
} = this.props;
|
|
326
|
+
var update = timeToValue(value);
|
|
327
|
+
this.updateInputValue(update);
|
|
328
|
+
this.setState({
|
|
329
|
+
customTime: value
|
|
330
|
+
});
|
|
331
|
+
}
|
|
376
332
|
|
|
377
|
-
|
|
333
|
+
updateFromCustom() {
|
|
334
|
+
var {
|
|
335
|
+
timeToValue
|
|
336
|
+
} = this.props;
|
|
337
|
+
var {
|
|
338
|
+
customTime
|
|
339
|
+
} = this.state;
|
|
340
|
+
var update = timeToValue(customTime);
|
|
341
|
+
this.updateInputValue(update);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
toggleMenu(event) {
|
|
345
|
+
var {
|
|
346
|
+
menuIsOpen
|
|
347
|
+
} = this.state;
|
|
348
|
+
|
|
349
|
+
if (menuIsOpen) {
|
|
350
|
+
this.closeMenu();
|
|
351
|
+
} else {
|
|
352
|
+
this.openMenu();
|
|
378
353
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
354
|
+
|
|
355
|
+
event.stopPropagation();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
openMenu() {
|
|
359
|
+
this.updateKeyboardIndex();
|
|
360
|
+
this.setInputWidth();
|
|
361
|
+
this.setState({
|
|
362
|
+
menuIsOpen: true
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
closeMenu() {
|
|
367
|
+
var focusButton = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
368
|
+
this.setState({
|
|
369
|
+
menuIsOpen: false
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
if (focusButton) {
|
|
373
|
+
var _this$button$current4;
|
|
374
|
+
|
|
375
|
+
(_this$button$current4 = this.button.current) === null || _this$button$current4 === void 0 ? void 0 : _this$button$current4.focus();
|
|
387
376
|
}
|
|
388
|
-
}
|
|
389
|
-
key: "closeMenu",
|
|
390
|
-
value: function closeMenu() {
|
|
391
|
-
var focusButton = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
392
|
-
this.setState({
|
|
393
|
-
menuIsOpen: false
|
|
394
|
-
});
|
|
377
|
+
}
|
|
395
378
|
|
|
396
|
-
|
|
397
|
-
|
|
379
|
+
updateKeyboardIndex() {
|
|
380
|
+
var {
|
|
381
|
+
options,
|
|
382
|
+
value
|
|
383
|
+
} = this.props;
|
|
398
384
|
|
|
399
|
-
|
|
400
|
-
|
|
385
|
+
if (value === null) {
|
|
386
|
+
return;
|
|
401
387
|
}
|
|
402
|
-
}, {
|
|
403
|
-
key: "updateKeyboardIndex",
|
|
404
|
-
value: function updateKeyboardIndex() {
|
|
405
|
-
var _this$props4 = this.props,
|
|
406
|
-
options = _this$props4.options,
|
|
407
|
-
value = _this$props4.value;
|
|
408
|
-
|
|
409
|
-
if (value === null) {
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
388
|
|
|
413
|
-
|
|
414
|
-
return option.value;
|
|
415
|
-
}).indexOf(value);
|
|
389
|
+
var valueIndex = options.map(option => option.value).indexOf(value);
|
|
416
390
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
391
|
+
if (valueIndex > 0) {
|
|
392
|
+
this.setState({
|
|
393
|
+
keyboardOptionIndex: valueIndex
|
|
394
|
+
});
|
|
422
395
|
}
|
|
423
|
-
}
|
|
424
|
-
key: "scrollOptionIntoView",
|
|
425
|
-
value: function scrollOptionIntoView(index) {
|
|
426
|
-
var _this$menuContainer$c3;
|
|
396
|
+
}
|
|
427
397
|
|
|
428
|
-
|
|
398
|
+
scrollOptionIntoView(index) {
|
|
399
|
+
var _this$menuContainer$c3;
|
|
429
400
|
|
|
430
|
-
|
|
431
|
-
var activeOption = options.children.item(index);
|
|
401
|
+
var options = (_this$menuContainer$c3 = this.menuContainer.current) === null || _this$menuContainer$c3 === void 0 ? void 0 : _this$menuContainer$c3.querySelector('.cs-options');
|
|
432
402
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
403
|
+
if (options && options.children) {
|
|
404
|
+
var activeOption = options.children.item(index);
|
|
405
|
+
|
|
406
|
+
if (activeOption instanceof HTMLElement && activeOption.offsetTop > CustomTimeSelect.DROP_DOWN_MENU_HEIGHT) {
|
|
407
|
+
options.scrollTop = activeOption.offsetTop - CustomTimeSelect.DROP_DOWN_MENU_HEIGHT;
|
|
408
|
+
} else if (activeOption instanceof HTMLElement && activeOption.offsetTop < 0 || index === 0) {
|
|
409
|
+
options.scrollTop = 0;
|
|
438
410
|
}
|
|
439
411
|
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
className: "cs-options-container"
|
|
457
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
458
|
-
className: "cs-options"
|
|
459
|
-
}, this.renderOptions())));
|
|
460
|
-
}
|
|
461
|
-
}, {
|
|
462
|
-
key: "renderOptions",
|
|
463
|
-
value: function renderOptions() {
|
|
464
|
-
var _this2 = this;
|
|
465
|
-
|
|
466
|
-
var _this$props5 = this.props,
|
|
467
|
-
options = _this$props5.options,
|
|
468
|
-
value = _this$props5.value,
|
|
469
|
-
icon = _this$props5.icon,
|
|
470
|
-
customText = _this$props5.customText;
|
|
471
|
-
var _this$state3 = this.state,
|
|
472
|
-
keyboardOptionIndex = _this$state3.keyboardOptionIndex,
|
|
473
|
-
customTime = _this$state3.customTime,
|
|
474
|
-
inputFocused = _this$state3.inputFocused;
|
|
475
|
-
var matchFound = false;
|
|
476
|
-
var optionArray = [];
|
|
477
|
-
|
|
478
|
-
for (var index = 0; index < options.length; index += 1) {
|
|
479
|
-
var option = options[index];
|
|
480
|
-
var key = "option-".concat(index, "-").concat(option.value);
|
|
481
|
-
matchFound = matchFound || option.value === value;
|
|
482
|
-
optionArray.push( /*#__PURE__*/React.createElement("button", {
|
|
483
|
-
key: key,
|
|
484
|
-
type: "button",
|
|
485
|
-
value: index,
|
|
486
|
-
className: classNames('cs-option-btn', {
|
|
487
|
-
'keyboard-active': keyboardOptionIndex === index && !inputFocused
|
|
488
|
-
}),
|
|
489
|
-
onClick: this.handleOptionClick,
|
|
490
|
-
onFocus: this.handleOptionFocus
|
|
491
|
-
}, option.value === value && /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
492
|
-
icon: icon,
|
|
493
|
-
className: "mr-2"
|
|
494
|
-
}), option.value !== value && /*#__PURE__*/React.createElement("span", {
|
|
495
|
-
className: "mr-4"
|
|
496
|
-
}), option.title));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
renderMenuElement() {
|
|
415
|
+
var {
|
|
416
|
+
inputWidth
|
|
417
|
+
} = this.state;
|
|
418
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
419
|
+
className: "cs-menu-container",
|
|
420
|
+
ref: this.menuContainer,
|
|
421
|
+
role: "presentation",
|
|
422
|
+
onKeyDown: this.handleMenuKeyDown,
|
|
423
|
+
onClick: event => {
|
|
424
|
+
event.stopPropagation();
|
|
425
|
+
},
|
|
426
|
+
style: {
|
|
427
|
+
width: inputWidth
|
|
497
428
|
}
|
|
429
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
430
|
+
className: "cs-options-container"
|
|
431
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
432
|
+
className: "cs-options"
|
|
433
|
+
}, this.renderOptions())));
|
|
434
|
+
}
|
|
498
435
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
436
|
+
renderOptions() {
|
|
437
|
+
var {
|
|
438
|
+
options,
|
|
439
|
+
value,
|
|
440
|
+
icon,
|
|
441
|
+
customText
|
|
442
|
+
} = this.props;
|
|
443
|
+
var {
|
|
444
|
+
keyboardOptionIndex,
|
|
445
|
+
customTime,
|
|
446
|
+
inputFocused
|
|
447
|
+
} = this.state;
|
|
448
|
+
var matchFound = false;
|
|
449
|
+
var optionArray = [];
|
|
450
|
+
|
|
451
|
+
for (var index = 0; index < options.length; index += 1) {
|
|
452
|
+
var option = options[index];
|
|
453
|
+
var key = "option-".concat(index, "-").concat(option.value);
|
|
454
|
+
matchFound = matchFound || option.value === value;
|
|
503
455
|
optionArray.push( /*#__PURE__*/React.createElement("button", {
|
|
504
|
-
key:
|
|
456
|
+
key: key,
|
|
505
457
|
type: "button",
|
|
506
|
-
value:
|
|
458
|
+
value: index,
|
|
507
459
|
className: classNames('cs-option-btn', {
|
|
508
|
-
'keyboard-active': inputFocused
|
|
460
|
+
'keyboard-active': keyboardOptionIndex === index && !inputFocused
|
|
509
461
|
}),
|
|
510
462
|
onClick: this.handleOptionClick,
|
|
511
463
|
onFocus: this.handleOptionFocus
|
|
512
|
-
},
|
|
464
|
+
}, option.value === value && /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
513
465
|
icon: icon,
|
|
514
466
|
className: "mr-2"
|
|
515
|
-
})
|
|
467
|
+
}), option.value !== value && /*#__PURE__*/React.createElement("span", {
|
|
516
468
|
className: "mr-4"
|
|
517
|
-
}),
|
|
518
|
-
optionArray.push( /*#__PURE__*/React.createElement("div", {
|
|
519
|
-
key: "cs-custom-container",
|
|
520
|
-
className: "cs-custom-container"
|
|
521
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
522
|
-
className: "mr-2"
|
|
523
|
-
}), /*#__PURE__*/React.createElement(TimeInput, {
|
|
524
|
-
key: "option-input",
|
|
525
|
-
ref: this.input,
|
|
526
|
-
onChange: this.handleCustomInput,
|
|
527
|
-
value: customTime,
|
|
528
|
-
onFocus: function onFocus() {
|
|
529
|
-
return _this2.setState({
|
|
530
|
-
inputFocused: true
|
|
531
|
-
});
|
|
532
|
-
},
|
|
533
|
-
onBlur: function onBlur() {
|
|
534
|
-
return _this2.setState({
|
|
535
|
-
inputFocused: false
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
539
|
-
className: "ml-2"
|
|
540
|
-
})));
|
|
541
|
-
optionArray.push( /*#__PURE__*/React.createElement("hr", {
|
|
542
|
-
key: "option-end",
|
|
543
|
-
className: "mb-2"
|
|
544
|
-
}));
|
|
545
|
-
return optionArray;
|
|
469
|
+
}), option.title));
|
|
546
470
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
},
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
471
|
+
|
|
472
|
+
optionArray.push( /*#__PURE__*/React.createElement("hr", {
|
|
473
|
+
className: "cs-divider",
|
|
474
|
+
key: "option-divider"
|
|
475
|
+
}));
|
|
476
|
+
optionArray.push( /*#__PURE__*/React.createElement("button", {
|
|
477
|
+
key: "option-custom-label",
|
|
478
|
+
type: "button",
|
|
479
|
+
value: CUSTOM_OPTION,
|
|
480
|
+
className: classNames('cs-option-btn', {
|
|
481
|
+
'keyboard-active': inputFocused
|
|
482
|
+
}),
|
|
483
|
+
onClick: this.handleOptionClick,
|
|
484
|
+
onFocus: this.handleOptionFocus
|
|
485
|
+
}, !matchFound && value !== null ? /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
486
|
+
icon: icon,
|
|
487
|
+
className: "mr-2"
|
|
488
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
489
|
+
className: "mr-4"
|
|
490
|
+
}), customText));
|
|
491
|
+
optionArray.push( /*#__PURE__*/React.createElement("div", {
|
|
492
|
+
key: "cs-custom-container",
|
|
493
|
+
className: "cs-custom-container"
|
|
494
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
495
|
+
className: "mr-2"
|
|
496
|
+
}), /*#__PURE__*/React.createElement(TimeInput, {
|
|
497
|
+
key: "option-input",
|
|
498
|
+
ref: this.input,
|
|
499
|
+
onChange: this.handleCustomInput,
|
|
500
|
+
value: customTime,
|
|
501
|
+
onFocus: () => this.setState({
|
|
502
|
+
inputFocused: true
|
|
503
|
+
}),
|
|
504
|
+
onBlur: () => this.setState({
|
|
505
|
+
inputFocused: false
|
|
506
|
+
})
|
|
507
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
508
|
+
className: "ml-2"
|
|
509
|
+
})));
|
|
510
|
+
optionArray.push( /*#__PURE__*/React.createElement("hr", {
|
|
511
|
+
key: "option-end",
|
|
512
|
+
className: "mb-2"
|
|
513
|
+
}));
|
|
514
|
+
return optionArray;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
render() {
|
|
518
|
+
var {
|
|
519
|
+
disabled,
|
|
520
|
+
invalid,
|
|
521
|
+
value
|
|
522
|
+
} = this.props;
|
|
523
|
+
var {
|
|
524
|
+
menuIsOpen
|
|
525
|
+
} = this.state;
|
|
526
|
+
var {
|
|
527
|
+
popperOptions
|
|
528
|
+
} = this.props;
|
|
529
|
+
popperOptions = _objectSpread({
|
|
530
|
+
placement: 'bottom-end',
|
|
531
|
+
modifiers: {
|
|
532
|
+
preventOverflow: {
|
|
533
|
+
enabled: false
|
|
597
534
|
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
535
|
+
}
|
|
536
|
+
}, popperOptions);
|
|
537
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
538
|
+
className: "input-group cs-container context-menu",
|
|
539
|
+
ref: this.csContainer
|
|
540
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
541
|
+
className: classNames('input-group-append cs-dropdown', {
|
|
542
|
+
'cs-dropdown-invalid': invalid
|
|
543
|
+
})
|
|
544
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
545
|
+
type: "button",
|
|
546
|
+
className: classNames('btn cs-btn form-control', {
|
|
547
|
+
'cs-btn-invalid': invalid
|
|
548
|
+
}),
|
|
549
|
+
ref: this.button,
|
|
550
|
+
onClick: this.toggleMenu,
|
|
551
|
+
disabled: disabled
|
|
552
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
553
|
+
className: classNames({
|
|
554
|
+
'text-muted': value === null
|
|
555
|
+
})
|
|
556
|
+
}, this.getSelectedText()), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
557
|
+
icon: dhSort,
|
|
558
|
+
className: "cs-caret"
|
|
559
|
+
})), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
560
|
+
isShown: menuIsOpen,
|
|
561
|
+
actions: {
|
|
562
|
+
menuElement: this.renderMenuElement()
|
|
563
|
+
},
|
|
564
|
+
popperOptions: popperOptions,
|
|
565
|
+
popperClassName: "CustomTimeSelect",
|
|
566
|
+
onMenuOpened: this.handleMenuOpened,
|
|
567
|
+
onMenuClosed: this.handleMenuExited,
|
|
568
|
+
menuStyle: {
|
|
569
|
+
maxWidth: '100rem'
|
|
570
|
+
}
|
|
571
|
+
}))));
|
|
572
|
+
}
|
|
601
573
|
|
|
602
|
-
|
|
603
|
-
}(Component);
|
|
574
|
+
}
|
|
604
575
|
|
|
605
576
|
_defineProperty(CustomTimeSelect, "MENU_NAVIGATION_DIRECTION", MENU_NAVIGATION_DIRECTION);
|
|
606
577
|
|
|
607
578
|
_defineProperty(CustomTimeSelect, "DROP_DOWN_MENU_HEIGHT", 125);
|
|
608
579
|
|
|
609
580
|
_defineProperty(CustomTimeSelect, "defaultProps", {
|
|
610
|
-
onChange
|
|
581
|
+
onChange() {// no-op
|
|
611
582
|
},
|
|
583
|
+
|
|
612
584
|
value: null,
|
|
613
585
|
disabled: false,
|
|
614
586
|
popperOptions: {},
|
|
615
587
|
icon: vsCheck,
|
|
616
588
|
customText: 'Custom',
|
|
617
589
|
placeholder: 'Select a time',
|
|
618
|
-
valueToTime:
|
|
619
|
-
|
|
620
|
-
},
|
|
621
|
-
timeToValue: function timeToValue(time) {
|
|
622
|
-
return time * 1000;
|
|
623
|
-
},
|
|
590
|
+
valueToTime: value => value === null ? 0 : Math.round(value / 1000),
|
|
591
|
+
timeToValue: time => time * 1000,
|
|
624
592
|
invalid: false
|
|
625
593
|
});
|
|
626
594
|
|