@dhis2-ui/select 10.16.3 → 10.16.5
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/locales/index.js +94 -57
- package/build/cjs/multi-select/features/menu_width_matches_input/index.js +2 -4
- package/build/cjs/multi-select/features/position/index.js +6 -12
- package/build/cjs/multi-select/filterable-menu.js +22 -25
- package/build/cjs/multi-select/input.js +14 -15
- package/build/cjs/multi-select/menu.js +24 -28
- package/build/cjs/multi-select/multi-select.e2e.stories.js +21 -32
- package/build/cjs/multi-select/multi-select.js +30 -31
- package/build/cjs/multi-select/multi-select.prod.stories.js +13 -21
- package/build/cjs/multi-select/selection-list.js +51 -57
- package/build/cjs/multi-select-option/multi-select-option.js +27 -30
- package/build/cjs/select/debounce/debounce.js +2 -6
- package/build/cjs/select/empty.js +11 -14
- package/build/cjs/select/filter-input.js +21 -24
- package/build/cjs/select/filterable-menu.js +6 -8
- package/build/cjs/select/input-clear-button.js +28 -31
- package/build/cjs/select/input-placeholder.js +5 -6
- package/build/cjs/select/input-prefix.js +5 -6
- package/build/cjs/select/input-wrapper.js +13 -14
- package/build/cjs/select/loading.js +15 -18
- package/build/cjs/select/menu-wrapper.js +8 -9
- package/build/cjs/select/no-match.js +9 -12
- package/build/cjs/select/select.js +3 -4
- package/build/cjs/simple-single-select/__stories__/DefaultPosition.js +1 -2
- package/build/cjs/simple-single-select/__stories__/Dense.js +1 -2
- package/build/cjs/simple-single-select/__stories__/Empty.js +1 -2
- package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyNode.js +1 -2
- package/build/cjs/simple-single-select/__stories__/EmptyWithEmptyText.js +1 -2
- package/build/cjs/simple-single-select/__stories__/FlippedPosition.js +1 -2
- package/build/cjs/simple-single-select/__stories__/InfiniteLoading.js +1 -2
- package/build/cjs/simple-single-select/__stories__/ShiftedIntoView.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithClearButton.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithCustomLowMaxHeight.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithCustomOptions.js +17 -21
- package/build/cjs/simple-single-select/__stories__/WithDisabledOption.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithFilterField.js +5 -9
- package/build/cjs/simple-single-select/__stories__/WithInitialFocus.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithManyOptions.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithMultipleSelectsAndScrollableParent.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithNoMatchText.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOnBlur.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOnFocus.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndDisabled.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoading.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithOptionsAndLoadingText.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithPlaceholder.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithPlaceholderAndSelection.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithPrefix.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithPrefixAndSelection.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithRTL.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithScrollingParent.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithSelection.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithSelectionAndDisabled.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithServerSideFilteringDemo.js +25 -36
- package/build/cjs/simple-single-select/__stories__/WithSimpleFilteringDemo.js +4 -6
- package/build/cjs/simple-single-select/__stories__/WithoutOptionsAndLoading.js +1 -2
- package/build/cjs/simple-single-select/__stories__/WithoutSelection.js +1 -2
- package/build/cjs/simple-single-select/__stories__/simple-single-select-server-side-filtering/CustomDataProvider.js +19 -26
- package/build/cjs/simple-single-select/features/keyboard-interactions.test.e2e.js +9 -18
- package/build/cjs/simple-single-select/features/menu-positioning.test.e2e.js +8 -16
- package/build/cjs/simple-single-select/menu/empty.js +8 -11
- package/build/cjs/simple-single-select/menu/filter.js +11 -12
- package/build/cjs/simple-single-select/menu/loading.js +3 -4
- package/build/cjs/simple-single-select/menu/menu.js +26 -28
- package/build/cjs/simple-single-select/menu/no-match.js +9 -12
- package/build/cjs/simple-single-select/menu/option.js +20 -23
- package/build/cjs/simple-single-select/menu/options-list.js +23 -26
- package/build/cjs/simple-single-select/selected-value/clear-button.js +5 -6
- package/build/cjs/simple-single-select/selected-value/container.js +23 -25
- package/build/cjs/simple-single-select/selected-value/placeholder.js +5 -6
- package/build/cjs/simple-single-select/selected-value/prefix.js +5 -6
- package/build/cjs/simple-single-select/selected-value/selected-value.js +34 -35
- package/build/cjs/simple-single-select/simple-single-select.e2e.stories.js +1 -2
- package/build/cjs/simple-single-select/simple-single-select.js +47 -50
- package/build/cjs/simple-single-select/simple-single-select.test.js +14 -24
- package/build/cjs/simple-single-select/use-handle-key-press/use-focus-option.js +5 -6
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +31 -34
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +11 -12
- package/build/cjs/simple-single-select/use-handle-key-press/use-handle-typing.js +10 -14
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +6 -7
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +5 -6
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +6 -7
- package/build/cjs/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +5 -6
- package/build/cjs/simple-single-select/use-handle-key-press/use-page-down.js +6 -7
- package/build/cjs/simple-single-select/use-handle-key-press/use-page-up.js +6 -7
- package/build/cjs/simple-single-select/use-handle-key-press/utils.js +17 -22
- package/build/cjs/simple-single-select-field/simple-single-select-field.js +3 -6
- package/build/cjs/simple-single-select-field/simple-single-select-field.prod.stories.js +1 -2
- package/build/cjs/simple-single-select-field/simple-single-select-field.test.js +3 -6
- package/build/cjs/single-select/features/menu_width_matches_input/index.js +2 -4
- package/build/cjs/single-select/features/position/index.js +4 -8
- package/build/cjs/single-select/filterable-menu.js +22 -25
- package/build/cjs/single-select/input.js +13 -14
- package/build/cjs/single-select/menu.js +9 -10
- package/build/cjs/single-select/selection.js +5 -6
- package/build/cjs/single-select/single-select.e2e.stories.js +18 -28
- package/build/cjs/single-select/single-select.js +29 -30
- package/build/cjs/single-select/single-select.prod.stories.js +7 -11
- package/build/cjs/single-select-option/single-select-option.js +25 -28
- package/build/es/locales/index.js +70 -33
- package/build/es/multi-select/features/menu_width_matches_input/index.js +2 -4
- package/build/es/multi-select/features/position/index.js +6 -12
- package/build/es/multi-select/filterable-menu.js +22 -25
- package/build/es/multi-select/input.js +14 -15
- package/build/es/multi-select/menu.js +24 -28
- package/build/es/multi-select/multi-select.e2e.stories.js +20 -30
- package/build/es/multi-select/multi-select.js +30 -31
- package/build/es/multi-select/multi-select.prod.stories.js +12 -19
- package/build/es/multi-select/selection-list.js +51 -57
- package/build/es/multi-select-option/multi-select-option.js +27 -30
- package/build/es/select/debounce/debounce.js +2 -6
- package/build/es/select/empty.js +11 -14
- package/build/es/select/filter-input.js +21 -24
- package/build/es/select/filterable-menu.js +5 -6
- package/build/es/select/input-clear-button.js +28 -31
- package/build/es/select/input-placeholder.js +5 -6
- package/build/es/select/input-prefix.js +5 -6
- package/build/es/select/input-wrapper.js +13 -14
- package/build/es/select/loading.js +15 -18
- package/build/es/select/menu-wrapper.js +8 -9
- package/build/es/select/no-match.js +9 -12
- package/build/es/select/select.js +2 -2
- package/build/es/simple-single-select/__stories__/WithCustomOptions.js +16 -19
- package/build/es/simple-single-select/__stories__/WithFilterField.js +4 -7
- package/build/es/simple-single-select/__stories__/WithServerSideFilteringDemo.js +24 -34
- package/build/es/simple-single-select/__stories__/WithSimpleFilteringDemo.js +3 -4
- package/build/es/simple-single-select/__stories__/simple-single-select-server-side-filtering/CustomDataProvider.js +19 -26
- package/build/es/simple-single-select/features/keyboard-interactions.test.e2e.js +9 -18
- package/build/es/simple-single-select/features/menu-positioning.test.e2e.js +8 -16
- package/build/es/simple-single-select/menu/empty.js +8 -11
- package/build/es/simple-single-select/menu/filter.js +11 -12
- package/build/es/simple-single-select/menu/loading.js +3 -4
- package/build/es/simple-single-select/menu/menu.js +25 -26
- package/build/es/simple-single-select/menu/no-match.js +9 -12
- package/build/es/simple-single-select/menu/option.js +19 -21
- package/build/es/simple-single-select/menu/options-list.js +22 -24
- package/build/es/simple-single-select/selected-value/clear-button.js +5 -6
- package/build/es/simple-single-select/selected-value/container.js +22 -23
- package/build/es/simple-single-select/selected-value/placeholder.js +5 -6
- package/build/es/simple-single-select/selected-value/prefix.js +5 -6
- package/build/es/simple-single-select/selected-value/selected-value.js +34 -35
- package/build/es/simple-single-select/simple-single-select.js +46 -48
- package/build/es/simple-single-select/simple-single-select.test.js +13 -22
- package/build/es/simple-single-select/use-handle-key-press/use-focus-option.js +5 -6
- package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-combobox.js +31 -34
- package/build/es/simple-single-select/use-handle-key-press/use-handle-key-press-on-filter-input.js +11 -12
- package/build/es/simple-single-select/use-handle-key-press/use-handle-typing.js +10 -14
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-option-on-previous-page.js +6 -7
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-first-visible-option.js +5 -6
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-option-on-next-page.js +6 -7
- package/build/es/simple-single-select/use-handle-key-press/use-highlight-last-visible-option.js +5 -6
- package/build/es/simple-single-select/use-handle-key-press/use-page-down.js +6 -7
- package/build/es/simple-single-select/use-handle-key-press/use-page-up.js +6 -7
- package/build/es/simple-single-select/use-handle-key-press/utils.js +17 -22
- package/build/es/simple-single-select-field/simple-single-select-field.js +3 -6
- package/build/es/simple-single-select-field/simple-single-select-field.test.js +3 -6
- package/build/es/single-select/features/menu_width_matches_input/index.js +2 -4
- package/build/es/single-select/features/position/index.js +4 -8
- package/build/es/single-select/filterable-menu.js +22 -25
- package/build/es/single-select/input.js +13 -14
- package/build/es/single-select/menu.js +9 -10
- package/build/es/single-select/selection.js +5 -6
- package/build/es/single-select/single-select.e2e.stories.js +17 -26
- package/build/es/single-select/single-select.js +29 -30
- package/build/es/single-select/single-select.prod.stories.js +6 -9
- package/build/es/single-select-option/single-select-option.js +25 -28
- package/package.json +15 -15
- package/src/locales/index.js +102 -33
|
@@ -2,11 +2,10 @@ import { useDataEngine, useDataQuery } from '@dhis2/app-runtime';
|
|
|
2
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { SimpleSingleSelect } from '../simple-single-select.js';
|
|
4
4
|
import { CustomDataProvider } from './simple-single-select-server-side-filtering/index.js';
|
|
5
|
-
function dataElementToOption(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
5
|
+
function dataElementToOption({
|
|
6
|
+
id,
|
|
7
|
+
displayName
|
|
8
|
+
}) {
|
|
10
9
|
return {
|
|
11
10
|
value: id,
|
|
12
11
|
label: displayName
|
|
@@ -16,12 +15,9 @@ function useLoadDataElementQuery(options) {
|
|
|
16
15
|
return useDataQuery({
|
|
17
16
|
result: {
|
|
18
17
|
resource: 'dataElements',
|
|
19
|
-
id:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} = _ref2;
|
|
23
|
-
return id;
|
|
24
|
-
}
|
|
18
|
+
id: ({
|
|
19
|
+
id
|
|
20
|
+
}) => id
|
|
25
21
|
}
|
|
26
22
|
}, {
|
|
27
23
|
...options,
|
|
@@ -32,15 +28,12 @@ function useLoadDataElementsQuery(options) {
|
|
|
32
28
|
return useDataQuery({
|
|
33
29
|
result: {
|
|
34
30
|
resource: 'dataElements',
|
|
35
|
-
params:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
pageSize: 10
|
|
42
|
-
};
|
|
43
|
-
}
|
|
31
|
+
params: ({
|
|
32
|
+
page
|
|
33
|
+
}) => ({
|
|
34
|
+
page,
|
|
35
|
+
pageSize: 10
|
|
36
|
+
})
|
|
44
37
|
}
|
|
45
38
|
}, options);
|
|
46
39
|
}
|
|
@@ -50,15 +43,14 @@ function useLoadFilteredDataElementsQuery(customOptions) {
|
|
|
50
43
|
const abortController = useRef();
|
|
51
44
|
const [loading, setLoading] = useState(false);
|
|
52
45
|
const [error, setError] = useState(null);
|
|
53
|
-
const refetch = useCallback(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} = _ref4;
|
|
46
|
+
const refetch = useCallback(({
|
|
47
|
+
searchTerm,
|
|
48
|
+
page
|
|
49
|
+
}) => {
|
|
58
50
|
if (timeout.current) {
|
|
59
51
|
var _abortController$curr;
|
|
60
52
|
clearTimeout(timeout.current);
|
|
61
|
-
(_abortController$curr = abortController.current) === null || _abortController$curr === void 0
|
|
53
|
+
(_abortController$curr = abortController.current) === null || _abortController$curr === void 0 || _abortController$curr.abort();
|
|
62
54
|
}
|
|
63
55
|
return new Promise((resolve, reject) => {
|
|
64
56
|
timeout.current = setTimeout(async () => {
|
|
@@ -135,10 +127,9 @@ function ServerSideFilteringSelect() {
|
|
|
135
127
|
}
|
|
136
128
|
});
|
|
137
129
|
const loadDataElementsQuery = useLoadDataElementsQuery({
|
|
138
|
-
onComplete:
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
} = _ref5;
|
|
130
|
+
onComplete: ({
|
|
131
|
+
result
|
|
132
|
+
}) => {
|
|
142
133
|
setDefaultPager(result.pager);
|
|
143
134
|
setLoadedOptions(prevLoadedOptions => [...prevLoadedOptions, ...result.dataElements.map(dataElementToOption)]);
|
|
144
135
|
},
|
|
@@ -151,10 +142,9 @@ function ServerSideFilteringSelect() {
|
|
|
151
142
|
}
|
|
152
143
|
});
|
|
153
144
|
const loadFilteredDataElementsQuery = useLoadFilteredDataElementsQuery({
|
|
154
|
-
onComplete:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
} = _ref6;
|
|
145
|
+
onComplete: ({
|
|
146
|
+
result
|
|
147
|
+
}) => {
|
|
158
148
|
setFilterPager(result.pager);
|
|
159
149
|
setFilteredOptions(prevFilteredOptions => {
|
|
160
150
|
const newOptions = result.dataElements.map(dataElementToOption);
|
|
@@ -24,10 +24,9 @@ function filterOptions(options, searchTerm) {
|
|
|
24
24
|
|
|
25
25
|
// We're transform both the label and the search term to
|
|
26
26
|
// lower-case strings so the search is case-insensitive
|
|
27
|
-
return options.filter(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} = _ref;
|
|
27
|
+
return options.filter(({
|
|
28
|
+
label
|
|
29
|
+
}) => {
|
|
31
30
|
return label.toLowerCase().startsWith(searchTerm.toLowerCase());
|
|
32
31
|
});
|
|
33
32
|
}
|
|
@@ -5,12 +5,11 @@ import { dataElements as allDataElements } from './dataElements.js';
|
|
|
5
5
|
function randomBetween(min, max) {
|
|
6
6
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
7
7
|
}
|
|
8
|
-
const fakeNetworkDelay =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = _ref;
|
|
8
|
+
const fakeNetworkDelay = ({
|
|
9
|
+
pager,
|
|
10
|
+
dataElements,
|
|
11
|
+
signal
|
|
12
|
+
}) => {
|
|
14
13
|
const delay = randomBetween(750, 1550);
|
|
15
14
|
const response = {
|
|
16
15
|
dataElements
|
|
@@ -23,26 +22,23 @@ const fakeNetworkDelay = _ref => {
|
|
|
23
22
|
clearTimeout(timeout);
|
|
24
23
|
reject('Aborted');
|
|
25
24
|
};
|
|
26
|
-
signal === null || signal === void 0
|
|
25
|
+
signal === null || signal === void 0 || signal.addEventListener('abort', onAbort);
|
|
27
26
|
const timeout = setTimeout(() => {
|
|
28
|
-
signal === null || signal === void 0
|
|
27
|
+
signal === null || signal === void 0 || signal.removeEventListener('abort', onAbort);
|
|
29
28
|
resolve(response);
|
|
30
29
|
}, delay);
|
|
31
30
|
});
|
|
32
31
|
};
|
|
33
|
-
const Provider =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} = _ref2;
|
|
32
|
+
const Provider = ({
|
|
33
|
+
children
|
|
34
|
+
}) => {
|
|
37
35
|
const data = {
|
|
38
|
-
dataElements: (_,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
signal
|
|
45
|
-
} = _ref4;
|
|
36
|
+
dataElements: (_, {
|
|
37
|
+
id,
|
|
38
|
+
params = {}
|
|
39
|
+
}, {
|
|
40
|
+
signal
|
|
41
|
+
}) => {
|
|
46
42
|
if (id) {
|
|
47
43
|
const dataElement = allDataElements.find(curDE => id === curDE.id);
|
|
48
44
|
return fakeNetworkDelay({
|
|
@@ -53,12 +49,9 @@ const Provider = _ref2 => {
|
|
|
53
49
|
|
|
54
50
|
// Only this specific filter is supported by this server-mock
|
|
55
51
|
const searchTerm = params.filter ? params.filter[0].split(':')[2] : '';
|
|
56
|
-
const filteredDataElements = searchTerm ? allDataElements.filter(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} = _ref5;
|
|
60
|
-
return displayName.startsWith(searchTerm);
|
|
61
|
-
}) : allDataElements;
|
|
52
|
+
const filteredDataElements = searchTerm ? allDataElements.filter(({
|
|
53
|
+
displayName
|
|
54
|
+
}) => displayName.startsWith(searchTerm)) : allDataElements;
|
|
62
55
|
const page = params.page || 1;
|
|
63
56
|
const total = filteredDataElements.length;
|
|
64
57
|
const pageSize = params.pageSize || 50;
|
|
@@ -165,8 +165,7 @@ describe('<SimpleSingleSelect/>', () => {
|
|
|
165
165
|
cy.wait(1);
|
|
166
166
|
cy.all(() => cy.findAllByRole('option').invoke('get', 0), () => cy.findByRole('option', {
|
|
167
167
|
selected: true
|
|
168
|
-
}).invoke('get', 0)).then(
|
|
169
|
-
let [firstOption, highlightedOption] = _ref;
|
|
168
|
+
}).invoke('get', 0)).then(([firstOption, highlightedOption]) => {
|
|
170
169
|
expect(highlightedOption).to.equal(firstOption);
|
|
171
170
|
});
|
|
172
171
|
});
|
|
@@ -205,8 +204,7 @@ describe('<SimpleSingleSelect/>', () => {
|
|
|
205
204
|
cy.wait(1);
|
|
206
205
|
cy.all(() => cy.findAllByRole('option').invoke('get', 1), () => cy.findByRole('option', {
|
|
207
206
|
selected: true
|
|
208
|
-
}).invoke('get', 0)).then(
|
|
209
|
-
let [firstOption, highlightedOption] = _ref2;
|
|
207
|
+
}).invoke('get', 0)).then(([firstOption, highlightedOption]) => {
|
|
210
208
|
expect(highlightedOption).to.equal(firstOption);
|
|
211
209
|
});
|
|
212
210
|
});
|
|
@@ -229,8 +227,7 @@ describe('<SimpleSingleSelect/>', () => {
|
|
|
229
227
|
cy.wait(1);
|
|
230
228
|
cy.all(() => cy.get('[role="option"]:visible').last().invoke('get', 0), () => cy.findByRole('option', {
|
|
231
229
|
selected: true
|
|
232
|
-
}).invoke('get', 0)).then(
|
|
233
|
-
let [lastVisibleOption, highlightedOption] = _ref3;
|
|
230
|
+
}).invoke('get', 0)).then(([lastVisibleOption, highlightedOption]) => {
|
|
234
231
|
expect(highlightedOption).to.equal(lastVisibleOption);
|
|
235
232
|
});
|
|
236
233
|
});
|
|
@@ -259,15 +256,13 @@ describe('<SimpleSingleSelect/>', () => {
|
|
|
259
256
|
cy.log('**Then the first enabled option after last option on the currently displayed page is highlighted**');
|
|
260
257
|
cy.all(() => cy.findAllByRole('option').invoke('get', 19), () => cy.findByRole('option', {
|
|
261
258
|
selected: true
|
|
262
|
-
}).invoke('get', 0)).then(
|
|
263
|
-
let [eighteensOptions, highlightedOption] = _ref4;
|
|
259
|
+
}).invoke('get', 0)).then(([eighteensOptions, highlightedOption]) => {
|
|
264
260
|
expect(highlightedOption).to.equal(eighteensOptions);
|
|
265
261
|
});
|
|
266
262
|
cy.log('**And the first enabled option after last option on the currently displayed page is the first visible option**');
|
|
267
263
|
cy.all(() => cy.get('[role="option"]:visible').invoke('get', 0), () => cy.findByRole('option', {
|
|
268
264
|
selected: true
|
|
269
|
-
}).invoke('get', 0)).then(
|
|
270
|
-
let [lastVisibleOption, highlightedOption] = _ref5;
|
|
265
|
+
}).invoke('get', 0)).then(([lastVisibleOption, highlightedOption]) => {
|
|
271
266
|
expect(highlightedOption).to.equal(lastVisibleOption);
|
|
272
267
|
});
|
|
273
268
|
});
|
|
@@ -321,8 +316,7 @@ describe('<SimpleSingleSelect/>', () => {
|
|
|
321
316
|
// scrollable div
|
|
322
317
|
() => cy.findByRole('option', {
|
|
323
318
|
selected: true
|
|
324
|
-
}).invoke('parent').invoke('parent')).then(
|
|
325
|
-
let [nextTopOption, listBoxParent] = _ref6;
|
|
319
|
+
}).invoke('parent').invoke('parent')).then(([nextTopOption, listBoxParent]) => {
|
|
326
320
|
const {
|
|
327
321
|
offsetTop
|
|
328
322
|
} = nextTopOption.get(0);
|
|
@@ -383,8 +377,7 @@ describe('<SimpleSingleSelect/>', () => {
|
|
|
383
377
|
cy.wait(1);
|
|
384
378
|
cy.all(() => cy.findAllByRole('option').last().invoke('get', 0), () => cy.findByRole('option', {
|
|
385
379
|
selected: true
|
|
386
|
-
}).invoke('get', 0)).then(
|
|
387
|
-
let [lastOption, highlightedOption] = _ref7;
|
|
380
|
+
}).invoke('get', 0)).then(([lastOption, highlightedOption]) => {
|
|
388
381
|
expect(highlightedOption).to.equal(lastOption);
|
|
389
382
|
});
|
|
390
383
|
cy.log('**And the last option is visible**');
|
|
@@ -407,8 +400,7 @@ describe('<SimpleSingleSelect/>', () => {
|
|
|
407
400
|
}).should('be.visible');
|
|
408
401
|
cy.log('**And the 3rd-last option is the last option on the current page**');
|
|
409
402
|
cy.all(() => cy.findAllByRole('option').eq(89), () => cy.findByRole('listbox').invoke('parent') // scrollable div
|
|
410
|
-
).then(
|
|
411
|
-
let [nextTopOption, listBoxParent] = _ref8;
|
|
403
|
+
).then(([nextTopOption, listBoxParent]) => {
|
|
412
404
|
const {
|
|
413
405
|
offsetTop
|
|
414
406
|
} = nextTopOption.get(0);
|
|
@@ -427,8 +419,7 @@ describe('<SimpleSingleSelect/>', () => {
|
|
|
427
419
|
cy.wait(1);
|
|
428
420
|
cy.all(() => cy.findAllByRole('option').invoke('get', 98), () => cy.findByRole('option', {
|
|
429
421
|
selected: true
|
|
430
|
-
}).invoke('get', 0)).then(
|
|
431
|
-
let [secondLastOption, highlightedOption] = _ref9;
|
|
422
|
+
}).invoke('get', 0)).then(([secondLastOption, highlightedOption]) => {
|
|
432
423
|
expect(highlightedOption).to.equal(secondLastOption);
|
|
433
424
|
});
|
|
434
425
|
cy.log('**And the second last option is visible**');
|
|
@@ -7,8 +7,7 @@ describe('SimpleSingleSelect: Menu positioning', () => {
|
|
|
7
7
|
cy.findByRole('combobox').click();
|
|
8
8
|
|
|
9
9
|
// Then the top of the menu is aligned with the bottom of the input
|
|
10
|
-
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(
|
|
11
|
-
let [selectedValue, menu] = _ref;
|
|
10
|
+
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(([selectedValue, menu]) => {
|
|
12
11
|
expect(selectedValue.length).to.equal(1);
|
|
13
12
|
expect(menu.length).to.equal(1);
|
|
14
13
|
const $selectedValue = selectedValue[0];
|
|
@@ -22,8 +21,7 @@ describe('SimpleSingleSelect: Menu positioning', () => {
|
|
|
22
21
|
});
|
|
23
22
|
|
|
24
23
|
// And the left of the SingleSelect is aligned with the left of the anchor
|
|
25
|
-
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(
|
|
26
|
-
let [selectedValue, menu] = _ref2;
|
|
24
|
+
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(([selectedValue, menu]) => {
|
|
27
25
|
expect(selectedValue.length).to.equal(1);
|
|
28
26
|
expect(menu.length).to.equal(1);
|
|
29
27
|
const $selectedValue = selectedValue[0];
|
|
@@ -47,8 +45,7 @@ describe('SimpleSingleSelect: Menu positioning', () => {
|
|
|
47
45
|
cy.all(() => cy.findByRole('combobox'),
|
|
48
46
|
// We need to get the parent as the menu itself
|
|
49
47
|
// extends withing the div container
|
|
50
|
-
() => cy.findByRole('listbox').invoke('parent')).should(
|
|
51
|
-
let [selectedValue, menu] = _ref3;
|
|
48
|
+
() => cy.findByRole('listbox').invoke('parent')).should(([selectedValue, menu]) => {
|
|
52
49
|
expect(selectedValue.length).to.equal(1);
|
|
53
50
|
expect(menu.length).to.equal(1);
|
|
54
51
|
const $selectedValue = selectedValue[0];
|
|
@@ -59,8 +56,7 @@ describe('SimpleSingleSelect: Menu positioning', () => {
|
|
|
59
56
|
});
|
|
60
57
|
|
|
61
58
|
// And the left of the SingleSelect is aligned with the left of the anchor
|
|
62
|
-
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(
|
|
63
|
-
let [selectedValue, menu] = _ref4;
|
|
59
|
+
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(([selectedValue, menu]) => {
|
|
64
60
|
expect(selectedValue.length).to.equal(1);
|
|
65
61
|
expect(menu.length).to.equal(1);
|
|
66
62
|
const $selectedValue = selectedValue[0];
|
|
@@ -81,8 +77,7 @@ describe('SimpleSingleSelect: Menu positioning', () => {
|
|
|
81
77
|
cy.findByRole('combobox').click();
|
|
82
78
|
|
|
83
79
|
// Then it is rendered on top of the SingleSelect
|
|
84
|
-
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(
|
|
85
|
-
let [selectedValue, menu] = _ref5;
|
|
80
|
+
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(([selectedValue, menu]) => {
|
|
86
81
|
expect(selectedValue.length).to.equal(1);
|
|
87
82
|
expect(menu.length).to.equal(1);
|
|
88
83
|
const $selectedValue = selectedValue[0];
|
|
@@ -94,8 +89,7 @@ describe('SimpleSingleSelect: Menu positioning', () => {
|
|
|
94
89
|
});
|
|
95
90
|
|
|
96
91
|
// And the left of the SingleSelect is aligned with the left of the anchor
|
|
97
|
-
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(
|
|
98
|
-
let [selectedValue, menu] = _ref6;
|
|
92
|
+
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(([selectedValue, menu]) => {
|
|
99
93
|
expect(selectedValue.length).to.equal(1);
|
|
100
94
|
expect(menu.length).to.equal(1);
|
|
101
95
|
const $selectedValue = selectedValue[0];
|
|
@@ -118,8 +112,7 @@ describe('SimpleSingleSelect: Menu positioning', () => {
|
|
|
118
112
|
cy.scrollTo(0, 800);
|
|
119
113
|
|
|
120
114
|
// Then the top of the menu is aligned with the bottom of the input
|
|
121
|
-
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(
|
|
122
|
-
let [selectedValue, menu] = _ref7;
|
|
115
|
+
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(([selectedValue, menu]) => {
|
|
123
116
|
expect(selectedValue.length).to.equal(1);
|
|
124
117
|
expect(menu.length).to.equal(1);
|
|
125
118
|
const $selectedValue = selectedValue[0];
|
|
@@ -133,8 +126,7 @@ describe('SimpleSingleSelect: Menu positioning', () => {
|
|
|
133
126
|
});
|
|
134
127
|
|
|
135
128
|
// And the left of the SingleSelect is aligned with the left of the anchor
|
|
136
|
-
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(
|
|
137
|
-
let [selectedValue, menu] = _ref8;
|
|
129
|
+
cy.all(() => cy.findByRole('combobox'), () => cy.findByRole('listbox')).should(([selectedValue, menu]) => {
|
|
138
130
|
expect(selectedValue.length).to.equal(1);
|
|
139
131
|
expect(menu.length).to.equal(1);
|
|
140
132
|
const $selectedValue = selectedValue[0];
|
|
@@ -2,17 +2,14 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors, spacers, theme } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
const Empty =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
dynamic: [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
14
|
-
}, [`div.__jsx-style-dynamic-selector{color:${colors.grey700};font-family:${theme.fonts};font-size:13px;line-height:16px;padding-block:${spacers.dp8};padding-inline:${spacers.dp24};text-align:center;}`]));
|
|
15
|
-
};
|
|
5
|
+
const Empty = ({
|
|
6
|
+
children
|
|
7
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
8
|
+
className: _JSXStyle.dynamic([["3788156646", [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]])
|
|
9
|
+
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
10
|
+
id: "3788156646",
|
|
11
|
+
dynamic: [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
12
|
+
}, [`div.__jsx-style-dynamic-selector{color:${colors.grey700};font-family:${theme.fonts};font-size:13px;line-height:16px;padding-block:${spacers.dp8};padding-inline:${spacers.dp24};text-align:center;}`]));
|
|
16
13
|
Empty.propTypes = {
|
|
17
14
|
children: PropTypes.string.isRequired
|
|
18
15
|
};
|
|
@@ -2,17 +2,16 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import i18n from '../../locales/index.js';
|
|
5
|
-
export function Filter(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = _ref;
|
|
5
|
+
export function Filter({
|
|
6
|
+
ariaControls,
|
|
7
|
+
dataTest,
|
|
8
|
+
inputRef,
|
|
9
|
+
label,
|
|
10
|
+
placeholder,
|
|
11
|
+
value,
|
|
12
|
+
onChange,
|
|
13
|
+
onKeyDown
|
|
14
|
+
}) {
|
|
16
15
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
17
16
|
ref: inputRef,
|
|
18
17
|
type: "text",
|
|
@@ -27,7 +26,7 @@ export function Filter(_ref) {
|
|
|
27
26
|
onClick: e => e.stopPropagation(),
|
|
28
27
|
onKeyDown: e => {
|
|
29
28
|
e.stopPropagation();
|
|
30
|
-
onKeyDown === null || onKeyDown === void 0
|
|
29
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(e);
|
|
31
30
|
},
|
|
32
31
|
className: "jsx-1122123784" + " " + "filter-input"
|
|
33
32
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
@@ -3,10 +3,9 @@ import { colors, spacers, theme } from '@dhis2/ui-constants';
|
|
|
3
3
|
import { CircularLoader } from '@dhis2-ui/loader';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
export function Loading(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
6
|
+
export function Loading({
|
|
7
|
+
message
|
|
8
|
+
}) {
|
|
10
9
|
return /*#__PURE__*/React.createElement("div", {
|
|
11
10
|
className: _JSXStyle.dynamic([["316664301", [spacers.dp16, colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]]) + " " + "container"
|
|
12
11
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -9,32 +9,31 @@ import { Empty } from './empty.js';
|
|
|
9
9
|
import { Loading } from './loading.js';
|
|
10
10
|
import { NoMatch } from './no-match.js';
|
|
11
11
|
import { OptionsList } from './options-list.js';
|
|
12
|
-
export function Menu(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} = _ref;
|
|
12
|
+
export function Menu({
|
|
13
|
+
comboBoxId,
|
|
14
|
+
focussedOptionIndex,
|
|
15
|
+
name,
|
|
16
|
+
options,
|
|
17
|
+
onChange,
|
|
18
|
+
optionComponent,
|
|
19
|
+
dataTest,
|
|
20
|
+
disabled,
|
|
21
|
+
empty,
|
|
22
|
+
filterValue,
|
|
23
|
+
hidden,
|
|
24
|
+
labelledBy,
|
|
25
|
+
listBoxRef,
|
|
26
|
+
loading,
|
|
27
|
+
loadingText,
|
|
28
|
+
maxHeight,
|
|
29
|
+
noMatchText,
|
|
30
|
+
optionUpdateStrategy,
|
|
31
|
+
selectRef,
|
|
32
|
+
selectedValue,
|
|
33
|
+
onBlur,
|
|
34
|
+
onClose,
|
|
35
|
+
onEndReached
|
|
36
|
+
}) {
|
|
38
37
|
const [menuWidth, setWidth] = useState('auto');
|
|
39
38
|
const dataTestPrefix = `${dataTest}-menu`;
|
|
40
39
|
useEffect(() => {
|
|
@@ -2,18 +2,15 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors, spacers, theme } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
const NoMatch =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
dynamic: [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
15
|
-
}, [`div.__jsx-style-dynamic-selector{color:${colors.grey700};font-family:${theme.fonts};font-size:13px;line-height:16px;padding-block:${spacers.dp8};padding-inline:${spacers.dp24};text-align:center;}`]));
|
|
16
|
-
};
|
|
5
|
+
const NoMatch = ({
|
|
6
|
+
children,
|
|
7
|
+
className
|
|
8
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
className: _JSXStyle.dynamic([["3788156646", [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]]]) + " " + (className || "")
|
|
10
|
+
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
11
|
+
id: "3788156646",
|
|
12
|
+
dynamic: [colors.grey700, theme.fonts, spacers.dp8, spacers.dp24]
|
|
13
|
+
}, [`div.__jsx-style-dynamic-selector{color:${colors.grey700};font-family:${theme.fonts};font-size:13px;line-height:16px;padding-block:${spacers.dp8};padding-inline:${spacers.dp24};text-align:center;}`]));
|
|
17
14
|
NoMatch.propTypes = {
|
|
18
15
|
children: PropTypes.string.isRequired,
|
|
19
16
|
className: PropTypes.string
|
|
@@ -5,12 +5,11 @@ import cx from 'classnames';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React, { useEffect, useRef } from 'react';
|
|
7
7
|
const VISIBILE_INTERSECTION_RATIO = 0.99;
|
|
8
|
-
function DefaultStyle(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = _ref;
|
|
8
|
+
function DefaultStyle({
|
|
9
|
+
label,
|
|
10
|
+
disabled,
|
|
11
|
+
highlighted
|
|
12
|
+
}) {
|
|
14
13
|
return /*#__PURE__*/React.createElement("span", {
|
|
15
14
|
className: _JSXStyle.dynamic([["4038065645", [colors.grey900, spacers.dp8, spacers.dp12, spacers.dp16, colors.grey200, colors.teal700, colors.white, colors.grey500]]]) + " " + (cx('option', {
|
|
16
15
|
disabled,
|
|
@@ -26,21 +25,20 @@ DefaultStyle.propTypes = {
|
|
|
26
25
|
disabled: PropTypes.bool,
|
|
27
26
|
highlighted: PropTypes.bool
|
|
28
27
|
};
|
|
29
|
-
export function Option(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} = _ref2;
|
|
28
|
+
export function Option({
|
|
29
|
+
comboBoxId,
|
|
30
|
+
index,
|
|
31
|
+
label,
|
|
32
|
+
value,
|
|
33
|
+
onClick,
|
|
34
|
+
component: StyleComponent = DefaultStyle,
|
|
35
|
+
dataTest,
|
|
36
|
+
disabled,
|
|
37
|
+
highlighted,
|
|
38
|
+
listBoxRef,
|
|
39
|
+
onBecameVisible,
|
|
40
|
+
...rest
|
|
41
|
+
}) {
|
|
44
42
|
const buttonRef = useRef();
|
|
45
43
|
useEffect(() => {
|
|
46
44
|
if (onBecameVisible) {
|
|
@@ -3,23 +3,22 @@ import React, { forwardRef, useEffect } from 'react';
|
|
|
3
3
|
import { isOptionHidden } from '../is-option-hidden.js';
|
|
4
4
|
import { optionProp } from '../shared-prop-types.js';
|
|
5
5
|
import { Option } from './option.js';
|
|
6
|
-
export const OptionsList = /*#__PURE__*/forwardRef(function OptionsList(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} = _ref;
|
|
6
|
+
export const OptionsList = /*#__PURE__*/forwardRef(function OptionsList({
|
|
7
|
+
comboBoxId,
|
|
8
|
+
optionComponent,
|
|
9
|
+
focussedOptionIndex,
|
|
10
|
+
id,
|
|
11
|
+
labelledBy,
|
|
12
|
+
optionUpdateStrategy,
|
|
13
|
+
options,
|
|
14
|
+
selectedValue,
|
|
15
|
+
dataTest,
|
|
16
|
+
disabled,
|
|
17
|
+
loading,
|
|
18
|
+
onChange,
|
|
19
|
+
onBlur,
|
|
20
|
+
onEndReached
|
|
21
|
+
}, ref) {
|
|
23
22
|
// scrolls the highlighted option into view when:
|
|
24
23
|
// * the highlighted option changes
|
|
25
24
|
// * the menu opens
|
|
@@ -45,13 +44,12 @@ export const OptionsList = /*#__PURE__*/forwardRef(function OptionsList(_ref, re
|
|
|
45
44
|
"aria-busy": loading.toString(),
|
|
46
45
|
"data-test": dataTest,
|
|
47
46
|
onBlur: onBlur
|
|
48
|
-
}, options.map((
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} = _ref2;
|
|
47
|
+
}, options.map(({
|
|
48
|
+
value,
|
|
49
|
+
label,
|
|
50
|
+
component,
|
|
51
|
+
disabled: optionDisabled = false
|
|
52
|
+
}, index) => {
|
|
55
53
|
const isSelected = value === selectedValue;
|
|
56
54
|
const isLast = index === options.length - 1;
|
|
57
55
|
return /*#__PURE__*/React.createElement(Option, {
|
|
@@ -3,12 +3,11 @@ import { colors, theme } from '@dhis2/ui-constants';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import i18n from '../../locales/index.js';
|
|
6
|
-
function ClearButton(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} = _ref;
|
|
6
|
+
function ClearButton({
|
|
7
|
+
onClear,
|
|
8
|
+
clearText,
|
|
9
|
+
dataTest
|
|
10
|
+
}) {
|
|
12
11
|
return /*#__PURE__*/React.createElement("button", {
|
|
13
12
|
"aria-label": i18n.t('{{clearText}}', {
|
|
14
13
|
clearText
|