ohctechv3/.svn/pristine/c7/c7d09351422b0b21970a77bc75d38b17cee58436.svn-base
2024-10-28 15:03:36 +05:30

26 lines
939 B
Plaintext

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
});
}
var newState = listReducer(state, action);
var selectionFollowsFocus = action.context.selectionFollowsFocus;
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;
}