1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import { listReducer, ListActionTypes, moveHighlight } from '../useList';
|
3 | import { TabsListActionTypes } from './useTabsList.types';
|
4 | export default function tabsListReducer(state, action) {
|
5 | if (action.type === TabsListActionTypes.valueChange) {
|
6 | return _extends({}, state, {
|
7 | highlightedValue: action.value
|
8 | });
|
9 | }
|
10 | var newState = listReducer(state, action);
|
11 | var selectionFollowsFocus = action.context.selectionFollowsFocus;
|
12 | if (action.type === ListActionTypes.itemsChange) {
|
13 | if (newState.selectedValues.length > 0) {
|
14 | return _extends({}, newState, {
|
15 | highlightedValue: newState.selectedValues[0]
|
16 | });
|
17 | }
|
18 | moveHighlight(null, 'reset', action.context);
|
19 | }
|
20 | if (selectionFollowsFocus && newState.highlightedValue != null) {
|
21 | return _extends({}, newState, {
|
22 | selectedValues: [newState.highlightedValue]
|
23 | });
|
24 | }
|
25 | return newState;
|
26 | } |
\ | No newline at end of file |