{"ast":null,"code":"import React from 'react';\n\nvar isCheckBoxInput = element => element.type === 'checkbox';\n\nvar isDateObject = value => value instanceof Date;\n\nvar isNullOrUndefined = value => value == null;\n\nconst isObjectType = value => typeof value === 'object';\n\nvar isObject = value => !isNullOrUndefined(value) && !Array.isArray(value) && isObjectType(value) && !isDateObject(value);\n\nvar getEventValue = event => isObject(event) && event.target ? isCheckBoxInput(event.target) ? event.target.checked : event.target.value : event;\n\nvar getNodeParentName = name => name.substring(0, name.search(/\\.\\d+(\\.|$)/)) || name;\n\nvar isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));\n\nvar compact = value => Array.isArray(value) ? value.filter(Boolean) : [];\n\nvar isUndefined = val => val === undefined;\n\nvar get = (obj, path, defaultValue) => {\n if (!path || !isObject(obj)) {\n return defaultValue;\n }\n\n const result = compact(path.split(/[,[\\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], obj);\n return isUndefined(result) || result === obj ? isUndefined(obj[path]) ? defaultValue : obj[path] : result;\n};\n\nconst EVENTS = {\n BLUR: 'blur',\n FOCUS_OUT: 'focusout',\n CHANGE: 'change'\n};\nconst VALIDATION_MODE = {\n onBlur: 'onBlur',\n onChange: 'onChange',\n onSubmit: 'onSubmit',\n onTouched: 'onTouched',\n all: 'all'\n};\nconst INPUT_VALIDATION_RULES = {\n max: 'max',\n min: 'min',\n maxLength: 'maxLength',\n minLength: 'minLength',\n pattern: 'pattern',\n required: 'required',\n validate: 'validate'\n};\nconst HookFormContext = React.createContext(null);\n/**\r\n * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.\r\n *\r\n * @remarks\r\n * [API](https://react-hook-form.com/api/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\r\n *\r\n * @returns return all useForm methods\r\n *\r\n * @example\r\n * ```tsx\r\n * function App() {\r\n * const methods = useForm();\r\n * const onSubmit = data => console.log(data);\r\n *\r\n * return (\r\n *
{fieldState.isTouched && \"Touched\"}
\r\n *{formState.isSubmitted ? \"submitted\" : \"\"}
\r\n *{fieldState.isTouched && \"Touched\"}
\n *{formState.isSubmitted ? \"submitted\" : \"\"}
\n *