{"version":3,"file":"timezone-picker-hooks.mjs","names":[],"sources":["../../../src/timezone-picker/timezone-picker-hooks.ts"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\nimport { useCallback, useEffect, useState } from 'react';\n\nexport const useTimeZonePickerPopover = (initialState: boolean) => {\n  const [isPopoverOpen, setIsPopoverOpen] = useState(initialState);\n  return { isPopoverOpen, setIsPopoverOpen };\n};\n\nexport const useKeyboardNavigation = (optionsLength: number) => {\n  const [focusedIndex, setFocusedIndex] = useState(0);\n\n  useEffect(() => {\n    setFocusedIndex(0);\n  }, [optionsLength]);\n\n  const handleArrowNavigation = useCallback(\n    (key: string) => {\n      if (key === 'ArrowDown') {\n        setFocusedIndex((prevIndex) => {\n          const newIndex = (prevIndex + 1) % optionsLength;\n          return newIndex;\n        });\n      } else if (key === 'ArrowUp') {\n        setFocusedIndex((prevIndex) => {\n          const newIndex = (prevIndex - 1 + optionsLength) % optionsLength;\n          return newIndex;\n        });\n      }\n    },\n    [optionsLength],\n  );\n\n  return { focusedIndex, handleArrowNavigation, setFocusedIndex };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,4BAA4B,iBAA0B;CACjE,MAAM,CAAC,eAAe,oBAAoB,SAAS,YAAY;CAC/D,OAAO;EAAE;EAAe;CAAiB;AAC3C;AAEA,MAAa,yBAAyB,kBAA0B;CAC9D,MAAM,CAAC,cAAc,mBAAmB,SAAS,CAAC;CAElD,gBAAgB;EACd,gBAAgB,CAAC;CACnB,GAAG,CAAC,aAAa,CAAC;CAmBlB,OAAO;EAAE;EAAc,uBAjBO,aAC3B,QAAgB;GACf,IAAI,QAAQ,aACV,iBAAiB,cAAc;IAE7B,QADkB,YAAY,KAAK;GAErC,CAAC;QACI,IAAI,QAAQ,WACjB,iBAAiB,cAAc;IAE7B,QADkB,YAAY,IAAI,iBAAiB;GAErD,CAAC;EAEL,GACA,CAAC,aAAa,CAG2B;EAAG;CAAgB;AAChE"}