@hitachivantara/uikit-react-core
Version:
Core React components for the NEXT Design System.
25 lines (24 loc) • 857 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const reducer = (state, action) => {
switch (action.type) {
case "setItemFocused":
return { itemFocused: action.itemFocused };
default:
return state;
}
};
const initialState = { itemFocused: void 0, dispatch: void 0 };
const FocusContext = React.createContext(initialState);
const FocusProvider = ({ children }) => {
const [state, dispatch] = React.useReducer(reducer, initialState);
const contextValue = React.useMemo(
() => ({ ...state, dispatch }),
[state, dispatch]
);
return /* @__PURE__ */ jsxRuntime.jsx(FocusContext.Provider, { value: contextValue, children });
};
exports.FocusContext = FocusContext;
exports.FocusProvider = FocusProvider;