{"ast":null,"code":"const _excluded = [\"as\", \"onSelect\", \"activeKey\", \"role\", \"onKeyDown\"];\nfunction _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n return target;\n}\nimport qsa from 'dom-helpers/querySelectorAll';\nimport * as React from 'react';\nimport { useContext, useEffect, useRef } from 'react';\nimport useForceUpdate from '@restart/hooks/useForceUpdate';\nimport useMergedRefs from '@restart/hooks/useMergedRefs';\nimport NavContext from './NavContext';\nimport SelectableContext, { makeEventKey } from './SelectableContext';\nimport TabContext from './TabContext';\nimport { dataAttr, dataProp } from './DataKey';\nimport NavItem from './NavItem';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\nconst EVENT_KEY_ATTR = dataAttr('event-key');\nconst Nav = /*#__PURE__*/React.forwardRef((_ref, ref) => {\n let {\n // Need to define the default \"as\" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595\n as: Component = 'div',\n onSelect,\n activeKey,\n role,\n onKeyDown\n } = _ref,\n props = _objectWithoutPropertiesLoose(_ref, _excluded);\n\n // A ref and forceUpdate for refocus, b/c we only want to trigger when needed\n // and don't want to reset the set in the effect\n const forceUpdate = useForceUpdate();\n const needsRefocusRef = useRef(false);\n const parentOnSelect = useContext(SelectableContext);\n const tabContext = useContext(TabContext);\n let getControlledId, getControllerId;\n if (tabContext) {\n role = role || 'tablist';\n activeKey = tabContext.activeKey; // TODO: do we need to duplicate these?\n\n getControlledId = tabContext.getControlledId;\n getControllerId = tabContext.getControllerId;\n }\n const listNode = useRef(null);\n const getNextActiveTab = offset => {\n const currentListNode = listNode.current;\n if (!currentListNode) return null;\n const items = qsa(currentListNode, `[${EVENT_KEY_ATTR}]:not([aria-disabled=true])`);\n const activeChild = currentListNode.querySelector('[aria-selected=true]');\n if (!activeChild || activeChild !== document.activeElement) return null;\n const index = items.indexOf(activeChild);\n if (index === -1) return null;\n let nextIndex = index + offset;\n if (nextIndex >= items.length) nextIndex = 0;\n if (nextIndex < 0) nextIndex = items.length - 1;\n return items[nextIndex];\n };\n const handleSelect = (key, event) => {\n if (key == null) return;\n onSelect == null ? void 0 : onSelect(key, event);\n parentOnSelect == null ? void 0 : parentOnSelect(key, event);\n };\n const handleKeyDown = event => {\n onKeyDown == null ? void 0 : onKeyDown(event);\n if (!tabContext) {\n return;\n }\n let nextActiveChild;\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowUp':\n nextActiveChild = getNextActiveTab(-1);\n break;\n case 'ArrowRight':\n case 'ArrowDown':\n nextActiveChild = getNextActiveTab(1);\n break;\n default:\n return;\n }\n if (!nextActiveChild) return;\n event.preventDefault();\n handleSelect(nextActiveChild.dataset[dataProp('EventKey')] || null, event);\n needsRefocusRef.current = true;\n forceUpdate();\n };\n useEffect(() => {\n if (listNode.current && needsRefocusRef.current) {\n const activeChild = listNode.current.querySelector(`[${EVENT_KEY_ATTR}][aria-selected=true]`);\n activeChild == null ? void 0 : activeChild.focus();\n }\n needsRefocusRef.current = false;\n });\n const mergedRef = useMergedRefs(ref, listNode);\n return /*#__PURE__*/_jsx(SelectableContext.Provider, {\n value: handleSelect,\n children: /*#__PURE__*/_jsx(NavContext.Provider, {\n value: {\n role,\n // used by NavLink to determine it's role\n activeKey: makeEventKey(activeKey),\n getControlledId: getControlledId || noop,\n getControllerId: getControllerId || noop\n },\n children: /*#__PURE__*/_jsx(Component, Object.assign({}, props, {\n onKeyDown: handleKeyDown,\n ref: mergedRef,\n role: role\n }))\n })\n });\n});\nNav.displayName = 'Nav';\nexport default Object.assign(Nav, {\n Item: NavItem\n});","map":{"version":3,"names":["_excluded","_objectWithoutPropertiesLoose","source","excluded","target","sourceKeys","Object","keys","key","i","length","indexOf","qsa","React","useContext","useEffect","useRef","useForceUpdate","useMergedRefs","NavContext","SelectableContext","makeEventKey","TabContext","dataAttr","dataProp","NavItem","jsx","_jsx","noop","EVENT_KEY_ATTR","Nav","forwardRef","_ref","ref","as","Component","onSelect","activeKey","role","onKeyDown","props","forceUpdate","needsRefocusRef","parentOnSelect","tabContext","getControlledId","getControllerId","listNode","getNextActiveTab","offset","currentListNode","current","items","activeChild","querySelector","document","activeElement","index","nextIndex","handleSelect","event","handleKeyDown","nextActiveChild","preventDefault","dataset","focus","mergedRef","Provider","value","children","assign","displayName","Item"],"sources":["C:/Cours/SAE/SAE-3.01/Scripted/Scripted/website/node_modules/@restart/ui/esm/Nav.js"],"sourcesContent":["const _excluded = [\"as\", \"onSelect\", \"activeKey\", \"role\", \"onKeyDown\"];\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport qsa from 'dom-helpers/querySelectorAll';\nimport * as React from 'react';\nimport { useContext, useEffect, useRef } from 'react';\nimport useForceUpdate from '@restart/hooks/useForceUpdate';\nimport useMergedRefs from '@restart/hooks/useMergedRefs';\nimport NavContext from './NavContext';\nimport SelectableContext, { makeEventKey } from './SelectableContext';\nimport TabContext from './TabContext';\nimport { dataAttr, dataProp } from './DataKey';\nimport NavItem from './NavItem';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\nconst EVENT_KEY_ATTR = dataAttr('event-key');\nconst Nav = /*#__PURE__*/React.forwardRef((_ref, ref) => {\n let {\n // Need to define the default \"as\" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595\n as: Component = 'div',\n onSelect,\n activeKey,\n role,\n onKeyDown\n } = _ref,\n props = _objectWithoutPropertiesLoose(_ref, _excluded);\n\n // A ref and forceUpdate for refocus, b/c we only want to trigger when needed\n // and don't want to reset the set in the effect\n const forceUpdate = useForceUpdate();\n const needsRefocusRef = useRef(false);\n const parentOnSelect = useContext(SelectableContext);\n const tabContext = useContext(TabContext);\n let getControlledId, getControllerId;\n\n if (tabContext) {\n role = role || 'tablist';\n activeKey = tabContext.activeKey; // TODO: do we need to duplicate these?\n\n getControlledId = tabContext.getControlledId;\n getControllerId = tabContext.getControllerId;\n }\n\n const listNode = useRef(null);\n\n const getNextActiveTab = offset => {\n const currentListNode = listNode.current;\n if (!currentListNode) return null;\n const items = qsa(currentListNode, `[${EVENT_KEY_ATTR}]:not([aria-disabled=true])`);\n const activeChild = currentListNode.querySelector('[aria-selected=true]');\n if (!activeChild || activeChild !== document.activeElement) return null;\n const index = items.indexOf(activeChild);\n if (index === -1) return null;\n let nextIndex = index + offset;\n if (nextIndex >= items.length) nextIndex = 0;\n if (nextIndex < 0) nextIndex = items.length - 1;\n return items[nextIndex];\n };\n\n const handleSelect = (key, event) => {\n if (key == null) return;\n onSelect == null ? void 0 : onSelect(key, event);\n parentOnSelect == null ? void 0 : parentOnSelect(key, event);\n };\n\n const handleKeyDown = event => {\n onKeyDown == null ? void 0 : onKeyDown(event);\n\n if (!tabContext) {\n return;\n }\n\n let nextActiveChild;\n\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowUp':\n nextActiveChild = getNextActiveTab(-1);\n break;\n\n case 'ArrowRight':\n case 'ArrowDown':\n nextActiveChild = getNextActiveTab(1);\n break;\n\n default:\n return;\n }\n\n if (!nextActiveChild) return;\n event.preventDefault();\n handleSelect(nextActiveChild.dataset[dataProp('EventKey')] || null, event);\n needsRefocusRef.current = true;\n forceUpdate();\n };\n\n useEffect(() => {\n if (listNode.current && needsRefocusRef.current) {\n const activeChild = listNode.current.querySelector(`[${EVENT_KEY_ATTR}][aria-selected=true]`);\n activeChild == null ? void 0 : activeChild.focus();\n }\n\n needsRefocusRef.current = false;\n });\n const mergedRef = useMergedRefs(ref, listNode);\n return /*#__PURE__*/_jsx(SelectableContext.Provider, {\n value: handleSelect,\n children: /*#__PURE__*/_jsx(NavContext.Provider, {\n value: {\n role,\n // used by NavLink to determine it's role\n activeKey: makeEventKey(activeKey),\n getControlledId: getControlledId || noop,\n getControllerId: getControllerId || noop\n },\n children: /*#__PURE__*/_jsx(Component, Object.assign({}, props, {\n onKeyDown: handleKeyDown,\n ref: mergedRef,\n role: role\n }))\n })\n });\n});\nNav.displayName = 'Nav';\nexport default Object.assign(Nav, {\n Item: NavItem\n});"],"mappings":"AAAA,MAAMA,SAAS,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC;AAEtE,SAASC,6BAA6B,CAACC,MAAM,EAAEC,QAAQ,EAAE;EAAE,IAAID,MAAM,IAAI,IAAI,EAAE,OAAO,CAAC,CAAC;EAAE,IAAIE,MAAM,GAAG,CAAC,CAAC;EAAE,IAAIC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACL,MAAM,CAAC;EAAE,IAAIM,GAAG,EAAEC,CAAC;EAAE,KAAKA,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,UAAU,CAACK,MAAM,EAAED,CAAC,EAAE,EAAE;IAAED,GAAG,GAAGH,UAAU,CAACI,CAAC,CAAC;IAAE,IAAIN,QAAQ,CAACQ,OAAO,CAACH,GAAG,CAAC,IAAI,CAAC,EAAE;IAAUJ,MAAM,CAACI,GAAG,CAAC,GAAGN,MAAM,CAACM,GAAG,CAAC;EAAE;EAAE,OAAOJ,MAAM;AAAE;AAElT,OAAOQ,GAAG,MAAM,8BAA8B;AAC9C,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACrD,OAAOC,cAAc,MAAM,+BAA+B;AAC1D,OAAOC,aAAa,MAAM,8BAA8B;AACxD,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,iBAAiB,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