import React from 'react' import Immutable from 'immutable' import color from 'color' import GlSpec from 'mapbox-gl-style-spec/reference/latest.min.js' import NumberField from './number' import EnumField from './enum' import BooleanField from './boolean' import ColorField from './color' import StringField from './string' import inputStyle from './input.js' import theme from '../theme.js' function isZoomField(value) { return Immutable.Map.isMap(value) } const specFieldProps = { onChange: React.PropTypes.func.isRequired, fieldName: React.PropTypes.string.isRequired, fieldSpec: React.PropTypes.object.isRequired, } /** Supports displaying spec field for zoom function objects * https://www.mapbox.com/mapbox-gl-style-spec/#types-function-zoom-property */ export class ZoomSpecField extends React.Component { static propTypes = { ...specFieldProps, value: React.PropTypes.oneOfType([ React.PropTypes.object, React.PropTypes.string, React.PropTypes.number, React.PropTypes.bool, ]), } render() { const label = if(isZoomField(this.props.value)) { const zoomFields = this.props.value.get('stops').map(stop => { const zoomLevel = stop.get(0) const value = stop.get(1) return