import * as React from "react"; import { attributeChanged } from "../../../../../actions"; import { SyntheticElement, PCComponent, PCElement, PCComponentInstanceElement, getNativeComponentName, DependencyGraph } from "paperclip"; import { Dispatch } from "redux"; import { BaseInputPropertiesProps } from "./input.pc"; import { dropdownMenuOptionFromValue } from "../../../../inputs/dropdown/controller"; export type Props = { baseName: string; dispatch: Dispatch; sourceNode: PCComponent | PCElement | PCComponentInstanceElement; graph: DependencyGraph; }; const INPUT_TYPE_OPTIONS = [ "color", "date", "file", "datetime-local", "email", "month", "number", "range", "search", "tel", "time", "url", "week", "checkbox" ] .map(dropdownMenuOptionFromValue) .sort((a, b) => { return a < b ? -1 : 1; }); export default (Base: React.ComponentClass) => class InputController extends React.PureComponent { onPlaceholderChange = value => { this.props.dispatch(attributeChanged("placeholder", value)); }; onInputTypeChange = value => { this.props.dispatch(attributeChanged("type", value)); }; render() { const { baseName, sourceNode, graph } = this.props; if (baseName !== "input") { return null; } const { onPlaceholderChange, onInputTypeChange } = this; return ( ); } };