// @flow
import PropTypes from 'prop-types';
import type { Element } from 'react';

export type ExpanderProps = {
  headingComponent: Element<*>,
  headingComponentOpen?: Element<*>,
  children: string | Element<*> | Array<Element<*>>,
  isOpen?: boolean,
  onToggle?: (isOpen: boolean) => void,
  buttonStyles?: ?{ [string]: string },
};

export const expanderPropTypes = {
  headingComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
    .isRequired,
  headingComponentOpen: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.element,
  ]),
  children: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
    .isRequired,
  buttonStyles: PropTypes.shape({}),
  onToggle: PropTypes.func,
};

export type ExpanderContextType = {
  toggleExpander: () => void,
};

export const expanderContextTypes = {
  toggleExpander: PropTypes.func,
};
