import React, { useState } from 'react'
import PropTypes from 'prop-types'
import FormFieldList from '../../.form/FormFieldList'
import OptionPreamble from '../OptionPreamble'
const PatternOptionList = props => {
const [value, setValue] = useState(props.dflt)
const [expanded, setExpanded] = useState(false)
const update = (name, newValue, evt) => {
props.updateValue(props.name, newValue)
setValue(newValue)
}
const reset = () => {
setValue(props.dflt)
props.updateValue(props.name, props.dflt)
}
const patternReset = () => {
setValue(props.patternDflt)
props.updateValue(props.name, props.patternDflt)
}
const toggleExpanded = () => setExpanded(!expanded)
// Add translations
let stringKey = `options.${props.pattern}.${props.name}.options.`
let list = {}
for (let item of props.list)
list[item] = props.intl.formatMessage({
id: stringKey + item,
defaultMessage: item
})
let option = (