1 line
5.8 KiB
JSON
1 line
5.8 KiB
JSON
{"ast":null,"code":"import * as React from 'react';\nimport { useForm as useRcForm } from 'rc-field-form';\nimport { getDOM } from \"rc-util/es/Dom/findDOMNode\";\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}\nfunction getFieldDOMNode(name, wrapForm) {\n const field = wrapForm.getFieldInstance(name);\n const fieldDom = getDOM(field);\n if (fieldDom) {\n return fieldDom;\n }\n const fieldId = getFieldId(toArray(name), wrapForm.__INTERNAL__.name);\n if (fieldId) {\n return document.getElementById(fieldId);\n }\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 node = getFieldDOMNode(name, wrapForm);\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","getDOM","scrollIntoView","getFieldId","toArray","toNamePathStr","name","namePath","join","getFieldDOMNode","wrapForm","field","getFieldInstance","fieldDom","fieldId","__INTERNAL__","document","getElementById","form","rcForm","itemsRef","useRef","useMemo","Object","assign","itemRef","node","namePathStr","current","scrollToField","options","arguments","length","undefined","scrollMode","block"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/form/hooks/useForm.js"],"sourcesContent":["import * as React from 'react';\nimport { useForm as useRcForm } from 'rc-field-form';\nimport { getDOM } from \"rc-util/es/Dom/findDOMNode\";\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}\nfunction getFieldDOMNode(name, wrapForm) {\n const field = wrapForm.getFieldInstance(name);\n const fieldDom = getDOM(field);\n if (fieldDom) {\n return fieldDom;\n }\n const fieldId = getFieldId(toArray(name), wrapForm.__INTERNAL__.name);\n if (fieldId) {\n return document.getElementById(fieldId);\n }\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 node = getFieldDOMNode(name, wrapForm);\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,SAASC,MAAM,QAAQ,4BAA4B;AACnD,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,SAASC,eAAeA,CAACH,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