/* @flow */ import React, { forwardRef } 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, 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, className, data = {}, disabled = false, error, label, multiple = false, name, onChange = () => {}, options = [], required = false, value, ...props }: SelectProps, ref: React.ElementRef<"select">) => { const ariaProps = buildAriaProps(aria) const dataProps = buildDataProps(data) const optionsList = createOptions(options) const classes = classnames(buildCss('pb_select'), globalProps(props), className) const selectWrapperClass = classnames(buildCss('pb_select_kit_wrapper'), { error }, className) return (
) } export default forwardRef(Select)