2018-02-12 10:25:02 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
* @flow
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
|
import YogaEnumSelect from './YogaEnumSelect';
|
|
|
|
import YogaPositionEditor from './YogaPositionEditor';
|
|
|
|
import {Input} from 'antd';
|
|
|
|
|
2018-02-13 06:13:29 -08:00
|
|
|
type Props<T> = {
|
2018-02-12 10:25:02 -08:00
|
|
|
property: string,
|
|
|
|
disabled?: boolean,
|
2018-02-13 06:13:29 -08:00
|
|
|
value?: ?T,
|
|
|
|
onChange: (property: string, value: T) => void,
|
2018-02-12 10:25:02 -08:00
|
|
|
};
|
|
|
|
|
2018-02-13 06:13:29 -08:00
|
|
|
export default (props: Props<*>) => {
|
2018-02-12 10:25:02 -08:00
|
|
|
if (YogaEnumSelect.availableProperties.indexOf(props.property) > -1) {
|
|
|
|
return <YogaEnumSelect {...props} />;
|
|
|
|
} else if (
|
|
|
|
YogaPositionEditor.availableProperties.indexOf(props.property) > -1
|
|
|
|
) {
|
|
|
|
return <YogaPositionEditor {...props} />;
|
|
|
|
} else {
|
2018-02-13 06:13:29 -08:00
|
|
|
return (
|
|
|
|
<Input
|
|
|
|
type="text"
|
|
|
|
{...props}
|
|
|
|
onChange={e => props.onChange(props.property, e.target.value)}
|
2018-02-16 05:47:31 -08:00
|
|
|
placeholder="undefined"
|
|
|
|
value={Number.isNaN(props.value) ? '' : props.value}
|
2018-02-13 06:13:29 -08:00
|
|
|
/>
|
|
|
|
);
|
2018-02-12 10:25:02 -08:00
|
|
|
}
|
|
|
|
};
|