You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
12 KiB
1 line
12 KiB
{"ast":null,"code":"import isSelectionValid from \"../../modules/isSelectionValid\";\nvar keyName = '__reactResponderId';\nfunction getEventPath(domEvent) {\n if (domEvent.type === 'selectionchange') {\n var target = window.getSelection().anchorNode;\n return composedPathFallback(target);\n } else {\n var path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);\n return path;\n }\n}\nfunction composedPathFallback(target) {\n var path = [];\n while (target != null && target !== document.body) {\n path.push(target);\n target = target.parentNode;\n }\n return path;\n}\nfunction getResponderId(node) {\n if (node != null) {\n return node[keyName];\n }\n return null;\n}\nexport function setResponderId(node, id) {\n if (node != null) {\n node[keyName] = id;\n }\n}\nexport function getResponderPaths(domEvent) {\n var idPath = [];\n var nodePath = [];\n var eventPath = getEventPath(domEvent);\n for (var i = 0; i < eventPath.length; i++) {\n var node = eventPath[i];\n var id = getResponderId(node);\n if (id != null) {\n idPath.push(id);\n nodePath.push(node);\n }\n }\n return {\n idPath: idPath,\n nodePath: nodePath\n };\n}\nexport function getLowestCommonAncestor(pathA, pathB) {\n var pathALength = pathA.length;\n var pathBLength = pathB.length;\n if (pathALength === 0 || pathBLength === 0 || pathA[pathALength - 1] !== pathB[pathBLength - 1]) {\n return null;\n }\n var itemA = pathA[0];\n var indexA = 0;\n var itemB = pathB[0];\n var indexB = 0;\n if (pathALength - pathBLength > 0) {\n indexA = pathALength - pathBLength;\n itemA = pathA[indexA];\n pathALength = pathBLength;\n }\n if (pathBLength - pathALength > 0) {\n indexB = pathBLength - pathALength;\n itemB = pathB[indexB];\n pathBLength = pathALength;\n }\n var depth = pathALength;\n while (depth--) {\n if (itemA === itemB) {\n return itemA;\n }\n itemA = pathA[indexA++];\n itemB = pathB[indexB++];\n }\n return null;\n}\nexport function hasTargetTouches(target, touches) {\n if (!touches || touches.length === 0) {\n return false;\n }\n for (var i = 0; i < touches.length; i++) {\n var node = touches[i].target;\n if (node != null) {\n if (target.contains(node)) {\n return true;\n }\n }\n }\n return false;\n}\nexport function hasValidSelection(domEvent) {\n if (domEvent.type === 'selectionchange') {\n return isSelectionValid();\n }\n return domEvent.type === 'select';\n}\nexport function isPrimaryPointerDown(domEvent) {\n var altKey = domEvent.altKey,\n button = domEvent.button,\n buttons = domEvent.buttons,\n ctrlKey = domEvent.ctrlKey,\n type = domEvent.type;\n var isTouch = type === 'touchstart' || type === 'touchmove';\n var isPrimaryMouseDown = type === 'mousedown' && (button === 0 || buttons === 1);\n var isPrimaryMouseMove = type === 'mousemove' && buttons === 1;\n var noModifiers = altKey === false && ctrlKey === false;\n if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {\n return true;\n }\n return false;\n}","map":{"version":3,"names":["isSelectionValid","keyName","getEventPath","domEvent","type","target","window","getSelection","anchorNode","composedPathFallback","path","composedPath","document","body","push","parentNode","getResponderId","node","setResponderId","id","getResponderPaths","idPath","nodePath","eventPath","i","length","getLowestCommonAncestor","pathA","pathB","pathALength","pathBLength","itemA","indexA","itemB","indexB","depth","hasTargetTouches","touches","contains","hasValidSelection","isPrimaryPointerDown","altKey","button","buttons","ctrlKey","isTouch","isPrimaryMouseDown","isPrimaryMouseMove","noModifiers"],"sources":["/Users/thomaschazot/Documents/But2A/LaSuperMeteo/iut-expo-starter/node_modules/react-native-web/dist/modules/useResponderEvents/utils.js"],"sourcesContent":["/**\n * Copyright (c) Nicolas Gallagher\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\nimport isSelectionValid from '../../modules/isSelectionValid';\nvar keyName = '__reactResponderId';\n\nfunction getEventPath(domEvent) {\n // The 'selectionchange' event always has the 'document' as the target.\n // Use the anchor node as the initial target to reconstruct a path.\n // (We actually only need the first \"responder\" node in practice.)\n if (domEvent.type === 'selectionchange') {\n var target = window.getSelection().anchorNode;\n return composedPathFallback(target);\n } else {\n var path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);\n return path;\n }\n}\n\nfunction composedPathFallback(target) {\n var path = [];\n\n while (target != null && target !== document.body) {\n path.push(target);\n target = target.parentNode;\n }\n\n return path;\n}\n/**\n * Retrieve the responderId from a host node\n */\n\n\nfunction getResponderId(node) {\n if (node != null) {\n return node[keyName];\n }\n\n return null;\n}\n/**\n * Store the responderId on a host node\n */\n\n\nexport function setResponderId(node, id) {\n if (node != null) {\n node[keyName] = id;\n }\n}\n/**\n * Filter the event path to contain only the nodes attached to the responder system\n */\n\nexport function getResponderPaths(domEvent) {\n var idPath = [];\n var nodePath = [];\n var eventPath = getEventPath(domEvent);\n\n for (var i = 0; i < eventPath.length; i++) {\n var node = eventPath[i];\n var id = getResponderId(node);\n\n if (id != null) {\n idPath.push(id);\n nodePath.push(node);\n }\n }\n\n return {\n idPath,\n nodePath\n };\n}\n/**\n * Walk the paths and find the first common ancestor\n */\n\nexport function getLowestCommonAncestor(pathA, pathB) {\n var pathALength = pathA.length;\n var pathBLength = pathB.length;\n\n if ( // If either path is empty\n pathALength === 0 || pathBLength === 0 || // If the last elements aren't the same there can't be a common ancestor\n // that is connected to the responder system\n pathA[pathALength - 1] !== pathB[pathBLength - 1]) {\n return null;\n }\n\n var itemA = pathA[0];\n var indexA = 0;\n var itemB = pathB[0];\n var indexB = 0; // If A is deeper, skip indices that can't match.\n\n if (pathALength - pathBLength > 0) {\n indexA = pathALength - pathBLength;\n itemA = pathA[indexA];\n pathALength = pathBLength;\n } // If B is deeper, skip indices that can't match\n\n\n if (pathBLength - pathALength > 0) {\n indexB = pathBLength - pathALength;\n itemB = pathB[indexB];\n pathBLength = pathALength;\n } // Walk in lockstep until a match is found\n\n\n var depth = pathALength;\n\n while (depth--) {\n if (itemA === itemB) {\n return itemA;\n }\n\n itemA = pathA[indexA++];\n itemB = pathB[indexB++];\n }\n\n return null;\n}\n/**\n * Determine whether any of the active touches are within the current responder.\n * This cannot rely on W3C `targetTouches`, as neither IE11 nor Safari implement it.\n */\n\nexport function hasTargetTouches(target, touches) {\n if (!touches || touches.length === 0) {\n return false;\n }\n\n for (var i = 0; i < touches.length; i++) {\n var node = touches[i].target;\n\n if (node != null) {\n if (target.contains(node)) {\n return true;\n }\n }\n }\n\n return false;\n}\n/**\n * Ignore 'selectionchange' events that don't correspond with a person's intent to\n * select text.\n */\n\nexport function hasValidSelection(domEvent) {\n if (domEvent.type === 'selectionchange') {\n return isSelectionValid();\n }\n\n return domEvent.type === 'select';\n}\n/**\n * Events are only valid if the primary button was used without specific modifier keys.\n */\n\nexport function isPrimaryPointerDown(domEvent) {\n var altKey = domEvent.altKey,\n button = domEvent.button,\n buttons = domEvent.buttons,\n ctrlKey = domEvent.ctrlKey,\n type = domEvent.type;\n var isTouch = type === 'touchstart' || type === 'touchmove';\n var isPrimaryMouseDown = type === 'mousedown' && (button === 0 || buttons === 1);\n var isPrimaryMouseMove = type === 'mousemove' && buttons === 1;\n var noModifiers = altKey === false && ctrlKey === false;\n\n if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {\n return true;\n }\n\n return false;\n}"],"mappings":"AAQA,OAAOA,gBAAgB;AACvB,IAAIC,OAAO,GAAG,oBAAoB;AAElC,SAASC,YAAY,CAACC,QAAQ,EAAE;EAI9B,IAAIA,QAAQ,CAACC,IAAI,KAAK,iBAAiB,EAAE;IACvC,IAAIC,MAAM,GAAGC,MAAM,CAACC,YAAY,EAAE,CAACC,UAAU;IAC7C,OAAOC,oBAAoB,CAACJ,MAAM,CAAC;EACrC,CAAC,MAAM;IACL,IAAIK,IAAI,GAAGP,QAAQ,CAACQ,YAAY,IAAI,IAAI,GAAGR,QAAQ,CAACQ,YAAY,EAAE,GAAGF,oBAAoB,CAACN,QAAQ,CAACE,MAAM,CAAC;IAC1G,OAAOK,IAAI;EACb;AACF;AAEA,SAASD,oBAAoB,CAACJ,MAAM,EAAE;EACpC,IAAIK,IAAI,GAAG,EAAE;EAEb,OAAOL,MAAM,IAAI,I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