PromoCursed/node_modules/.cache/babel-loader/ac0cf1b62ffb72e11835e3b59c36d617a0057c503e2cbb2e6d5fd42e615aac1c.json

1 line
8.8 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport { isValidElement, version } from 'react';\nimport { ForwardRef, isFragment, isMemo } from 'react-is';\nimport useMemo from \"./hooks/useMemo\";\nexport var fillRef = function fillRef(ref, node) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (_typeof(ref) === 'object' && ref && 'current' in ref) {\n ref.current = node;\n }\n};\n\n/**\n * Merge refs into one ref function to support ref passing.\n */\nexport var composeRef = function composeRef() {\n for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {\n refs[_key] = arguments[_key];\n }\n var refList = refs.filter(Boolean);\n if (refList.length <= 1) {\n return refList[0];\n }\n return function (node) {\n refs.forEach(function (ref) {\n fillRef(ref, node);\n });\n };\n};\nexport var useComposeRef = function useComposeRef() {\n for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n refs[_key2] = arguments[_key2];\n }\n return useMemo(function () {\n return composeRef.apply(void 0, refs);\n }, refs, function (prev, next) {\n return prev.length !== next.length || prev.every(function (ref, i) {\n return ref !== next[i];\n });\n });\n};\nexport var supportRef = function supportRef(nodeOrComponent) {\n var _type$prototype, _nodeOrComponent$prot;\n var type = isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type;\n\n // Function component node\n if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render) && type.$$typeof !== ForwardRef) {\n return false;\n }\n\n // Class component\n if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render) && nodeOrComponent.$$typeof !== ForwardRef) {\n return false;\n }\n return true;\n};\nfunction isReactElement(node) {\n return /*#__PURE__*/isValidElement(node) && !isFragment(node);\n}\nexport var supportNodeRef = function supportNodeRef(node) {\n return isReactElement(node) && supportRef(node);\n};\n\n/**\n * In React 19. `ref` is not a property from node.\n * But a property from `props.ref`.\n * To check if `props.ref` exist or fallback to `ref`.\n */\nexport var getNodeRef = Number(version.split('.')[0]) >= 19 ?\n// >= React 19\nfunction (node) {\n if (isReactElement(node)) {\n return node.props.ref;\n }\n return null;\n} :\n// < React 19\nfunction (node) {\n if (isReactElement(node)) {\n return node.ref;\n }\n return null;\n};","map":{"version":3,"names":["_typeof","isValidElement","version","ForwardRef","isFragment","isMemo","useMemo","fillRef","ref","node","current","composeRef","_len","arguments","length","refs","Array","_key","refList","filter","Boolean","forEach","useComposeRef","_len2","_key2","apply","prev","next","every","i","supportRef","nodeOrComponent","_type$prototype","_nodeOrComponent$prot","type","prototype","render","$$typeof","isReactElement","supportNodeRef","getNodeRef","Number","split","props"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-util/es/ref.js"],"sourcesContent":["import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport { isValidElement, version } from 'react';\nimport { ForwardRef, isFragment, isMemo } from 'react-is';\nimport useMemo from \"./hooks/useMemo\";\nexport var fillRef = function fillRef(ref, node) {\n if (typeof ref === 'function') {\n ref(node);\n } else if (_typeof(ref) === 'object' && ref && 'current' in ref) {\n ref.current = node;\n }\n};\n\n/**\n * Merge refs into one ref function to support ref passing.\n */\nexport var composeRef = function composeRef() {\n for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {\n refs[_key] = arguments[_key];\n }\n var refList = refs.filter(Boolean);\n if (refList.length <= 1) {\n re