UNPKG

react-browser-form

Version:

<div align="center"> <a href="https://deniskabana.github.io/react-browser-form/introduction" title="React Browser Form - Form management in React made simple for browsers."> <img src="https://raw.githubusercontent.com/deniskabana/react-browser-form/

18 lines (13 loc) 595 B
import { DataFlowState } from "../types"; import { transformValueType } from "./transformValueType"; export function getDomInputValue<Schema>(dataFlowState: DataFlowState<Schema>): any { const targetInput = dataFlowState.event.nativeEvent?.target as HTMLInputElement; if (!targetInput || !targetInput.name) { return; } if (!(dataFlowState.fieldsData.names as any)[targetInput.name]) { return; } const value = targetInput.type === "checkbox" ? targetInput.checked : targetInput.value; return transformValueType(targetInput.name as keyof Schema, value, dataFlowState); }