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.
Scripted/website/node_modules/.cache/babel-loader/aec9e31422a5d652e0a8d3d5608...

1 line
5.5 KiB

{"ast":null,"code":"import listen from 'dom-helpers/listen';\nimport ownerDocument from 'dom-helpers/ownerDocument';\nimport { useEffect } from 'react';\nimport useEventCallback from '@restart/hooks/useEventCallback';\nimport useClickOutside, { getRefTarget } from './useClickOutside';\nconst escapeKeyCode = 27;\nconst noop = () => {};\n\n/**\n * The `useRootClose` hook registers your callback on the document\n * when rendered. Powers the `<Overlay/>` component. This is used achieve modal\n * style behavior where your callback is triggered when the user tries to\n * interact with the rest of the document or hits the `esc` key.\n *\n * @param {Ref<HTMLElement>| HTMLElement} ref The element boundary\n * @param {function} onRootClose\n * @param {object=} options\n * @param {boolean=} options.disabled\n * @param {string=} options.clickTrigger The DOM event name (click, mousedown, etc) to attach listeners on\n */\nfunction useRootClose(ref, onRootClose) {\n let {\n disabled,\n clickTrigger\n } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n const onClose = onRootClose || noop;\n useClickOutside(ref, onClose, {\n disabled,\n clickTrigger\n });\n const handleKeyUp = useEventCallback(e => {\n if (e.keyCode === escapeKeyCode) {\n onClose(e);\n }\n });\n useEffect(() => {\n if (disabled || ref == null) return undefined;\n const doc = ownerDocument(getRefTarget(ref)); // Store the current event to avoid triggering handlers immediately\n // https://github.com/facebook/react/issues/20074\n\n let currentEvent = (doc.defaultView || window).event;\n const removeKeyupListener = listen(doc, 'keyup', e => {\n // skip if this event is the same as the one running when we added the handlers\n if (e === currentEvent) {\n currentEvent = undefined;\n return;\n }\n handleKeyUp(e);\n });\n return () => {\n removeKeyupListener();\n };\n }, [ref, disabled, handleKeyUp]);\n}\nexport default useRootClose;","map":{"version":3,"names":["listen","ownerDocument","useEffect","useEventCallback","useClickOutside","getRefTarget","escapeKeyCode","noop","useRootClose","ref","onRootClose","disabled","clickTrigger","onClose","handleKeyUp","e","keyCode","undefined","doc","currentEvent","defaultView","window","event","removeKeyupListener"],"sources":["C:/Cours/SAE/SAE-3.01/Scripted/Scripted/website/node_modules/@restart/ui/esm/useRootClose.js"],"sourcesContent":["import listen from 'dom-helpers/listen';\nimport ownerDocument from 'dom-helpers/ownerDocument';\nimport { useEffect } from 'react';\nimport useEventCallback from '@restart/hooks/useEventCallback';\nimport useClickOutside, { getRefTarget } from './useClickOutside';\nconst escapeKeyCode = 27;\n\nconst noop = () => {};\n\n/**\n * The `useRootClose` hook registers your callback on the document\n * when rendered. Powers the `<Overlay/>` component. This is used achieve modal\n * style behavior where your callback is triggered when the user tries to\n * interact with the rest of the document or hits the `esc` key.\n *\n * @param {Ref<HTMLElement>| HTMLElement} ref The element boundary\n * @param {function} onRootClose\n * @param {object=} options\n * @param {boolean=} options.disabled\n * @param {string=} options.clickTrigger The DOM event name (click, mousedown, etc) to attach listeners on\n */\nfunction useRootClose(ref, onRootClose, {\n disabled,\n clickTrigger\n} = {}) {\n const onClose = onRootClose || noop;\n useClickOutside(ref, onClose, {\n disabled,\n clickTrigger\n });\n const handleKeyUp = useEventCallback(e => {\n if (e.keyCode === escapeKeyCode) {\n onClose(e);\n }\n });\n useEffect(() => {\n if (disabled || ref == null) return undefined;\n const doc = ownerDocument(getRefTarget(ref)); // Store the current event to avoid triggering handlers immediately\n // https://github.com/facebook/react/issues/20074\n\n let currentEvent = (doc.defaultView || window).event;\n const removeKeyupListener = listen(doc, 'keyup', e => {\n // skip if this event is the same as the one running when we added the handlers\n if (e === currentEvent) {\n currentEvent = undefined;\n return;\n }\n\n handleKeyUp(e);\n });\n return () => {\n removeKeyupListener();\n };\n }, [ref, disabled, handleKeyUp]);\n}\n\nexport default useRootClose;"],"mappings":"AAAA,OAAOA,MAAM,MAAM,oBAAoB;AACvC,OAAOC,aAAa,MAAM,2BAA2B;AACrD,SAASC,SAAS,QAAQ,OAAO;AACjC,OAAOC,gBAAgB,MAAM,iCAAiC;AAC9D,OAAOC,eAAe,IAAIC,Y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