PromoCursed/node_modules/.cache/babel-loader/9aaed674feae22f6f20eb2fe2a7f4aaa366e0075b075daf3640c6dcfcd5f2069.json

1 line
5.8 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"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,SA