UNPKG

@mskcc/carbon-react

Version:

Carbon react components for the MSKCC DSM

35 lines (31 loc) 702 B
/** * MSKCC 2021, 2024 */ import React__default from 'react'; const menuDefaultState = { isRoot: true, hasIcons: false, size: null, items: [], requestCloseRoot: () => {} }; function menuReducer(state, action) { switch (action.type) { case 'enableIcons': return { ...state, hasIcons: true }; case 'registerItem': return { ...state, items: [...state.items, action.payload].filter(item => item.ref.current !== null) }; } } const MenuContext = /*#__PURE__*/React__default.createContext({ state: menuDefaultState, // 'dispatch' is populated by the root menu dispatch: () => {} }); export { MenuContext, menuReducer };