import React from "react"; import * as R from "ramda"; import { compose, withHandlers } from "recompose"; const OnlyLabelName = ({ labelName }: { labelName?: string }) => ( ); const RequiredLabelName = ({ labelName, requiredFieldText }: { labelName?: string; requiredFieldText?: string; }) => ( ); export type InputProps = { value: number | string; update: any; inputClassName?: string; id?: string; labelName?: string; disabled?: boolean; readOnly?: boolean; autoComplete?: string; requiredFieldText?: string; step?: string; placeholder?: string; max?: number; min?: number; }; export type OutputProps = InputProps & { change: any; }; const NumericInput = ({ value, change, inputClassName = "", id = "arkNumberInput", labelName = "", readOnly = false, disabled = false, autoComplete = "on", step = "1", min, max, requiredFieldText = "", placeholder = "" }: OutputProps) => (
{!R.isEmpty(labelName) && R.isEmpty(requiredFieldText) ? ( ) : null} {!R.isEmpty(labelName) && !R.isEmpty(requiredFieldText) ? ( ) : null}
); export default compose( withHandlers({ change: ({ update, max, min }: { update: any; max?: number; min?: number; }) => (e: any) => { const val = e.target.value; if (min !== undefined || max !== undefined) { const minTest = min !== undefined && parseFloat(val) < min; const maxTest = max !== undefined && parseFloat(val) > max; debugger; return R.any(R.equals(true))([minTest, maxTest]) ? update("") : update(val); } return update(val); } }) )(NumericInput);