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

1 line
8.3 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport isVisible from \"./isVisible\";\nfunction focusable(node) {\n var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (isVisible(node)) {\n var nodeName = node.nodeName.toLowerCase();\n var isFocusableElement =\n // Focusable element\n ['input', 'select', 'textarea', 'button'].includes(nodeName) ||\n // Editable element\n node.isContentEditable ||\n // Anchor with href element\n nodeName === 'a' && !!node.getAttribute('href');\n\n // Get tabIndex\n var tabIndexAttr = node.getAttribute('tabindex');\n var tabIndexNum = Number(tabIndexAttr);\n\n // Parse as number if validate\n var tabIndex = null;\n if (tabIndexAttr && !Number.isNaN(tabIndexNum)) {\n tabIndex = tabIndexNum;\n } else if (isFocusableElement && tabIndex === null) {\n tabIndex = 0;\n }\n\n // Block focusable if disabled\n if (isFocusableElement && node.disabled) {\n tabIndex = null;\n }\n return tabIndex !== null && (tabIndex >= 0 || includePositive && tabIndex < 0);\n }\n return false;\n}\nexport function getFocusNodeList(node) {\n var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var res = _toConsumableArray(node.querySelectorAll('*')).filter(function (child) {\n return focusable(child, includePositive);\n });\n if (focusable(node, includePositive)) {\n res.unshift(node);\n }\n return res;\n}\nvar lastFocusElement = null;\n\n/** @deprecated Do not use since this may failed when used in async */\nexport function saveLastFocusNode() {\n lastFocusElement = document.activeElement;\n}\n\n/** @deprecated Do not use since this may failed when used in async */\nexport function clearLastFocusNode() {\n lastFocusElement = null;\n}\n\n/** @deprecated Do not use since this may failed when used in async */\nexport function backLastFocusNode() {\n if (lastFocusElement) {\n try {\n // 元素可能已经被移动了\n lastFocusElement.focus();\n\n /* eslint-disable no-empty */\n } catch (e) {\n // empty\n }\n /* eslint-enable no-empty */\n }\n}\nexport function limitTabRange(node, e) {\n if (e.keyCode === 9) {\n var tabNodeList = getFocusNodeList(node);\n var lastTabNode = tabNodeList[e.shiftKey ? 0 : tabNodeList.length - 1];\n var leavingTab = lastTabNode === document.activeElement || node === document.activeElement;\n if (leavingTab) {\n var target = tabNodeList[e.shiftKey ? tabNodeList.length - 1 : 0];\n target.focus();\n e.preventDefault();\n }\n }\n}","map":{"version":3,"names":["_toConsumableArray","isVisible","focusable","node","includePositive","arguments","length","undefined","nodeName","toLowerCase","isFocusableElement","includes","isContentEditable","getAttribute","tabIndexAttr","tabIndexNum","Number","tabIndex","isNaN","disabled","getFocusNodeList","res","querySelectorAll","filter","child","unshift","lastFocusElement","saveLastFocusNode","document","activeElement","clearLastFocusNode","backLastFocusNode","focus","e","limitTabRange","keyCode","tabNodeList","lastTabNode","shiftKey","leavingTab","target","preventDefault"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-util/es/Dom/focus.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport isVisible from \"./isVisible\";\nfunction focusable(node) {\n var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (isVisible(node)) {\n var nodeName = node.nodeName.toLowerCase();\n var isFocusableElement =\n // Focusable element\n ['input', 'select', 'textarea', 'button'].includes(nodeName) ||\n // Editable element\n node.isContentEditable ||\n // Anchor with href element\n nodeName === 'a' && !!node.getAttribute('href');\n\n // Get tabIndex\n var tabIndexAttr = node.getAttribute('tabindex');\n var ta