// @flow
import { createContext, useContext } from 'react';

type SelectorContextContents = {|
  name: string,
  onChange: (SyntheticInputEvent<HTMLElement>) => void,
  managedValue?: string | number | string[],
  stateful?: boolean,
  type: 'radio' | 'checkbox',
|};

const SelectorContext = createContext<SelectorContextContents>({
  stateful: false,
  type: 'radio',
  name: '',
  onChange: () => {},
});

export const SelectorContextProvider = SelectorContext.Provider;

export const useSelectorContext = () => useContext(SelectorContext);
