pre-installations and preparations
This commit is contained in:
1 parent
3e5a0329cb
commit
201d621ac3
6977 files changed
+742826
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import { listReducer, ListActionTypes, moveHighlight } from '../useList';
|
||||
import { TabsListActionTypes } from './useTabsList.types';
|
||||
export function tabsListReducer(state, action) {
|
||||
if (action.type === TabsListActionTypes.valueChange) {
|
||||
return _extends({}, state, {
|
||||
highlightedValue: action.value
|
||||
});
|
||||
}
|
||||
const newState = listReducer(state, action);
|
||||
const {
|
||||
context: {
|
||||
selectionFollowsFocus
|
||||
}
|
||||
} = action;
|
||||
if (action.type === ListActionTypes.itemsChange) {
|
||||
if (newState.selectedValues.length > 0) {
|
||||
return _extends({}, newState, {
|
||||
highlightedValue: newState.selectedValues[0]
|
||||
});
|
||||
}
|
||||
moveHighlight(null, 'reset', action.context);
|
||||
}
|
||||
if (selectionFollowsFocus && newState.highlightedValue != null) {
|
||||
return _extends({}, newState, {
|
||||
selectedValues: [newState.highlightedValue]
|
||||
});
|
||||
}
|
||||
return newState;
|
||||
}
|
||||
Reference in new issue
Block a user