// @flow
import PropTypes from 'prop-types';
import { range } from 'lodash';

import {
  numColsSm,
  numColsMd,
  numColsLg,
  numColsXl,
} from './grid-item.constants';

type BaseColumnNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;

type SmallColumnNumbers = BaseColumnNumbers;
type MediumColumnNumbers = BaseColumnNumbers;
type LargeColumnNumbers = BaseColumnNumbers;
type ExtraLargeColumnNumbers = BaseColumnNumbers;

export type GridItemProps = {
  sm: 'hide' | SmallColumnNumbers,
  md?: 'hide' | MediumColumnNumbers,
  lg?: 'hide' | LargeColumnNumbers,
  xl?: 'hide' | BaseColumnNumbers,
  offsetSm?: SmallColumnNumbers,
  offsetMd?: MediumColumnNumbers,
  offsetLg?: LargeColumnNumbers,
  offsetXl?: ExtraLargeColumnNumbers,
};

export const gridItemPropTypes = {
  sm: PropTypes.oneOf(['hide', ...range(1, numColsSm + 1)]).isRequired,
  md: PropTypes.oneOf(['hide', ...range(1, numColsMd + 1)]),
  lg: PropTypes.oneOf(['hide', ...range(1, numColsLg + 1)]),
  xl: PropTypes.oneOf(['hide', ...range(1, numColsXl + 1)]),
  offsetSm: PropTypes.oneOf(range(1, numColsSm + 1)),
  offsetMd: PropTypes.oneOf(range(1, numColsMd + 1)),
  offsetLg: PropTypes.oneOf(range(1, numColsLg + 1)),
  offsetXl: PropTypes.oneOf(range(1, numColsXl + 1)),
};
