/* @flow */ import React from 'react' import classnames from 'classnames' import { Body, Caption, Icon, } from '../' import { buildAriaProps, buildCss, buildDataProps, } from '../utilities/props' import { globalProps } from '../utilities/globalProps.js' import type { InputCallback } from '../types' type SelectOption = { value: string, text: string, disabled?: boolean, } type SelectProps = { aria?: object, blankSelection?: string, children?: React.Node, className?: string, dark?: boolean, data?: object, disabled?: boolean, error?: string, onChange: InputCallback, options: SelectOption[], id?: string, includeBlank?: string, label?: string, multiple?: boolean, name?: string, required?: boolean, value?: string, } const createOptions = (options: SelectOption[]) => options.map((option, index) => ( )) const Select = ({ aria = {}, blankSelection, children, dark = false, data = {}, disabled = false, error, label, multiple = false, name, onChange = () => {}, options = [], required = false, value, ...props }: SelectProps) => { const errorClass = error ? ' error' : '' const css = classnames(buildCss('pb_select', { dark }) + errorClass, globalProps(props)) const ariaProps = buildAriaProps(aria) const dataProps = buildDataProps(data) const optionsList = createOptions(options) return (
) } export default Select