@dhis2-ui/select 10.12.8 → 10.13.0-alpha.1
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/build/cjs/simple-single-select/menu/filter.js +12 -6
- package/build/cjs/simple-single-select/menu/menu.js +11 -3
- package/build/cjs/simple-single-select/menu/options-list.js +13 -5
- package/build/cjs/simple-single-select/simple-single-select.js +5 -1
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +6 -1
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +3 -1
- package/build/es/simple-single-select/menu/filter.js +9 -5
- package/build/es/simple-single-select/menu/menu.js +11 -3
- package/build/es/simple-single-select/menu/options-list.js +13 -5
- package/build/es/simple-single-select/simple-single-select.js +5 -1
- package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +6 -1
- package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +3 -1
- package/package.json +15 -15
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Filter =
|
|
6
|
+
exports.Filter = void 0;
|
|
7
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
8
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
9
|
var _input = require("@dhis2-ui/input");
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
var _react =
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _index = _interopRequireDefault(require("../../locales/index.js"));
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
function Filter(_ref) {
|
|
16
|
+
const Filter = exports.Filter = /*#__PURE__*/(0, _react.forwardRef)(function Filter(_ref, ref) {
|
|
15
17
|
let {
|
|
16
18
|
ariaControls,
|
|
17
19
|
dataTest,
|
|
@@ -20,13 +22,15 @@ function Filter(_ref) {
|
|
|
20
22
|
tabIndex,
|
|
21
23
|
value,
|
|
22
24
|
onChange,
|
|
23
|
-
onKeyDown
|
|
25
|
+
onKeyDown,
|
|
26
|
+
onFocus
|
|
24
27
|
} = _ref;
|
|
25
28
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
26
29
|
"data-test": dataTest,
|
|
27
30
|
className: _style.default.dynamic([["3850436710", [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp8, _uiConstants.spacers.dp4, _uiConstants.spacers.dp8]]])
|
|
28
31
|
}, /*#__PURE__*/_react.default.createElement(_input.Input, {
|
|
29
32
|
dense: true,
|
|
33
|
+
ref: ref,
|
|
30
34
|
tabIndex: tabIndex,
|
|
31
35
|
ariaControls: ariaControls,
|
|
32
36
|
ariaHaspopup: "listbox",
|
|
@@ -42,12 +46,13 @@ function Filter(_ref) {
|
|
|
42
46
|
type: "text",
|
|
43
47
|
name: "filter",
|
|
44
48
|
placeholder: placeholder,
|
|
45
|
-
onKeyDown: (_, e) => onKeyDown(e)
|
|
49
|
+
onKeyDown: (_, e) => onKeyDown(e),
|
|
50
|
+
onFocus: onFocus
|
|
46
51
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
47
52
|
id: "3850436710",
|
|
48
53
|
dynamic: [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp8, _uiConstants.spacers.dp4, _uiConstants.spacers.dp8]
|
|
49
54
|
}, [`div.__jsx-style-dynamic-selector{height:100%;-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;background:${_uiConstants.colors.white};}`]));
|
|
50
|
-
}
|
|
55
|
+
});
|
|
51
56
|
Filter.propTypes = {
|
|
52
57
|
ariaControls: _propTypes.default.string.isRequired,
|
|
53
58
|
value: _propTypes.default.string.isRequired,
|
|
@@ -56,5 +61,6 @@ Filter.propTypes = {
|
|
|
56
61
|
label: _propTypes.default.string,
|
|
57
62
|
placeholder: _propTypes.default.string,
|
|
58
63
|
tabIndex: _propTypes.default.string,
|
|
64
|
+
onFocus: _propTypes.default.func,
|
|
59
65
|
onKeyDown: _propTypes.default.func
|
|
60
66
|
};
|
|
@@ -49,7 +49,9 @@ function Menu(_ref) {
|
|
|
49
49
|
onClose,
|
|
50
50
|
onEndReached,
|
|
51
51
|
onFilterChange,
|
|
52
|
-
onFilterInputKeyDown
|
|
52
|
+
onFilterInputKeyDown,
|
|
53
|
+
filterRef,
|
|
54
|
+
onOptionsKeyDown
|
|
53
55
|
} = _ref;
|
|
54
56
|
const [menuWidth, setWidth] = (0, _react.useState)('auto');
|
|
55
57
|
const dataTestPrefix = `${dataTest}-menu`;
|
|
@@ -86,6 +88,7 @@ function Menu(_ref) {
|
|
|
86
88
|
}, filterable && /*#__PURE__*/_react.default.createElement("div", {
|
|
87
89
|
className: _style.default.dynamic([["2949029222", [_uiConstants.colors.white, _uiConstants.colors.grey200, _uiConstants.elevations.e300]]]) + " " + "filter-container"
|
|
88
90
|
}, /*#__PURE__*/_react.default.createElement(_filter.Filter, {
|
|
91
|
+
ref: filterRef,
|
|
89
92
|
dataTest: `${dataTestPrefix}-filter`,
|
|
90
93
|
value: filterValue,
|
|
91
94
|
label: filterLabel,
|
|
@@ -100,6 +103,7 @@ function Menu(_ref) {
|
|
|
100
103
|
className: _style.default.dynamic([["2949029222", [_uiConstants.colors.white, _uiConstants.colors.grey200, _uiConstants.elevations.e300]]]) + " " + "listbox-wrapper"
|
|
101
104
|
}, /*#__PURE__*/_react.default.createElement(_optionsList.OptionsList, {
|
|
102
105
|
ref: listBoxRef,
|
|
106
|
+
onKeyDown: onOptionsKeyDown,
|
|
103
107
|
comboBoxId: comboBoxId,
|
|
104
108
|
optionComponent: optionComponent,
|
|
105
109
|
dataTest: `${dataTestPrefix}-list`,
|
|
@@ -131,12 +135,14 @@ Menu.propTypes = {
|
|
|
131
135
|
}).isRequired,
|
|
132
136
|
name: _propTypes.default.string.isRequired,
|
|
133
137
|
options: _propTypes.default.arrayOf(_sharedPropTypes.optionProp).isRequired,
|
|
134
|
-
onChange: _propTypes.default.func.isRequired,
|
|
135
138
|
dataTest: _propTypes.default.string,
|
|
136
139
|
disabled: _propTypes.default.bool,
|
|
137
140
|
empty: _propTypes.default.node,
|
|
138
141
|
filterLabel: _propTypes.default.string,
|
|
139
142
|
filterPlaceholder: _propTypes.default.string,
|
|
143
|
+
filterRef: _propTypes.default.shape({
|
|
144
|
+
current: _propTypes.default.instanceOf(HTMLElement)
|
|
145
|
+
}),
|
|
140
146
|
filterValue: _propTypes.default.string,
|
|
141
147
|
filterable: _propTypes.default.bool,
|
|
142
148
|
hidden: _propTypes.default.bool,
|
|
@@ -151,8 +157,10 @@ Menu.propTypes = {
|
|
|
151
157
|
selectedValue: _propTypes.default.string,
|
|
152
158
|
tabIndex: _propTypes.default.string,
|
|
153
159
|
onBlur: _propTypes.default.func,
|
|
160
|
+
onChange: _propTypes.default.func,
|
|
154
161
|
onClose: _propTypes.default.func,
|
|
155
162
|
onEndReached: _propTypes.default.func,
|
|
156
163
|
onFilterChange: _propTypes.default.func,
|
|
157
|
-
onFilterInputKeyDown: _propTypes.default.func
|
|
164
|
+
onFilterInputKeyDown: _propTypes.default.func,
|
|
165
|
+
onOptionsKeyDown: _propTypes.default.func
|
|
158
166
|
};
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.OptionsList = void 0;
|
|
7
|
+
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
7
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _isOptionHidden = require("../is-option-hidden.js");
|
|
@@ -27,7 +28,8 @@ const OptionsList = exports.OptionsList = /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
27
28
|
loading,
|
|
28
29
|
onChange,
|
|
29
30
|
onBlur,
|
|
30
|
-
onEndReached
|
|
31
|
+
onEndReached,
|
|
32
|
+
onKeyDown
|
|
31
33
|
} = _ref;
|
|
32
34
|
// scrolls the highlighted option into view when:
|
|
33
35
|
// * the highlighted option changes
|
|
@@ -48,12 +50,15 @@ const OptionsList = exports.OptionsList = /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
48
50
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
49
51
|
ref: ref,
|
|
50
52
|
role: "listbox",
|
|
53
|
+
tabIndex: "-1",
|
|
51
54
|
id: id,
|
|
52
55
|
"aria-labelledby": labelledBy,
|
|
53
56
|
"aria-live": optionUpdateStrategy,
|
|
54
57
|
"aria-busy": loading.toString(),
|
|
55
58
|
"data-test": dataTest,
|
|
56
|
-
onBlur: onBlur
|
|
59
|
+
onBlur: onBlur,
|
|
60
|
+
onKeyDown: onKeyDown,
|
|
61
|
+
className: "jsx-233683301"
|
|
57
62
|
}, options.map((_ref2, index) => {
|
|
58
63
|
let {
|
|
59
64
|
value,
|
|
@@ -77,14 +82,15 @@ const OptionsList = exports.OptionsList = /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
77
82
|
component: component || optionComponent,
|
|
78
83
|
onBecameVisible: isLast ? onEndReached : undefined
|
|
79
84
|
});
|
|
80
|
-
})
|
|
85
|
+
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
86
|
+
id: "233683301"
|
|
87
|
+
}, ["div.jsx-233683301{outline:none;}"]));
|
|
81
88
|
});
|
|
82
89
|
OptionsList.propTypes = {
|
|
83
90
|
comboBoxId: _propTypes.default.string.isRequired,
|
|
84
91
|
focussedOptionIndex: _propTypes.default.number.isRequired,
|
|
85
92
|
id: _propTypes.default.string.isRequired,
|
|
86
93
|
options: _propTypes.default.arrayOf(_sharedPropTypes.optionProp).isRequired,
|
|
87
|
-
onChange: _propTypes.default.func.isRequired,
|
|
88
94
|
dataTest: _propTypes.default.string,
|
|
89
95
|
disabled: _propTypes.default.bool,
|
|
90
96
|
labelledBy: _propTypes.default.string,
|
|
@@ -93,5 +99,7 @@ OptionsList.propTypes = {
|
|
|
93
99
|
optionUpdateStrategy: _propTypes.default.oneOf(['off', 'polite', 'assertive']),
|
|
94
100
|
selectedValue: _propTypes.default.string,
|
|
95
101
|
onBlur: _propTypes.default.func,
|
|
96
|
-
|
|
102
|
+
onChange: _propTypes.default.func,
|
|
103
|
+
onEndReached: _propTypes.default.func,
|
|
104
|
+
onKeyDown: _propTypes.default.func
|
|
97
105
|
};
|
|
@@ -104,6 +104,7 @@ function SimpleSingleSelect(_ref2) {
|
|
|
104
104
|
const comboBoxId = `${name}-combo`;
|
|
105
105
|
const comboBoxRef = (0, _react.useRef)();
|
|
106
106
|
const listBoxRef = (0, _react.useRef)();
|
|
107
|
+
const filterRef = (0, _react.useRef)();
|
|
107
108
|
const [focussedOptionIndex, setFocussedOptionIndex] = useFocussedOptionIndex({
|
|
108
109
|
filterable,
|
|
109
110
|
filterValue,
|
|
@@ -154,6 +155,7 @@ function SimpleSingleSelect(_ref2) {
|
|
|
154
155
|
focussedOptionIndex,
|
|
155
156
|
setFocussedOptionIndex,
|
|
156
157
|
selectFocussedOption,
|
|
158
|
+
filterRef,
|
|
157
159
|
clearable,
|
|
158
160
|
onClear
|
|
159
161
|
});
|
|
@@ -242,7 +244,9 @@ function SimpleSingleSelect(_ref2) {
|
|
|
242
244
|
},
|
|
243
245
|
onClose: closeMenu,
|
|
244
246
|
onEndReached: onEndReached,
|
|
245
|
-
onFilterChange: onFilterChange
|
|
247
|
+
onFilterChange: onFilterChange,
|
|
248
|
+
filterRef: filterRef,
|
|
249
|
+
onOptionsKeyDown: handleKeyDown
|
|
246
250
|
}));
|
|
247
251
|
}
|
|
248
252
|
SimpleSingleSelect.propTypes = {
|
package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js
CHANGED
|
@@ -46,6 +46,7 @@ function useHandleKeyPressOnCombobox(_ref2) {
|
|
|
46
46
|
setFocussedOptionIndex,
|
|
47
47
|
selectFocussedOption,
|
|
48
48
|
onChange,
|
|
49
|
+
filterRef,
|
|
49
50
|
clearable,
|
|
50
51
|
onClear
|
|
51
52
|
} = _ref2;
|
|
@@ -159,6 +160,10 @@ function useHandleKeyPressOnCombobox(_ref2) {
|
|
|
159
160
|
return;
|
|
160
161
|
}
|
|
161
162
|
if (key === 'ArrowUp') {
|
|
163
|
+
if (filterRef !== null && filterRef !== void 0 && filterRef.current && focussedOptionIndex === 0) {
|
|
164
|
+
filterRef.current.focus();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
162
167
|
focusPrevOption();
|
|
163
168
|
return;
|
|
164
169
|
}
|
|
@@ -184,6 +189,6 @@ function useHandleKeyPressOnCombobox(_ref2) {
|
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
// Do nothing
|
|
187
|
-
}, [closeMenu, disabled, expanded, loading, openMenu, options, value, typing, focussedOptionIndex, selectFocussedOption, selectNextOption, selectPrevOption, focusNextOption, focusPrevOption, focusFirstOption, focusLastOption, pageDown, pageUp, onTyping]);
|
|
192
|
+
}, [closeMenu, disabled, expanded, loading, openMenu, options, value, typing, focussedOptionIndex, selectFocussedOption, selectNextOption, selectPrevOption, focusNextOption, focusPrevOption, focusFirstOption, focusLastOption, pageDown, pageUp, onTyping, filterRef]);
|
|
188
193
|
return handleKeyPress;
|
|
189
194
|
}
|
package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js
CHANGED
|
@@ -72,8 +72,10 @@ function useHandleKeyPressOnFilterInput(_ref) {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (key === 'ArrowDown') {
|
|
75
|
+
var _listBoxRef$current;
|
|
75
76
|
e.preventDefault(); // Disable moving cursor to end
|
|
76
77
|
focusNextOption();
|
|
78
|
+
(_listBoxRef$current = listBoxRef.current) === null || _listBoxRef$current === void 0 ? void 0 : _listBoxRef$current.focus();
|
|
77
79
|
return;
|
|
78
80
|
}
|
|
79
81
|
if (key === 'ArrowUp') {
|
|
@@ -101,6 +103,6 @@ function useHandleKeyPressOnFilterInput(_ref) {
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
// Do nothing
|
|
104
|
-
}, [closeMenu, options, value, loading, focussedOptionIndex, selectFocussedOption, focusComboBox, focusNextOption, focusPrevOption, focusFirstOption, focusLastOption, pageDown, pageUp]);
|
|
106
|
+
}, [closeMenu, options, value, loading, focussedOptionIndex, selectFocussedOption, focusComboBox, focusNextOption, focusPrevOption, focusFirstOption, focusLastOption, pageDown, pageUp, listBoxRef]);
|
|
105
107
|
return handleKeyPress;
|
|
106
108
|
}
|
|
@@ -2,9 +2,9 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors, spacers } from '@dhis2/ui-constants';
|
|
3
3
|
import { Input } from '@dhis2-ui/input';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
6
|
import i18n from '../../locales/index.js';
|
|
7
|
-
export function Filter(_ref) {
|
|
7
|
+
export const Filter = /*#__PURE__*/forwardRef(function Filter(_ref, ref) {
|
|
8
8
|
let {
|
|
9
9
|
ariaControls,
|
|
10
10
|
dataTest,
|
|
@@ -13,13 +13,15 @@ export function Filter(_ref) {
|
|
|
13
13
|
tabIndex,
|
|
14
14
|
value,
|
|
15
15
|
onChange,
|
|
16
|
-
onKeyDown
|
|
16
|
+
onKeyDown,
|
|
17
|
+
onFocus
|
|
17
18
|
} = _ref;
|
|
18
19
|
return /*#__PURE__*/React.createElement("div", {
|
|
19
20
|
"data-test": dataTest,
|
|
20
21
|
className: _JSXStyle.dynamic([["3850436710", [colors.white, spacers.dp8, spacers.dp8, spacers.dp4, spacers.dp8]]])
|
|
21
22
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
22
23
|
dense: true,
|
|
24
|
+
ref: ref,
|
|
23
25
|
tabIndex: tabIndex,
|
|
24
26
|
ariaControls: ariaControls,
|
|
25
27
|
ariaHaspopup: "listbox",
|
|
@@ -35,12 +37,13 @@ export function Filter(_ref) {
|
|
|
35
37
|
type: "text",
|
|
36
38
|
name: "filter",
|
|
37
39
|
placeholder: placeholder,
|
|
38
|
-
onKeyDown: (_, e) => onKeyDown(e)
|
|
40
|
+
onKeyDown: (_, e) => onKeyDown(e),
|
|
41
|
+
onFocus: onFocus
|
|
39
42
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
40
43
|
id: "3850436710",
|
|
41
44
|
dynamic: [colors.white, spacers.dp8, spacers.dp8, spacers.dp4, spacers.dp8]
|
|
42
45
|
}, [`div.__jsx-style-dynamic-selector{height:100%;-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;background:${colors.white};}`]));
|
|
43
|
-
}
|
|
46
|
+
});
|
|
44
47
|
Filter.propTypes = {
|
|
45
48
|
ariaControls: PropTypes.string.isRequired,
|
|
46
49
|
value: PropTypes.string.isRequired,
|
|
@@ -49,5 +52,6 @@ Filter.propTypes = {
|
|
|
49
52
|
label: PropTypes.string,
|
|
50
53
|
placeholder: PropTypes.string,
|
|
51
54
|
tabIndex: PropTypes.string,
|
|
55
|
+
onFocus: PropTypes.func,
|
|
52
56
|
onKeyDown: PropTypes.func
|
|
53
57
|
};
|
|
@@ -40,7 +40,9 @@ export function Menu(_ref) {
|
|
|
40
40
|
onClose,
|
|
41
41
|
onEndReached,
|
|
42
42
|
onFilterChange,
|
|
43
|
-
onFilterInputKeyDown
|
|
43
|
+
onFilterInputKeyDown,
|
|
44
|
+
filterRef,
|
|
45
|
+
onOptionsKeyDown
|
|
44
46
|
} = _ref;
|
|
45
47
|
const [menuWidth, setWidth] = useState('auto');
|
|
46
48
|
const dataTestPrefix = `${dataTest}-menu`;
|
|
@@ -77,6 +79,7 @@ export function Menu(_ref) {
|
|
|
77
79
|
}, filterable && /*#__PURE__*/React.createElement("div", {
|
|
78
80
|
className: _JSXStyle.dynamic([["2949029222", [colors.white, colors.grey200, elevations.e300]]]) + " " + "filter-container"
|
|
79
81
|
}, /*#__PURE__*/React.createElement(Filter, {
|
|
82
|
+
ref: filterRef,
|
|
80
83
|
dataTest: `${dataTestPrefix}-filter`,
|
|
81
84
|
value: filterValue,
|
|
82
85
|
label: filterLabel,
|
|
@@ -91,6 +94,7 @@ export function Menu(_ref) {
|
|
|
91
94
|
className: _JSXStyle.dynamic([["2949029222", [colors.white, colors.grey200, elevations.e300]]]) + " " + "listbox-wrapper"
|
|
92
95
|
}, /*#__PURE__*/React.createElement(OptionsList, {
|
|
93
96
|
ref: listBoxRef,
|
|
97
|
+
onKeyDown: onOptionsKeyDown,
|
|
94
98
|
comboBoxId: comboBoxId,
|
|
95
99
|
optionComponent: optionComponent,
|
|
96
100
|
dataTest: `${dataTestPrefix}-list`,
|
|
@@ -122,12 +126,14 @@ Menu.propTypes = {
|
|
|
122
126
|
}).isRequired,
|
|
123
127
|
name: PropTypes.string.isRequired,
|
|
124
128
|
options: PropTypes.arrayOf(optionProp).isRequired,
|
|
125
|
-
onChange: PropTypes.func.isRequired,
|
|
126
129
|
dataTest: PropTypes.string,
|
|
127
130
|
disabled: PropTypes.bool,
|
|
128
131
|
empty: PropTypes.node,
|
|
129
132
|
filterLabel: PropTypes.string,
|
|
130
133
|
filterPlaceholder: PropTypes.string,
|
|
134
|
+
filterRef: PropTypes.shape({
|
|
135
|
+
current: PropTypes.instanceOf(HTMLElement)
|
|
136
|
+
}),
|
|
131
137
|
filterValue: PropTypes.string,
|
|
132
138
|
filterable: PropTypes.bool,
|
|
133
139
|
hidden: PropTypes.bool,
|
|
@@ -142,8 +148,10 @@ Menu.propTypes = {
|
|
|
142
148
|
selectedValue: PropTypes.string,
|
|
143
149
|
tabIndex: PropTypes.string,
|
|
144
150
|
onBlur: PropTypes.func,
|
|
151
|
+
onChange: PropTypes.func,
|
|
145
152
|
onClose: PropTypes.func,
|
|
146
153
|
onEndReached: PropTypes.func,
|
|
147
154
|
onFilterChange: PropTypes.func,
|
|
148
|
-
onFilterInputKeyDown: PropTypes.func
|
|
155
|
+
onFilterInputKeyDown: PropTypes.func,
|
|
156
|
+
onOptionsKeyDown: PropTypes.func
|
|
149
157
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
1
2
|
import PropTypes from 'prop-types';
|
|
2
3
|
import React, { forwardRef, useEffect } from 'react';
|
|
3
4
|
import { isOptionHidden } from '../is-option-hidden.js';
|
|
@@ -18,7 +19,8 @@ export const OptionsList = /*#__PURE__*/forwardRef(function OptionsList(_ref, re
|
|
|
18
19
|
loading,
|
|
19
20
|
onChange,
|
|
20
21
|
onBlur,
|
|
21
|
-
onEndReached
|
|
22
|
+
onEndReached,
|
|
23
|
+
onKeyDown
|
|
22
24
|
} = _ref;
|
|
23
25
|
// scrolls the highlighted option into view when:
|
|
24
26
|
// * the highlighted option changes
|
|
@@ -39,12 +41,15 @@ export const OptionsList = /*#__PURE__*/forwardRef(function OptionsList(_ref, re
|
|
|
39
41
|
return /*#__PURE__*/React.createElement("div", {
|
|
40
42
|
ref: ref,
|
|
41
43
|
role: "listbox",
|
|
44
|
+
tabIndex: "-1",
|
|
42
45
|
id: id,
|
|
43
46
|
"aria-labelledby": labelledBy,
|
|
44
47
|
"aria-live": optionUpdateStrategy,
|
|
45
48
|
"aria-busy": loading.toString(),
|
|
46
49
|
"data-test": dataTest,
|
|
47
|
-
onBlur: onBlur
|
|
50
|
+
onBlur: onBlur,
|
|
51
|
+
onKeyDown: onKeyDown,
|
|
52
|
+
className: "jsx-233683301"
|
|
48
53
|
}, options.map((_ref2, index) => {
|
|
49
54
|
let {
|
|
50
55
|
value,
|
|
@@ -68,14 +73,15 @@ export const OptionsList = /*#__PURE__*/forwardRef(function OptionsList(_ref, re
|
|
|
68
73
|
component: component || optionComponent,
|
|
69
74
|
onBecameVisible: isLast ? onEndReached : undefined
|
|
70
75
|
});
|
|
71
|
-
})
|
|
76
|
+
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
77
|
+
id: "233683301"
|
|
78
|
+
}, ["div.jsx-233683301{outline:none;}"]));
|
|
72
79
|
});
|
|
73
80
|
OptionsList.propTypes = {
|
|
74
81
|
comboBoxId: PropTypes.string.isRequired,
|
|
75
82
|
focussedOptionIndex: PropTypes.number.isRequired,
|
|
76
83
|
id: PropTypes.string.isRequired,
|
|
77
84
|
options: PropTypes.arrayOf(optionProp).isRequired,
|
|
78
|
-
onChange: PropTypes.func.isRequired,
|
|
79
85
|
dataTest: PropTypes.string,
|
|
80
86
|
disabled: PropTypes.bool,
|
|
81
87
|
labelledBy: PropTypes.string,
|
|
@@ -84,5 +90,7 @@ OptionsList.propTypes = {
|
|
|
84
90
|
optionUpdateStrategy: PropTypes.oneOf(['off', 'polite', 'assertive']),
|
|
85
91
|
selectedValue: PropTypes.string,
|
|
86
92
|
onBlur: PropTypes.func,
|
|
87
|
-
|
|
93
|
+
onChange: PropTypes.func,
|
|
94
|
+
onEndReached: PropTypes.func,
|
|
95
|
+
onKeyDown: PropTypes.func
|
|
88
96
|
};
|
|
@@ -95,6 +95,7 @@ export function SimpleSingleSelect(_ref2) {
|
|
|
95
95
|
const comboBoxId = `${name}-combo`;
|
|
96
96
|
const comboBoxRef = useRef();
|
|
97
97
|
const listBoxRef = useRef();
|
|
98
|
+
const filterRef = useRef();
|
|
98
99
|
const [focussedOptionIndex, setFocussedOptionIndex] = useFocussedOptionIndex({
|
|
99
100
|
filterable,
|
|
100
101
|
filterValue,
|
|
@@ -145,6 +146,7 @@ export function SimpleSingleSelect(_ref2) {
|
|
|
145
146
|
focussedOptionIndex,
|
|
146
147
|
setFocussedOptionIndex,
|
|
147
148
|
selectFocussedOption,
|
|
149
|
+
filterRef,
|
|
148
150
|
clearable,
|
|
149
151
|
onClear
|
|
150
152
|
});
|
|
@@ -233,7 +235,9 @@ export function SimpleSingleSelect(_ref2) {
|
|
|
233
235
|
},
|
|
234
236
|
onClose: closeMenu,
|
|
235
237
|
onEndReached: onEndReached,
|
|
236
|
-
onFilterChange: onFilterChange
|
|
238
|
+
onFilterChange: onFilterChange,
|
|
239
|
+
filterRef: filterRef,
|
|
240
|
+
onOptionsKeyDown: handleKeyDown
|
|
237
241
|
}));
|
|
238
242
|
}
|
|
239
243
|
SimpleSingleSelect.propTypes = {
|
package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js
CHANGED
|
@@ -40,6 +40,7 @@ export function useHandleKeyPressOnCombobox(_ref2) {
|
|
|
40
40
|
setFocussedOptionIndex,
|
|
41
41
|
selectFocussedOption,
|
|
42
42
|
onChange,
|
|
43
|
+
filterRef,
|
|
43
44
|
clearable,
|
|
44
45
|
onClear
|
|
45
46
|
} = _ref2;
|
|
@@ -153,6 +154,10 @@ export function useHandleKeyPressOnCombobox(_ref2) {
|
|
|
153
154
|
return;
|
|
154
155
|
}
|
|
155
156
|
if (key === 'ArrowUp') {
|
|
157
|
+
if (filterRef !== null && filterRef !== void 0 && filterRef.current && focussedOptionIndex === 0) {
|
|
158
|
+
filterRef.current.focus();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
156
161
|
focusPrevOption();
|
|
157
162
|
return;
|
|
158
163
|
}
|
|
@@ -178,6 +183,6 @@ export function useHandleKeyPressOnCombobox(_ref2) {
|
|
|
178
183
|
}
|
|
179
184
|
|
|
180
185
|
// Do nothing
|
|
181
|
-
}, [closeMenu, disabled, expanded, loading, openMenu, options, value, typing, focussedOptionIndex, selectFocussedOption, selectNextOption, selectPrevOption, focusNextOption, focusPrevOption, focusFirstOption, focusLastOption, pageDown, pageUp, onTyping]);
|
|
186
|
+
}, [closeMenu, disabled, expanded, loading, openMenu, options, value, typing, focussedOptionIndex, selectFocussedOption, selectNextOption, selectPrevOption, focusNextOption, focusPrevOption, focusFirstOption, focusLastOption, pageDown, pageUp, onTyping, filterRef]);
|
|
182
187
|
return handleKeyPress;
|
|
183
188
|
}
|
package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js
CHANGED
|
@@ -66,8 +66,10 @@ export function useHandleKeyPressOnFilterInput(_ref) {
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (key === 'ArrowDown') {
|
|
69
|
+
var _listBoxRef$current;
|
|
69
70
|
e.preventDefault(); // Disable moving cursor to end
|
|
70
71
|
focusNextOption();
|
|
72
|
+
(_listBoxRef$current = listBoxRef.current) === null || _listBoxRef$current === void 0 ? void 0 : _listBoxRef$current.focus();
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
75
|
if (key === 'ArrowUp') {
|
|
@@ -95,6 +97,6 @@ export function useHandleKeyPressOnFilterInput(_ref) {
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// Do nothing
|
|
98
|
-
}, [closeMenu, options, value, loading, focussedOptionIndex, selectFocussedOption, focusComboBox, focusNextOption, focusPrevOption, focusFirstOption, focusLastOption, pageDown, pageUp]);
|
|
100
|
+
}, [closeMenu, options, value, loading, focussedOptionIndex, selectFocussedOption, focusComboBox, focusNextOption, focusPrevOption, focusFirstOption, focusLastOption, pageDown, pageUp, listBoxRef]);
|
|
99
101
|
return handleKeyPress;
|
|
100
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/select",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.13.0-alpha.1",
|
|
4
4
|
"description": "UI Select",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,21 +33,21 @@
|
|
|
33
33
|
"styled-jsx": "^4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dhis2-ui/box": "10.
|
|
37
|
-
"@dhis2-ui/button": "10.
|
|
38
|
-
"@dhis2-ui/card": "10.
|
|
39
|
-
"@dhis2-ui/checkbox": "10.
|
|
40
|
-
"@dhis2-ui/chip": "10.
|
|
41
|
-
"@dhis2-ui/field": "10.
|
|
42
|
-
"@dhis2-ui/input": "10.
|
|
43
|
-
"@dhis2-ui/layer": "10.
|
|
44
|
-
"@dhis2-ui/loader": "10.
|
|
45
|
-
"@dhis2-ui/popper": "10.
|
|
46
|
-
"@dhis2-ui/status-icon": "10.
|
|
47
|
-
"@dhis2-ui/tooltip": "10.
|
|
36
|
+
"@dhis2-ui/box": "10.13.0-alpha.1",
|
|
37
|
+
"@dhis2-ui/button": "10.13.0-alpha.1",
|
|
38
|
+
"@dhis2-ui/card": "10.13.0-alpha.1",
|
|
39
|
+
"@dhis2-ui/checkbox": "10.13.0-alpha.1",
|
|
40
|
+
"@dhis2-ui/chip": "10.13.0-alpha.1",
|
|
41
|
+
"@dhis2-ui/field": "10.13.0-alpha.1",
|
|
42
|
+
"@dhis2-ui/input": "10.13.0-alpha.1",
|
|
43
|
+
"@dhis2-ui/layer": "10.13.0-alpha.1",
|
|
44
|
+
"@dhis2-ui/loader": "10.13.0-alpha.1",
|
|
45
|
+
"@dhis2-ui/popper": "10.13.0-alpha.1",
|
|
46
|
+
"@dhis2-ui/status-icon": "10.13.0-alpha.1",
|
|
47
|
+
"@dhis2-ui/tooltip": "10.13.0-alpha.1",
|
|
48
48
|
"@dhis2/prop-types": "^3.1.2",
|
|
49
|
-
"@dhis2/ui-constants": "10.
|
|
50
|
-
"@dhis2/ui-icons": "10.
|
|
49
|
+
"@dhis2/ui-constants": "10.13.0-alpha.1",
|
|
50
|
+
"@dhis2/ui-icons": "10.13.0-alpha.1",
|
|
51
51
|
"classnames": "^2.3.1",
|
|
52
52
|
"prop-types": "^15.7.2"
|
|
53
53
|
},
|