{"ast":null,"code":"import * as React from 'react';\nimport { useForm as useRcForm } from 'rc-field-form';\nimport scrollIntoView from 'scroll-into-view-if-needed';\nimport { getFieldId, toArray } from '../util';\nfunction toNamePathStr(name) {\n  const namePath = toArray(name);\n  return namePath.join('_');\n}\nexport default function useForm(form) {\n  const [rcForm] = useRcForm();\n  const itemsRef = React.useRef({});\n  const wrapForm = React.useMemo(() => form !== null && form !== void 0 ? form : Object.assign(Object.assign({}, rcForm), {\n    __INTERNAL__: {\n      itemRef: name => node => {\n        const namePathStr = toNamePathStr(name);\n        if (node) {\n          itemsRef.current[namePathStr] = node;\n        } else {\n          delete itemsRef.current[namePathStr];\n        }\n      }\n    },\n    scrollToField: function (name) {\n      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      const namePath = toArray(name);\n      const fieldId = getFieldId(namePath, wrapForm.__INTERNAL__.name);\n      const node = fieldId ? document.getElementById(fieldId) : null;\n      if (node) {\n        scrollIntoView(node, Object.assign({\n          scrollMode: 'if-needed',\n          block: 'nearest'\n        }, options));\n      }\n    },\n    getFieldInstance: name => {\n      const namePathStr = toNamePathStr(name);\n      return itemsRef.current[namePathStr];\n    }\n  }), [form, rcForm]);\n  return [wrapForm];\n}","map":{"version":3,"names":["React","useForm","useRcForm","scrollIntoView","getFieldId","toArray","toNamePathStr","name","namePath","join","form","rcForm","itemsRef","useRef","wrapForm","useMemo","Object","assign","__INTERNAL__","itemRef","node","namePathStr","current","scrollToField","options","arguments","length","undefined","fieldId","document","getElementById","scrollMode","block","getFieldInstance"],"sources":["/var/www/gavt/node_modules/antd/es/form/hooks/useForm.js"],"sourcesContent":["import * as React from 'react';\nimport { useForm as useRcForm } from 'rc-field-form';\nimport scrollIntoView from 'scroll-into-view-if-needed';\nimport { getFieldId, toArray } from '../util';\nfunction toNamePathStr(name) {\n  const namePath = toArray(name);\n  return namePath.join('_');\n}\nexport default function useForm(form) {\n  const [rcForm] = useRcForm();\n  const itemsRef = React.useRef({});\n  const wrapForm = React.useMemo(() => form !== null && form !== void 0 ? form : Object.assign(Object.assign({}, rcForm), {\n    __INTERNAL__: {\n      itemRef: name => node => {\n        const namePathStr = toNamePathStr(name);\n        if (node) {\n          itemsRef.current[namePathStr] = node;\n        } else {\n          delete itemsRef.current[namePathStr];\n        }\n      }\n    },\n    scrollToField: function (name) {\n      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      const namePath = toArray(name);\n      const fieldId = getFieldId(namePath, wrapForm.__INTERNAL__.name);\n      const node = fieldId ? document.getElementById(fieldId) : null;\n      if (node) {\n        scrollIntoView(node, Object.assign({\n          scrollMode: 'if-needed',\n          block: 'nearest'\n        }, options));\n      }\n    },\n    getFieldInstance: name => {\n      const namePathStr = toNamePathStr(name);\n      return itemsRef.current[namePathStr];\n    }\n  }), [form, rcForm]);\n  return [wrapForm];\n}"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,OAAO,IAAIC,SAAS,QAAQ,eAAe;AACpD,OAAOC,cAAc,MAAM,4BAA4B;AACvD,SAASC,UAAU,EAAEC,OAAO,QAAQ,SAAS;AAC7C,SAASC,aAAaA,CAACC,IAAI,EAAE;EAC3B,MAAMC,QAAQ,GAAGH,OAAO,CAACE,IAAI,CAAC;EAC9B,OAAOC,QAAQ,CAACC,IAAI,CAAC,GAAG,CAAC;AAC3B;AACA,eAAe,SAASR,OAAOA,CAACS,IAAI,EAAE;EACpC,MAAM,CAACC,MAAM,CAAC,GAAGT,SAAS,CAAC,CAAC;EAC5B,MAAMU,QAAQ,GAAGZ,KAAK,CAACa,MAAM,CAAC,CAAC,CAAC,CAAC;EACjC,MAAMC,QAAQ,GAAGd,KAAK,CAACe,OAAO,CAAC,MAAML,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAK,KAAK,CAAC,GAAGA,IAAI,GAAGM,MAAM,CAACC,MAAM,CAACD,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEN,MAAM,CAAC,EAAE;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